From 51e6897a1dc72dd5e39921e8a1c8fa4efb568ca6 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Thu, 22 Mar 2018 18:37:52 +0200 Subject: [PATCH] Add support for %a and %A in printf. --- NEWS | 5 + builtin.c | 31 +- configh.in | 3 + configure | 42 +++ configure.ac | 28 ++ doc/awkcard.in | 1 + doc/gawk.1 | 12 +- doc/gawk.info | 925 ++++++++++++++++++++++++++++---------------------------- doc/gawk.texi | 19 ++ doc/gawktexi.in | 19 ++ doc/wordlist | 2 + doc/wordlist2 | 1 + pc/config.h | 3 + pc/config.sed | 2 + 14 files changed, 631 insertions(+), 462 deletions(-) diff --git a/NEWS b/NEWS index c2885c8..71d9608 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,11 @@ are permitted in any medium without royalty provided the copyright notice and this notice are preserved. +Changes from 4.2.1 to 4.2.2 +--------------------------- + +1. Support for the POSIX standard %a and %A formats has been added. + Changes from 4.2.0 to 4.2.1 --------------------------- diff --git a/builtin.c b/builtin.c index 6927205..c54be9b 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) diff --git a/configh.in b/configh.in index e600005..8c4d94d 100644 --- a/configh.in +++ b/configh.in @@ -368,6 +368,9 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* Define to 1 if *printf supports %a format */ +#undef PRINTF_HAS_A_FORMAT + /* Define to 1 if *printf supports %F format */ #undef PRINTF_HAS_F_FORMAT diff --git a/configure b/configure index 2283f09..f492a75 100755 --- a/configure +++ b/configure @@ -10210,6 +10210,48 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_f_format" >&5 $as_echo "$has_f_format" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf %a format" >&5 +$as_echo_n "checking for printf %a format... " >&6; } +if test "$cross_compiling" = yes; then : + has_a_format=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#include + +int main() +{ + char buf[100]; + + sprintf(buf, "%a", 8.0); + + if (strncmp(buf, "0x", 2) == 0) + return 0; + else + return 1; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + has_a_format=yes +else + has_a_format=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +if test "$has_a_format" = yes +then + +$as_echo "#define PRINTF_HAS_A_FORMAT 1" >>confdefs.h + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_a_format" >&5 +$as_echo "$has_a_format" >&6; } + gawk_have_sockets=no # Check for system-dependent location of socket libraries diff --git a/configure.ac b/configure.ac index f45c710..a4817ee 100644 --- a/configure.ac +++ b/configure.ac @@ -395,6 +395,34 @@ then fi AC_MSG_RESULT($has_f_format) +dnl check for printf %a format +AC_MSG_CHECKING([for printf %a format]) +AC_RUN_IFELSE([ +AC_LANG_SOURCE([ +#include + +int main() +{ + char buf[[100]]; + + sprintf(buf, "%a", 8.0); + + if (strncmp(buf, "0x", 2) == 0) + return 0; + else + return 1; +} +])], + has_a_format=yes, + has_a_format=no, + has_a_format=no dnl Cross-compiling, assuming the worst. +) +if test "$has_a_format" = yes +then + AC_DEFINE(PRINTF_HAS_A_FORMAT, 1, [Define to 1 if *printf supports %a format]) +fi +AC_MSG_RESULT($has_a_format) + dnl check for sockets GAWK_AC_LIB_SOCKETS diff --git a/doc/awkcard.in b/doc/awkcard.in index 1148294..d4df342 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -1431,6 +1431,7 @@ the error.\*(CX accept the following conversion specification formats: .sp .5 .nf +\*(CB\*(FC%a\fP, \*(FC%A\fP A C99 floating point hexadecimal number\*(CD \*(FC%c\fP An \s-1ASCII\s+1 character \*(FC%d\fP, \*(FC%i\fP A decimal number (the integer part) \*(FC%e\fP A floating point number of the form diff --git a/doc/gawk.1 b/doc/gawk.1 index 16762a8..48c07b7 100644 --- a/doc/gawk.1 +++ b/doc/gawk.1 @@ -13,7 +13,7 @@ . if \w'\(rq' .ds rq "\(rq . \} .\} -.TH GAWK 1 "Feb 15 2018" "Free Software Foundation" "Utility Commands" +.TH GAWK 1 "Mar 22 2018" "Free Software Foundation" "Utility Commands" .SH NAME gawk \- pattern scanning and processing language .SH SYNOPSIS @@ -1264,7 +1264,7 @@ behavior: \fBPROCINFO["NONFATAL"]\fR If this exists, then I/O errors for all redirections become nonfatal. .TP -\fBPROCINFO["\fname\fB", "NONFATAL"]\fR +\fBPROCINFO["\fIname\fB", "NONFATAL"]\fR Make I/O errors for .I name be nonfatal. @@ -2429,6 +2429,14 @@ function (see below) accept the following conversion specification formats: .TP "\w'\fB%g\fR, \fB%G\fR'u+2n" +.BR "%a" "," " %A" +A floating point number of the form +[\fB\-\fP]\fB0x\fIh\fB.\fIhhhh\fBp+\-\fIdd\fR +(C99 hexadecimal floating point format). +For +.BR %A , +uppercase letters are used instead of lowercase ones. +.TP .B %c A single character. If the argument used for diff --git a/doc/gawk.info b/doc/gawk.info index 738de09..c01e43b 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -6614,6 +6614,21 @@ print. The rest of the format specifier is made up of optional "modifiers" that control _how_ to print the value, such as the field width. Here is a list of the format-control letters: +'%a', '%A' + A floating point number of the form ['-']'0xH.HHHHp+-DD' (C99 + hexadecimal floating point format). For '%A', uppercase letters + are used instead of lowercase ones. + + NOTE: While the current POSIX standard requires support for + '%a' and '%A' in 'awk', as far as we know, no other version of + 'awk' actually implements it. It's use is thus highly + nonportable! + + Furthermore, these formats are not available on any system + where the underlying C library 'printf()' function does not + support them. As of this writing, among current systems, only + OpenVMS is known to not support them. + '%c' Print a number as a character; thus, 'printf "%c", 65' outputs the letter 'A'. The output for a string value is the first character @@ -33759,9 +33774,9 @@ Index * dark corner, FILENAME variable: Getline Notes. (line 19) * dark corner, FILENAME variable <1>: Auto-set. (line 108) * dark corner, FNR/NR variables: Auto-set. (line 389) -* dark corner, format-control characters: Control Letters. (line 18) +* dark corner, format-control characters: Control Letters. (line 33) * dark corner, format-control characters <1>: Control Letters. - (line 93) + (line 108) * dark corner, FS as null string: Single Character Fields. (line 20) * dark corner, input files: awk split records. (line 110) @@ -34459,8 +34474,8 @@ Index * gawk, FIELDWIDTHS variable in: Fixed width data. (line 17) * gawk, FIELDWIDTHS variable in <1>: User-modified. (line 37) * gawk, file names in: Special Files. (line 6) -* gawk, format-control characters: Control Letters. (line 18) -* gawk, format-control characters <1>: Control Letters. (line 93) +* gawk, format-control characters: Control Letters. (line 33) +* gawk, format-control characters <1>: Control Letters. (line 108) * gawk, FPAT variable in: Splitting By Content. (line 25) * gawk, FPAT variable in <1>: User-modified. (line 46) @@ -36129,456 +36144,456 @@ Node: OFMT288591 Node: Printf289947 Node: Basic Printf290732 Node: Control Letters292306 -Node: Format Modifiers296302 -Node: Printf Examples302317 -Node: Redirection304803 -Node: Special FD311644 -Ref: Special FD-Footnote-1314812 -Node: Special Files314886 -Node: Other Inherited Files315503 -Node: Special Network316504 -Node: Special Caveats317364 -Node: Close Files And Pipes318313 -Ref: table-close-pipe-return-values325220 -Ref: Close Files And Pipes-Footnote-1326033 -Ref: Close Files And Pipes-Footnote-2326181 -Node: Nonfatal326333 -Node: Output Summary328671 -Node: Output Exercises329893 -Node: Expressions330572 -Node: Values331760 -Node: Constants332438 -Node: Scalar Constants333129 -Ref: Scalar Constants-Footnote-1333993 -Node: Nondecimal-numbers334243 -Node: Regexp Constants337244 -Node: Using Constant Regexps337770 -Node: Standard Regexp Constants338392 -Node: Strong Regexp Constants341580 -Node: Variables344538 -Node: Using Variables345195 -Node: Assignment Options347105 -Node: Conversion348978 -Node: Strings And Numbers349502 -Ref: Strings And Numbers-Footnote-1352565 -Node: Locale influences conversions352674 -Ref: table-locale-affects355432 -Node: All Operators356050 -Node: Arithmetic Ops356679 -Node: Concatenation359185 -Ref: Concatenation-Footnote-1362032 -Node: Assignment Ops362139 -Ref: table-assign-ops367130 -Node: Increment Ops368443 -Node: Truth Values and Conditions371903 -Node: Truth Values372977 -Node: Typing and Comparison374025 -Node: Variable Typing374845 -Ref: Variable Typing-Footnote-1381308 -Ref: Variable Typing-Footnote-2381380 -Node: Comparison Operators381457 -Ref: table-relational-ops381876 -Node: POSIX String Comparison385371 -Ref: POSIX String Comparison-Footnote-1387066 -Ref: POSIX String Comparison-Footnote-2387205 -Node: Boolean Ops387289 -Ref: Boolean Ops-Footnote-1391771 -Node: Conditional Exp391863 -Node: Function Calls393599 -Node: Precedence397476 -Node: Locales401135 -Node: Expressions Summary402767 -Node: Patterns and Actions405340 -Node: Pattern Overview406460 -Node: Regexp Patterns408137 -Node: Expression Patterns408679 -Node: Ranges412460 -Node: BEGIN/END415568 -Node: Using BEGIN/END416329 -Ref: Using BEGIN/END-Footnote-1419065 -Node: I/O And BEGIN/END419171 -Node: BEGINFILE/ENDFILE421485 -Node: Empty424398 -Node: Using Shell Variables424715 -Node: Action Overview426989 -Node: Statements429314 -Node: If Statement431162 -Node: While Statement432657 -Node: Do Statement434685 -Node: For Statement435833 -Node: Switch Statement439004 -Node: Break Statement441390 -Node: Continue Statement443482 -Node: Next Statement445309 -Node: Nextfile Statement447692 -Node: Exit Statement450344 -Node: Built-in Variables452747 -Node: User-modified453880 -Node: Auto-set461647 -Ref: Auto-set-Footnote-1477946 -Ref: Auto-set-Footnote-2478152 -Node: ARGC and ARGV478208 -Node: Pattern Action Summary482421 -Node: Arrays484851 -Node: Array Basics486180 -Node: Array Intro487024 -Ref: figure-array-elements488999 -Ref: Array Intro-Footnote-1491703 -Node: Reference to Elements491831 -Node: Assigning Elements494295 -Node: Array Example494786 -Node: Scanning an Array496545 -Node: Controlling Scanning499567 -Ref: Controlling Scanning-Footnote-1504966 -Node: Numeric Array Subscripts505282 -Node: Uninitialized Subscripts507466 -Node: Delete509085 -Ref: Delete-Footnote-1511837 -Node: Multidimensional511894 -Node: Multiscanning514989 -Node: Arrays of Arrays516580 -Node: Arrays Summary521347 -Node: Functions523440 -Node: Built-in524478 -Node: Calling Built-in525559 -Node: Numeric Functions527555 -Ref: Numeric Functions-Footnote-1531583 -Ref: Numeric Functions-Footnote-2531940 -Ref: Numeric Functions-Footnote-3531988 -Node: String Functions532260 -Ref: String Functions-Footnote-1555918 -Ref: String Functions-Footnote-2556046 -Ref: String Functions-Footnote-3556294 -Node: Gory Details556381 -Ref: table-sub-escapes558172 -Ref: table-sub-proposed559691 -Ref: table-posix-sub561054 -Ref: table-gensub-escapes562595 -Ref: Gory Details-Footnote-1563418 -Node: I/O Functions563572 -Ref: table-system-return-values570040 -Ref: I/O Functions-Footnote-1572020 -Ref: I/O Functions-Footnote-2572168 -Node: Time Functions572288 -Ref: Time Functions-Footnote-1582959 -Ref: Time Functions-Footnote-2583027 -Ref: Time Functions-Footnote-3583185 -Ref: Time Functions-Footnote-4583296 -Ref: Time Functions-Footnote-5583408 -Ref: Time Functions-Footnote-6583635 -Node: Bitwise Functions583901 -Ref: table-bitwise-ops584495 -Ref: Bitwise Functions-Footnote-1590540 -Ref: Bitwise Functions-Footnote-2590713 -Node: Type Functions590904 -Node: I18N Functions593655 -Node: User-defined595306 -Node: Definition Syntax596111 -Ref: Definition Syntax-Footnote-1601798 -Node: Function Example601869 -Ref: Function Example-Footnote-1604791 -Node: Function Caveats604813 -Node: Calling A Function605331 -Node: Variable Scope606289 -Node: Pass By Value/Reference609283 -Node: Return Statement612782 -Node: Dynamic Typing615761 -Node: Indirect Calls616691 -Ref: Indirect Calls-Footnote-1626943 -Node: Functions Summary627071 -Node: Library Functions629776 -Ref: Library Functions-Footnote-1633383 -Ref: Library Functions-Footnote-2633526 -Node: Library Names633697 -Ref: Library Names-Footnote-1637157 -Ref: Library Names-Footnote-2637380 -Node: General Functions637466 -Node: Strtonum Function638569 -Node: Assert Function641591 -Node: Round Function644917 -Node: Cliff Random Function646457 -Node: Ordinal Functions647473 -Ref: Ordinal Functions-Footnote-1650536 -Ref: Ordinal Functions-Footnote-2650788 -Node: Join Function650998 -Ref: Join Function-Footnote-1652768 -Node: Getlocaltime Function652968 -Node: Readfile Function656710 -Node: Shell Quoting658687 -Node: Data File Management660088 -Node: Filetrans Function660720 -Node: Rewind Function664816 -Node: File Checking666726 -Ref: File Checking-Footnote-1668060 -Node: Empty Files668261 -Node: Ignoring Assigns670240 -Node: Getopt Function671790 -Ref: Getopt Function-Footnote-1683259 -Node: Passwd Functions683459 -Ref: Passwd Functions-Footnote-1692298 -Node: Group Functions692386 -Ref: Group Functions-Footnote-1700284 -Node: Walking Arrays700491 -Node: Library Functions Summary703499 -Node: Library Exercises704905 -Node: Sample Programs705370 -Node: Running Examples706140 -Node: Clones706868 -Node: Cut Program708092 -Node: Egrep Program718021 -Ref: Egrep Program-Footnote-1725533 -Node: Id Program725643 -Node: Split Program729323 -Ref: Split Program-Footnote-1732781 -Node: Tee Program732910 -Node: Uniq Program735700 -Node: Wc Program743126 -Ref: Wc Program-Footnote-1747381 -Node: Miscellaneous Programs747475 -Node: Dupword Program748688 -Node: Alarm Program750718 -Node: Translate Program755573 -Ref: Translate Program-Footnote-1760138 -Node: Labels Program760408 -Ref: Labels Program-Footnote-1763759 -Node: Word Sorting763843 -Node: History Sorting767915 -Node: Extract Program769750 -Node: Simple Sed777280 -Node: Igawk Program780354 -Ref: Igawk Program-Footnote-1794685 -Ref: Igawk Program-Footnote-2794887 -Ref: Igawk Program-Footnote-3795009 -Node: Anagram Program795124 -Node: Signature Program798186 -Node: Programs Summary799433 -Node: Programs Exercises800647 -Ref: Programs Exercises-Footnote-1804776 -Node: Advanced Features804867 -Node: Nondecimal Data806857 -Node: Array Sorting808448 -Node: Controlling Array Traversal809148 -Ref: Controlling Array Traversal-Footnote-1817516 -Node: Array Sorting Functions817634 -Ref: Array Sorting Functions-Footnote-1822725 -Node: Two-way I/O822921 -Ref: Two-way I/O-Footnote-1829473 -Ref: Two-way I/O-Footnote-2829660 -Node: TCP/IP Networking829742 -Node: Profiling832860 -Ref: Profiling-Footnote-1841532 -Node: Advanced Features Summary841855 -Node: Internationalization843699 -Node: I18N and L10N845179 -Node: Explaining gettext845866 -Ref: Explaining gettext-Footnote-1851758 -Ref: Explaining gettext-Footnote-2851943 -Node: Programmer i18n852108 -Ref: Programmer i18n-Footnote-1857057 -Node: Translator i18n857106 -Node: String Extraction857900 -Ref: String Extraction-Footnote-1859032 -Node: Printf Ordering859118 -Ref: Printf Ordering-Footnote-1861904 -Node: I18N Portability861968 -Ref: I18N Portability-Footnote-1864424 -Node: I18N Example864487 -Ref: I18N Example-Footnote-1867293 -Node: Gawk I18N867366 -Node: I18N Summary868011 -Node: Debugger869352 -Node: Debugging870375 -Node: Debugging Concepts870816 -Node: Debugging Terms872625 -Node: Awk Debugging875200 -Node: Sample Debugging Session876106 -Node: Debugger Invocation876640 -Node: Finding The Bug878026 -Node: List of Debugger Commands884504 -Node: Breakpoint Control885837 -Node: Debugger Execution Control889531 -Node: Viewing And Changing Data892893 -Node: Execution Stack896267 -Node: Debugger Info897904 -Node: Miscellaneous Debugger Commands901975 -Node: Readline Support907037 -Node: Limitations907933 -Node: Debugging Summary910042 -Node: Arbitrary Precision Arithmetic911321 -Node: Computer Arithmetic912806 -Ref: table-numeric-ranges916572 -Ref: table-floating-point-ranges917065 -Ref: Computer Arithmetic-Footnote-1917723 -Node: Math Definitions917780 -Ref: table-ieee-formats921096 -Ref: Math Definitions-Footnote-1921699 -Node: MPFR features921804 -Node: FP Math Caution923522 -Ref: FP Math Caution-Footnote-1924594 -Node: Inexactness of computations924963 -Node: Inexact representation925923 -Node: Comparing FP Values927283 -Node: Errors accumulate928365 -Node: Getting Accuracy929798 -Node: Try To Round932508 -Node: Setting precision933407 -Ref: table-predefined-precision-strings934104 -Node: Setting the rounding mode935934 -Ref: table-gawk-rounding-modes936308 -Ref: Setting the rounding mode-Footnote-1940239 -Node: Arbitrary Precision Integers940418 -Ref: Arbitrary Precision Integers-Footnote-1943593 -Node: Checking for MPFR943742 -Node: POSIX Floating Point Problems945216 -Ref: POSIX Floating Point Problems-Footnote-1949087 -Node: Floating point summary949125 -Node: Dynamic Extensions951315 -Node: Extension Intro952868 -Node: Plugin License954134 -Node: Extension Mechanism Outline954931 -Ref: figure-load-extension955370 -Ref: figure-register-new-function956935 -Ref: figure-call-new-function958027 -Node: Extension API Description960089 -Node: Extension API Functions Introduction961731 -Node: General Data Types967271 -Ref: General Data Types-Footnote-1975632 -Node: Memory Allocation Functions975931 -Ref: Memory Allocation Functions-Footnote-1980141 -Node: Constructor Functions980240 -Node: Registration Functions983826 -Node: Extension Functions984511 -Node: Exit Callback Functions989726 -Node: Extension Version String990976 -Node: Input Parsers991639 -Node: Output Wrappers1004360 -Node: Two-way processors1008872 -Node: Printing Messages1011137 -Ref: Printing Messages-Footnote-11012308 -Node: Updating ERRNO1012461 -Node: Requesting Values1013200 -Ref: table-value-types-returned1013937 -Node: Accessing Parameters1014873 -Node: Symbol Table Access1016108 -Node: Symbol table by name1016620 -Node: Symbol table by cookie1018409 -Ref: Symbol table by cookie-Footnote-11022594 -Node: Cached values1022658 -Ref: Cached values-Footnote-11026194 -Node: Array Manipulation1026347 -Ref: Array Manipulation-Footnote-11027438 -Node: Array Data Types1027475 -Ref: Array Data Types-Footnote-11030133 -Node: Array Functions1030225 -Node: Flattening Arrays1034723 -Node: Creating Arrays1041699 -Node: Redirection API1046466 -Node: Extension API Variables1049299 -Node: Extension Versioning1050010 -Ref: gawk-api-version1050439 -Node: Extension GMP/MPFR Versioning1052170 -Node: Extension API Informational Variables1053798 -Node: Extension API Boilerplate1054871 -Node: Changes from API V11058845 -Node: Finding Extensions1060417 -Node: Extension Example1060976 -Node: Internal File Description1061774 -Node: Internal File Ops1065854 -Ref: Internal File Ops-Footnote-11077204 -Node: Using Internal File Ops1077344 -Ref: Using Internal File Ops-Footnote-11079727 -Node: Extension Samples1080001 -Node: Extension Sample File Functions1081530 -Node: Extension Sample Fnmatch1089179 -Node: Extension Sample Fork1090666 -Node: Extension Sample Inplace1091884 -Node: Extension Sample Ord1095101 -Node: Extension Sample Readdir1095937 -Ref: table-readdir-file-types1096826 -Node: Extension Sample Revout1097631 -Node: Extension Sample Rev2way1098220 -Node: Extension Sample Read write array1098960 -Node: Extension Sample Readfile1100902 -Node: Extension Sample Time1101997 -Node: Extension Sample API Tests1103345 -Node: gawkextlib1103837 -Node: Extension summary1106755 -Node: Extension Exercises1110457 -Node: Language History1111955 -Node: V7/SVR3.11113611 -Node: SVR41115763 -Node: POSIX1117197 -Node: BTL1118577 -Node: POSIX/GNU1119306 -Node: Feature History1125084 -Node: Common Extensions1140943 -Node: Ranges and Locales1142226 -Ref: Ranges and Locales-Footnote-11146842 -Ref: Ranges and Locales-Footnote-21146869 -Ref: Ranges and Locales-Footnote-31147104 -Node: Contributors1147325 -Node: History summary1153270 -Node: Installation1154650 -Node: Gawk Distribution1155594 -Node: Getting1156078 -Node: Extracting1157041 -Node: Distribution contents1158679 -Node: Unix Installation1165159 -Node: Quick Installation1165841 -Node: Shell Startup Files1168255 -Node: Additional Configuration Options1169344 -Node: Configuration Philosophy1171637 -Node: Non-Unix Installation1174006 -Node: PC Installation1174466 -Node: PC Binary Installation1175304 -Node: PC Compiling1175739 -Node: PC Using1176856 -Node: Cygwin1180071 -Node: MSYS1181170 -Node: VMS Installation1181671 -Node: VMS Compilation1182462 -Ref: VMS Compilation-Footnote-11183691 -Node: VMS Dynamic Extensions1183749 -Node: VMS Installation Details1185434 -Node: VMS Running1187687 -Node: VMS GNV1191966 -Node: VMS Old Gawk1192701 -Node: Bugs1193172 -Node: Bug address1193835 -Node: Usenet1196627 -Node: Maintainers1197404 -Node: Other Versions1198665 -Node: Installation summary1205427 -Node: Notes1206629 -Node: Compatibility Mode1207494 -Node: Additions1208276 -Node: Accessing The Source1209201 -Node: Adding Code1210638 -Node: New Ports1216857 -Node: Derived Files1221345 -Ref: Derived Files-Footnote-11226991 -Ref: Derived Files-Footnote-21227026 -Ref: Derived Files-Footnote-31227624 -Node: Future Extensions1227738 -Node: Implementation Limitations1228396 -Node: Extension Design1229579 -Node: Old Extension Problems1230733 -Ref: Old Extension Problems-Footnote-11232251 -Node: Extension New Mechanism Goals1232308 -Ref: Extension New Mechanism Goals-Footnote-11235672 -Node: Extension Other Design Decisions1235861 -Node: Extension Future Growth1237974 -Node: Old Extension Mechanism1238810 -Node: Notes summary1240573 -Node: Basic Concepts1241755 -Node: Basic High Level1242436 -Ref: figure-general-flow1242718 -Ref: figure-process-flow1243403 -Ref: Basic High Level-Footnote-11246704 -Node: Basic Data Typing1246889 -Node: Glossary1250217 -Node: Copying1282055 -Node: GNU Free Documentation License1319598 -Node: Index1344718 +Node: Format Modifiers296985 +Node: Printf Examples303000 +Node: Redirection305486 +Node: Special FD312327 +Ref: Special FD-Footnote-1315495 +Node: Special Files315569 +Node: Other Inherited Files316186 +Node: Special Network317187 +Node: Special Caveats318047 +Node: Close Files And Pipes318996 +Ref: table-close-pipe-return-values325903 +Ref: Close Files And Pipes-Footnote-1326716 +Ref: Close Files And Pipes-Footnote-2326864 +Node: Nonfatal327016 +Node: Output Summary329354 +Node: Output Exercises330576 +Node: Expressions331255 +Node: Values332443 +Node: Constants333121 +Node: Scalar Constants333812 +Ref: Scalar Constants-Footnote-1334676 +Node: Nondecimal-numbers334926 +Node: Regexp Constants337927 +Node: Using Constant Regexps338453 +Node: Standard Regexp Constants339075 +Node: Strong Regexp Constants342263 +Node: Variables345221 +Node: Using Variables345878 +Node: Assignment Options347788 +Node: Conversion349661 +Node: Strings And Numbers350185 +Ref: Strings And Numbers-Footnote-1353248 +Node: Locale influences conversions353357 +Ref: table-locale-affects356115 +Node: All Operators356733 +Node: Arithmetic Ops357362 +Node: Concatenation359868 +Ref: Concatenation-Footnote-1362715 +Node: Assignment Ops362822 +Ref: table-assign-ops367813 +Node: Increment Ops369126 +Node: Truth Values and Conditions372586 +Node: Truth Values373660 +Node: Typing and Comparison374708 +Node: Variable Typing375528 +Ref: Variable Typing-Footnote-1381991 +Ref: Variable Typing-Footnote-2382063 +Node: Comparison Operators382140 +Ref: table-relational-ops382559 +Node: POSIX String Comparison386054 +Ref: POSIX String Comparison-Footnote-1387749 +Ref: POSIX String Comparison-Footnote-2387888 +Node: Boolean Ops387972 +Ref: Boolean Ops-Footnote-1392454 +Node: Conditional Exp392546 +Node: Function Calls394282 +Node: Precedence398159 +Node: Locales401818 +Node: Expressions Summary403450 +Node: Patterns and Actions406023 +Node: Pattern Overview407143 +Node: Regexp Patterns408820 +Node: Expression Patterns409362 +Node: Ranges413143 +Node: BEGIN/END416251 +Node: Using BEGIN/END417012 +Ref: Using BEGIN/END-Footnote-1419748 +Node: I/O And BEGIN/END419854 +Node: BEGINFILE/ENDFILE422168 +Node: Empty425081 +Node: Using Shell Variables425398 +Node: Action Overview427672 +Node: Statements429997 +Node: If Statement431845 +Node: While Statement433340 +Node: Do Statement435368 +Node: For Statement436516 +Node: Switch Statement439687 +Node: Break Statement442073 +Node: Continue Statement444165 +Node: Next Statement445992 +Node: Nextfile Statement448375 +Node: Exit Statement451027 +Node: Built-in Variables453430 +Node: User-modified454563 +Node: Auto-set462330 +Ref: Auto-set-Footnote-1478629 +Ref: Auto-set-Footnote-2478835 +Node: ARGC and ARGV478891 +Node: Pattern Action Summary483104 +Node: Arrays485534 +Node: Array Basics486863 +Node: Array Intro487707 +Ref: figure-array-elements489682 +Ref: Array Intro-Footnote-1492386 +Node: Reference to Elements492514 +Node: Assigning Elements494978 +Node: Array Example495469 +Node: Scanning an Array497228 +Node: Controlling Scanning500250 +Ref: Controlling Scanning-Footnote-1505649 +Node: Numeric Array Subscripts505965 +Node: Uninitialized Subscripts508149 +Node: Delete509768 +Ref: Delete-Footnote-1512520 +Node: Multidimensional512577 +Node: Multiscanning515672 +Node: Arrays of Arrays517263 +Node: Arrays Summary522030 +Node: Functions524123 +Node: Built-in525161 +Node: Calling Built-in526242 +Node: Numeric Functions528238 +Ref: Numeric Functions-Footnote-1532266 +Ref: Numeric Functions-Footnote-2532623 +Ref: Numeric Functions-Footnote-3532671 +Node: String Functions532943 +Ref: String Functions-Footnote-1556601 +Ref: String Functions-Footnote-2556729 +Ref: String Functions-Footnote-3556977 +Node: Gory Details557064 +Ref: table-sub-escapes558855 +Ref: table-sub-proposed560374 +Ref: table-posix-sub561737 +Ref: table-gensub-escapes563278 +Ref: Gory Details-Footnote-1564101 +Node: I/O Functions564255 +Ref: table-system-return-values570723 +Ref: I/O Functions-Footnote-1572703 +Ref: I/O Functions-Footnote-2572851 +Node: Time Functions572971 +Ref: Time Functions-Footnote-1583642 +Ref: Time Functions-Footnote-2583710 +Ref: Time Functions-Footnote-3583868 +Ref: Time Functions-Footnote-4583979 +Ref: Time Functions-Footnote-5584091 +Ref: Time Functions-Footnote-6584318 +Node: Bitwise Functions584584 +Ref: table-bitwise-ops585178 +Ref: Bitwise Functions-Footnote-1591223 +Ref: Bitwise Functions-Footnote-2591396 +Node: Type Functions591587 +Node: I18N Functions594338 +Node: User-defined595989 +Node: Definition Syntax596794 +Ref: Definition Syntax-Footnote-1602481 +Node: Function Example602552 +Ref: Function Example-Footnote-1605474 +Node: Function Caveats605496 +Node: Calling A Function606014 +Node: Variable Scope606972 +Node: Pass By Value/Reference609966 +Node: Return Statement613465 +Node: Dynamic Typing616444 +Node: Indirect Calls617374 +Ref: Indirect Calls-Footnote-1627626 +Node: Functions Summary627754 +Node: Library Functions630459 +Ref: Library Functions-Footnote-1634066 +Ref: Library Functions-Footnote-2634209 +Node: Library Names634380 +Ref: Library Names-Footnote-1637840 +Ref: Library Names-Footnote-2638063 +Node: General Functions638149 +Node: Strtonum Function639252 +Node: Assert Function642274 +Node: Round Function645600 +Node: Cliff Random Function647140 +Node: Ordinal Functions648156 +Ref: Ordinal Functions-Footnote-1651219 +Ref: Ordinal Functions-Footnote-2651471 +Node: Join Function651681 +Ref: Join Function-Footnote-1653451 +Node: Getlocaltime Function653651 +Node: Readfile Function657393 +Node: Shell Quoting659370 +Node: Data File Management660771 +Node: Filetrans Function661403 +Node: Rewind Function665499 +Node: File Checking667409 +Ref: File Checking-Footnote-1668743 +Node: Empty Files668944 +Node: Ignoring Assigns670923 +Node: Getopt Function672473 +Ref: Getopt Function-Footnote-1683942 +Node: Passwd Functions684142 +Ref: Passwd Functions-Footnote-1692981 +Node: Group Functions693069 +Ref: Group Functions-Footnote-1700967 +Node: Walking Arrays701174 +Node: Library Functions Summary704182 +Node: Library Exercises705588 +Node: Sample Programs706053 +Node: Running Examples706823 +Node: Clones707551 +Node: Cut Program708775 +Node: Egrep Program718704 +Ref: Egrep Program-Footnote-1726216 +Node: Id Program726326 +Node: Split Program730006 +Ref: Split Program-Footnote-1733464 +Node: Tee Program733593 +Node: Uniq Program736383 +Node: Wc Program743809 +Ref: Wc Program-Footnote-1748064 +Node: Miscellaneous Programs748158 +Node: Dupword Program749371 +Node: Alarm Program751401 +Node: Translate Program756256 +Ref: Translate Program-Footnote-1760821 +Node: Labels Program761091 +Ref: Labels Program-Footnote-1764442 +Node: Word Sorting764526 +Node: History Sorting768598 +Node: Extract Program770433 +Node: Simple Sed777963 +Node: Igawk Program781037 +Ref: Igawk Program-Footnote-1795368 +Ref: Igawk Program-Footnote-2795570 +Ref: Igawk Program-Footnote-3795692 +Node: Anagram Program795807 +Node: Signature Program798869 +Node: Programs Summary800116 +Node: Programs Exercises801330 +Ref: Programs Exercises-Footnote-1805459 +Node: Advanced Features805550 +Node: Nondecimal Data807540 +Node: Array Sorting809131 +Node: Controlling Array Traversal809831 +Ref: Controlling Array Traversal-Footnote-1818199 +Node: Array Sorting Functions818317 +Ref: Array Sorting Functions-Footnote-1823408 +Node: Two-way I/O823604 +Ref: Two-way I/O-Footnote-1830156 +Ref: Two-way I/O-Footnote-2830343 +Node: TCP/IP Networking830425 +Node: Profiling833543 +Ref: Profiling-Footnote-1842215 +Node: Advanced Features Summary842538 +Node: Internationalization844382 +Node: I18N and L10N845862 +Node: Explaining gettext846549 +Ref: Explaining gettext-Footnote-1852441 +Ref: Explaining gettext-Footnote-2852626 +Node: Programmer i18n852791 +Ref: Programmer i18n-Footnote-1857740 +Node: Translator i18n857789 +Node: String Extraction858583 +Ref: String Extraction-Footnote-1859715 +Node: Printf Ordering859801 +Ref: Printf Ordering-Footnote-1862587 +Node: I18N Portability862651 +Ref: I18N Portability-Footnote-1865107 +Node: I18N Example865170 +Ref: I18N Example-Footnote-1867976 +Node: Gawk I18N868049 +Node: I18N Summary868694 +Node: Debugger870035 +Node: Debugging871058 +Node: Debugging Concepts871499 +Node: Debugging Terms873308 +Node: Awk Debugging875883 +Node: Sample Debugging Session876789 +Node: Debugger Invocation877323 +Node: Finding The Bug878709 +Node: List of Debugger Commands885187 +Node: Breakpoint Control886520 +Node: Debugger Execution Control890214 +Node: Viewing And Changing Data893576 +Node: Execution Stack896950 +Node: Debugger Info898587 +Node: Miscellaneous Debugger Commands902658 +Node: Readline Support907720 +Node: Limitations908616 +Node: Debugging Summary910725 +Node: Arbitrary Precision Arithmetic912004 +Node: Computer Arithmetic913489 +Ref: table-numeric-ranges917255 +Ref: table-floating-point-ranges917748 +Ref: Computer Arithmetic-Footnote-1918406 +Node: Math Definitions918463 +Ref: table-ieee-formats921779 +Ref: Math Definitions-Footnote-1922382 +Node: MPFR features922487 +Node: FP Math Caution924205 +Ref: FP Math Caution-Footnote-1925277 +Node: Inexactness of computations925646 +Node: Inexact representation926606 +Node: Comparing FP Values927966 +Node: Errors accumulate929048 +Node: Getting Accuracy930481 +Node: Try To Round933191 +Node: Setting precision934090 +Ref: table-predefined-precision-strings934787 +Node: Setting the rounding mode936617 +Ref: table-gawk-rounding-modes936991 +Ref: Setting the rounding mode-Footnote-1940922 +Node: Arbitrary Precision Integers941101 +Ref: Arbitrary Precision Integers-Footnote-1944276 +Node: Checking for MPFR944425 +Node: POSIX Floating Point Problems945899 +Ref: POSIX Floating Point Problems-Footnote-1949770 +Node: Floating point summary949808 +Node: Dynamic Extensions951998 +Node: Extension Intro953551 +Node: Plugin License954817 +Node: Extension Mechanism Outline955614 +Ref: figure-load-extension956053 +Ref: figure-register-new-function957618 +Ref: figure-call-new-function958710 +Node: Extension API Description960772 +Node: Extension API Functions Introduction962414 +Node: General Data Types967954 +Ref: General Data Types-Footnote-1976315 +Node: Memory Allocation Functions976614 +Ref: Memory Allocation Functions-Footnote-1980824 +Node: Constructor Functions980923 +Node: Registration Functions984509 +Node: Extension Functions985194 +Node: Exit Callback Functions990409 +Node: Extension Version String991659 +Node: Input Parsers992322 +Node: Output Wrappers1005043 +Node: Two-way processors1009555 +Node: Printing Messages1011820 +Ref: Printing Messages-Footnote-11012991 +Node: Updating ERRNO1013144 +Node: Requesting Values1013883 +Ref: table-value-types-returned1014620 +Node: Accessing Parameters1015556 +Node: Symbol Table Access1016791 +Node: Symbol table by name1017303 +Node: Symbol table by cookie1019092 +Ref: Symbol table by cookie-Footnote-11023277 +Node: Cached values1023341 +Ref: Cached values-Footnote-11026877 +Node: Array Manipulation1027030 +Ref: Array Manipulation-Footnote-11028121 +Node: Array Data Types1028158 +Ref: Array Data Types-Footnote-11030816 +Node: Array Functions1030908 +Node: Flattening Arrays1035406 +Node: Creating Arrays1042382 +Node: Redirection API1047149 +Node: Extension API Variables1049982 +Node: Extension Versioning1050693 +Ref: gawk-api-version1051122 +Node: Extension GMP/MPFR Versioning1052853 +Node: Extension API Informational Variables1054481 +Node: Extension API Boilerplate1055554 +Node: Changes from API V11059528 +Node: Finding Extensions1061100 +Node: Extension Example1061659 +Node: Internal File Description1062457 +Node: Internal File Ops1066537 +Ref: Internal File Ops-Footnote-11077887 +Node: Using Internal File Ops1078027 +Ref: Using Internal File Ops-Footnote-11080410 +Node: Extension Samples1080684 +Node: Extension Sample File Functions1082213 +Node: Extension Sample Fnmatch1089862 +Node: Extension Sample Fork1091349 +Node: Extension Sample Inplace1092567 +Node: Extension Sample Ord1095784 +Node: Extension Sample Readdir1096620 +Ref: table-readdir-file-types1097509 +Node: Extension Sample Revout1098314 +Node: Extension Sample Rev2way1098903 +Node: Extension Sample Read write array1099643 +Node: Extension Sample Readfile1101585 +Node: Extension Sample Time1102680 +Node: Extension Sample API Tests1104028 +Node: gawkextlib1104520 +Node: Extension summary1107438 +Node: Extension Exercises1111140 +Node: Language History1112638 +Node: V7/SVR3.11114294 +Node: SVR41116446 +Node: POSIX1117880 +Node: BTL1119260 +Node: POSIX/GNU1119989 +Node: Feature History1125767 +Node: Common Extensions1141626 +Node: Ranges and Locales1142909 +Ref: Ranges and Locales-Footnote-11147525 +Ref: Ranges and Locales-Footnote-21147552 +Ref: Ranges and Locales-Footnote-31147787 +Node: Contributors1148008 +Node: History summary1153953 +Node: Installation1155333 +Node: Gawk Distribution1156277 +Node: Getting1156761 +Node: Extracting1157724 +Node: Distribution contents1159362 +Node: Unix Installation1165842 +Node: Quick Installation1166524 +Node: Shell Startup Files1168938 +Node: Additional Configuration Options1170027 +Node: Configuration Philosophy1172320 +Node: Non-Unix Installation1174689 +Node: PC Installation1175149 +Node: PC Binary Installation1175987 +Node: PC Compiling1176422 +Node: PC Using1177539 +Node: Cygwin1180754 +Node: MSYS1181853 +Node: VMS Installation1182354 +Node: VMS Compilation1183145 +Ref: VMS Compilation-Footnote-11184374 +Node: VMS Dynamic Extensions1184432 +Node: VMS Installation Details1186117 +Node: VMS Running1188370 +Node: VMS GNV1192649 +Node: VMS Old Gawk1193384 +Node: Bugs1193855 +Node: Bug address1194518 +Node: Usenet1197310 +Node: Maintainers1198087 +Node: Other Versions1199348 +Node: Installation summary1206110 +Node: Notes1207312 +Node: Compatibility Mode1208177 +Node: Additions1208959 +Node: Accessing The Source1209884 +Node: Adding Code1211321 +Node: New Ports1217540 +Node: Derived Files1222028 +Ref: Derived Files-Footnote-11227674 +Ref: Derived Files-Footnote-21227709 +Ref: Derived Files-Footnote-31228307 +Node: Future Extensions1228421 +Node: Implementation Limitations1229079 +Node: Extension Design1230262 +Node: Old Extension Problems1231416 +Ref: Old Extension Problems-Footnote-11232934 +Node: Extension New Mechanism Goals1232991 +Ref: Extension New Mechanism Goals-Footnote-11236355 +Node: Extension Other Design Decisions1236544 +Node: Extension Future Growth1238657 +Node: Old Extension Mechanism1239493 +Node: Notes summary1241256 +Node: Basic Concepts1242438 +Node: Basic High Level1243119 +Ref: figure-general-flow1243401 +Ref: figure-process-flow1244086 +Ref: Basic High Level-Footnote-11247387 +Node: Basic Data Typing1247572 +Node: Glossary1250900 +Node: Copying1282738 +Node: GNU Free Documentation License1320281 +Node: Index1345401  End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 7b69b52..7dfa3b3 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -9557,6 +9557,25 @@ the field width. Here is a list of the format-control letters: @c @asis for docbook to come out right @table @asis +@item @code{%a}, @code{%A} +A floating point number of the form +[@code{-}]@code{0x@var{h}.@var{hhhh}p+-@var{dd}} +(C99 hexadecimal floating point format). +For @code{%A}, +uppercase letters are used instead of lowercase ones. + +@quotation NOTE +While the current POSIX standard requires support for @code{%a} +and @code{%A} in @command{awk}, as far as we know, no other version +of @command{awk} actually implements it. It's use is thus highly +nonportable! + +Furthermore, these formats are not available on any system where the +underlying C library @code{printf()} function does not support them. As +of this writing, among current systems, only OpenVMS is known to not +support them. +@end quotation + @item @code{%c} Print a number as a character; thus, @samp{printf "%c", 65} outputs the letter @samp{A}. The output for a string value is diff --git a/doc/gawktexi.in b/doc/gawktexi.in index 6203e1a..f2cb710 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -9156,6 +9156,25 @@ the field width. Here is a list of the format-control letters: @c @asis for docbook to come out right @table @asis +@item @code{%a}, @code{%A} +A floating point number of the form +[@code{-}]@code{0x@var{h}.@var{hhhh}p+-@var{dd}} +(C99 hexadecimal floating point format). +For @code{%A}, +uppercase letters are used instead of lowercase ones. + +@quotation NOTE +While the current POSIX standard requires support for @code{%a} +and @code{%A} in @command{awk}, as far as we know, no other version +of @command{awk} actually implements it. It's use is thus highly +nonportable! + +Furthermore, these formats are not available on any system where the +underlying C library @code{printf()} function does not support them. As +of this writing, among current systems, only OpenVMS is known to not +support them. +@end quotation + @item @code{%c} Print a number as a character; thus, @samp{printf "%c", 65} outputs the letter @samp{A}. The output for a string value is diff --git a/doc/wordlist b/doc/wordlist index 3c3c7e9..3763056 100644 --- a/doc/wordlist +++ b/doc/wordlist @@ -865,6 +865,7 @@ dayname db dcgettext dcngettext +dd ddd de deallocations @@ -1132,6 +1133,7 @@ helpfull helplib hfil hh +hhhh hhob histsort hlp diff --git a/doc/wordlist2 b/doc/wordlist2 index 9275fdb..7bf7ad3 100644 --- a/doc/wordlist2 +++ b/doc/wordlist2 @@ -60,6 +60,7 @@ distclean docbook du dvi +elled emph en env diff --git a/pc/config.h b/pc/config.h index de2b7ec..2ec5352 100644 --- a/pc/config.h +++ b/pc/config.h @@ -473,6 +473,9 @@ /* Define to the version of this package. */ #define PACKAGE_VERSION "4.2.1" +/* Define to 1 if *printf supports %a format */ +#define PRINTF_HAS_A_FORMAT 1 + /* Define to 1 if *printf supports %F format */ #ifdef __DJGPP__ #define PRINTF_HAS_F_FORMAT 1 diff --git a/pc/config.sed b/pc/config.sed index 5b3cc32..a7ba878 100644 --- a/pc/config.sed +++ b/pc/config.sed @@ -273,6 +273,8 @@ s/^#undef HAVE_VPRINTF *$/#define HAVE_VPRINTF 1/ #ifdef __DJGPP__\ #define HAVE__BOOL 1\ #endif +/^#undef PRINTF_HAS_A_FORMAT *$/c\ +#define PRINTF_HAS_A_FORMAT 1 /^#undef PRINTF_HAS_F_FORMAT *$/c\ #ifdef __DJGPP__\ #define PRINTF_HAS_F_FORMAT 1\ -- 2.14.4