diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2018-03-22 20:03:45 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2018-03-22 20:03:45 +0200 |
commit | 264ef6a7dad099f3fdb10c7cab88f1d4e6257c96 (patch) | |
tree | ea31ac104d7a903f9c86905abca5b65ceca5493b /builtin.c | |
parent | 9e06eb5b97fb92f15344a909dfbf7455946564c5 (diff) | |
parent | 047fa8844122d13e2898972c9e0a2332ddddc2f5 (diff) | |
download | egawk-264ef6a7dad099f3fdb10c7cab88f1d4e6257c96.tar.gz egawk-264ef6a7dad099f3fdb10c7cab88f1d4e6257c96.tar.bz2 egawk-264ef6a7dad099f3fdb10c7cab88f1d4e6257c96.zip |
Merge branch 'master' into feature/fix-comments
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -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) |