aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2011-04-13 10:19:18 +0300
committerArnold D. Robbins <arnold@skeeve.com>2011-04-13 10:19:18 +0300
commit338600c0115fa68fe85c4d601e85bf16965d3a91 (patch)
tree01257b03d23a3303d4d7df20eed4232a270874ac
parent933418a5f59d54887c43dc4fb9167faf1330db30 (diff)
downloadegawk-338600c0115fa68fe85c4d601e85bf16965d3a91.tar.gz
egawk-338600c0115fa68fe85c4d601e85bf16965d3a91.tar.bz2
egawk-338600c0115fa68fe85c4d601e85bf16965d3a91.zip
Bug fixes, see ChangeLog.
-rw-r--r--ChangeLog7
-rw-r--r--awklib/eg/lib/nextfile.awk16
-rw-r--r--builtin.c15
-rw-r--r--io.c7
4 files changed, 24 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 01176a75..d60c0c42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Apr 13 10:17:37 2011 John Haque <j.eh@mchsi.com>
+
+ * builtin.c (do_strftime): Make the third argument to strftime
+ really work.
+ * io.c (redirect): Do not free `rp' after failure to open socket
+ in redirect_twoway. Fixes a double-free memory error.
+
Thu Apr 7 21:38:08 2011 Arnold D. Robbins <arnold@skeeve.com>
* array.c (merge): Use sort_cmp_nodes for asort/asorti.
diff --git a/awklib/eg/lib/nextfile.awk b/awklib/eg/lib/nextfile.awk
deleted file mode 100644
index 33f5af36..00000000
--- a/awklib/eg/lib/nextfile.awk
+++ /dev/null
@@ -1,16 +0,0 @@
-# nextfile --- skip remaining records in current file
-# correctly handle successive occurrences of the same file
-#
-# Arnold Robbins, arnold@skeeve.com, Public Domain
-# May, 1993
-
-# this should be read in before the "main" awk program
-
-function nextfile() { _abandon_ = FILENAME; next }
-
-_abandon_ == FILENAME {
- if (FNR == 1)
- _abandon_ = ""
- else
- next
-}
diff --git a/builtin.c b/builtin.c
index 8349e639..d4dfb20d 100644
--- a/builtin.c
+++ b/builtin.c
@@ -798,7 +798,7 @@ do_substr(int nargs)
NODE *
do_strftime(int nargs)
{
- NODE *t1, *t2, *ret;
+ NODE *t1, *t2, *t3, *ret;
struct tm *tm;
time_t fclock;
char *bufp;
@@ -830,11 +830,20 @@ do_strftime(int nargs)
}
}
- t1 = t2 = NULL;
+ t1 = t2 = t3 = NULL;
if (nargs > 0) { /* have args */
NODE *tmp;
- if (nargs == 2) {
+ if (nargs == 3) {
+ t3 = POP_SCALAR();
+ if ((t3->flags & (NUMCUR|NUMBER)) != 0)
+ do_gmt = (t3->numbr != 0);
+ else
+ do_gmt = (t3->stlen > 0);
+ DEREF(t3);
+ }
+
+ if (nargs >= 2) {
t2 = POP_SCALAR();
if (do_lint && (t2->flags & (NUMCUR|NUMBER)) == 0)
lintwarn(_("strftime: received non-numeric second argument"));
diff --git a/io.c b/io.c
index dfe449cd..a4ed1e77 100644
--- a/io.c
+++ b/io.c
@@ -732,6 +732,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
fd = devopen(str, binmode("r"));
if (fd == INVALID_HANDLE && errno == EISDIR) {
*errflg = EISDIR;
+ /* do not free rp, saving it for reuse (save_rp = rp) */
return NULL;
}
rp->iop = iop_alloc(fd, str, NULL, TRUE);
@@ -742,7 +743,7 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
#ifdef HAVE_SOCKETS
if (inetfile(str, NULL, NULL)) {
*errflg = errno;
- free_rp(rp);
+ /* do not free rp, saving it for reuse (save_rp = rp) */
return NULL;
} else
#endif
@@ -833,8 +834,10 @@ redirect(NODE *redir_exp, int redirtype, int *errflg)
else
fatal(_("can't redirect to `%s' (%s)"),
str, strerror(errno));
- } else
+ } else {
+ /* do not free rp, saving it for reuse (save_rp = rp) */
return NULL;
+ }
}
}
}