diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-12-16 21:06:07 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-12-16 21:06:07 +0200 |
commit | d587d4e5a72d08926d36288663a92ca6efbe0a6b (patch) | |
tree | bc0ca68333c11f7c56d4c6894b1a725ff707e4c8 | |
parent | edfb721ac785219e9b881d8ac3a841cef8270a79 (diff) | |
download | egawk-d587d4e5a72d08926d36288663a92ca6efbe0a6b.tar.gz egawk-d587d4e5a72d08926d36288663a92ca6efbe0a6b.tar.bz2 egawk-d587d4e5a72d08926d36288663a92ca6efbe0a6b.zip |
Add PROCINFO["strftime"] as default strftime() format.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | NEWS | 24 | ||||
-rw-r--r-- | awk.h | 1 | ||||
-rw-r--r-- | builtin.c | 19 | ||||
-rw-r--r-- | doc/awkcard.in | 6 | ||||
-rw-r--r-- | doc/gawk.1 | 6 | ||||
-rw-r--r-- | doc/gawk.info | 707 | ||||
-rw-r--r-- | doc/gawk.texi | 28 | ||||
-rw-r--r-- | main.c | 14 |
9 files changed, 450 insertions, 365 deletions
@@ -1,3 +1,13 @@ +Thu Dec 16 11:06:50 2010 Arnold D. Robbins <arnold@skeeve.com> + + Put strftime() default format into PROCINFO["strftime"]. + + * awk.h (def_strftime_format): Declare const char[] array. + * main.c (def_strftime_format): Define it. + (load_procinfo): Load it into PROCINFO. + * builtin.c (do_strftime): Use value in PROCINFO for format + string if it's there. Remove old def_format static array. + Mon Dec 13 17:12:44 2010 Arnold D. Robbins <arnold@skeeve.com> If not POSIX, turn [d-h] into [defgh]. @@ -16,7 +16,7 @@ Changes from 3.1.8 to 4.0.0 3. The \s and \S escape sequences are now recognized in regular expressions. -4. The split function accepts an optional fourth argument which is an array +4. The split() function accepts an optional fourth argument which is an array to hold the values of the separators. 5. New -b / --characters-as-bytes option that means "hands off my data"; gawk @@ -56,12 +56,11 @@ Changes from 3.1.8 to 4.0.0 18. `break' and `continue' are no longer valid outside a loop, even with --traditional. -19. POSIX character classes work, even with --traditional (BWK awk supports - them). +19. POSIX character classes work with --traditional (BWK awk supports them). 20. Nuked redundant --compat, --copyleft, and --usage long options. -21. Arrays of arrays added. +21. Arrays of arrays added. See the doc. 22. Per the GNU Coding Standards, dynamic extensions must now define a global symbol indicating that they are GPL-compatible. See @@ -73,7 +72,22 @@ Changes from 3.1.8 to 4.0.0 24. The option for raw sockets was removed, since it was never implemented. -25. Many code cleanups. Removed code for many old, unsupported systems. +25. If not in POSIX mode, gawk turns ranges of the form [d-h] into + [defgh] before compiling a regexp. Maybe this will stop all the + questions about [a-z] matching uppercase letters. + THIS CHANGES BEHAVIOR!!!! + +26. PROCINFO["strftime"] now holds the default format for strftime(). + +27. Many code cleanups. Removed code for many old, unsupported systems: + - Atari + - Amiga + - BeOS + - Tandem (non-POSIX) + - MS-DOS with Microsoft Compiler + - MS-Windows with Microsoft Compiler + - SunOS 3.x, Sun 386 (Road Runner) + - Probably others that I've forgotten Changes from 3.1.7 to 3.1.8 --------------------------- @@ -901,6 +901,7 @@ extern struct lconv loc; #endif /* HAVE_LOCALE_H */ extern const char *myname; +extern const char def_strftime_format[]; extern char quote; extern char *defpath; @@ -802,17 +802,32 @@ do_strftime(int nargs) char *bufp; size_t buflen, bufsize; char buf[BUFSIZ]; - static const char def_format[] = "%a %b %e %H:%M:%S %Z %Y"; const char *format; int formatlen; int do_gmt; + NODE *val = NULL; + NODE *sub = NULL; /* set defaults first */ - format = def_format; /* traditional date format */ + format = def_strftime_format; /* traditional date format */ formatlen = strlen(format); (void) time(& fclock); /* current time of day */ do_gmt = FALSE; + if (PROCINFO_node != NULL) { + sub = make_string("strftime", 8); + val = in_array(PROCINFO_node, sub); + unref(sub); + + if (val != NULL) { + if (do_lint && (val->flags & STRING) == 0) + lintwarn(_("strftime: format value in PROCINFO[\"strftime\"] has numeric type")); + val = force_string(val); + format = val->stptr; + formatlen = val->stlen; + } + } + t1 = t2 = t3 = NULL; if (nargs > 0) { /* have args */ NODE *tmp; diff --git a/doc/awkcard.in b/doc/awkcard.in index 2389ca38..15a98281 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -1775,8 +1775,10 @@ If \*(FIutc-flag\*(FR is present and is non-zero or non-null, the result is in UTC, otherwise the result is in local time. If \*(FItimestamp\fP is missing, the current time of day is used. If -\*(FIformat\fP is missing, a default format equivalent to the output -of \*(FIdate\*(FR(1) is used. +\*(FIformat\fP is missing, use \*(FCPROCINFO["strftime"]\fP. +The default value is +equivalent to the output +of \*(FIdate\*(FR(1). .ti -.2i \*(FCsystime()\fP .br @@ -1041,6 +1041,10 @@ the value of the .IR getegid (2) system call. .TP +\fBPROCINFO["strftime"]\fP +The default time format string for +.BR strftime() . +.TP \fBPROCINFO["euid"]\fP the value of the .IR geteuid (2) @@ -2814,6 +2818,8 @@ If is missing, a default format equivalent to the output of .IR date (1) is used. +The default format is available in +.BR PROCINFO["strftime"] . See the specification for the .B strftime() function in \*(AN C for the format conversions that are diff --git a/doc/gawk.info b/doc/gawk.info index 78385ba5..6bf42aa4 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -4590,8 +4590,10 @@ value is `"FS"' if regular field splitting is being used, or it is if (PROCINFO["FS"] == "FS") REGULAR FIELD SPLITTING ... - else + else if (PROCINFO["FS"] == "FIELDWIDTHS") FIXED-WIDTH FIELD SPLITTING ... + else + CONTENT-BASED FIELD SPLITTING ... This information is useful when writing a function that needs to temporarily change `FS' or `FIELDWIDTHS', read some records, and then @@ -4675,6 +4677,9 @@ would be to remove the quotes when they occur, with something like this: As with `FS', the `IGNORECASE' variable (*note User-modified::) affects field splitting with `FPAT'. + Similar to `FIELDWIDTHS', the value of `PROCINFO["FS"]' will be +`"FPAT"' if content-based field splitting is being used. + NOTE: Some programs export CSV data that contains embedded newlines between the double quotes. `gawk' provides no way to deal with this. Since there is no formal specification for CSV @@ -4682,8 +4687,8 @@ affects field splitting with `FPAT'. provides an elegant solution for the majority of cases, and the `gawk' maintainer is satisfied with that. - As written, the regexp used for `FPATH' requires that each field -have a least one character. A straightforward modification (changing + As written, the regexp used for `FPAT' requires that each field have +a least one character. A straightforward modification (changing changed the first `+' to `*') allows fields to be empty: FPAT = "([^,]*)|(\"[^\"]+\")" @@ -9369,6 +9374,11 @@ with a pound sign (`#'). `PROCINFO["uid"]' The value of the `getuid()' system call. + `PROCINFO["strftime"]' + The default time format string for `strftime()'. Assigning a + new value to this element changes the default. *Note Time + Functions::. + `PROCINFO["version"]' The version of `gawk'. @@ -11423,9 +11433,12 @@ Optional parameters are enclosed in square brackets ([ ]): TIMESTAMP is in the same format as the value returned by the `systime()' function. If no TIMESTAMP argument is supplied, `gawk' uses the current time of day as the timestamp. If no - FORMAT argument is supplied, `strftime()' uses - `"%a %b %e %H:%M:%S %Z %Y"'. This format string produces output - that is equivalent to that of the `date' utility. + FORMAT argument is supplied, `strftime()' uses the value of + `PROCINFO["strftime"]' as the format string. The default string + value is `"%a %b %e %H:%M:%S %Z %Y"'. This format string produces + output that is equivalent to that of the `date' utility. You can + assign a new value to `PROCINFO["strftime"]' to change the default + format. `systime()' Return the current time as the number of seconds since the system @@ -11471,8 +11484,8 @@ the following date format specifications: `%A %B %d %T %Y' in the `"C"' locale.) `%C' - The century. This is the year divided by 100 and truncated to the - next lower integer. + The century part of the current year. This is the year divided by + 100 and truncated to the next lower integer. `%d' The day of the month as a decimal number (01-31). @@ -19570,6 +19583,8 @@ all be disabled with either the `--traditional' or `--posix' options * The `FPAT' variable and its effects (*note Splitting By Content::). + * `PROCINFO["strftime"]' was added (*note Auto-set::). + * The `patsplit()' function (*note String Functions::). * The `/inet4' and `/inet6' special files for TCP/IP networking @@ -24760,7 +24775,7 @@ Index (line 67) * advanced features, data files as single record: Records. (line 172) * advanced features, fixed-width data: Constant Size. (line 9) -* advanced features, FNR/NR variables: Auto-set. (line 195) +* advanced features, FNR/NR variables: Auto-set. (line 200) * advanced features, gawk: Advanced Features. (line 6) * advanced features, gawk, network programming: TCP/IP Networking. (line 6) @@ -25184,7 +25199,7 @@ Index * continue statement: Continue Statement. (line 6) * control statements: Statements. (line 6) * converting, case: String Functions. (line 494) -* converting, dates to timestamps: Time Functions. (line 71) +* converting, dates to timestamps: Time Functions. (line 74) * converting, during subscripting: Numeric Array Subscripts. (line 31) * converting, numbers: Conversion. (line 6) @@ -25234,7 +25249,7 @@ Index (line 47) * dark corner, FILENAME variable <1>: Auto-set. (line 92) * dark corner, FILENAME variable: Getline Notes. (line 19) -* dark corner, FNR/NR variables: Auto-set. (line 195) +* dark corner, FNR/NR variables: Auto-set. (line 200) * dark corner, format-control characters: Control Letters. (line 18) * dark corner, FS as null string: Single Character Fields. (line 20) @@ -25258,8 +25273,8 @@ Index * database, group, reading: Group Functions. (line 6) * database, users, reading: Passwd Functions. (line 6) * date utility, GNU: Time Functions. (line 17) -* date utility, POSIX: Time Functions. (line 258) -* dates, converting to timestamps: Time Functions. (line 71) +* date utility, POSIX: Time Functions. (line 261) +* dates, converting to timestamps: Time Functions. (line 74) * dates, information related to, localization: Explaining gettext. (line 115) * Davies, Stephen <1>: Contributors. (line 69) @@ -25433,7 +25448,7 @@ Index * differences in awk and gawk, regular expressions: Case-sensitivity. (line 26) * differences in awk and gawk, RS/RT variables: Records. (line 164) -* differences in awk and gawk, RT variable: Auto-set. (line 184) +* differences in awk and gawk, RT variable: Auto-set. (line 189) * differences in awk and gawk, single-character fields: Single Character Fields. (line 6) * differences in awk and gawk, split() function: String Functions. @@ -25696,7 +25711,7 @@ Index * floating-point, numbers, AWKNUM internal type: Internals. (line 19) * FNR variable <1>: Auto-set. (line 102) * FNR variable: Records. (line 6) -* FNR variable, changing: Auto-set. (line 195) +* FNR variable, changing: Auto-set. (line 200) * for statement: For Statement. (line 6) * for statement, in arrays: Scanning an Array. (line 20) * force_number internal function: Internals. (line 27) @@ -25705,7 +25720,7 @@ Index (line 57) * format specifiers, printf statement: Control Letters. (line 6) * format specifiers, strftime() function (gawk): Time Functions. - (line 84) + (line 87) * format strings: Basic Printf. (line 15) * formats, numeric output: OFMT. (line 6) * formatting output: Printf. (line 6) @@ -26252,7 +26267,7 @@ Index * not Boolean-logic operator: Boolean Ops. (line 6) * NR variable <1>: Auto-set. (line 118) * NR variable: Records. (line 6) -* NR variable, changing: Auto-set. (line 195) +* NR variable, changing: Auto-set. (line 200) * null strings <1>: Basic Data Typing. (line 47) * null strings <2>: Truth Values. (line 6) * null strings <3>: Regexp Field Splitting. @@ -26469,7 +26484,7 @@ Index (line 29) * POSIX awk, continue statement and: Continue Statement. (line 43) * POSIX awk, CONVFMT variable and: User-modified. (line 28) -* POSIX awk, date utility and: Time Functions. (line 258) +* POSIX awk, date utility and: Time Functions. (line 261) * POSIX awk, field separators and <1>: Field Splitting Summary. (line 41) * POSIX awk, field separators and: Fields. (line 6) @@ -26677,7 +26692,7 @@ Index * right angle bracket (>), >> operator (I/O): Redirection. (line 50) * right shift, bitwise: Bitwise Functions. (line 32) * Ritchie, Dennis: Basic Data Typing. (line 71) -* RLENGTH variable: Auto-set. (line 171) +* RLENGTH variable: Auto-set. (line 176) * RLENGTH variable, match() function and: String Functions. (line 194) * Robbins, Arnold <1>: Future Extensions. (line 6) * Robbins, Arnold <2>: Bugs. (line 29) @@ -26703,9 +26718,9 @@ Index * RS variable: Records. (line 20) * RS variable, multiline records and: Multiple Line. (line 17) * rshift() function (gawk): Bitwise Functions. (line 51) -* RSTART variable: Auto-set. (line 177) +* RSTART variable: Auto-set. (line 182) * RSTART variable, match() function and: String Functions. (line 194) -* RT variable <1>: Auto-set. (line 184) +* RT variable <1>: Auto-set. (line 189) * RT variable <2>: Multiple Line. (line 129) * RT variable: Records. (line 112) * Rubin, Paul <1>: Contributors. (line 16) @@ -26882,7 +26897,7 @@ Index * syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) * system() function: I/O Functions. (line 64) -* systime() function (gawk): Time Functions. (line 61) +* systime() function (gawk): Time Functions. (line 64) * t debugger command (alias for tbreak): Breakpoint Control. (line 83) * tandem: Tandem Installation. (line 6) * tbreak debugger command: Breakpoint Control. (line 83) @@ -26925,7 +26940,7 @@ Index (line 6) * time, retrieving: Time Functions. (line 17) * timestamps: Time Functions. (line 6) -* timestamps, converting dates to: Time Functions. (line 71) +* timestamps, converting dates to: Time Functions. (line 74) * timestamps, formatted: Gettimeofday Function. (line 6) * tolower() function: String Functions. (line 495) @@ -27208,328 +27223,328 @@ Node: Command Line Field Separator191551 Node: Field Splitting Summary194990 Ref: Field Splitting Summary-Footnote-1198176 Node: Constant Size198277 -Node: Splitting By Content202748 -Ref: Splitting By Content-Footnote-1206350 -Node: Multiple Line206390 -Ref: Multiple Line-Footnote-1212130 -Node: Getline212309 -Node: Plain Getline214537 -Node: Getline/Variable216626 -Node: Getline/File217767 -Node: Getline/Variable/File219089 -Ref: Getline/Variable/File-Footnote-1220688 -Node: Getline/Pipe220775 -Node: Getline/Variable/Pipe223323 -Node: Getline/Coprocess224430 -Node: Getline/Variable/Coprocess225673 -Node: Getline Notes226387 -Node: Getline Summary228329 -Ref: table-getline-variants228613 -Node: Command line directories229518 -Node: Printing230143 -Node: Print231774 -Node: Print Examples233111 -Node: Output Separators235895 -Node: OFMT237654 -Node: Printf239012 -Node: Basic Printf239918 -Node: Control Letters241455 -Node: Format Modifiers245267 -Node: Printf Examples251278 -Node: Redirection253993 -Node: Special Files260971 -Node: Special FD261504 -Ref: Special FD-Footnote-1265079 -Node: Special Network265153 -Node: Special Caveats266008 -Node: Close Files And Pipes266802 -Ref: Close Files And Pipes-Footnote-1273746 -Ref: Close Files And Pipes-Footnote-2273894 -Node: Expressions274044 -Node: Values275113 -Node: Constants275789 -Node: Scalar Constants276469 -Ref: Scalar Constants-Footnote-1277328 -Node: Nondecimal-numbers277510 -Node: Regexp Constants280569 -Node: Using Constant Regexps281044 -Node: Variables284049 -Node: Using Variables284704 -Node: Assignment Options286431 -Node: Conversion288312 -Ref: table-locale-affects293686 -Ref: Conversion-Footnote-1294310 -Node: All Operators294419 -Node: Arithmetic Ops295049 -Node: Concatenation297548 -Ref: Concatenation-Footnote-1300341 -Node: Assignment Ops300460 -Ref: table-assign-ops305448 -Node: Increment Ops306849 -Node: Truth Values and Conditions310327 -Node: Truth Values311410 -Node: Typing and Comparison312458 -Node: Variable Typing313247 -Ref: Variable Typing-Footnote-1317144 -Node: Comparison Operators317266 -Ref: table-relational-ops317676 -Node: POSIX String Comparison321225 -Ref: POSIX String Comparison-Footnote-1322182 -Node: Boolean Ops322320 -Ref: Boolean Ops-Footnote-1326398 -Node: Conditional Exp326489 -Node: Function Calls328221 -Node: Precedence331780 -Node: Patterns and Actions335433 -Node: Pattern Overview336487 -Node: Regexp Patterns338153 -Node: Expression Patterns338696 -Node: Ranges342270 -Node: BEGIN/END345236 -Node: Using BEGIN/END345986 -Ref: Using BEGIN/END-Footnote-1348717 -Node: I/O And BEGIN/END348831 -Node: Empty351100 -Node: BEGINFILE/ENDFILE351434 -Node: Using Shell Variables354259 -Node: Action Overview356538 -Node: Statements358895 -Node: If Statement360754 -Node: While Statement362253 -Node: Do Statement364297 -Node: For Statement365453 -Node: Switch Statement368605 -Node: Break Statement370702 -Node: Continue Statement372678 -Node: Next Statement374379 -Node: Nextfile Statement376761 -Node: Exit Statement379279 -Node: Built-in Variables381610 -Node: User-modified382705 -Ref: User-modified-Footnote-1390706 -Node: Auto-set390768 -Ref: Auto-set-Footnote-1399559 -Node: ARGC and ARGV399764 -Node: Arrays403523 -Node: Array Basics405094 -Node: Array Intro405805 -Node: Reference to Elements410123 -Node: Assigning Elements412393 -Node: Array Example412884 -Node: Scanning an Array414616 -Node: Delete416893 -Ref: Delete-Footnote-1419291 -Node: Numeric Array Subscripts419348 -Node: Uninitialized Subscripts421531 -Node: Multi-dimensional423159 -Node: Multi-scanning426250 -Node: Array Sorting427834 -Ref: Array Sorting-Footnote-1431032 -Node: Arrays of Arrays431226 -Node: Functions435388 -Node: Built-in436210 -Node: Calling Built-in437224 -Node: Numeric Functions439200 -Ref: Numeric Functions-Footnote-1442909 -Ref: Numeric Functions-Footnote-2443245 -Ref: Numeric Functions-Footnote-3443293 -Node: String Functions443562 -Ref: String Functions-Footnote-1465361 -Ref: String Functions-Footnote-2465490 -Ref: String Functions-Footnote-3465738 -Node: Gory Details465825 -Ref: table-sub-escapes467482 -Ref: table-posix-sub468796 -Ref: table-gensub-escapes469696 -Node: I/O Functions470867 -Ref: I/O Functions-Footnote-1477564 -Node: Time Functions477711 -Ref: Time Functions-Footnote-1488367 -Ref: Time Functions-Footnote-2488435 -Ref: Time Functions-Footnote-3488593 -Ref: Time Functions-Footnote-4488704 -Ref: Time Functions-Footnote-5488816 -Ref: Time Functions-Footnote-6489043 -Node: Bitwise Functions489309 -Ref: table-bitwise-ops489867 -Ref: Bitwise Functions-Footnote-1494027 -Node: I18N Functions494211 -Node: User-defined495841 -Node: Definition Syntax496645 -Ref: Definition Syntax-Footnote-1501275 -Node: Function Example501344 -Node: Function Caveats503938 -Node: Calling A Function504359 -Node: Variable Scope505448 -Node: Pass By Value/Reference507376 -Node: Return Statement510816 -Node: Dynamic Typing513758 -Node: Indirect Calls514495 -Node: Internationalization524180 -Node: I18N and L10N525608 -Node: Explaining gettext526294 -Ref: Explaining gettext-Footnote-1531356 -Ref: Explaining gettext-Footnote-2531539 -Node: Programmer i18n531704 -Node: Translator i18n535967 -Node: String Extraction536760 -Ref: String Extraction-Footnote-1537721 -Node: Printf Ordering537807 -Ref: Printf Ordering-Footnote-1540591 -Node: I18N Portability540655 -Ref: I18N Portability-Footnote-1543104 -Node: I18N Example543167 -Ref: I18N Example-Footnote-1545802 -Node: Gawk I18N545874 -Node: Advanced Features546443 -Node: Nondecimal Data547762 -Node: Two-way I/O549323 -Ref: Two-way I/O-Footnote-1554737 -Node: TCP/IP Networking554814 -Node: Profiling557586 -Node: Library Functions564986 -Ref: Library Functions-Footnote-1567956 -Node: Library Names568127 -Ref: Library Names-Footnote-1571598 -Ref: Library Names-Footnote-2571818 -Node: General Functions571904 -Node: Nextfile Function572967 -Node: Strtonum Function577348 -Node: Assert Function580299 -Node: Round Function583625 -Node: Cliff Random Function585166 -Node: Ordinal Functions586182 -Ref: Ordinal Functions-Footnote-1589252 -Ref: Ordinal Functions-Footnote-2589504 -Node: Join Function589720 -Ref: Join Function-Footnote-1591491 -Node: Gettimeofday Function591691 -Node: Data File Management595406 -Node: Filetrans Function596038 -Node: Rewind Function600275 -Node: File Checking601728 -Node: Empty Files602822 -Node: Ignoring Assigns605052 -Node: Getopt Function606605 -Ref: Getopt Function-Footnote-1617930 -Node: Passwd Functions618133 -Ref: Passwd Functions-Footnote-1627121 -Node: Group Functions627209 -Node: Sample Programs635289 -Node: Running Examples635954 -Node: Clones636682 -Node: Cut Program637805 -Node: Egrep Program647646 -Ref: Egrep Program-Footnote-1655417 -Node: Id Program655527 -Node: Split Program659143 -Ref: Split Program-Footnote-1662662 -Node: Tee Program662790 -Node: Uniq Program665593 -Node: Wc Program673016 -Ref: Wc Program-Footnote-1677280 -Node: Miscellaneous Programs677480 -Node: Dupword Program678600 -Node: Alarm Program680631 -Node: Translate Program685353 -Ref: Translate Program-Footnote-1689732 -Ref: Translate Program-Footnote-2689960 -Node: Labels Program690094 -Ref: Labels Program-Footnote-1693385 -Node: Word Sorting693469 -Node: History Sorting697816 -Node: Extract Program699654 -Node: Simple Sed707017 -Node: Igawk Program710078 -Ref: Igawk Program-Footnote-1724813 -Ref: Igawk Program-Footnote-2725014 -Node: Signature Program725152 -Node: Debugger726232 -Node: Debugging727108 -Node: Debugging Concepts727422 -Node: Debugging Terms729275 -Node: Awk Debugging731823 -Node: Sample dgawk session732715 -Node: dgawk invocation733207 -Node: Finding The Bug734391 -Node: List of Debugger Commands740922 -Node: Breakpoint Control742237 -Node: Dgawk Execution Control745447 -Node: Viewing And Changing Data748796 -Node: Dgawk Stack752092 -Node: Dgawk Info753553 -Node: Miscellaneous Dgawk Commands757491 -Node: Readline Support763207 -Node: Dgawk Limitations764023 -Node: Language History766195 -Node: V7/SVR3.1767572 -Node: SVR4769867 -Node: POSIX771312 -Node: BTL773024 -Node: POSIX/GNU774714 -Node: Contributors784461 -Node: Installation788070 -Node: Gawk Distribution789041 -Node: Getting789525 -Node: Extracting790351 -Node: Distribution contents791739 -Node: Unix Installation796812 -Node: Quick Installation797403 -Node: Additional Configuration Options799105 -Node: Configuration Philosophy800868 -Node: Non-Unix Installation803232 -Node: PC Installation803697 -Node: PC Binary Installation805003 -Node: PC Compiling806846 -Node: PC Dynamic811351 -Node: PC Using813714 -Node: Cygwin818262 -Node: MSYS819246 -Node: VMS Installation819752 -Node: VMS Compilation820356 -Node: VMS Installation Details821933 -Node: VMS Running823563 -Node: VMS POSIX825160 -Node: VMS Old Gawk826458 -Node: Unsupported826927 -Node: Atari Installation827389 -Node: Atari Compiling828676 -Node: Atari Using830565 -Node: BeOS Installation833412 -Node: Tandem Installation834557 -Node: Bugs836236 -Node: Other Versions840068 -Node: Notes845290 -Node: Compatibility Mode845982 -Node: Additions846765 -Node: Adding Code847515 -Node: New Ports853567 -Node: Dynamic Extensions857699 -Node: Internals859080 -Node: Plugin License869485 -Node: Sample Library870119 -Node: Internal File Description870783 -Node: Internal File Ops874478 -Ref: Internal File Ops-Footnote-1879354 -Node: Using Internal File Ops879502 -Node: Future Extensions881527 -Node: Basic Concepts885564 -Node: Basic High Level886321 -Ref: Basic High Level-Footnote-1890440 -Node: Basic Data Typing890634 -Node: Floating Point Issues895071 -Node: String Conversion Precision896154 -Ref: String Conversion Precision-Footnote-1897848 -Node: Unexpected Results897957 -Node: POSIX Floating Point Problems899783 -Ref: POSIX Floating Point Problems-Footnote-1903482 -Node: Glossary903520 -Node: Copying927303 -Node: GNU Free Documentation License964860 -Node: next-edition990004 -Node: unresolved990356 -Node: revision990856 -Node: consistency991279 -Node: Index994632 +Node: Splitting By Content202839 +Ref: Splitting By Content-Footnote-1206565 +Node: Multiple Line206605 +Ref: Multiple Line-Footnote-1212345 +Node: Getline212524 +Node: Plain Getline214752 +Node: Getline/Variable216841 +Node: Getline/File217982 +Node: Getline/Variable/File219304 +Ref: Getline/Variable/File-Footnote-1220903 +Node: Getline/Pipe220990 +Node: Getline/Variable/Pipe223538 +Node: Getline/Coprocess224645 +Node: Getline/Variable/Coprocess225888 +Node: Getline Notes226602 +Node: Getline Summary228544 +Ref: table-getline-variants228828 +Node: Command line directories229733 +Node: Printing230358 +Node: Print231989 +Node: Print Examples233326 +Node: Output Separators236110 +Node: OFMT237869 +Node: Printf239227 +Node: Basic Printf240133 +Node: Control Letters241670 +Node: Format Modifiers245482 +Node: Printf Examples251493 +Node: Redirection254208 +Node: Special Files261186 +Node: Special FD261719 +Ref: Special FD-Footnote-1265294 +Node: Special Network265368 +Node: Special Caveats266223 +Node: Close Files And Pipes267017 +Ref: Close Files And Pipes-Footnote-1273961 +Ref: Close Files And Pipes-Footnote-2274109 +Node: Expressions274259 +Node: Values275328 +Node: Constants276004 +Node: Scalar Constants276684 +Ref: Scalar Constants-Footnote-1277543 +Node: Nondecimal-numbers277725 +Node: Regexp Constants280784 +Node: Using Constant Regexps281259 +Node: Variables284264 +Node: Using Variables284919 +Node: Assignment Options286646 +Node: Conversion288527 +Ref: table-locale-affects293901 +Ref: Conversion-Footnote-1294525 +Node: All Operators294634 +Node: Arithmetic Ops295264 +Node: Concatenation297763 +Ref: Concatenation-Footnote-1300556 +Node: Assignment Ops300675 +Ref: table-assign-ops305663 +Node: Increment Ops307064 +Node: Truth Values and Conditions310542 +Node: Truth Values311625 +Node: Typing and Comparison312673 +Node: Variable Typing313462 +Ref: Variable Typing-Footnote-1317359 +Node: Comparison Operators317481 +Ref: table-relational-ops317891 +Node: POSIX String Comparison321440 +Ref: POSIX String Comparison-Footnote-1322397 +Node: Boolean Ops322535 +Ref: Boolean Ops-Footnote-1326613 +Node: Conditional Exp326704 +Node: Function Calls328436 +Node: Precedence331995 +Node: Patterns and Actions335648 +Node: Pattern Overview336702 +Node: Regexp Patterns338368 +Node: Expression Patterns338911 +Node: Ranges342485 +Node: BEGIN/END345451 +Node: Using BEGIN/END346201 +Ref: Using BEGIN/END-Footnote-1348932 +Node: I/O And BEGIN/END349046 +Node: Empty351315 +Node: BEGINFILE/ENDFILE351649 +Node: Using Shell Variables354474 +Node: Action Overview356753 +Node: Statements359110 +Node: If Statement360969 +Node: While Statement362468 +Node: Do Statement364512 +Node: For Statement365668 +Node: Switch Statement368820 +Node: Break Statement370917 +Node: Continue Statement372893 +Node: Next Statement374594 +Node: Nextfile Statement376976 +Node: Exit Statement379494 +Node: Built-in Variables381825 +Node: User-modified382920 +Ref: User-modified-Footnote-1390921 +Node: Auto-set390983 +Ref: Auto-set-Footnote-1399966 +Node: ARGC and ARGV400171 +Node: Arrays403930 +Node: Array Basics405501 +Node: Array Intro406212 +Node: Reference to Elements410530 +Node: Assigning Elements412800 +Node: Array Example413291 +Node: Scanning an Array415023 +Node: Delete417300 +Ref: Delete-Footnote-1419698 +Node: Numeric Array Subscripts419755 +Node: Uninitialized Subscripts421938 +Node: Multi-dimensional423566 +Node: Multi-scanning426657 +Node: Array Sorting428241 +Ref: Array Sorting-Footnote-1431439 +Node: Arrays of Arrays431633 +Node: Functions435795 +Node: Built-in436617 +Node: Calling Built-in437631 +Node: Numeric Functions439607 +Ref: Numeric Functions-Footnote-1443316 +Ref: Numeric Functions-Footnote-2443652 +Ref: Numeric Functions-Footnote-3443700 +Node: String Functions443969 +Ref: String Functions-Footnote-1465768 +Ref: String Functions-Footnote-2465897 +Ref: String Functions-Footnote-3466145 +Node: Gory Details466232 +Ref: table-sub-escapes467889 +Ref: table-posix-sub469203 +Ref: table-gensub-escapes470103 +Node: I/O Functions471274 +Ref: I/O Functions-Footnote-1477971 +Node: Time Functions478118 +Ref: Time Functions-Footnote-1488985 +Ref: Time Functions-Footnote-2489053 +Ref: Time Functions-Footnote-3489211 +Ref: Time Functions-Footnote-4489322 +Ref: Time Functions-Footnote-5489434 +Ref: Time Functions-Footnote-6489661 +Node: Bitwise Functions489927 +Ref: table-bitwise-ops490485 +Ref: Bitwise Functions-Footnote-1494645 +Node: I18N Functions494829 +Node: User-defined496459 +Node: Definition Syntax497263 +Ref: Definition Syntax-Footnote-1501893 +Node: Function Example501962 +Node: Function Caveats504556 +Node: Calling A Function504977 +Node: Variable Scope506066 +Node: Pass By Value/Reference507994 +Node: Return Statement511434 +Node: Dynamic Typing514376 +Node: Indirect Calls515113 +Node: Internationalization524798 +Node: I18N and L10N526226 +Node: Explaining gettext526912 +Ref: Explaining gettext-Footnote-1531974 +Ref: Explaining gettext-Footnote-2532157 +Node: Programmer i18n532322 +Node: Translator i18n536585 +Node: String Extraction537378 +Ref: String Extraction-Footnote-1538339 +Node: Printf Ordering538425 +Ref: Printf Ordering-Footnote-1541209 +Node: I18N Portability541273 +Ref: I18N Portability-Footnote-1543722 +Node: I18N Example543785 +Ref: I18N Example-Footnote-1546420 +Node: Gawk I18N546492 +Node: Advanced Features547061 +Node: Nondecimal Data548380 +Node: Two-way I/O549941 +Ref: Two-way I/O-Footnote-1555355 +Node: TCP/IP Networking555432 +Node: Profiling558204 +Node: Library Functions565604 +Ref: Library Functions-Footnote-1568574 +Node: Library Names568745 +Ref: Library Names-Footnote-1572216 +Ref: Library Names-Footnote-2572436 +Node: General Functions572522 +Node: Nextfile Function573585 +Node: Strtonum Function577966 +Node: Assert Function580917 +Node: Round Function584243 +Node: Cliff Random Function585784 +Node: Ordinal Functions586800 +Ref: Ordinal Functions-Footnote-1589870 +Ref: Ordinal Functions-Footnote-2590122 +Node: Join Function590338 +Ref: Join Function-Footnote-1592109 +Node: Gettimeofday Function592309 +Node: Data File Management596024 +Node: Filetrans Function596656 +Node: Rewind Function600893 +Node: File Checking602346 +Node: Empty Files603440 +Node: Ignoring Assigns605670 +Node: Getopt Function607223 +Ref: Getopt Function-Footnote-1618548 +Node: Passwd Functions618751 +Ref: Passwd Functions-Footnote-1627739 +Node: Group Functions627827 +Node: Sample Programs635907 +Node: Running Examples636572 +Node: Clones637300 +Node: Cut Program638423 +Node: Egrep Program648264 +Ref: Egrep Program-Footnote-1656035 +Node: Id Program656145 +Node: Split Program659761 +Ref: Split Program-Footnote-1663280 +Node: Tee Program663408 +Node: Uniq Program666211 +Node: Wc Program673634 +Ref: Wc Program-Footnote-1677898 +Node: Miscellaneous Programs678098 +Node: Dupword Program679218 +Node: Alarm Program681249 +Node: Translate Program685971 +Ref: Translate Program-Footnote-1690350 +Ref: Translate Program-Footnote-2690578 +Node: Labels Program690712 +Ref: Labels Program-Footnote-1694003 +Node: Word Sorting694087 +Node: History Sorting698434 +Node: Extract Program700272 +Node: Simple Sed707635 +Node: Igawk Program710696 +Ref: Igawk Program-Footnote-1725431 +Ref: Igawk Program-Footnote-2725632 +Node: Signature Program725770 +Node: Debugger726850 +Node: Debugging727726 +Node: Debugging Concepts728040 +Node: Debugging Terms729893 +Node: Awk Debugging732441 +Node: Sample dgawk session733333 +Node: dgawk invocation733825 +Node: Finding The Bug735009 +Node: List of Debugger Commands741540 +Node: Breakpoint Control742855 +Node: Dgawk Execution Control746065 +Node: Viewing And Changing Data749414 +Node: Dgawk Stack752710 +Node: Dgawk Info754171 +Node: Miscellaneous Dgawk Commands758109 +Node: Readline Support763825 +Node: Dgawk Limitations764641 +Node: Language History766813 +Node: V7/SVR3.1768190 +Node: SVR4770485 +Node: POSIX771930 +Node: BTL773642 +Node: POSIX/GNU775332 +Node: Contributors785138 +Node: Installation788747 +Node: Gawk Distribution789718 +Node: Getting790202 +Node: Extracting791028 +Node: Distribution contents792416 +Node: Unix Installation797489 +Node: Quick Installation798080 +Node: Additional Configuration Options799782 +Node: Configuration Philosophy801545 +Node: Non-Unix Installation803909 +Node: PC Installation804374 +Node: PC Binary Installation805680 +Node: PC Compiling807523 +Node: PC Dynamic812028 +Node: PC Using814391 +Node: Cygwin818939 +Node: MSYS819923 +Node: VMS Installation820429 +Node: VMS Compilation821033 +Node: VMS Installation Details822610 +Node: VMS Running824240 +Node: VMS POSIX825837 +Node: VMS Old Gawk827135 +Node: Unsupported827604 +Node: Atari Installation828066 +Node: Atari Compiling829353 +Node: Atari Using831242 +Node: BeOS Installation834089 +Node: Tandem Installation835234 +Node: Bugs836913 +Node: Other Versions840745 +Node: Notes845967 +Node: Compatibility Mode846659 +Node: Additions847442 +Node: Adding Code848192 +Node: New Ports854244 +Node: Dynamic Extensions858376 +Node: Internals859757 +Node: Plugin License870162 +Node: Sample Library870796 +Node: Internal File Description871460 +Node: Internal File Ops875155 +Ref: Internal File Ops-Footnote-1880031 +Node: Using Internal File Ops880179 +Node: Future Extensions882204 +Node: Basic Concepts886241 +Node: Basic High Level886998 +Ref: Basic High Level-Footnote-1891117 +Node: Basic Data Typing891311 +Node: Floating Point Issues895748 +Node: String Conversion Precision896831 +Ref: String Conversion Precision-Footnote-1898525 +Node: Unexpected Results898634 +Node: POSIX Floating Point Problems900460 +Ref: POSIX Floating Point Problems-Footnote-1904159 +Node: Glossary904197 +Node: Copying927980 +Node: GNU Free Documentation License965537 +Node: next-edition990681 +Node: unresolved991033 +Node: revision991533 +Node: consistency991956 +Node: Index995309 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index aea4bf9f..66db12cc 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -6393,8 +6393,10 @@ or it is @code{"FIELDWIDTHS"} if fixed-width field splitting is being used: @example if (PROCINFO["FS"] == "FS") @var{regular field splitting} @dots{} -else +else if (PROCINFO["FS"] == "FIELDWIDTHS") @var{fixed-width field splitting} @dots{} +else + @var{content-based field splitting} @dots{} @end example This information is useful when writing a function @@ -6505,6 +6507,9 @@ if (substr($i, 1, 1) == "\"") @{ As with @code{FS}, the @code{IGNORECASE} variable (@pxref{User-modified}) affects field splitting with @code{FPAT}. +Similar to @code{FIELDWIDTHS}, the value of @code{PROCINFO["FS"]} +will be @code{"FPAT"} if content-based field splitting is being used. + @quotation NOTE Some programs export CSV data that contains embedded newlines between the double quotes. @command{gawk} provides no way to deal with this. @@ -6514,7 +6519,7 @@ the @code{FPAT} mechanism provides an elegant solution for the majority of cases, and the @command{gawk} maintainer is satisfied with that. @end quotation -As written, the regexp used for @code{FPATH} requires that each field +As written, the regexp used for @code{FPAT} requires that each field have a least one character. A straightforward modification (changing changed the first @samp{+} to @samp{*}) allows fields to be empty: @@ -12679,6 +12684,11 @@ The parent process ID of the current process. @item PROCINFO["uid"] The value of the @code{getuid()} system call. +@item PROCINFO["strftime"] +The default time format string for @code{strftime()}. +Assigning a new value to this element changes the default. +@xref{Time Functions}. + @item PROCINFO["version"] The version of @command{gawk}. @end table @@ -15522,8 +15532,12 @@ The @var{timestamp} is in the same format as the value returned by the @code{systime()} function. If no @var{timestamp} argument is supplied, @command{gawk} uses the current time of day as the timestamp. If no @var{format} argument is supplied, @code{strftime()} uses +the value of @code{PROCINFO["strftime"]} as the format string. +The default string value is @code{@w{"%a %b %e %H:%M:%S %Z %Y"}}. This format string produces output that is equivalent to that of the @command{date} utility. +You can assign a new value to @code{PROCINFO["strftime"]} to +change the default format. @item systime() @cindex @code{systime()} function (@command{gawk}) @@ -15556,7 +15570,8 @@ returned string, while substituting date and time values for format specifications in the @var{format} string. @cindex format specifiers, @code{strftime()} function (@command{gawk}) -@code{strftime()} is guaranteed by the 1999 ISO C standard@footnote{Unfortunately, +@code{strftime()} is guaranteed by the 1999 ISO C +standard@footnote{Unfortunately, not every system's @code{strftime()} necessarily supports all of the conversions listed here.} to support the following date format specifications: @@ -15579,7 +15594,8 @@ The locale's ``appropriate'' date and time representation. (This is @samp{%A %B %d %T %Y} in the @code{"C"} locale.) @item %C -The century. This is the year divided by 100 and truncated to the next +The century part of the current year. +This is the year divided by 100 and truncated to the next lower integer. @item %d @@ -26339,6 +26355,10 @@ The @code{FPAT} variable and its effects (@pxref{Splitting By Content}). @item +@code{PROCINFO["strftime"]} was added +(@pxref{Auto-set}). + +@item The @code{patsplit()} function (@pxref{String Functions}). @@ -171,6 +171,8 @@ const int gawk_mb_cur_max = 1; FILE *output_fp; int output_is_tty = FALSE; /* control flushing of output */ +const char def_strftime_format[] = "%a %b %e %H:%M:%S %Z %Y"; + extern const char *version_string; #if defined (HAVE_GETGROUPS) && defined(NGROUPS_MAX) && NGROUPS_MAX > 0 @@ -1056,6 +1058,9 @@ load_procinfo() PROCINFO_node = install_symbol(estrdup("PROCINFO", 8), mk_symbol(Node_var_array, (NODE *) NULL)); + update_PROCINFO_str("version", VERSION); + update_PROCINFO_str("strftime", def_strftime_format); + #ifdef GETPGRP_VOID #define getpgrp_arg() /* nothing */ #else @@ -1065,15 +1070,12 @@ load_procinfo() value = getpgrp(getpgrp_arg()); update_PROCINFO_num("pgrpid", value); - /* - * could put a lot of this into a table, but then there's - * portability problems declaring all the functions. so just - * do it the slow and stupid way. sigh. + * Could put a lot of this into a table, but then there's + * portability problems declaring all the functions. So just + * do it the slow and stupid way. Sigh. */ - update_PROCINFO_str("version", VERSION); - value = getpid(); update_PROCINFO_num("pid", value); |