diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2017-02-23 05:56:22 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2017-02-23 05:56:22 +0200 |
commit | 7bbeac0ea5f8ecf4925dc982dbebfcc4ba0c5b11 (patch) | |
tree | 0df4d527821ad6efb6fd0877eb9aab03ebcc62be | |
parent | f91f8ee802f852135c237aafe6e17c02e4439aa5 (diff) | |
parent | 7704e90c4f3aa4b3ce093bd9d67dee2b70f5acbc (diff) | |
download | egawk-7bbeac0ea5f8ecf4925dc982dbebfcc4ba0c5b11.tar.gz egawk-7bbeac0ea5f8ecf4925dc982dbebfcc4ba0c5b11.tar.bz2 egawk-7bbeac0ea5f8ecf4925dc982dbebfcc4ba0c5b11.zip |
Merge branch 'master' into feature/stringfix
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | awk.h | 2 | ||||
-rw-r--r-- | awkgram.c | 2 | ||||
-rw-r--r-- | awkgram.y | 2 | ||||
-rw-r--r-- | builtin.c | 42 | ||||
-rw-r--r-- | doc/ChangeLog | 6 | ||||
-rw-r--r-- | doc/awkcard.in | 5 | ||||
-rw-r--r-- | doc/gawk.1 | 8 | ||||
-rw-r--r-- | doc/gawk.info | 676 | ||||
-rw-r--r-- | doc/gawk.texi | 6 | ||||
-rw-r--r-- | doc/gawktexi.in | 6 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 10 | ||||
-rw-r--r-- | test/Maketests | 5 | ||||
-rw-r--r-- | test/mktime.awk | 3 | ||||
-rw-r--r-- | test/mktime.in | 1 | ||||
-rw-r--r-- | test/mktime.ok | 1 |
21 files changed, 458 insertions, 355 deletions
@@ -1,3 +1,21 @@ +2017-02-23 Arnold D. Robbins <arnold@skeeve.com> + + * awk.h (boolval): Return bool instead of int. + * eval.c (eval_condition): Same. + * io.c (pty_vs_pipe): Same + Thanks to Andrew Schorr for pointing these out. + +2017-02-21 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * NEWS: Document that mktime now takes an optional utc-flag argument. + * awkgram.y (tokentab): Modify mktime entry to indicate that it may + accept two arguments. + * builtin.c (mktime_tz): New function to run mktime in an arbitrary + time zone. Code was copied from the Linux timegm man page. + (do_mktime): Add support for new optional 2nd argument utc-flag by + using the new mktime_tz function. + (do_strftime): Change do_gmt type from int to bool. + 2017-02-17 Arnold D. Robbins <arnold@skeeve.com> * builtin.c (do_typeof): Handle arguments that have @@ -100,6 +100,10 @@ Changes from 4.1.x to 4.2.0 24. Programs that toggle IGNORECASE a lot should now be noticeably faster. +25. The mktime function now accepts an optional second argument. If this + argument is present and is non-zero or non-null, the time will be converted + from UTC instead of from the local timezone. + Changes from 4.1.3 to 4.1.4 --------------------------- @@ -1914,7 +1914,7 @@ fixtype(NODE *n) * non-null. Otherwise, the value is false. */ -static inline int +static inline bool boolval(NODE *t) { (void) fixtype(t); @@ -4554,7 +4554,7 @@ static const struct token tokentab[] = { {"log", Op_builtin, LEX_BUILTIN, A(1), do_log, MPF(log)}, {"lshift", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_lshift, MPF(lshift)}, {"match", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_match, 0}, -{"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_mktime, 0}, +{"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_mktime, 0}, {"next", Op_K_next, LEX_NEXT, 0, 0, 0}, {"nextfile", Op_K_nextfile, LEX_NEXTFILE, 0, 0, 0}, {"or", Op_builtin, LEX_BUILTIN, GAWKX, do_or, MPF(or)}, @@ -2134,7 +2134,7 @@ static const struct token tokentab[] = { {"log", Op_builtin, LEX_BUILTIN, A(1), do_log, MPF(log)}, {"lshift", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_lshift, MPF(lshift)}, {"match", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_match, 0}, -{"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_mktime, 0}, +{"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_mktime, 0}, {"next", Op_K_next, LEX_NEXT, 0, 0, 0}, {"nextfile", Op_K_nextfile, LEX_NEXTFILE, 0, 0, 0}, {"or", Op_builtin, LEX_BUILTIN, GAWKX, do_or, MPF(or)}, @@ -1904,7 +1904,7 @@ do_strftime(int nargs) char buf[BUFSIZ]; const char *format; int formatlen; - int do_gmt; + bool do_gmt; NODE *val = NULL; NODE *sub = NULL; char save; @@ -2037,19 +2037,55 @@ do_systime(int nargs ATTRIBUTE_UNUSED) return make_number((AWKNUM) lclock); } +/* mktime_tz --- based on Linux timegm man page */ + +static time_t +mktime_tz(struct tm *tm, const char *tzreq) +{ + time_t ret; + char *tz = getenv("TZ"); + + if (tz) + tz = estrdup(tz, strlen(tz)); + if (setenv("TZ", tzreq, 1) < 0) { + warning(_("setenv(TZ, %s) failed (%s)"), tzreq, strerror(errno)); + return -1; + } + tzset(); + ret = mktime(tm); + if (tz) { + if (setenv("TZ", tz, 1) < 0) + fatal(_("setenv(TZ, %s) restoration failed (%s)"), tz, strerror(errno)); + free(tz); + } else { + if (unsetenv("TZ") < 0) + fatal(_("unsetenv(TZ) failed (%s)"), strerror(errno)); + } + tzset(); + return ret; +} + /* do_mktime --- turn a time string into a timestamp */ NODE * do_mktime(int nargs) { - NODE *t1; + NODE *t1, *t2; struct tm then; long year; int month, day, hour, minute, second, count; int dst = -1; /* default is unknown */ time_t then_stamp; char save; + bool do_gmt; + if (nargs == 2) { + t2 = POP_SCALAR(); + do_gmt = boolval(t2); + DEREF(t2); + } + else + do_gmt = false; t1 = POP_SCALAR(); if (do_lint && (fixtype(t1)->flags & STRING) == 0) lintwarn(_("mktime: received non-string argument")); @@ -2089,7 +2125,7 @@ do_mktime(int nargs) then.tm_year = year - 1900; then.tm_isdst = dst; - then_stamp = mktime(& then); + then_stamp = (do_gmt ? mktime_tz(& then, "UTC+0") : mktime(& then)); return make_number((AWKNUM) then_stamp); } diff --git a/doc/ChangeLog b/doc/ChangeLog index 58b206f9..fb1adbde 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2017-02-21 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * gawk.1: Document new mktime optional 2nd utc-flag argument. + * gawktex.in: Ditto. + * awkcard.in: Ditto. + 2017-02-13 Arnold D. Robbins <arnold@skeeve.com> * gawktexi.in: Fix two typos. diff --git a/doc/awkcard.in b/doc/awkcard.in index 16e4b19d..7c9eab75 100644 --- a/doc/awkcard.in +++ b/doc/awkcard.in @@ -1794,13 +1794,16 @@ formatting them. .fi .in +.2i .ti -.2i -\*(FCmktime(\*(FIdatespec\*(FC)\*(FR +\*(FCmktime(\*(FIdatespec \*(FR[\*(FC, \*(FIutc-flag\*(FR]\*(FC)\*(FR .br Convert \*(FIdatespec\fP into a time stamp of the same form as returned by \*(FCsystime()\*(FR and return it. The \*(FIdatespec\fP is a string of the form \*(FC"\*(FIYYYY MM DD HH MM SS[ DST]\*(FC"\*(FR. +If \*(FIutc-flag\*(FR +is present and is non-zero or non-null, the result +is in UTC, otherwise it is in local time. .ti -.2i \*(FCstrftime(\*(FR[\*(FIformat \*(FR[\*(FC, \*(FItimestamp\*(FR[\*(FC, \*(FIutc-flag\*(FR]]]\*(FC)\*(FR .br @@ -3105,7 +3105,7 @@ provides the following functions for obtaining time stamps and formatting them. .PP .TP "\w'\fBsystime()\fR'u+1n" -\fBmktime(\fIdatespec\fB)\fR +\fBmktime(\fIdatespec\fR [\fB, \fIutc-flag\fR]\fB)\fR Turn .I datespec into a time stamp of the same form as returned by @@ -3127,7 +3127,11 @@ The values of these numbers need not be within the ranges specified; for example, an hour of \-1 means 1 hour before midnight. The origin-zero Gregorian calendar is assumed, with year 0 preceding year 1 and year \-1 preceding year 0. -The time is assumed to be in the local timezone. +If +.I utc-flag +is present and is non-zero or non-null, the time is assumed to be in +the UTC timezone; otherwise, the +time is assumed to be in the local timezone. If the daylight saving flag is positive, the time is assumed to be daylight saving time; if zero, the time is assumed to be standard time; diff --git a/doc/gawk.info b/doc/gawk.info index 356051f8..188b78cd 100644 --- a/doc/gawk.info +++ b/doc/gawk.info @@ -13257,7 +13257,7 @@ POSIX standard.(2) However, recent versions of 'mawk' (*note Other Versions::) also support these functions. Optional parameters are enclosed in square brackets ([ ]): -'mktime(DATESPEC)' +'mktime(DATESPEC' [', UTC-FLAG' ]')' Turn DATESPEC into a timestamp in the same form as is returned by 'systime()'. It is similar to the function of the same name in ISO C. The argument, DATESPEC, is a string of the form @@ -13270,12 +13270,14 @@ enclosed in square brackets ([ ]): The values of these numbers need not be within the ranges specified; for example, an hour of -1 means 1 hour before midnight. The origin-zero Gregorian calendar is assumed, with year 0 - preceding year 1 and year -1 preceding year 0. The time is assumed - to be in the local time zone. If the daylight-savings flag is - positive, the time is assumed to be daylight savings time; if zero, - the time is assumed to be standard time; and if negative (the - default), 'mktime()' attempts to determine whether daylight savings - time is in effect for the specified time. + preceding year 1 and year -1 preceding year 0. If UTC-FLAG is + present and is either nonzero or non-null, the time is assumed to + be in the UTC time zone; otherwise, the time is assumed to be in + the local time zone. If the daylight-savings flag is positive, the + time is assumed to be daylight savings time; if zero, the time is + assumed to be standard time; and if negative (the default), + 'mktime()' attempts to determine whether daylight savings time is + in effect for the specified time. If DATESPEC does not contain enough elements or if the resulting time is out of range, 'mktime()' returns -1. @@ -33146,7 +33148,7 @@ Index * convert string to upper case: String Functions. (line 530) * converting integer array subscripts: Numeric Array Subscripts. (line 31) -* converting, dates to timestamps: Time Functions. (line 76) +* converting, dates to timestamps: Time Functions. (line 78) * converting, numbers to strings: Strings And Numbers. (line 6) * converting, numbers to strings <1>: Bitwise Functions. (line 108) * converting, strings to numbers: Strings And Numbers. (line 6) @@ -33169,7 +33171,7 @@ Index * csh utility, |& operator, comparison with: Two-way I/O. (line 27) * ctime() user-defined function: Function Example. (line 74) * currency symbols, localization: Explaining gettext. (line 104) -* current system time: Time Functions. (line 66) +* current system time: Time Functions. (line 68) * custom.h file: Configuration Philosophy. (line 30) * customized input parser: Input Parsers. (line 6) @@ -33232,8 +33234,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 253) -* dates, converting to timestamps: Time Functions. (line 76) +* date utility, POSIX: Time Functions. (line 255) +* dates, converting to timestamps: Time Functions. (line 78) * dates, information related to, localization: Explaining gettext. (line 112) * Davies, Stephen: Acknowledgments. (line 60) @@ -33768,8 +33770,8 @@ Index (line 57) * format specifiers, printf statement: Control Letters. (line 6) * format specifiers, strftime() function (gawk): Time Functions. - (line 89) -* format time string: Time Functions. (line 48) + (line 91) +* format time string: Time Functions. (line 50) * formats, numeric output: OFMT. (line 6) * formatting output: Printf. (line 6) * formatting strings: String Functions. (line 384) @@ -33927,7 +33929,7 @@ Index * gawk, octal numbers and: Nondecimal-numbers. (line 41) * gawk, predefined variables and: Built-in Variables. (line 14) * gawk, PROCINFO array in: Auto-set. (line 148) -* gawk, PROCINFO array in <1>: Time Functions. (line 47) +* gawk, PROCINFO array in <1>: Time Functions. (line 49) * gawk, PROCINFO array in <2>: Two-way I/O. (line 114) * gawk, regexp constants and: Standard Regexp Constants. (line 28) @@ -34632,7 +34634,7 @@ Index * POSIX awk, changes in awk versions: POSIX. (line 6) * POSIX awk, continue statement and: Continue Statement. (line 44) * POSIX awk, CONVFMT variable and: User-modified. (line 30) -* POSIX awk, date utility and: Time Functions. (line 253) +* POSIX awk, date utility and: Time Functions. (line 255) * POSIX awk, field separators and: Full Line Fields. (line 16) * POSIX awk, function keyword in: Definition Syntax. (line 99) * POSIX awk, functions and, gsub()/sub(): Gory Details. (line 90) @@ -34705,7 +34707,7 @@ Index * processes, two-way communications with: Two-way I/O. (line 6) * processing data: Basic High Level. (line 6) * PROCINFO array: Auto-set. (line 148) -* PROCINFO array <1>: Time Functions. (line 47) +* PROCINFO array <1>: Time Functions. (line 49) * PROCINFO array <2>: Passwd Functions. (line 6) * PROCINFO array, and communications via ptys: Two-way I/O. (line 114) * PROCINFO array, and group membership: Group Functions. (line 6) @@ -35126,7 +35128,7 @@ Index (line 79) * stream editors: Full Line Fields. (line 22) * stream editors <1>: Simple Sed. (line 6) -* strftime: Time Functions. (line 48) +* strftime: Time Functions. (line 50) * string constants: Scalar Constants. (line 15) * string constants, vs. regexp constants: Computed Regexps. (line 40) * string extraction (internationalization): String Extraction. @@ -35180,7 +35182,7 @@ Index * syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops. (line 149) * system: I/O Functions. (line 107) -* systime: Time Functions. (line 66) +* systime: Time Functions. (line 68) * t debugger command (alias for tbreak): Breakpoint Control. (line 90) * tbreak debugger command: Breakpoint Control. (line 90) * Tcl: Library Names. (line 58) @@ -35228,8 +35230,8 @@ Index * time, retrieving: Time Functions. (line 17) * timeout, reading input: Read Timeout. (line 6) * timestamps: Time Functions. (line 6) -* timestamps <1>: Time Functions. (line 66) -* timestamps, converting dates to: Time Functions. (line 76) +* timestamps <1>: Time Functions. (line 68) +* timestamps, converting dates to: Time Functions. (line 78) * timestamps, formatted: Getlocaltime Function. (line 6) * tolower: String Functions. (line 524) @@ -35680,322 +35682,322 @@ Ref: table-system-return-values561361 Ref: I/O Functions-Footnote-1563341 Ref: I/O Functions-Footnote-2563489 Node: Time Functions563609 -Ref: Time Functions-Footnote-1574131 -Ref: Time Functions-Footnote-2574199 -Ref: Time Functions-Footnote-3574357 -Ref: Time Functions-Footnote-4574468 -Ref: Time Functions-Footnote-5574580 -Ref: Time Functions-Footnote-6574807 -Node: Bitwise Functions575073 -Ref: table-bitwise-ops575667 -Ref: Bitwise Functions-Footnote-1581693 -Ref: Bitwise Functions-Footnote-2581866 -Node: Type Functions582057 -Node: I18N Functions584733 -Node: User-defined586384 -Node: Definition Syntax587189 -Ref: Definition Syntax-Footnote-1592876 -Node: Function Example592947 -Ref: Function Example-Footnote-1595869 -Node: Function Caveats595891 -Node: Calling A Function596409 -Node: Variable Scope597367 -Node: Pass By Value/Reference600361 -Node: Return Statement603860 -Node: Dynamic Typing606839 -Node: Indirect Calls607769 -Ref: Indirect Calls-Footnote-1618020 -Node: Functions Summary618148 -Node: Library Functions620853 -Ref: Library Functions-Footnote-1624460 -Ref: Library Functions-Footnote-2624603 -Node: Library Names624774 -Ref: Library Names-Footnote-1628234 -Ref: Library Names-Footnote-2628457 -Node: General Functions628543 -Node: Strtonum Function629646 -Node: Assert Function632668 -Node: Round Function635994 -Node: Cliff Random Function637535 -Node: Ordinal Functions638551 -Ref: Ordinal Functions-Footnote-1641614 -Ref: Ordinal Functions-Footnote-2641866 -Node: Join Function642076 -Ref: Join Function-Footnote-1643846 -Node: Getlocaltime Function644046 -Node: Readfile Function647788 -Node: Shell Quoting649760 -Node: Data File Management651161 -Node: Filetrans Function651793 -Node: Rewind Function655889 -Node: File Checking657795 -Ref: File Checking-Footnote-1659129 -Node: Empty Files659330 -Node: Ignoring Assigns661309 -Node: Getopt Function662859 -Ref: Getopt Function-Footnote-1674328 -Node: Passwd Functions674528 -Ref: Passwd Functions-Footnote-1683367 -Node: Group Functions683455 -Ref: Group Functions-Footnote-1691353 -Node: Walking Arrays691560 -Node: Library Functions Summary694568 -Node: Library Exercises695974 -Node: Sample Programs696439 -Node: Running Examples697209 -Node: Clones697937 -Node: Cut Program699161 -Node: Egrep Program709090 -Ref: Egrep Program-Footnote-1716602 -Node: Id Program716712 -Node: Split Program720392 -Ref: Split Program-Footnote-1723851 -Node: Tee Program723980 -Node: Uniq Program726770 -Node: Wc Program734196 -Ref: Wc Program-Footnote-1738451 -Node: Miscellaneous Programs738545 -Node: Dupword Program739758 -Node: Alarm Program741788 -Node: Translate Program746643 -Ref: Translate Program-Footnote-1751208 -Node: Labels Program751478 -Ref: Labels Program-Footnote-1754829 -Node: Word Sorting754913 -Node: History Sorting758985 -Node: Extract Program760820 -Node: Simple Sed768349 -Node: Igawk Program771423 -Ref: Igawk Program-Footnote-1785754 -Ref: Igawk Program-Footnote-2785956 -Ref: Igawk Program-Footnote-3786078 -Node: Anagram Program786193 -Node: Signature Program789255 -Node: Programs Summary790502 -Node: Programs Exercises791716 -Ref: Programs Exercises-Footnote-1795845 -Node: Advanced Features795936 -Node: Nondecimal Data797926 -Node: Array Sorting799517 -Node: Controlling Array Traversal800217 -Ref: Controlling Array Traversal-Footnote-1808584 -Node: Array Sorting Functions808702 -Ref: Array Sorting Functions-Footnote-1813793 -Node: Two-way I/O813989 -Ref: Two-way I/O-Footnote-1820539 -Ref: Two-way I/O-Footnote-2820726 -Node: TCP/IP Networking820808 -Node: Profiling823926 -Ref: Profiling-Footnote-1832419 -Node: Advanced Features Summary832742 -Node: Internationalization834586 -Node: I18N and L10N836066 -Node: Explaining gettext836753 -Ref: Explaining gettext-Footnote-1842645 -Ref: Explaining gettext-Footnote-2842830 -Node: Programmer i18n842995 -Ref: Programmer i18n-Footnote-1847944 -Node: Translator i18n847993 -Node: String Extraction848787 -Ref: String Extraction-Footnote-1849919 -Node: Printf Ordering850005 -Ref: Printf Ordering-Footnote-1852791 -Node: I18N Portability852855 -Ref: I18N Portability-Footnote-1855311 -Node: I18N Example855374 -Ref: I18N Example-Footnote-1858180 -Node: Gawk I18N858253 -Node: I18N Summary858898 -Node: Debugger860239 -Node: Debugging861261 -Node: Debugging Concepts861702 -Node: Debugging Terms863511 -Node: Awk Debugging866086 -Node: Sample Debugging Session866992 -Node: Debugger Invocation867526 -Node: Finding The Bug868912 -Node: List of Debugger Commands875390 -Node: Breakpoint Control876723 -Node: Debugger Execution Control880417 -Node: Viewing And Changing Data883779 -Node: Execution Stack887153 -Node: Debugger Info888790 -Node: Miscellaneous Debugger Commands892861 -Node: Readline Support897949 -Node: Limitations898845 -Node: Debugging Summary900954 -Node: Arbitrary Precision Arithmetic902233 -Node: Computer Arithmetic903649 -Ref: table-numeric-ranges907240 -Ref: Computer Arithmetic-Footnote-1907962 -Node: Math Definitions908019 -Ref: table-ieee-formats911333 -Ref: Math Definitions-Footnote-1911936 -Node: MPFR features912041 -Node: FP Math Caution913758 -Ref: FP Math Caution-Footnote-1914830 -Node: Inexactness of computations915199 -Node: Inexact representation916159 -Node: Comparing FP Values917519 -Node: Errors accumulate918601 -Node: Getting Accuracy920034 -Node: Try To Round922744 -Node: Setting precision923643 -Ref: table-predefined-precision-strings924340 -Node: Setting the rounding mode926170 -Ref: table-gawk-rounding-modes926544 -Ref: Setting the rounding mode-Footnote-1929952 -Node: Arbitrary Precision Integers930131 -Ref: Arbitrary Precision Integers-Footnote-1935048 -Node: POSIX Floating Point Problems935197 -Ref: POSIX Floating Point Problems-Footnote-1939079 -Node: Floating point summary939117 -Node: Dynamic Extensions941307 -Node: Extension Intro942860 -Node: Plugin License944126 -Node: Extension Mechanism Outline944923 -Ref: figure-load-extension945362 -Ref: figure-register-new-function946927 -Ref: figure-call-new-function948019 -Node: Extension API Description950081 -Node: Extension API Functions Introduction951723 -Node: General Data Types957034 -Ref: General Data Types-Footnote-1964243 -Node: Memory Allocation Functions964542 -Ref: Memory Allocation Functions-Footnote-1967387 -Node: Constructor Functions967486 -Node: Registration Functions970485 -Node: Extension Functions971170 -Node: Exit Callback Functions976371 -Node: Extension Version String977621 -Node: Input Parsers978284 -Node: Output Wrappers988166 -Node: Two-way processors992678 -Node: Printing Messages994943 -Ref: Printing Messages-Footnote-1996114 -Node: Updating ERRNO996267 -Node: Requesting Values997006 -Ref: table-value-types-returned997743 -Node: Accessing Parameters998679 -Node: Symbol Table Access999914 -Node: Symbol table by name1000426 -Node: Symbol table by cookie1002215 -Ref: Symbol table by cookie-Footnote-11006400 -Node: Cached values1006464 -Ref: Cached values-Footnote-11010000 -Node: Array Manipulation1010091 -Ref: Array Manipulation-Footnote-11011182 -Node: Array Data Types1011219 -Ref: Array Data Types-Footnote-11013877 -Node: Array Functions1013969 -Node: Flattening Arrays1018364 -Node: Creating Arrays1025305 -Node: Redirection API1030074 -Node: Extension API Variables1032905 -Node: Extension Versioning1033538 -Ref: gawk-api-version1033975 -Node: Extension API Informational Variables1035703 -Node: Extension API Boilerplate1036767 -Node: Changes from API V11040629 -Node: Finding Extensions1041289 -Node: Extension Example1041848 -Node: Internal File Description1042646 -Node: Internal File Ops1046726 -Ref: Internal File Ops-Footnote-11058126 -Node: Using Internal File Ops1058266 -Ref: Using Internal File Ops-Footnote-11060649 -Node: Extension Samples1060923 -Node: Extension Sample File Functions1062452 -Node: Extension Sample Fnmatch1070101 -Node: Extension Sample Fork1071588 -Node: Extension Sample Inplace1072806 -Node: Extension Sample Ord1076016 -Node: Extension Sample Readdir1076852 -Ref: table-readdir-file-types1077741 -Node: Extension Sample Revout1078546 -Node: Extension Sample Rev2way1079135 -Node: Extension Sample Read write array1079875 -Node: Extension Sample Readfile1081817 -Node: Extension Sample Time1082912 -Node: Extension Sample API Tests1084260 -Node: gawkextlib1084752 -Node: Extension summary1087199 -Node: Extension Exercises1090901 -Node: Language History1092399 -Node: V7/SVR3.11094055 -Node: SVR41096207 -Node: POSIX1097641 -Node: BTL1099020 -Node: POSIX/GNU1099749 -Node: Feature History1105611 -Node: Common Extensions1119981 -Node: Ranges and Locales1121264 -Ref: Ranges and Locales-Footnote-11125880 -Ref: Ranges and Locales-Footnote-21125907 -Ref: Ranges and Locales-Footnote-31126142 -Node: Contributors1126363 -Node: History summary1131923 -Node: Installation1133303 -Node: Gawk Distribution1134247 -Node: Getting1134731 -Node: Extracting1135692 -Node: Distribution contents1137330 -Node: Unix Installation1143672 -Node: Quick Installation1144354 -Node: Shell Startup Files1146768 -Node: Additional Configuration Options1147846 -Node: Configuration Philosophy1149651 -Node: Non-Unix Installation1152020 -Node: PC Installation1152480 -Node: PC Binary Installation1153318 -Node: PC Compiling1153753 -Node: PC Using1154870 -Node: Cygwin1157915 -Node: MSYS1158685 -Node: VMS Installation1159186 -Node: VMS Compilation1159977 -Ref: VMS Compilation-Footnote-11161206 -Node: VMS Dynamic Extensions1161264 -Node: VMS Installation Details1162949 -Node: VMS Running1165202 -Node: VMS GNV1169481 -Node: VMS Old Gawk1170216 -Node: Bugs1170687 -Node: Bug address1171350 -Node: Usenet1173747 -Node: Maintainers1174524 -Node: Other Versions1175900 -Node: Installation summary1182484 -Node: Notes1183519 -Node: Compatibility Mode1184384 -Node: Additions1185166 -Node: Accessing The Source1186091 -Node: Adding Code1187526 -Node: New Ports1193744 -Node: Derived Files1198232 -Ref: Derived Files-Footnote-11203717 -Ref: Derived Files-Footnote-21203752 -Ref: Derived Files-Footnote-31204350 -Node: Future Extensions1204464 -Node: Implementation Limitations1205122 -Node: Extension Design1206305 -Node: Old Extension Problems1207459 -Ref: Old Extension Problems-Footnote-11208977 -Node: Extension New Mechanism Goals1209034 -Ref: Extension New Mechanism Goals-Footnote-11212398 -Node: Extension Other Design Decisions1212587 -Node: Extension Future Growth1214700 -Node: Old Extension Mechanism1215536 -Node: Notes summary1217299 -Node: Basic Concepts1218481 -Node: Basic High Level1219162 -Ref: figure-general-flow1219444 -Ref: figure-process-flow1220129 -Ref: Basic High Level-Footnote-11223430 -Node: Basic Data Typing1223615 -Node: Glossary1226943 -Node: Copying1258890 -Node: GNU Free Documentation License1296429 -Node: Index1321547 +Ref: Time Functions-Footnote-1574276 +Ref: Time Functions-Footnote-2574344 +Ref: Time Functions-Footnote-3574502 +Ref: Time Functions-Footnote-4574613 +Ref: Time Functions-Footnote-5574725 +Ref: Time Functions-Footnote-6574952 +Node: Bitwise Functions575218 +Ref: table-bitwise-ops575812 +Ref: Bitwise Functions-Footnote-1581838 +Ref: Bitwise Functions-Footnote-2582011 +Node: Type Functions582202 +Node: I18N Functions584878 +Node: User-defined586529 +Node: Definition Syntax587334 +Ref: Definition Syntax-Footnote-1593021 +Node: Function Example593092 +Ref: Function Example-Footnote-1596014 +Node: Function Caveats596036 +Node: Calling A Function596554 +Node: Variable Scope597512 +Node: Pass By Value/Reference600506 +Node: Return Statement604005 +Node: Dynamic Typing606984 +Node: Indirect Calls607914 +Ref: Indirect Calls-Footnote-1618165 +Node: Functions Summary618293 +Node: Library Functions620998 +Ref: Library Functions-Footnote-1624605 +Ref: Library Functions-Footnote-2624748 +Node: Library Names624919 +Ref: Library Names-Footnote-1628379 +Ref: Library Names-Footnote-2628602 +Node: General Functions628688 +Node: Strtonum Function629791 +Node: Assert Function632813 +Node: Round Function636139 +Node: Cliff Random Function637680 +Node: Ordinal Functions638696 +Ref: Ordinal Functions-Footnote-1641759 +Ref: Ordinal Functions-Footnote-2642011 +Node: Join Function642221 +Ref: Join Function-Footnote-1643991 +Node: Getlocaltime Function644191 +Node: Readfile Function647933 +Node: Shell Quoting649905 +Node: Data File Management651306 +Node: Filetrans Function651938 +Node: Rewind Function656034 +Node: File Checking657940 +Ref: File Checking-Footnote-1659274 +Node: Empty Files659475 +Node: Ignoring Assigns661454 +Node: Getopt Function663004 +Ref: Getopt Function-Footnote-1674473 +Node: Passwd Functions674673 +Ref: Passwd Functions-Footnote-1683512 +Node: Group Functions683600 +Ref: Group Functions-Footnote-1691498 +Node: Walking Arrays691705 +Node: Library Functions Summary694713 +Node: Library Exercises696119 +Node: Sample Programs696584 +Node: Running Examples697354 +Node: Clones698082 +Node: Cut Program699306 +Node: Egrep Program709235 +Ref: Egrep Program-Footnote-1716747 +Node: Id Program716857 +Node: Split Program720537 +Ref: Split Program-Footnote-1723996 +Node: Tee Program724125 +Node: Uniq Program726915 +Node: Wc Program734341 +Ref: Wc Program-Footnote-1738596 +Node: Miscellaneous Programs738690 +Node: Dupword Program739903 +Node: Alarm Program741933 +Node: Translate Program746788 +Ref: Translate Program-Footnote-1751353 +Node: Labels Program751623 +Ref: Labels Program-Footnote-1754974 +Node: Word Sorting755058 +Node: History Sorting759130 +Node: Extract Program760965 +Node: Simple Sed768494 +Node: Igawk Program771568 +Ref: Igawk Program-Footnote-1785899 +Ref: Igawk Program-Footnote-2786101 +Ref: Igawk Program-Footnote-3786223 +Node: Anagram Program786338 +Node: Signature Program789400 +Node: Programs Summary790647 +Node: Programs Exercises791861 +Ref: Programs Exercises-Footnote-1795990 +Node: Advanced Features796081 +Node: Nondecimal Data798071 +Node: Array Sorting799662 +Node: Controlling Array Traversal800362 +Ref: Controlling Array Traversal-Footnote-1808729 +Node: Array Sorting Functions808847 +Ref: Array Sorting Functions-Footnote-1813938 +Node: Two-way I/O814134 +Ref: Two-way I/O-Footnote-1820684 +Ref: Two-way I/O-Footnote-2820871 +Node: TCP/IP Networking820953 +Node: Profiling824071 +Ref: Profiling-Footnote-1832564 +Node: Advanced Features Summary832887 +Node: Internationalization834731 +Node: I18N and L10N836211 +Node: Explaining gettext836898 +Ref: Explaining gettext-Footnote-1842790 +Ref: Explaining gettext-Footnote-2842975 +Node: Programmer i18n843140 +Ref: Programmer i18n-Footnote-1848089 +Node: Translator i18n848138 +Node: String Extraction848932 +Ref: String Extraction-Footnote-1850064 +Node: Printf Ordering850150 +Ref: Printf Ordering-Footnote-1852936 +Node: I18N Portability853000 +Ref: I18N Portability-Footnote-1855456 +Node: I18N Example855519 +Ref: I18N Example-Footnote-1858325 +Node: Gawk I18N858398 +Node: I18N Summary859043 +Node: Debugger860384 +Node: Debugging861406 +Node: Debugging Concepts861847 +Node: Debugging Terms863656 +Node: Awk Debugging866231 +Node: Sample Debugging Session867137 +Node: Debugger Invocation867671 +Node: Finding The Bug869057 +Node: List of Debugger Commands875535 +Node: Breakpoint Control876868 +Node: Debugger Execution Control880562 +Node: Viewing And Changing Data883924 +Node: Execution Stack887298 +Node: Debugger Info888935 +Node: Miscellaneous Debugger Commands893006 +Node: Readline Support898094 +Node: Limitations898990 +Node: Debugging Summary901099 +Node: Arbitrary Precision Arithmetic902378 +Node: Computer Arithmetic903794 +Ref: table-numeric-ranges907385 +Ref: Computer Arithmetic-Footnote-1908107 +Node: Math Definitions908164 +Ref: table-ieee-formats911478 +Ref: Math Definitions-Footnote-1912081 +Node: MPFR features912186 +Node: FP Math Caution913903 +Ref: FP Math Caution-Footnote-1914975 +Node: Inexactness of computations915344 +Node: Inexact representation916304 +Node: Comparing FP Values917664 +Node: Errors accumulate918746 +Node: Getting Accuracy920179 +Node: Try To Round922889 +Node: Setting precision923788 +Ref: table-predefined-precision-strings924485 +Node: Setting the rounding mode926315 +Ref: table-gawk-rounding-modes926689 +Ref: Setting the rounding mode-Footnote-1930097 +Node: Arbitrary Precision Integers930276 +Ref: Arbitrary Precision Integers-Footnote-1935193 +Node: POSIX Floating Point Problems935342 +Ref: POSIX Floating Point Problems-Footnote-1939224 +Node: Floating point summary939262 +Node: Dynamic Extensions941452 +Node: Extension Intro943005 +Node: Plugin License944271 +Node: Extension Mechanism Outline945068 +Ref: figure-load-extension945507 +Ref: figure-register-new-function947072 +Ref: figure-call-new-function948164 +Node: Extension API Description950226 +Node: Extension API Functions Introduction951868 +Node: General Data Types957179 +Ref: General Data Types-Footnote-1964388 +Node: Memory Allocation Functions964687 +Ref: Memory Allocation Functions-Footnote-1967532 +Node: Constructor Functions967631 +Node: Registration Functions970630 +Node: Extension Functions971315 +Node: Exit Callback Functions976516 +Node: Extension Version String977766 +Node: Input Parsers978429 +Node: Output Wrappers988311 +Node: Two-way processors992823 +Node: Printing Messages995088 +Ref: Printing Messages-Footnote-1996259 +Node: Updating ERRNO996412 +Node: Requesting Values997151 +Ref: table-value-types-returned997888 +Node: Accessing Parameters998824 +Node: Symbol Table Access1000059 +Node: Symbol table by name1000571 +Node: Symbol table by cookie1002360 +Ref: Symbol table by cookie-Footnote-11006545 +Node: Cached values1006609 +Ref: Cached values-Footnote-11010145 +Node: Array Manipulation1010236 +Ref: Array Manipulation-Footnote-11011327 +Node: Array Data Types1011364 +Ref: Array Data Types-Footnote-11014022 +Node: Array Functions1014114 +Node: Flattening Arrays1018509 +Node: Creating Arrays1025450 +Node: Redirection API1030219 +Node: Extension API Variables1033050 +Node: Extension Versioning1033683 +Ref: gawk-api-version1034120 +Node: Extension API Informational Variables1035848 +Node: Extension API Boilerplate1036912 +Node: Changes from API V11040774 +Node: Finding Extensions1041434 +Node: Extension Example1041993 +Node: Internal File Description1042791 +Node: Internal File Ops1046871 +Ref: Internal File Ops-Footnote-11058271 +Node: Using Internal File Ops1058411 +Ref: Using Internal File Ops-Footnote-11060794 +Node: Extension Samples1061068 +Node: Extension Sample File Functions1062597 +Node: Extension Sample Fnmatch1070246 +Node: Extension Sample Fork1071733 +Node: Extension Sample Inplace1072951 +Node: Extension Sample Ord1076161 +Node: Extension Sample Readdir1076997 +Ref: table-readdir-file-types1077886 +Node: Extension Sample Revout1078691 +Node: Extension Sample Rev2way1079280 +Node: Extension Sample Read write array1080020 +Node: Extension Sample Readfile1081962 +Node: Extension Sample Time1083057 +Node: Extension Sample API Tests1084405 +Node: gawkextlib1084897 +Node: Extension summary1087344 +Node: Extension Exercises1091046 +Node: Language History1092544 +Node: V7/SVR3.11094200 +Node: SVR41096352 +Node: POSIX1097786 +Node: BTL1099165 +Node: POSIX/GNU1099894 +Node: Feature History1105756 +Node: Common Extensions1120126 +Node: Ranges and Locales1121409 +Ref: Ranges and Locales-Footnote-11126025 +Ref: Ranges and Locales-Footnote-21126052 +Ref: Ranges and Locales-Footnote-31126287 +Node: Contributors1126508 +Node: History summary1132068 +Node: Installation1133448 +Node: Gawk Distribution1134392 +Node: Getting1134876 +Node: Extracting1135837 +Node: Distribution contents1137475 +Node: Unix Installation1143817 +Node: Quick Installation1144499 +Node: Shell Startup Files1146913 +Node: Additional Configuration Options1147991 +Node: Configuration Philosophy1149796 +Node: Non-Unix Installation1152165 +Node: PC Installation1152625 +Node: PC Binary Installation1153463 +Node: PC Compiling1153898 +Node: PC Using1155015 +Node: Cygwin1158060 +Node: MSYS1158830 +Node: VMS Installation1159331 +Node: VMS Compilation1160122 +Ref: VMS Compilation-Footnote-11161351 +Node: VMS Dynamic Extensions1161409 +Node: VMS Installation Details1163094 +Node: VMS Running1165347 +Node: VMS GNV1169626 +Node: VMS Old Gawk1170361 +Node: Bugs1170832 +Node: Bug address1171495 +Node: Usenet1173892 +Node: Maintainers1174669 +Node: Other Versions1176045 +Node: Installation summary1182629 +Node: Notes1183664 +Node: Compatibility Mode1184529 +Node: Additions1185311 +Node: Accessing The Source1186236 +Node: Adding Code1187671 +Node: New Ports1193889 +Node: Derived Files1198377 +Ref: Derived Files-Footnote-11203862 +Ref: Derived Files-Footnote-21203897 +Ref: Derived Files-Footnote-31204495 +Node: Future Extensions1204609 +Node: Implementation Limitations1205267 +Node: Extension Design1206450 +Node: Old Extension Problems1207604 +Ref: Old Extension Problems-Footnote-11209122 +Node: Extension New Mechanism Goals1209179 +Ref: Extension New Mechanism Goals-Footnote-11212543 +Node: Extension Other Design Decisions1212732 +Node: Extension Future Growth1214845 +Node: Old Extension Mechanism1215681 +Node: Notes summary1217444 +Node: Basic Concepts1218626 +Node: Basic High Level1219307 +Ref: figure-general-flow1219589 +Ref: figure-process-flow1220274 +Ref: Basic High Level-Footnote-11223575 +Node: Basic Data Typing1223760 +Node: Glossary1227088 +Node: Copying1259035 +Node: GNU Free Documentation License1296574 +Node: Index1321692 End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi index 220dfb86..01bc1a5c 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -19039,7 +19039,7 @@ Optional parameters are enclosed in square brackets ([ ]): @c @asis for docbook @table @asis -@item @code{mktime(@var{datespec})} +@item @code{mktime(@var{datespec}} [@code{, @var{utc-flag}} ]@code{)} @cindexgawkfunc{mktime} @cindex generate time values Turn @var{datespec} into a timestamp in the same form @@ -19058,7 +19058,9 @@ The values of these numbers need not be within the ranges specified; for example, an hour of @minus{}1 means 1 hour before midnight. The origin-zero Gregorian calendar is assumed, with year 0 preceding year 1 and year @minus{}1 preceding year 0. -The time is assumed to be in the local time zone. +If @var{utc-flag} is present and is either nonzero or non-null, the time +is assumed to be in the UTC time zone; otherwise, the +time is assumed to be in the local time zone. If the daylight-savings flag is positive, the time is assumed to be daylight savings time; if zero, the time is assumed to be standard time; and if negative (the default), @code{mktime()} attempts to determine diff --git a/doc/gawktexi.in b/doc/gawktexi.in index dd06a90b..9e6ce8d8 100644 --- a/doc/gawktexi.in +++ b/doc/gawktexi.in @@ -18151,7 +18151,7 @@ Optional parameters are enclosed in square brackets ([ ]): @c @asis for docbook @table @asis -@item @code{mktime(@var{datespec})} +@item @code{mktime(@var{datespec}} [@code{, @var{utc-flag}} ]@code{)} @cindexgawkfunc{mktime} @cindex generate time values Turn @var{datespec} into a timestamp in the same form @@ -18170,7 +18170,9 @@ The values of these numbers need not be within the ranges specified; for example, an hour of @minus{}1 means 1 hour before midnight. The origin-zero Gregorian calendar is assumed, with year 0 preceding year 1 and year @minus{}1 preceding year 0. -The time is assumed to be in the local time zone. +If @var{utc-flag} is present and is either nonzero or non-null, the time +is assumed to be in the UTC time zone; otherwise, the +time is assumed to be in the local time zone. If the daylight-savings flag is positive, the time is assumed to be daylight savings time; if zero, the time is assumed to be standard time; and if negative (the default), @code{mktime()} attempts to determine @@ -1510,7 +1510,7 @@ unwind_stack(long n) #define pop_stack() (void) unwind_stack(0) -static inline int +static inline bool eval_condition(NODE *t) { if (t == node_Boolean[false]) @@ -275,7 +275,7 @@ static IOBUF *iop_finish(IOBUF *iop); static int gawk_pclose(struct redirect *rp); static int str2mode(const char *mode); static int two_way_open(const char *str, struct redirect *rp, int extfd); -static int pty_vs_pipe(const char *command); +static bool pty_vs_pipe(const char *command); static void find_input_parser(IOBUF *iop); static bool find_output_wrapper(awk_output_buf_t *outbuf); static void init_output_wrapper(awk_output_buf_t *outbuf); @@ -3918,7 +3918,7 @@ set_FS: * This works by checking if PROCINFO["command", "pty"] exists and is true. */ -static int +static bool pty_vs_pipe(const char *command) { #ifdef HAVE_TERMIOS_H diff --git a/test/ChangeLog b/test/ChangeLog index 918c16c5..5f3c349c 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,8 @@ +2017-02-21 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (mktime): New test. + * mktime.awk, mktime.in, mktime.ok: New files. + 2017-02-17 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (typeof5): New test. diff --git a/test/Makefile.am b/test/Makefile.am index 00d50a0a..1f482122 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -621,6 +621,9 @@ EXTRA_DIST = \ minusstr.awk \ minusstr.ok \ mixed1.ok \ + mktime.awk \ + mktime.in \ + mktime.ok \ mmap8k.in \ mpfrbigint.awk \ mpfrbigint.ok \ @@ -1227,7 +1230,7 @@ GAWK_EXT_TESTS = \ incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \ include include2 indirectbuiltin indirectcall indirectcall2 intarray \ lint lintexp lintindex lintint lintlength lintold lintset lintwarn \ - mixed1 manyfiles match1 match2 match3 mbstr1 mbstr2 \ + mixed1 mktime manyfiles match1 match2 match3 mbstr1 mbstr2 \ muldimposix \ nastyparm negtime next nondec nondec2 \ nonfatal1 nonfatal2 nonfatal3 \ diff --git a/test/Makefile.in b/test/Makefile.in index 727fdb4b..7059b73d 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -879,6 +879,9 @@ EXTRA_DIST = \ minusstr.awk \ minusstr.ok \ mixed1.ok \ + mktime.awk \ + mktime.in \ + mktime.ok \ mmap8k.in \ mpfrbigint.awk \ mpfrbigint.ok \ @@ -1484,7 +1487,7 @@ GAWK_EXT_TESTS = \ incdupe incdupe2 incdupe3 incdupe4 incdupe5 incdupe6 incdupe7 \ include include2 indirectbuiltin indirectcall indirectcall2 intarray \ lint lintexp lintindex lintint lintlength lintold lintset lintwarn \ - mixed1 manyfiles match1 match2 match3 mbstr1 mbstr2 \ + mixed1 mktime manyfiles match1 match2 match3 mbstr1 mbstr2 \ muldimposix \ nastyparm negtime next nondec nondec2 \ nonfatal1 nonfatal2 nonfatal3 \ @@ -4128,6 +4131,11 @@ lintwarn: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mktime: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + match1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index ac3cedca..95321a57 100644 --- a/test/Maketests +++ b/test/Maketests @@ -1317,6 +1317,11 @@ lintwarn: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +mktime: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + match1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/mktime.awk b/test/mktime.awk new file mode 100644 index 00000000..8a83df14 --- /dev/null +++ b/test/mktime.awk @@ -0,0 +1,3 @@ +{ + print mktime($0, 1) +} diff --git a/test/mktime.in b/test/mktime.in new file mode 100644 index 00000000..bfc7d68a --- /dev/null +++ b/test/mktime.in @@ -0,0 +1 @@ +2017 1 1 0 0 0 diff --git a/test/mktime.ok b/test/mktime.ok new file mode 100644 index 00000000..677b3ebc --- /dev/null +++ b/test/mktime.ok @@ -0,0 +1 @@ +1483228800 |