[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-4982-g6e195e45
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-4982-g6e195e45 |
Date: |
Sun, 22 Jan 2023 14:59:03 -0500 (EST) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, gawk-5.2-stable has been updated
via 6e195e45a972b9c88ab8c5627d09049268b29df0 (commit)
via 7672ce8c8f4819e4a24e26660f1cfe08655735b3 (commit)
from c81b15f4c7b4c5473305e5c3cd9ed6b233b8a9d3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=6e195e45a972b9c88ab8c5627d09049268b29df0
commit 6e195e45a972b9c88ab8c5627d09049268b29df0
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Sun Jan 22 21:58:33 2023 +0200
Undeprecate the time extension, add strptime, update tests and doc.
diff --git a/ChangeLog b/ChangeLog
index 5407ea9d..d9f31be0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
(check_pma_security): New routine.
(main): Call it.
(UPDATE_YEAR): Bump to 2023.
+ (NEWS): Updated.
2023-01-03 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/NEWS b/NEWS
index 0f5b69c2..d6437ce7 100644
--- a/NEWS
+++ b/NEWS
@@ -24,7 +24,10 @@ Changes from 5.2.1 to 5.2.2
5. PROCINFO["pma"] exists if the PMA allocator is compiled into gawk.
Its value is the PMA version.
-6. As usual, there have been several minor code cleanups and bug fixes.
+6. The time extension is no longer deprecated. The strptime() function
+ from gawkextlib's timex extension has been added to it.
+
+7. As usual, there have been several minor code cleanups and bug fixes.
See the ChangeLog for details.
Changes from 5.2.0 to 5.2.1
diff --git a/doc/ChangeLog b/doc/ChangeLog
index ebe5a7b4..8bc9c2dc 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -3,6 +3,8 @@
* gawktexi.in (Persistent Memory): Document that root can't
use persistent memory and we recommend chmod 600 on the file.
Also, update the copyright year.
+ (Extension Sample Time): Undeprecate time extension. Add
+ strptime() doc.
2023-01-03 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/doc/gawk.info b/doc/gawk.info
index 392dd2c5..ea8ce5e0 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -29553,17 +29553,8 @@ File: gawk.info, Node: Extension Sample Time, Next:
Extension Sample API Tests
17.7.11 Extension Time Functions
--------------------------------
- CAUTION: As âgawkâ version 5.1.0, this extension is considered to
- be obsolete. It is replaced by the âtimexâ extension in
- âgawkextlibâ (*note gawkextlib::).
-
- For version 5.1, no warning will be issued if this extension is
- used. For the next major release, a warning will be issued. In
- the release after that this extension will be removed from the
- distribution.
-
- The âtimeâ extension adds two functions, named âgettimeofday()â and
-âsleep()â, as follows:
+The âtimeâ extension adds three functions, named âgettimeofday()â
+âsleep()â, and âstrptime()â, as follows:
â@load "time"â
This is how you load the extension.
@@ -29587,6 +29578,21 @@ File: gawk.info, Node: Extension Sample Time, Next:
Extension Sample API Tests
function tries to use ânanosleep()â or âselect()â to implement the
delay.
+âtimeval = strptime(STRING, FORMAT)â
+ This function takes two arguments, a string representing a date and
+ time, and a format string describing the data in the string. It
+ calls the C library âstrptime()â function with the given values.
+ If the parsing succeeds, the results are passed to the C library
+ âmktime()â function, and its result is returned, expressing the
+ time in seconds since the epoch in the current local timezone,
+ regardless of any timezone specified in the string arguments.
+ (This is the same as âgawkââs built-in âsystime()â function.)
+ Otherwise it returns â1 upon error. In the latter case,
+
+ Note that the underlying âstrptime()â C library routine apparently
+ ignores any time zone indication in the date string, producing
+ values relative to the current time zone.
+
File: gawk.info, Node: Extension Sample API Tests, Prev: Extension Sample
Time, Up: Extension Samples
@@ -37657,7 +37663,7 @@ Index
* gettext library, locale categories: Explaining gettext. (line 81)
* gettext() function (C library): Explaining gettext. (line 63)
* gettimeofday() extension function: Extension Sample Time.
- (line 21)
+ (line 12)
* git utility: gawkextlib. (line 31)
* git utility <1>: Other Versions. (line 18)
* git utility <2>: Accessing The Source.
@@ -38860,7 +38866,7 @@ Index
* Skywalker, Luke: Undocumented. (line 6)
* sleep utility: Alarm Program. (line 109)
* sleep() extension function: Extension Sample Time.
- (line 31)
+ (line 22)
* Smith, Gavin: Acknowledgments. (line 75)
* Solaris, POSIX-compliant awk: Other Versions. (line 100)
* sort array: String Functions. (line 41)
@@ -38958,6 +38964,8 @@ Index
* strings, merging arrays into: Join Function. (line 6)
* strings, for localization: Programmer i18n. (line 13)
* strings, extracting: String Extraction. (line 6)
+* strptime() extension function: Extension Sample Time.
+ (line 31)
* strtonum: String Functions. (line 408)
* strtonum() function (gawk), --non-decimal-data option and: Nondecimal Data.
(line 35)
@@ -39808,90 +39816,90 @@ Node: Extension Sample Rev2way1233765
Node: Extension Sample Read write array1234517
Node: Extension Sample Readfile1237791
Node: Extension Sample Time1238922
-Node: Extension Sample API Tests1240738
-Node: gawkextlib1241246
-Node: Extension summary1244282
-Node: Extension Exercises1248140
-Node: Language History1249418
-Node: V7/SVR3.11251132
-Node: SVR41253482
-Node: POSIX1255014
-Node: BTL1256439
-Node: POSIX/GNU1257208
-Node: Feature History1263739
-Node: Common Extensions1282804
-Node: Ranges and Locales1284173
-Ref: Ranges and Locales-Footnote-11288974
-Ref: Ranges and Locales-Footnote-21289001
-Ref: Ranges and Locales-Footnote-31289240
-Node: Contributors1289463
-Node: History summary1295668
-Node: Installation1297114
-Node: Gawk Distribution1298078
-Node: Getting1298570
-Node: Extracting1299569
-Node: Distribution contents1301281
-Node: Unix Installation1309361
-Node: Quick Installation1310183
-Node: Compiling with MPFR1312729
-Node: Shell Startup Files1313435
-Node: Additional Configuration Options1314592
-Node: Configuration Philosophy1316979
-Node: Compiling from Git1319481
-Node: Building the Documentation1320040
-Node: Non-Unix Installation1321452
-Node: PC Installation1321928
-Node: PC Binary Installation1322801
-Node: PC Compiling1323706
-Node: PC Using1324884
-Node: Cygwin1328612
-Node: MSYS1329868
-Node: OpenVMS Installation1330500
-Node: OpenVMS Compilation1331181
-Ref: OpenVMS Compilation-Footnote-11332664
-Node: OpenVMS Dynamic Extensions1332726
-Node: OpenVMS Installation Details1334362
-Node: OpenVMS Running1336797
-Node: OpenVMS GNV1340934
-Node: Bugs1341689
-Node: Bug definition1342613
-Node: Bug address1346264
-Node: Usenet1349855
-Node: Performance bugs1351086
-Node: Asking for help1354104
-Node: Maintainers1356095
-Node: Other Versions1357122
-Node: Installation summary1366054
-Node: Notes1367438
-Node: Compatibility Mode1368248
-Node: Additions1369070
-Node: Accessing The Source1370015
-Node: Adding Code1371550
-Node: New Ports1378686
-Node: Derived Files1383196
-Ref: Derived Files-Footnote-11389043
-Ref: Derived Files-Footnote-21389078
-Ref: Derived Files-Footnote-31389695
-Node: Future Extensions1389809
-Node: Implementation Limitations1390481
-Node: Extension Design1391723
-Node: Old Extension Problems1392887
-Ref: Old Extension Problems-Footnote-11394463
-Node: Extension New Mechanism Goals1394524
-Ref: Extension New Mechanism Goals-Footnote-11398020
-Node: Extension Other Design Decisions1398221
-Node: Extension Future Growth1400420
-Node: Notes summary1401044
-Node: Basic Concepts1402257
-Node: Basic High Level1402942
-Ref: figure-general-flow1403224
-Ref: figure-process-flow1403926
-Ref: Basic High Level-Footnote-11407322
-Node: Basic Data Typing1407511
-Node: Glossary1410929
-Node: Copying1444051
-Node: GNU Free Documentation License1481812
-Node: Index1507135
+Node: Extension Sample API Tests1241212
+Node: gawkextlib1241720
+Node: Extension summary1244756
+Node: Extension Exercises1248614
+Node: Language History1249892
+Node: V7/SVR3.11251606
+Node: SVR41253956
+Node: POSIX1255488
+Node: BTL1256913
+Node: POSIX/GNU1257682
+Node: Feature History1264213
+Node: Common Extensions1283278
+Node: Ranges and Locales1284647
+Ref: Ranges and Locales-Footnote-11289448
+Ref: Ranges and Locales-Footnote-21289475
+Ref: Ranges and Locales-Footnote-31289714
+Node: Contributors1289937
+Node: History summary1296142
+Node: Installation1297588
+Node: Gawk Distribution1298552
+Node: Getting1299044
+Node: Extracting1300043
+Node: Distribution contents1301755
+Node: Unix Installation1309835
+Node: Quick Installation1310657
+Node: Compiling with MPFR1313203
+Node: Shell Startup Files1313909
+Node: Additional Configuration Options1315066
+Node: Configuration Philosophy1317453
+Node: Compiling from Git1319955
+Node: Building the Documentation1320514
+Node: Non-Unix Installation1321926
+Node: PC Installation1322402
+Node: PC Binary Installation1323275
+Node: PC Compiling1324180
+Node: PC Using1325358
+Node: Cygwin1329086
+Node: MSYS1330342
+Node: OpenVMS Installation1330974
+Node: OpenVMS Compilation1331655
+Ref: OpenVMS Compilation-Footnote-11333138
+Node: OpenVMS Dynamic Extensions1333200
+Node: OpenVMS Installation Details1334836
+Node: OpenVMS Running1337271
+Node: OpenVMS GNV1341408
+Node: Bugs1342163
+Node: Bug definition1343087
+Node: Bug address1346738
+Node: Usenet1350329
+Node: Performance bugs1351560
+Node: Asking for help1354578
+Node: Maintainers1356569
+Node: Other Versions1357596
+Node: Installation summary1366528
+Node: Notes1367912
+Node: Compatibility Mode1368722
+Node: Additions1369544
+Node: Accessing The Source1370489
+Node: Adding Code1372024
+Node: New Ports1379160
+Node: Derived Files1383670
+Ref: Derived Files-Footnote-11389517
+Ref: Derived Files-Footnote-21389552
+Ref: Derived Files-Footnote-31390169
+Node: Future Extensions1390283
+Node: Implementation Limitations1390955
+Node: Extension Design1392197
+Node: Old Extension Problems1393361
+Ref: Old Extension Problems-Footnote-11394937
+Node: Extension New Mechanism Goals1394998
+Ref: Extension New Mechanism Goals-Footnote-11398494
+Node: Extension Other Design Decisions1398695
+Node: Extension Future Growth1400894
+Node: Notes summary1401518
+Node: Basic Concepts1402731
+Node: Basic High Level1403416
+Ref: figure-general-flow1403698
+Ref: figure-process-flow1404400
+Ref: Basic High Level-Footnote-11407796
+Node: Basic Data Typing1407985
+Node: Glossary1411403
+Node: Copying1444525
+Node: GNU Free Documentation License1482286
+Node: Index1507609
End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 2b085ece..ab71a529 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -40267,18 +40267,8 @@ if (contents == "" && ERRNO != "") @{
@node Extension Sample Time
@subsection Extension Time Functions
-@quotation CAUTION
-As @command{gawk} @value{PVERSION} 5.1.0, this extension is considered to be
obsolete.
-It is replaced by the @code{timex} extension in @code{gawkextlib}
-(@pxref{gawkextlib}).
-
-For @value{PVERSION} 5.1, no warning will be issued if this extension is used.
-For the next major release, a warning will be issued. In the release after that
-this extension will be removed from the distribution.
-@end quotation
-
-The @code{time} extension adds two functions, named @code{gettimeofday()}
-and @code{sleep()}, as follows:
+The @code{time} extension adds three functions, named @code{gettimeofday()}
+@code{sleep()}, and @code{strptime()}, as follows:
@table @code
@item @@load "time"
@@ -40302,6 +40292,27 @@ Otherwise, return zero after sleeping for the
indicated amount of time.
Note that @var{seconds} may be a floating-point (nonintegral) value.
Implementation details: depending on platform availability, this function
tries to use @code{nanosleep()} or @code{select()} to implement the delay.
+
+@cindex @code{strptime()} extension function
+@item timeval = strptime(@var{string}, @var{format})
+This function takes two arguments, a string representing a date and
+time, and a format string describing the data in the string. It
+calls the C library @code{strptime()} function with the given values.
+If the parsing succeeds, the results are passed to the C library
+@code{mktime()} function, and its result is returned, expressing
+the time in seconds since the epoch in the current local timezone,
+regardless of any timezone specified in the string arguments. (This
+is the same as @command{gawk}'s built-in @code{systime()} function.)
+Otherwise it returns @minus{}1 upon error. In the latter case,
+
+Note that the underlying @code{strptime()} C library routine apparently
+ignores any time zone indication in the date string, producing values
+relative to the current time zone.
+@ignore
+It might be better to have this
+routine return a string similar to what @command{gawk}'s @code{mktime()}
+function expects, but we ran out of energy.
+@end ignore
@end table
@node Extension Sample API Tests
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index d3d1410d..d5d13128 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -39183,18 +39183,8 @@ if (contents == "" && ERRNO != "") @{
@node Extension Sample Time
@subsection Extension Time Functions
-@quotation CAUTION
-As @command{gawk} @value{PVERSION} 5.1.0, this extension is considered to be
obsolete.
-It is replaced by the @code{timex} extension in @code{gawkextlib}
-(@pxref{gawkextlib}).
-
-For @value{PVERSION} 5.1, no warning will be issued if this extension is used.
-For the next major release, a warning will be issued. In the release after that
-this extension will be removed from the distribution.
-@end quotation
-
-The @code{time} extension adds two functions, named @code{gettimeofday()}
-and @code{sleep()}, as follows:
+The @code{time} extension adds three functions, named @code{gettimeofday()}
+@code{sleep()}, and @code{strptime()}, as follows:
@table @code
@item @@load "time"
@@ -39218,6 +39208,27 @@ Otherwise, return zero after sleeping for the
indicated amount of time.
Note that @var{seconds} may be a floating-point (nonintegral) value.
Implementation details: depending on platform availability, this function
tries to use @code{nanosleep()} or @code{select()} to implement the delay.
+
+@cindex @code{strptime()} extension function
+@item timeval = strptime(@var{string}, @var{format})
+This function takes two arguments, a string representing a date and
+time, and a format string describing the data in the string. It
+calls the C library @code{strptime()} function with the given values.
+If the parsing succeeds, the results are passed to the C library
+@code{mktime()} function, and its result is returned, expressing
+the time in seconds since the epoch in the current local timezone,
+regardless of any timezone specified in the string arguments. (This
+is the same as @command{gawk}'s built-in @code{systime()} function.)
+Otherwise it returns @minus{}1 upon error. In the latter case,
+
+Note that the underlying @code{strptime()} C library routine apparently
+ignores any time zone indication in the date string, producing values
+relative to the current time zone.
+@ignore
+It might be better to have this
+routine return a string similar to what @command{gawk}'s @code{mktime()}
+function expects, but we ran out of energy.
+@end ignore
@end table
@node Extension Sample API Tests
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 403f0bfb..abc2bf95 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,13 @@
+2023-01-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Check also for strptime.
+ Update copyright year.
+ * time.3am: Update copyright. Undeprecate this extension.
+ Add strptime() doc.
+ * time.c (issue_warning): Removed function and use.
+ (do_strptime): Added.
+ (ext_version): Bump to 1.2.
+
2022-11-17 Arnold D. Robbins <arnold@skeeve.com>
* 5.2.1: Release tar ball made.
diff --git a/extension/configh.in b/extension/configh.in
index f732c3b2..77c8167b 100644
--- a/extension/configh.in
+++ b/extension/configh.in
@@ -112,6 +112,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the `strptime' function. */
+#undef HAVE_STRPTIME
+
/* Define to 1 if `st_blksize' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
diff --git a/extension/configure b/extension/configure
index 6e28f0db..ffc0c7a4 100755
--- a/extension/configure
+++ b/extension/configure
@@ -17565,6 +17565,12 @@ then :
printf "%s\n" "#define HAVE_GETSYSTEMTIMEASFILETIME 1" >>confdefs.h
fi
+ac_fn_c_check_func "$LINENO" "strptime" "ac_cv_func_strptime"
+if test "x$ac_cv_func_strptime" = xyes
+then :
+ printf "%s\n" "#define HAVE_STRPTIME 1" >>confdefs.h
+
+fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed
to detect all undeclared functions" >&5
diff --git a/extension/configure.ac b/extension/configure.ac
index 0f86caeb..fe863621 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -1,7 +1,7 @@
dnl
dnl configure.ac --- autoconf input file for gawk
dnl
-dnl Copyright (C) 2012-2021 the Free Software Foundation, Inc.
+dnl Copyright (C) 2012-2021, 2023 the Free Software Foundation, Inc.
dnl
dnl This file is part of GAWK, the GNU implementation of the
dnl AWK Programming Language.
@@ -123,7 +123,7 @@ esac
AC_SEARCH_LIBS(fmod, m)
AC_CHECK_FUNCS(fdopendir fmod fnmatch getdtablesize \
gettimeofday nanosleep select statvfs \
- GetSystemTimeAsFileTime)
+ GetSystemTimeAsFileTime strptime)
GAWK_FUNC_DIRFD
GAWK_PREREQ_DIRFD
diff --git a/extension/time.3am b/extension/time.3am
index 884f56f4..d60cb743 100644
--- a/extension/time.3am
+++ b/extension/time.3am
@@ -1,4 +1,4 @@
-.TH TIME 3am "Jul 11 2022" "Free Software Foundation" "GNU Awk Extension
Modules"
+.TH TIME 3am "Jan 16 2023" "Free Software Foundation" "GNU Awk Extension
Modules"
.SH NAME
time \- time functions for gawk
.SH SYNOPSIS
@@ -8,24 +8,17 @@ time \- time functions for gawk
time = gettimeofday()
.br
ret = sleep(amount)
+.br
+timeval = strptime(string, format)
.ft R
-.SH CAUTION
-This extension is deprecated in favor of the
-.B timex
-extension in the
-.I gawkextlib
-project.
-Loading it issues a warning.
-It will be removed from the
-.I gawk
-distribution in the next major release.
.SH DESCRIPTION
The
.I time
-extension adds two functions named
+extension adds three functions named
.B gettimeofday()
-and
.BR sleep() ,
+and
+.BR stptrime() ,
as follows.
.TP
.B gettimeofday()
@@ -45,15 +38,51 @@ then it returns \-1 and sets
.BR ERRNO .
Otherwise, the function should return 0 after sleeping
for the indicated amount of time.
+.TP
+.B strptime()
+This function takes two arguments, a string representing a date and time,
+and a format string describing the data in the string. It calls the
+C library
+.IR strptime (3)
+function with the given values.
+If the parsing succeeds, the results are passed to the C library
+.IR mktime (3)
+function, and its result is returned, expressing the time in seconds
+since the epoch in the current local timezone, regardless
+of any timezone specified in the string arguments.
+(This is the same as
+.IR gawk 's
+built-in
+.B systime()
+function.)
+Otherwise it returns \-1 upon error. In the latter case,
+.B ERRNO
+indicates the problem.
.\" .SH NOTES
-.\" .SH BUGS
+.SH BUGS
+The underlying
+.IR strptime (3)
+C library routine apparently ignores any time zone indication
+in the date string, producing values relative to the current time zone.
+It might be better to have this routine return a string similar
+to what
+.IR gawk 's
+.B mktime()
+function expects, but we ran out of energy.
.SH EXAMPLE
.ft CW
.nf
@load "time"
\&...
printf "It is now %g seconds since the Epoch\en", gettimeofday()
+\&...
printf "Pausing for a while... " ; sleep(2.5) ; print "done"
+\&...
+format = "%b %d %H:%M:%S %Z %Y"
+now = systime()
+print now, "<" (result = strftime(format, now)) ">",
+then = strptime(result, format)
+print strftime(format, then)
.fi
.ft R
.SH "SEE ALSO"
@@ -70,13 +99,18 @@ printf "Pausing for a while... " ; sleep(2.5) ; print "done"
.PP
.IR gettimeofday (2),
.IR nanosleep (2),
-.IR select (2).
+.IR select (2),
+and
+.IR strptime (3).
.SH AUTHOR
Arnold Robbins,
.BR arnold@skeeve.com .
.SH COPYING PERMISSIONS
-Copyright \(co 2012, 2013, 2018, 2022,
+Copyright \(co 2012, 2013, 2018, 2022, 2023,
Free Software Foundation, Inc.
+.br
+Copyright \(co 2019,
+Arnold David Robbins.
.PP
Permission is granted to make and distribute verbatim copies of
this manual page provided the copyright notice and this permission
diff --git a/extension/time.c b/extension/time.c
index 7122c1c8..9271c99f 100644
--- a/extension/time.c
+++ b/extension/time.c
@@ -81,9 +81,8 @@ vms_fake_nanosleep(struct timespec *rqdly, struct timespec
*rmdly)
static const gawk_api_t *api; /* for convenience macros to work */
static awk_ext_id_t ext_id;
-static const char *ext_version = "time extension: version 1.1";
-static awk_bool_t issue_warning(void);
-static awk_bool_t (*init_func)(void) = issue_warning;
+static const char *ext_version = "time extension: version 1.2";
+static awk_bool_t (*init_func)(void) = NULL;
int plugin_is_GPL_compatible;
@@ -99,16 +98,6 @@ int plugin_is_GPL_compatible;
#include <windows.h>
#endif
-/* issue_warning --- issue a warning that this extension is obsolete */
-
-static awk_bool_t
-issue_warning(void)
-{
- warning(ext_id, _("The time extension is obsolete. Use the timex
extension from gawkextlib instead."));
-
- return awk_true;
-}
-
/*
* Returns time since 1/1/1970 UTC as a floating point value; should
* have sub-second precision, but the actual precision will vary based
@@ -217,9 +206,65 @@ do_sleep(int nargs, awk_value_t *result, struct
awk_ext_func *unused)
return make_number(rc, result);
}
+#ifdef HAVE_STRPTIME
+
+/* do_strptime --- call strptime */
+
+static awk_value_t *
+do_strptime(int nargs, awk_value_t *result, struct awk_ext_func *unused)
+{
+ awk_value_t string, format;
+
+ assert(result != NULL);
+ make_number(0.0, result);
+
+ if (do_lint) {
+ if (nargs == 0) {
+ lintwarn(ext_id, _("strptime: called with no
arguments"));
+ make_number(-1.0, result);
+ goto done0;
+ }
+ }
+
+ /* string is first arg, format is second arg */
+ if (! get_argument(0, AWK_STRING, & string)) {
+ fprintf(stderr, _("do_strptime: argument 1 is not a string\n"));
+ errno = EINVAL;
+ goto done1;
+ }
+ if (! get_argument(1, AWK_STRING, & format)) {
+ fprintf(stderr, _("do_strptime: argument 2 is not a string\n"));
+ errno = EINVAL;
+ goto done1;
+ }
+
+ struct tm broken_time;
+ memset(& broken_time, 0, sizeof(broken_time));
+ broken_time.tm_isdst = -1;
+ if (strptime(string.str_value.str, format.str_value.str, & broken_time)
== NULL) {
+ make_number(-1.0, result);
+ goto done0;
+ }
+
+ time_t epoch_time = mktime(& broken_time);
+ make_number((double) epoch_time, result);
+ goto done0;
+
+done1:
+ update_ERRNO_int(errno);
+
+done0:
+ return result;
+}
+
+#endif
+
static awk_ext_func_t func_table[] = {
{ "gettimeofday", do_gettimeofday, 0, 0, awk_false, NULL },
{ "sleep", do_sleep, 1, 1, awk_false, NULL },
+#ifdef HAVE_STRPTIME
+ { "strptime", do_strptime, 2, 2, awk_false, NULL },
+#endif
};
/* define the dl_load function using the boilerplate macro */
diff --git a/test/ChangeLog b/test/ChangeLog
index f630fe9d..9855113e 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -2,6 +2,7 @@
* makepmafile.c (main): Make the file mode 0600.
Update copyright year.
+ * time.awk, time.ok: Add test for strptime().
2022-11-25 Arnold D. Robbins <arnold@skeeve.com>
diff --git a/test/time.awk b/test/time.awk
index 517377e2..377aba45 100644
--- a/test/time.awk
+++ b/test/time.awk
@@ -4,19 +4,25 @@
# gettimeofday() before systime() to make sure the subtraction gives 0
# without risk of rolling over to the next second.
function timecheck(st,res) {
- res = gettimeofday()
- st = systime()
- printf "gettimeofday - systime = %d\n", res-st
- return res
+ res = gettimeofday()
+ st = systime()
+ printf "gettimeofday - systime = %d\n", res-st
+ return res
}
BEGIN {
- delta = 1.3
- t0 = timecheck()
- printf "sleep(%s) = %s\n",delta,sleep(delta)
- t1 = timecheck()
- slept = t1-t0
- if ((slept < 0.9*delta) || (slept > 1.3*delta))
- printf "Warning: tried to sleep %.2f secs, but slept for %.2f secs\n",
- delta,slept
+ delta = 1.3
+ t0 = timecheck()
+ printf "sleep(%s) = %s\n",delta,sleep(delta)
+ t1 = timecheck()
+ slept = t1-t0
+ if ((slept < 0.9*delta) || (slept > 1.3*delta))
+ printf "Warning: tried to sleep %.2f secs, but slept for %.2f
secs\n",
+ delta,slept
+
+ format = "%b %d %H:%M:%S %Y"
+ the_date = "Feb 11 13:12:11 1990"
+ then = strptime(the_date, format)
+ when = strftime(format, then)
+ print "<" the_date ">", "<<" when ">>"
}
diff --git a/test/time.ok b/test/time.ok
index ffd21696..b781f212 100644
--- a/test/time.ok
+++ b/test/time.ok
@@ -1,4 +1,4 @@
-gawk: time.awk:2: warning: The time extension is obsolete. Use the timex
extension from gawkextlib instead.
gettimeofday - systime = 0
sleep(1.3) = 0
gettimeofday - systime = 0
+<Feb 11 13:12:11 1990> <<Feb 11 13:12:11 1990>>
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=7672ce8c8f4819e4a24e26660f1cfe08655735b3
commit 7672ce8c8f4819e4a24e26660f1cfe08655735b3
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Sun Jan 22 21:42:33 2023 +0200
Add security restriction on pma use.
diff --git a/ChangeLog b/ChangeLog
index 81f71c03..5407ea9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-01-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * main.c: Update copyright year.
+ (check_pma_security): New routine.
+ (main): Call it.
+ (UPDATE_YEAR): Bump to 2023.
+
2023-01-03 Arnold D. Robbins <arnold@skeeve.com>
* README: Updated with texinfo.tex and makeinfo versions.
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 9952dc3c..ebe5a7b4 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Persistent Memory): Document that root can't
+ use persistent memory and we recommend chmod 600 on the file.
+ Also, update the copyright year.
+
2023-01-03 Arnold D. Robbins <arnold@skeeve.com>
* texinfo.tex: Updated to latest version from ftp.gnu.org.
diff --git a/doc/gawk.info b/doc/gawk.info
index 04fbc9a5..392dd2c5 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -1,6 +1,6 @@
This is gawk.info, produced by makeinfo version 7.0.1 from gawk.texi.
-Copyright © 1989, 1991, 1992, 1993, 1996â2005, 2007, 2009â2022
+Copyright © 1989, 1991, 1992, 1993, 1996â2005, 2007, 2009â2023
Free Software Foundation, Inc.
@@ -37,7 +37,7 @@ General Introduction
This file documents âawkâ, a program that you can use to select
particular records in a file and perform operations upon them.
- Copyright © 1989, 1991, 1992, 1993, 1996â2005, 2007, 2009â2022
+ Copyright © 1989, 1991, 1992, 1993, 1996â2005, 2007, 2009â2023
Free Software Foundation, Inc.
@@ -22204,14 +22204,19 @@ the tests pass, please let the maintainer know.
$ truncate -s 4G data.pma
- 2. Provide the path to the data file in the âGAWK_PERSIST_FILEâ
+ 2. It is recommended (but not required) to change the permissions on
+ the file so that only the owner can read and write it:
+
+ $ chmod 0600 data.pma
+
+ 3. Provide the path to the data file in the âGAWK_PERSIST_FILEâ
environment variable. This is best done by placing the value in
the environment just for the run of âgawkâ, like so:
$ GAWK_PERSIST_FILE=data.pma gawk 'BEGIN { print ++i }'
1
- 3. Use the same data file in subsequent runs to use the preserved data
+ 4. Use the same data file in subsequent runs to use the preserved data
values:
$ GAWK_PERSIST_FILE=data.pma gawk 'BEGIN { print ++i }'
@@ -22254,7 +22259,9 @@ information the persistent memory allocator will print.
âgawkâ sets the
default to one. See the âsupport/pma.câ source code to understand what
the different verbosity levels are.
- NOTE: If you use MPFR mode (the â-Mâ option) on the first run of a
+ There are a few constraints on the use of persistent memory:
+
+ ⢠If you use MPFR mode (the â-Mâ option) on the first run of a
program using persistent memory, you _must_ continue to use it on
all subsequent runs. Similarly, if you donât use â-Mâ on the first
run, do not use it on any subsequent runs.
@@ -22263,9 +22270,13 @@ the different verbosity levels are.
backing file is not allowed. âgawkâ detects such a situation and
issues a fatal error message.
- Additionally, the GNU/Linux CIFS filesystem is known to not work
- well with the PMA allocator. Donât use a backing file on a CIFS
- filesystem.
+ ⢠The GNU/Linux CIFS filesystem is known to not work well with the
+ PMA allocator. Donât use a backing file on a CIFS filesystem.
+
+ ⢠If âgawkâ is run by the ârootâ user, then persistent memory is
not
+ allowed. This is to avoid the possibility of private data
+ âleakingâ into the backing file and being recovered later by an
+ attacker.
Terence Kelly has provided a separate âPersistent-Memory âgawkâ User
Manualâ document, which is included in the âgawkâ distribution. It is
@@ -37093,9 +37104,9 @@ Index
* environment variables, REALLY_USE_PERSIST_MALLOC: Persistent Memory.
(line 29)
* environment variables, GAWK_PERSIST_FILE <1>: Persistent Memory.
- (line 45)
+ (line 50)
* environment variables, PMA_VERBOSITY <1>: Persistent Memory.
- (line 89)
+ (line 94)
* environment variables, LANGUAGE: Explaining gettext. (line 120)
* environment variables, GAWK_LOCALE_DIR <1>: Explaining gettext.
(line 132)
@@ -37587,7 +37598,7 @@ Index
* GAWK_PERSIST_FILE environment variable: Other Environment Variables.
(line 15)
* GAWK_PERSIST_FILE environment variable <1>: Persistent Memory.
- (line 45)
+ (line 50)
* GAWK_READ_TIMEOUT environment variable: Other Environment Variables.
(line 19)
* GAWK_READ_TIMEOUT environment variable <1>: Read Timeout. (line 71)
@@ -37846,8 +37857,8 @@ Index
* Kahrs, Jürgen: Acknowledgments. (line 60)
* Kahrs, Jürgen <1>: Contributors. (line 71)
* Kasal, Stepan: Acknowledgments. (line 60)
-* Kelly, Terence: Persistent Memory. (line 71)
-* Kelly, Terence <1>: Persistent Memory. (line 116)
+* Kelly, Terence: Persistent Memory. (line 76)
+* Kelly, Terence <1>: Persistent Memory. (line 127)
* Kelly, Terence <2>: Feature History. (line 508)
* Kenobi, Obi-Wan: Undocumented. (line 6)
* Kernighan, Brian: History. (line 17)
@@ -38287,7 +38298,7 @@ Index
* PMA memory allocator <1>: Persistent Memory. (line 6)
* PMA_VERBOSITY environment variable: Other Environment Variables.
(line 29)
-* PMA_VERBOSITY environment variable <1>: Persistent Memory. (line 89)
+* PMA_VERBOSITY environment variable <1>: Persistent Memory. (line 94)
* pointers to functions: Indirect Calls. (line 6)
* portability, #! (executable scripts): Executable Scripts. (line 29)
* portability, ARGV variable: Executable Scripts. (line 55)
@@ -39643,244 +39654,244 @@ Ref: Two-way I/O-Footnote-2917472
Node: TCP/IP Networking917554
Node: Profiling920734
Node: Persistent Memory930444
-Ref: Persistent Memory-Footnote-1938958
-Node: Extension Philosophy939089
-Node: Advanced Features Summary940624
-Node: Internationalization942894
-Node: I18N and L10N944600
-Node: Explaining gettext945295
-Ref: Explaining gettext-Footnote-1951448
-Ref: Explaining gettext-Footnote-2951643
-Node: Programmer i18n951808
-Ref: Programmer i18n-Footnote-1956921
-Node: Translator i18n956970
-Node: String Extraction957806
-Ref: String Extraction-Footnote-1958984
-Node: Printf Ordering959082
-Ref: Printf Ordering-Footnote-1961944
-Node: I18N Portability962012
-Ref: I18N Portability-Footnote-1964586
-Node: I18N Example964657
-Ref: I18N Example-Footnote-1968057
-Ref: I18N Example-Footnote-2968133
-Node: Gawk I18N968250
-Node: I18N Summary968906
-Node: Debugger970307
-Node: Debugging971331
-Node: Debugging Concepts971780
-Node: Debugging Terms973606
-Node: Awk Debugging976219
-Ref: Awk Debugging-Footnote-1977196
-Node: Sample Debugging Session977336
-Node: Debugger Invocation977888
-Node: Finding The Bug979517
-Node: List of Debugger Commands986203
-Node: Breakpoint Control987580
-Node: Debugger Execution Control991412
-Node: Viewing And Changing Data994892
-Node: Execution Stack998630
-Node: Debugger Info1000311
-Node: Miscellaneous Debugger Commands1004610
-Node: Readline Support1009863
-Node: Limitations1010809
-Node: Debugging Summary1013453
-Node: Namespaces1014756
-Node: Global Namespace1015883
-Node: Qualified Names1017328
-Node: Default Namespace1018363
-Node: Changing The Namespace1019138
-Node: Naming Rules1020832
-Node: Internal Name Management1022747
-Node: Namespace Example1023817
-Node: Namespace And Features1026400
-Node: Namespace Summary1027857
-Node: Arbitrary Precision Arithmetic1029370
-Node: Computer Arithmetic1030889
-Ref: table-numeric-ranges1034706
-Ref: table-floating-point-ranges1035204
-Ref: Computer Arithmetic-Footnote-11035863
-Node: Math Definitions1035922
-Ref: table-ieee-formats1038967
-Node: MPFR features1039541
-Node: MPFR On Parole1039994
-Ref: MPFR On Parole-Footnote-11040838
-Node: MPFR Intro1040997
-Node: FP Math Caution1042687
-Ref: FP Math Caution-Footnote-11043761
-Node: Inexactness of computations1044138
-Node: Inexact representation1045169
-Node: Comparing FP Values1046552
-Node: Errors accumulate1047810
-Node: Strange values1049277
-Ref: Strange values-Footnote-11051943
-Node: Getting Accuracy1052048
-Node: Try To Round1054785
-Node: Setting precision1055692
-Ref: table-predefined-precision-strings1056397
-Node: Setting the rounding mode1058282
-Ref: table-gawk-rounding-modes1058664
-Ref: Setting the rounding mode-Footnote-11062722
-Node: Arbitrary Precision Integers1062905
-Ref: Arbitrary Precision Integers-Footnote-11066117
-Node: Checking for MPFR1066273
-Node: POSIX Floating Point Problems1067763
-Ref: POSIX Floating Point Problems-Footnote-11072627
-Node: Floating point summary1072665
-Node: Dynamic Extensions1074929
-Node: Extension Intro1076528
-Node: Plugin License1077836
-Node: Extension Mechanism Outline1078649
-Ref: figure-load-extension1079100
-Ref: figure-register-new-function1080680
-Ref: figure-call-new-function1081785
-Node: Extension API Description1083904
-Node: Extension API Functions Introduction1085633
-Ref: table-api-std-headers1087531
-Node: General Data Types1091995
-Ref: General Data Types-Footnote-11101163
-Node: Memory Allocation Functions1101478
-Ref: Memory Allocation Functions-Footnote-11106203
-Node: Constructor Functions1106302
-Node: API Ownership of MPFR and GMP Values1110207
-Node: Registration Functions1111768
-Node: Extension Functions1112472
-Node: Exit Callback Functions1118048
-Node: Extension Version String1119367
-Node: Input Parsers1120062
-Node: Output Wrappers1133436
-Node: Two-way processors1138144
-Node: Printing Messages1140505
-Ref: Printing Messages-Footnote-11141719
-Node: Updating ERRNO1141874
-Node: Requesting Values1142673
-Ref: table-value-types-returned1143426
-Node: Accessing Parameters1144535
-Node: Symbol Table Access1145819
-Node: Symbol table by name1146335
-Ref: Symbol table by name-Footnote-11149546
-Node: Symbol table by cookie1149678
-Ref: Symbol table by cookie-Footnote-11153959
-Node: Cached values1154023
-Ref: Cached values-Footnote-11157667
-Node: Array Manipulation1157824
-Ref: Array Manipulation-Footnote-11158927
-Node: Array Data Types1158964
-Ref: Array Data Types-Footnote-11161786
-Node: Array Functions1161886
-Node: Flattening Arrays1166915
-Node: Creating Arrays1173967
-Node: Redirection API1178817
-Node: Extension API Variables1181838
-Node: Extension Versioning1182563
-Ref: gawk-api-version1183000
-Node: Extension GMP/MPFR Versioning1184788
-Node: Extension API Informational Variables1186494
-Node: Extension API Boilerplate1187655
-Node: Changes from API V11191791
-Node: Finding Extensions1193425
-Node: Extension Example1194000
-Node: Internal File Description1194824
-Node: Internal File Ops1199148
-Ref: Internal File Ops-Footnote-11210706
-Node: Using Internal File Ops1210854
-Ref: Using Internal File Ops-Footnote-11213285
-Node: Extension Samples1213563
-Node: Extension Sample File Functions1215132
-Node: Extension Sample Fnmatch1223270
-Node: Extension Sample Fork1224865
-Node: Extension Sample Inplace1226141
-Node: Extension Sample Ord1229813
-Node: Extension Sample Readdir1230689
-Ref: table-readdir-file-types1231586
-Node: Extension Sample Revout1232724
-Node: Extension Sample Rev2way1233321
-Node: Extension Sample Read write array1234073
-Node: Extension Sample Readfile1237347
-Node: Extension Sample Time1238478
-Node: Extension Sample API Tests1240294
-Node: gawkextlib1240802
-Node: Extension summary1243838
-Node: Extension Exercises1247696
-Node: Language History1248974
-Node: V7/SVR3.11250688
-Node: SVR41253038
-Node: POSIX1254570
-Node: BTL1255995
-Node: POSIX/GNU1256764
-Node: Feature History1263295
-Node: Common Extensions1282360
-Node: Ranges and Locales1283729
-Ref: Ranges and Locales-Footnote-11288530
-Ref: Ranges and Locales-Footnote-21288557
-Ref: Ranges and Locales-Footnote-31288796
-Node: Contributors1289019
-Node: History summary1295224
-Node: Installation1296670
-Node: Gawk Distribution1297634
-Node: Getting1298126
-Node: Extracting1299125
-Node: Distribution contents1300837
-Node: Unix Installation1308917
-Node: Quick Installation1309739
-Node: Compiling with MPFR1312285
-Node: Shell Startup Files1312991
-Node: Additional Configuration Options1314148
-Node: Configuration Philosophy1316535
-Node: Compiling from Git1319037
-Node: Building the Documentation1319596
-Node: Non-Unix Installation1321008
-Node: PC Installation1321484
-Node: PC Binary Installation1322357
-Node: PC Compiling1323262
-Node: PC Using1324440
-Node: Cygwin1328168
-Node: MSYS1329424
-Node: OpenVMS Installation1330056
-Node: OpenVMS Compilation1330737
-Ref: OpenVMS Compilation-Footnote-11332220
-Node: OpenVMS Dynamic Extensions1332282
-Node: OpenVMS Installation Details1333918
-Node: OpenVMS Running1336353
-Node: OpenVMS GNV1340490
-Node: Bugs1341245
-Node: Bug definition1342169
-Node: Bug address1345820
-Node: Usenet1349411
-Node: Performance bugs1350642
-Node: Asking for help1353660
-Node: Maintainers1355651
-Node: Other Versions1356678
-Node: Installation summary1365610
-Node: Notes1366994
-Node: Compatibility Mode1367804
-Node: Additions1368626
-Node: Accessing The Source1369571
-Node: Adding Code1371106
-Node: New Ports1378242
-Node: Derived Files1382752
-Ref: Derived Files-Footnote-11388599
-Ref: Derived Files-Footnote-21388634
-Ref: Derived Files-Footnote-31389251
-Node: Future Extensions1389365
-Node: Implementation Limitations1390037
-Node: Extension Design1391279
-Node: Old Extension Problems1392443
-Ref: Old Extension Problems-Footnote-11394019
-Node: Extension New Mechanism Goals1394080
-Ref: Extension New Mechanism Goals-Footnote-11397576
-Node: Extension Other Design Decisions1397777
-Node: Extension Future Growth1399976
-Node: Notes summary1400600
-Node: Basic Concepts1401813
-Node: Basic High Level1402498
-Ref: figure-general-flow1402780
-Ref: figure-process-flow1403482
-Ref: Basic High Level-Footnote-11406878
-Node: Basic Data Typing1407067
-Node: Glossary1410485
-Node: Copying1443607
-Node: GNU Free Documentation License1481368
-Node: Index1506691
+Ref: Persistent Memory-Footnote-1939402
+Node: Extension Philosophy939533
+Node: Advanced Features Summary941068
+Node: Internationalization943338
+Node: I18N and L10N945044
+Node: Explaining gettext945739
+Ref: Explaining gettext-Footnote-1951892
+Ref: Explaining gettext-Footnote-2952087
+Node: Programmer i18n952252
+Ref: Programmer i18n-Footnote-1957365
+Node: Translator i18n957414
+Node: String Extraction958250
+Ref: String Extraction-Footnote-1959428
+Node: Printf Ordering959526
+Ref: Printf Ordering-Footnote-1962388
+Node: I18N Portability962456
+Ref: I18N Portability-Footnote-1965030
+Node: I18N Example965101
+Ref: I18N Example-Footnote-1968501
+Ref: I18N Example-Footnote-2968577
+Node: Gawk I18N968694
+Node: I18N Summary969350
+Node: Debugger970751
+Node: Debugging971775
+Node: Debugging Concepts972224
+Node: Debugging Terms974050
+Node: Awk Debugging976663
+Ref: Awk Debugging-Footnote-1977640
+Node: Sample Debugging Session977780
+Node: Debugger Invocation978332
+Node: Finding The Bug979961
+Node: List of Debugger Commands986647
+Node: Breakpoint Control988024
+Node: Debugger Execution Control991856
+Node: Viewing And Changing Data995336
+Node: Execution Stack999074
+Node: Debugger Info1000755
+Node: Miscellaneous Debugger Commands1005054
+Node: Readline Support1010307
+Node: Limitations1011253
+Node: Debugging Summary1013897
+Node: Namespaces1015200
+Node: Global Namespace1016327
+Node: Qualified Names1017772
+Node: Default Namespace1018807
+Node: Changing The Namespace1019582
+Node: Naming Rules1021276
+Node: Internal Name Management1023191
+Node: Namespace Example1024261
+Node: Namespace And Features1026844
+Node: Namespace Summary1028301
+Node: Arbitrary Precision Arithmetic1029814
+Node: Computer Arithmetic1031333
+Ref: table-numeric-ranges1035150
+Ref: table-floating-point-ranges1035648
+Ref: Computer Arithmetic-Footnote-11036307
+Node: Math Definitions1036366
+Ref: table-ieee-formats1039411
+Node: MPFR features1039985
+Node: MPFR On Parole1040438
+Ref: MPFR On Parole-Footnote-11041282
+Node: MPFR Intro1041441
+Node: FP Math Caution1043131
+Ref: FP Math Caution-Footnote-11044205
+Node: Inexactness of computations1044582
+Node: Inexact representation1045613
+Node: Comparing FP Values1046996
+Node: Errors accumulate1048254
+Node: Strange values1049721
+Ref: Strange values-Footnote-11052387
+Node: Getting Accuracy1052492
+Node: Try To Round1055229
+Node: Setting precision1056136
+Ref: table-predefined-precision-strings1056841
+Node: Setting the rounding mode1058726
+Ref: table-gawk-rounding-modes1059108
+Ref: Setting the rounding mode-Footnote-11063166
+Node: Arbitrary Precision Integers1063349
+Ref: Arbitrary Precision Integers-Footnote-11066561
+Node: Checking for MPFR1066717
+Node: POSIX Floating Point Problems1068207
+Ref: POSIX Floating Point Problems-Footnote-11073071
+Node: Floating point summary1073109
+Node: Dynamic Extensions1075373
+Node: Extension Intro1076972
+Node: Plugin License1078280
+Node: Extension Mechanism Outline1079093
+Ref: figure-load-extension1079544
+Ref: figure-register-new-function1081124
+Ref: figure-call-new-function1082229
+Node: Extension API Description1084348
+Node: Extension API Functions Introduction1086077
+Ref: table-api-std-headers1087975
+Node: General Data Types1092439
+Ref: General Data Types-Footnote-11101607
+Node: Memory Allocation Functions1101922
+Ref: Memory Allocation Functions-Footnote-11106647
+Node: Constructor Functions1106746
+Node: API Ownership of MPFR and GMP Values1110651
+Node: Registration Functions1112212
+Node: Extension Functions1112916
+Node: Exit Callback Functions1118492
+Node: Extension Version String1119811
+Node: Input Parsers1120506
+Node: Output Wrappers1133880
+Node: Two-way processors1138588
+Node: Printing Messages1140949
+Ref: Printing Messages-Footnote-11142163
+Node: Updating ERRNO1142318
+Node: Requesting Values1143117
+Ref: table-value-types-returned1143870
+Node: Accessing Parameters1144979
+Node: Symbol Table Access1146263
+Node: Symbol table by name1146779
+Ref: Symbol table by name-Footnote-11149990
+Node: Symbol table by cookie1150122
+Ref: Symbol table by cookie-Footnote-11154403
+Node: Cached values1154467
+Ref: Cached values-Footnote-11158111
+Node: Array Manipulation1158268
+Ref: Array Manipulation-Footnote-11159371
+Node: Array Data Types1159408
+Ref: Array Data Types-Footnote-11162230
+Node: Array Functions1162330
+Node: Flattening Arrays1167359
+Node: Creating Arrays1174411
+Node: Redirection API1179261
+Node: Extension API Variables1182282
+Node: Extension Versioning1183007
+Ref: gawk-api-version1183444
+Node: Extension GMP/MPFR Versioning1185232
+Node: Extension API Informational Variables1186938
+Node: Extension API Boilerplate1188099
+Node: Changes from API V11192235
+Node: Finding Extensions1193869
+Node: Extension Example1194444
+Node: Internal File Description1195268
+Node: Internal File Ops1199592
+Ref: Internal File Ops-Footnote-11211150
+Node: Using Internal File Ops1211298
+Ref: Using Internal File Ops-Footnote-11213729
+Node: Extension Samples1214007
+Node: Extension Sample File Functions1215576
+Node: Extension Sample Fnmatch1223714
+Node: Extension Sample Fork1225309
+Node: Extension Sample Inplace1226585
+Node: Extension Sample Ord1230257
+Node: Extension Sample Readdir1231133
+Ref: table-readdir-file-types1232030
+Node: Extension Sample Revout1233168
+Node: Extension Sample Rev2way1233765
+Node: Extension Sample Read write array1234517
+Node: Extension Sample Readfile1237791
+Node: Extension Sample Time1238922
+Node: Extension Sample API Tests1240738
+Node: gawkextlib1241246
+Node: Extension summary1244282
+Node: Extension Exercises1248140
+Node: Language History1249418
+Node: V7/SVR3.11251132
+Node: SVR41253482
+Node: POSIX1255014
+Node: BTL1256439
+Node: POSIX/GNU1257208
+Node: Feature History1263739
+Node: Common Extensions1282804
+Node: Ranges and Locales1284173
+Ref: Ranges and Locales-Footnote-11288974
+Ref: Ranges and Locales-Footnote-21289001
+Ref: Ranges and Locales-Footnote-31289240
+Node: Contributors1289463
+Node: History summary1295668
+Node: Installation1297114
+Node: Gawk Distribution1298078
+Node: Getting1298570
+Node: Extracting1299569
+Node: Distribution contents1301281
+Node: Unix Installation1309361
+Node: Quick Installation1310183
+Node: Compiling with MPFR1312729
+Node: Shell Startup Files1313435
+Node: Additional Configuration Options1314592
+Node: Configuration Philosophy1316979
+Node: Compiling from Git1319481
+Node: Building the Documentation1320040
+Node: Non-Unix Installation1321452
+Node: PC Installation1321928
+Node: PC Binary Installation1322801
+Node: PC Compiling1323706
+Node: PC Using1324884
+Node: Cygwin1328612
+Node: MSYS1329868
+Node: OpenVMS Installation1330500
+Node: OpenVMS Compilation1331181
+Ref: OpenVMS Compilation-Footnote-11332664
+Node: OpenVMS Dynamic Extensions1332726
+Node: OpenVMS Installation Details1334362
+Node: OpenVMS Running1336797
+Node: OpenVMS GNV1340934
+Node: Bugs1341689
+Node: Bug definition1342613
+Node: Bug address1346264
+Node: Usenet1349855
+Node: Performance bugs1351086
+Node: Asking for help1354104
+Node: Maintainers1356095
+Node: Other Versions1357122
+Node: Installation summary1366054
+Node: Notes1367438
+Node: Compatibility Mode1368248
+Node: Additions1369070
+Node: Accessing The Source1370015
+Node: Adding Code1371550
+Node: New Ports1378686
+Node: Derived Files1383196
+Ref: Derived Files-Footnote-11389043
+Ref: Derived Files-Footnote-21389078
+Ref: Derived Files-Footnote-31389695
+Node: Future Extensions1389809
+Node: Implementation Limitations1390481
+Node: Extension Design1391723
+Node: Old Extension Problems1392887
+Ref: Old Extension Problems-Footnote-11394463
+Node: Extension New Mechanism Goals1394524
+Ref: Extension New Mechanism Goals-Footnote-11398020
+Node: Extension Other Design Decisions1398221
+Node: Extension Future Growth1400420
+Node: Notes summary1401044
+Node: Basic Concepts1402257
+Node: Basic High Level1402942
+Ref: figure-general-flow1403224
+Ref: figure-process-flow1403926
+Ref: Basic High Level-Footnote-11407322
+Node: Basic Data Typing1407511
+Node: Glossary1410929
+Node: Copying1444051
+Node: GNU Free Documentation License1481812
+Node: Index1507135
End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index ee88ab06..2b085ece 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -308,13 +308,13 @@ Fax: +1-617-542-2652
Email: <email>gnu@@gnu.org</email>
URL: <ulink
url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout>
-<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993,
1996–2005, 2007, 2009–2022
+<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993,
1996–2005, 2007, 2009–2023
Free Software Foundation, Inc.
All Rights Reserved.</literallayout>
@end docbook
@ifnotdocbook
-Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2022 @*
+Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2023 @*
Free Software Foundation, Inc.
@end ifnotdocbook
@sp 2
@@ -31066,6 +31066,14 @@ utility:
$ @kbd{truncate -s 4G data.pma}
@end example
+@item
+It is recommended (but not required) to change the permissions on the
+file so that only the owner can read and write it:
+
+@example
+$ @kbd{chmod 0600 data.pma}
+@end example
+
@cindex @env{GAWK_PERSIST_FILE} environment variable
@cindex environment variables @subentry @env{GAWK_PERSIST_FILE}
@item
@@ -31141,7 +31149,10 @@ and error information the persistent memory allocator
will print.
@command{gawk} sets the default to one. See the @file{support/pma.c}
source code to understand what the different verbosity levels are.
-@quotation NOTE
+There are a few constraints on the use of persistent memory:
+
+@itemize @bullet
+@item
If you use MPFR mode (the @option{-M} option) on the first run
of a program using persistent memory, you @emph{must} continue
to use it on all subsequent runs. Similarly, if you don't use @option{-M}
@@ -31151,10 +31162,17 @@ Mixing and matching MPFR mode and regular mode with
the same backing
file is not allowed. @command{gawk} detects such a situation and issues
a fatal error message.
-Additionally, the GNU/Linux CIFS filesystem is known to not
+@item
+The GNU/Linux CIFS filesystem is known to not
work well with the PMA allocator.
Don't use a backing file on a CIFS filesystem.
-@end quotation
+
+@item
+If @command{gawk} is run by the @command{root} user, then
+persistent memory is not allowed. This is to avoid the possibility
+of private data ``leaking'' into the backing file and being
+recovered later by an attacker.
+@end itemize
Terence Kelly has provided a separate @cite{@value{PMGAWKTITLE}}
document, which is included in the @command{gawk}
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index fe9d31d0..d3d1410d 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -303,13 +303,13 @@ Fax: +1-617-542-2652
Email: <email>gnu@@gnu.org</email>
URL: <ulink
url="https://www.gnu.org">https://www.gnu.org/</ulink></literallayout>
-<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993,
1996–2005, 2007, 2009–2022
+<literallayout class="normal">Copyright © 1989, 1991, 1992, 1993,
1996–2005, 2007, 2009–2023
Free Software Foundation, Inc.
All Rights Reserved.</literallayout>
@end docbook
@ifnotdocbook
-Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2022 @*
+Copyright @copyright{} 1989, 1991, 1992, 1993, 1996--2005, 2007, 2009--2023 @*
Free Software Foundation, Inc.
@end ifnotdocbook
@sp 2
@@ -30021,6 +30021,14 @@ utility:
$ @kbd{truncate -s 4G data.pma}
@end example
+@item
+It is recommended (but not required) to change the permissions on the
+file so that only the owner can read and write it:
+
+@example
+$ @kbd{chmod 0600 data.pma}
+@end example
+
@cindex @env{GAWK_PERSIST_FILE} environment variable
@cindex environment variables @subentry @env{GAWK_PERSIST_FILE}
@item
@@ -30096,7 +30104,10 @@ and error information the persistent memory allocator
will print.
@command{gawk} sets the default to one. See the @file{support/pma.c}
source code to understand what the different verbosity levels are.
-@quotation NOTE
+There are a few constraints on the use of persistent memory:
+
+@itemize @bullet
+@item
If you use MPFR mode (the @option{-M} option) on the first run
of a program using persistent memory, you @emph{must} continue
to use it on all subsequent runs. Similarly, if you don't use @option{-M}
@@ -30106,10 +30117,17 @@ Mixing and matching MPFR mode and regular mode with
the same backing
file is not allowed. @command{gawk} detects such a situation and issues
a fatal error message.
-Additionally, the GNU/Linux CIFS filesystem is known to not
+@item
+The GNU/Linux CIFS filesystem is known to not
work well with the PMA allocator.
Don't use a backing file on a CIFS filesystem.
-@end quotation
+
+@item
+If @command{gawk} is run by the @command{root} user, then
+persistent memory is not allowed. This is to avoid the possibility
+of private data ``leaking'' into the backing file and being
+recovered later by an attacker.
+@end itemize
Terence Kelly has provided a separate @cite{@value{PMGAWKTITLE}}
document, which is included in the @command{gawk}
diff --git a/main.c b/main.c
index a3e05e1c..75cbdca4 100644
--- a/main.c
+++ b/main.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-2022,
+ * Copyright (C) 1986, 1988, 1989, 1991-2023,
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -25,7 +25,7 @@
*/
/* FIX THIS BEFORE EVERY RELEASE: */
-#define UPDATE_YEAR 2022
+#define UPDATE_YEAR 2023
#include "awk.h"
#include "getopt.h"
@@ -70,6 +70,7 @@ static void init_fds(void);
static void init_groupset(void);
static void save_argv(int, char **);
static const char *platform_name();
+static void check_pma_security(const char *pma_file);
/* These nodes store all the special variables AWK uses */
NODE *ARGC_node, *ARGIND_node, *ARGV_node, *BINMODE_node, *CONVFMT_node;
@@ -236,10 +237,11 @@ main(int argc, char **argv)
myname = gawk_name(argv[0]);
+ check_pma_security(persist_file);
+
int pma_result = pma_init(1, persist_file);
if (pma_result != 0) {
- // don't use 'fatal' routine, it seems to need to
- // allocate memory
+ // don't use 'fatal' routine, memory can't be allocated
fprintf(stderr, _("%s: fatal: persistent memory allocator
failed to initialize: return value %d, pma.c line: %d.\n"),
myname, pma_result, pma_errno);
exit(EXIT_FATAL);
@@ -264,6 +266,7 @@ main(int argc, char **argv)
mtrace();
#endif /* HAVE_MTRACE */
#endif /* HAVE_MCHECK_H */
+
os_arg_fixup(&argc, &argv); /* emulate redirection, expand wildcards */
if (argc < 2)
@@ -1938,3 +1941,31 @@ set_current_namespace(const char *new_namespace)
current_namespace = new_namespace;
}
+
+/* check_pma_security --- make some minimal security checks */
+
+static void
+check_pma_security(const char *pma_file)
+{
+#ifdef USE_PERSISTENT_MALLOC
+ struct stat sbuf;
+ int euid = geteuid();
+
+ // don't use 'fatal' routine, it seems to need to allocate memory
+ // and we haven't initialized PMA yet.
+
+ if (pma_file == NULL)
+ return;
+ else if (stat(pma_file, & sbuf) < 0) {
+ fprintf(stderr, _("%s: fatal: cannot stat %s: %s\n"),
+ myname, pma_file, strerror(errno));
+ exit(EXIT_FATAL);
+ } else if (euid == 0) {
+ fprintf(stderr, _("%s: fatal: using persistent memory is not
allowed when running as root.\n"), myname);
+ exit(EXIT_FATAL);
+ } else if (sbuf.st_uid != euid) {
+ fprintf(stderr, _("%s: warning: %s is not owned by euid %d.\n"),
+ myname, pma_file, euid);
+ }
+#endif /* USE_PERSISTENT_MALLOC */
+}
diff --git a/test/ChangeLog b/test/ChangeLog
index e6269d22..f630fe9d 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2023-01-22 Arnold D. Robbins <arnold@skeeve.com>
+
+ * makepmafile.c (main): Make the file mode 0600.
+ Update copyright year.
+
2022-11-25 Arnold D. Robbins <arnold@skeeve.com>
* Makefile.am: Use `grep -E' instead of egrep in some of the test
diff --git a/test/makepmafile.c b/test/makepmafile.c
index c6df717d..8f7d2257 100644
--- a/test/makepmafile.c
+++ b/test/makepmafile.c
@@ -3,7 +3,7 @@
*/
/*
- * Copyright (C) 2022,
+ * Copyright (C) 2022, 2023,
* the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
@@ -38,7 +38,7 @@ main(int argc, char **argv)
{
size_t four_meg = 1024 * 1024 * 4;
char c = 0;
- int fd = creat("test.pma", 0666);
+ int fd = creat("test.pma", 0600);
if (fd < 0) {
fprintf(stderr, "%s: could not create test.pma: %s\n",
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 8 +
NEWS | 5 +-
doc/ChangeLog | 8 +
doc/gawk.info | 549 +++++++++++++++++++++++++------------------------
doc/gawk.texi | 63 ++++--
doc/gawktexi.in | 63 ++++--
extension/ChangeLog | 10 +
extension/configh.in | 3 +
extension/configure | 6 +
extension/configure.ac | 4 +-
extension/time.3am | 66 ++++--
extension/time.c | 71 +++++--
main.c | 39 +++-
test/ChangeLog | 6 +
test/makepmafile.c | 4 +-
test/time.awk | 30 +--
test/time.ok | 2 +-
17 files changed, 587 insertions(+), 350 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, gawk-5.2-stable, updated. gawk-4.1.0-4982-g6e195e45,
Arnold Robbins <=