aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2018-03-22 18:39:52 +0200
committerArnold D. Robbins <arnold@skeeve.com>2018-03-22 18:39:52 +0200
commit047fa8844122d13e2898972c9e0a2332ddddc2f5 (patch)
treecbd95dcaa714ecdaa8bc66c39a15dee876587d91 /builtin.c
parent4fa6f57bf897e7f69dbb606115d4e17a88e90532 (diff)
parent20a79b31c9897f825323eedee4c0eb01922d53da (diff)
downloadegawk-047fa8844122d13e2898972c9e0a2332ddddc2f5.tar.gz
egawk-047fa8844122d13e2898972c9e0a2332ddddc2f5.tar.bz2
egawk-047fa8844122d13e2898972c9e0a2332ddddc2f5.zip
Merge branch 'gawk-4.2-stable'
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/builtin.c b/builtin.c
index 6927205c..c54be9b2 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1493,6 +1493,17 @@ mpf1:
case 'e':
case 'f':
case 'E':
+#if defined(PRINTF_HAS_A_FORMAT) && PRINTF_HAS_A_FORMAT == 1
+ case 'A':
+ case 'a':
+ {
+ static bool warned = false;
+ if (do_lint && tolower(cs1) == 'a' && ! warned) {
+ warned = true;
+ lintwarn(_("%%%c format is POSIX standard but not portable to other awks"), cs1);
+ }
+ }
+#endif
need_format = false;
parse_next_arg();
(void) force_number(arg);
@@ -1557,11 +1568,21 @@ mpf1:
break;
#endif
default:
- sprintf(cp, "*.*%c", cs1);
- while ((nc = snprintf(obufout, ofre, cpbuf,
- (int) fw, (int) prec,
- (double) tmpval)) >= ofre)
- chksize(nc)
+ if (have_prec || tolower(cs1) != 'a') {
+ sprintf(cp, "*.*%c", cs1);
+ while ((nc = snprintf(obufout, ofre, cpbuf,
+ (int) fw, (int) prec,
+ (double) tmpval)) >= ofre)
+ chksize(nc)
+ } else {
+ // For %a and %A, use the default precision if it
+ // wasn't supplied by the user.
+ sprintf(cp, "*%c", cs1);
+ while ((nc = snprintf(obufout, ofre, cpbuf,
+ (int) fw,
+ (double) tmpval)) >= ofre)
+ chksize(nc)
+ }
}
#if defined(LC_NUMERIC)