gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-3993-g901a6bf


From: Arnold Robbins
Subject: [SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-3993-g901a6bf
Date: Thu, 11 Jun 2020 01:49:45 -0400 (EDT)

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.1-stable has been updated
       via  901a6bf25b693537c59c4d1990c700e5c68db5e7 (commit)
       via  9cfec0497fb83a69bd77b0d2c940fe70b76c23da (commit)
       via  e0fd662ce71025cd98193e6c3229dbdff22aeccc (commit)
       via  17d03a4deb7ed18abb4e0e590e6315050d9c29fd (commit)
      from  5aae00200fc44bdfefbb497cf57eb23a9d2517be (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=901a6bf25b693537c59c4d1990c700e5c68db5e7

commit 901a6bf25b693537c59c4d1990c700e5c68db5e7
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Thu Jun 11 08:38:52 2020 +0300

    Finish up patches from Michael Builov.

diff --git a/ChangeLog b/ChangeLog
index 322c7ae..48f08cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2020-06-10         Arnold D. Robbins     <arnold@skeeve.com>
 
+       More miscellaneous fixes from Michael Builov <mbuilov@gmail.com>.
+
+       * node.c (r_unref): Handle GAWKDEBUG same as in awk.h:unref.
+       (parse_escape): isxdigit/isdigit/isupper called with possible negative
+       int: fixed. Dead code under "if (do_lint && j > 2)" eliminated,
+       j cannot be > 2.
+       (init_btowc_cache): Also initialize wide-char at index 255.
+
+       And so that `make check' passes with GAWKDEBUG defined:
+
+       * msg.c (err): Remvoe abort() call if fatal. Didn't really do
+       anything special for us.
+
+2020-06-10         Arnold D. Robbins     <arnold@skeeve.com>
+
        * awkgram.c, command.c: Regenerated with bison 3.6.3.
        * NEWS: Updated.
 
@@ -14,7 +29,7 @@
 
 2020-06-10         Arnold D. Robbins     <arnold@skeeve.com>
 
-       Miscellanious fixes from Michael Builov <mbuilov@gmail.com>.
+       Miscellaneous fixes from Michael Builov <mbuilov@gmail.com>.
 
        * awkgram.y (rule_block): Fix size declaration
        (parse_program): Adjust memset call.
diff --git a/msg.c b/msg.c
index 53df2c0..0dc3f71 100644
--- a/msg.c
+++ b/msg.c
@@ -106,14 +106,9 @@ err(bool isfatal, const char *s, const char *emsg, va_list 
argp)
        (void) fprintf(stderr, "\n");
        (void) fflush(stderr);
 
-       if (isfatal) {
-#ifdef GAWKDEBUG
-               // GLIBC 2.27 doesn't necessarily flush on abort. Sigh.
-               fflush(NULL);
-               abort();
-#endif
+       if (isfatal)
                gawk_exit(EXIT_FATAL);
-       }
+
 }
 
 /* msg --- take a varargs error message and print it */

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=9cfec0497fb83a69bd77b0d2c940fe70b76c23da

commit 9cfec0497fb83a69bd77b0d2c940fe70b76c23da
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Wed Jun 10 09:03:46 2020 +0300

    Makefile fixes after update to test/Gentests.

diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 2670ae4..7da52fd 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -3390,7 +3390,7 @@ mbprintf1:
 
 mbprintf2:
        @echo $@ $(ZOS_FAIL)
-       @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=; export GAWKLOCALE; \
+       @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=JPN_JPN.932; export GAWKLOCALE; \
        AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? 
>>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
diff --git a/test/Makefile.in b/test/Makefile.in
index b774c54..c4b7210 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -5007,7 +5007,7 @@ mbprintf1:
 
 mbprintf2:
        @echo $@ $(ZOS_FAIL)
-       @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=; export GAWKLOCALE; \
+       @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=ja_JP.UTF-8; export GAWKLOCALE; \
        AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? 
>>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
diff --git a/test/Maketests b/test/Maketests
index a59771a..1c54a7c 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -2133,7 +2133,7 @@ mbprintf1:
 
 mbprintf2:
        @echo $@ $(ZOS_FAIL)
-       @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=; export GAWKLOCALE; \
+       @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=ja_JP.UTF-8; export GAWKLOCALE; \
        AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? 
>>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=e0fd662ce71025cd98193e6c3229dbdff22aeccc

commit e0fd662ce71025cd98193e6c3229dbdff22aeccc
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Wed Jun 10 08:51:47 2020 +0300

    Add ChangeLog entries and some more minor fixes.

diff --git a/ChangeLog b/ChangeLog
index 35fc3cc..322c7ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,18 @@
 
 2020-06-10         Arnold D. Robbins     <arnold@skeeve.com>
 
+       Miscellanious fixes from Michael Builov <mbuilov@gmail.com>.
+
+       * awkgram.y (rule_block): Fix size declaration
+       (parse_program): Adjust memset call.
+       (get_comment): Check for end of file before checking for space.
+       * io.c (gawk_popen): Move os_close_on_exec call inside #endif.
+       * builtin.c (do_bindtextdomain): Don't pass NULL to strlen.
+       * debug.c (set_breakpoint): Don't dereference NULL pointer in D_func.
+       (serialize_list): Get the buffer management right to avoid overrun.
+
+2020-06-10         Arnold D. Robbins     <arnold@skeeve.com>
+
        Thanks to Andrew Schorr for suggestion of better way to
        handle exec_count being a long long.
 
diff --git a/debug.c b/debug.c
index d6bb0bd..26a6755 100644
--- a/debug.c
+++ b/debug.c
@@ -4433,8 +4433,8 @@ serialize_subscript(char *buf, int buflen, struct 
list_item *item)
 }
 
 
-
-/* serialize_list--- convert a list structure to a byte stream and
+/*
+ * serialize_list--- convert a list structure to a byte stream and
  *               save in environment.
  */
 
@@ -4607,9 +4607,9 @@ enlarge_buffer:
                        }
 
                        if (nchar > 0) {        /* non-empty commands list */
-                               nchar += (strlen("commands ") + 20/*cnum*/ + 
1/*CSEP*/ + strlen("end") + 1/*FSEP*/);
+                               nchar += (strlen("commands ") + 20 /*cnum*/ + 1 
/*CSEP*/ + strlen("end") + 1 /*FSEP*/);
                                if (nchar >= buflen - bl) {
-                                       buflen = bl + nchar + 1/*RSEP*/;
+                                       buflen = bl + nchar + 1 /*RSEP*/;
                                        erealloc(buf, char *, buflen + 1, 
"serialize_list");
                                }
                                nchar = sprintf(buf + bl, "commands %d", cnum);
@@ -4645,8 +4645,8 @@ enlarge_buffer:
                        if (cndn->expr) {
                                bl--;   /* undo RSEP from above */
                                nchar = strlen(cndn->expr);
-                               if (nchar + 1/*FSEP*/ >= buflen - bl) {
-                                       buflen = bl + nchar + 1/*FSEP*/ + 
1/*RSEP*/;
+                               if (nchar + 1 /*FSEP*/ >= buflen - bl) {
+                                       buflen = bl + nchar + 1 /*FSEP*/ + 1 
/*RSEP*/;
                                        erealloc(buf, char *, buflen + 1, 
"serialize_list");
                                }
                                memcpy(buf + bl, cndn->expr, nchar);
diff --git a/extension/ChangeLog b/extension/ChangeLog
index addf936..223b817 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,24 @@
+2020-06-10         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Miscellanious fixes from Michael Builov <mbuilov@gmail.com>.
+
+       * fts.c (fts_open): Fix memory leak: fts_sort() allocates
+       sp->fts_array, but it's not freed if next fts_alloc() fails.
+       (fts_build): Need to free "head" list before returning NULL
+       on failure.
+       * readdir.c (get_inode): On Windows handle leak: opened handle
+       was not closed.
+       * filefuncs.c (get_inode): On Windows handle leak: opened handle
+       was not closed.
+       (fill_stat_array): Correct the block size calculation.
+       (init_filefuncs, do_fts): According to the documentation,
+       setting the FTS_NOCHDIR flag should only disable the optimization of
+       changing the current directory when scanning directories.
+       However, setting this flag in the gawk script also included setting
+       FTS_SKIP, which prevented recursive directory traversal. Fix this.
+       * rwarray0.c (read_value): Result of read_array() is awk_bool_t,
+       not error code. Fix the check.
+
 2020-04-14         Arnold D. Robbins     <arnold@skeeve.com>
 
        * 5.1.0: Release tar ball made.
diff --git a/missing_d/ChangeLog b/missing_d/ChangeLog
index 2ae8093..07939c2 100644
--- a/missing_d/ChangeLog
+++ b/missing_d/ChangeLog
@@ -1,3 +1,9 @@
+2020-06-10         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Miscellanious fixes from Michael Builov <mbuilov@gmail.com>.
+
+       * fnmatch.c (internal_fnmatch): Misc small fixes.
+
 2020-04-14         Arnold D. Robbins     <arnold@skeeve.com>
 
        * 5.1.0: Release tar ball made.
diff --git a/missing_d/fnmatch.c b/missing_d/fnmatch.c
index 4da8c5f..3e6e5ce 100644
--- a/missing_d/fnmatch.c
+++ b/missing_d/fnmatch.c
@@ -329,6 +329,8 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
 
                    if (c == fn)
                      goto matched;
+
+                   c = *p++;
                  }
                else if (c == '[' && *p == ':')
                  {
@@ -353,7 +355,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
                            p += 2;
                            break;
                          }
-                       if (c < 'a' || c >= 'z')
+                       if (c < 'a' || c > 'z')
                          {
                            /* This cannot possibly be a character class name.
                               Match it as a normal range.  */
@@ -388,6 +390,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
                        || (STREQ (str, "xdigit") && ISXDIGIT ((unsigned char) 
*n)))
                      goto matched;
 # endif
+                   c = *p++;
                  }
                else if (c == '\0')
                  /* [ (unterminated) loses.  */
@@ -398,7 +401,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
                    if (FOLD (c) == fn)
                      goto matched;
 
-                   cold = c;
+                   cold = FOLD(c);
                    c = *p++;
 
                    if (c == '-' && *p != ']')
diff --git a/test/ChangeLog b/test/ChangeLog
index cca09eb..ca213e8 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,9 @@
+2020-06-10         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Miscellanious fixes from Michael Builov <mbuilov@gmail.com>.
+
+       * Gentests: Use correct locale for JP.
+
 2020-06-08         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.am (EXTRA_DIST): New test, strfieldnum.

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=17d03a4deb7ed18abb4e0e590e6315050d9c29fd

commit 17d03a4deb7ed18abb4e0e590e6315050d9c29fd
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Wed Jun 10 06:10:04 2020 +0300

    Add mbuilov fixes. Still needs review.

diff --git a/awk.h b/awk.h
index 283817a..9005ff3 100644
--- a/awk.h
+++ b/awk.h
@@ -1267,8 +1267,11 @@ static inline void
 DEREF(NODE *r)
 {
        assert(r->valref > 0);
-       if (--r->valref == 0)
-               r_unref(r);
+#ifndef GAWKDEBUG
+       if (--r->valref > 0)
+               return;
+#endif
+       r_unref(r);
 }
 
 #define POP_NUMBER() force_number(POP_SCALAR())
@@ -1926,6 +1929,7 @@ force_string_fmt(NODE *s, const char *fmtstr, int fmtidx)
 static inline void
 unref(NODE *r)
 {
+       assert(r == NULL || r->valref > 0);
        if (r != NULL && --r->valref <= 0)
                r_unref(r);
 }
diff --git a/awkgram.c b/awkgram.c
index b5985fe..469184e 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -212,7 +212,7 @@ const char awk_namespace[] = "awk";
 const char *current_namespace = awk_namespace;
 bool namespace_changed = false;
 
-static INSTRUCTION *rule_block[sizeof(ruletab)];
+static INSTRUCTION *rule_block[sizeof(ruletab)/sizeof(ruletab[0])];
 
 static INSTRUCTION *ip_rec;
 static INSTRUCTION *ip_newfile;
@@ -5293,7 +5293,7 @@ parse_program(INSTRUCTION **pcode, bool from_eval)
        lexeof = false;
        lexptr = NULL;
        lasttok = 0;
-       memset(rule_block, 0, sizeof(ruletab) * sizeof(INSTRUCTION *));
+       memset(rule_block, 0, sizeof(rule_block));
        errcount = 0;
        tok = tokstart != NULL ? tokstart : tokexpand();
 
@@ -5974,7 +5974,7 @@ get_comment(enum commenttype flag, INSTRUCTION 
**comment_instruction)
                                        sourceline++;
                                        tokadd(c);
                                }
-                       } while (isspace(c) && c != END_FILE);
+                       } while (c != END_FILE && isspace(c));
                        if (c == END_FILE)
                                break;
                        else if (c != '#') {
diff --git a/awkgram.y b/awkgram.y
index 0eb9694..ec917c3 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -167,7 +167,7 @@ const char awk_namespace[] = "awk";
 const char *current_namespace = awk_namespace;
 bool namespace_changed = false;
 
-static INSTRUCTION *rule_block[sizeof(ruletab)];
+static INSTRUCTION *rule_block[sizeof(ruletab)/sizeof(ruletab[0])];
 
 static INSTRUCTION *ip_rec;
 static INSTRUCTION *ip_newfile;
@@ -2779,7 +2779,7 @@ parse_program(INSTRUCTION **pcode, bool from_eval)
        lexeof = false;
        lexptr = NULL;
        lasttok = 0;
-       memset(rule_block, 0, sizeof(ruletab) * sizeof(INSTRUCTION *));
+       memset(rule_block, 0, sizeof(rule_block));
        errcount = 0;
        tok = tokstart != NULL ? tokstart : tokexpand();
 
@@ -3460,7 +3460,7 @@ get_comment(enum commenttype flag, INSTRUCTION 
**comment_instruction)
                                        sourceline++;
                                        tokadd(c);
                                }
-                       } while (isspace(c) && c != END_FILE);
+                       } while (c != END_FILE && isspace(c));
                        if (c == END_FILE)
                                break;
                        else if (c != '#') {
diff --git a/builtin.c b/builtin.c
index dc8d1a8..7ef2acd 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3997,6 +3997,9 @@ do_bindtextdomain(int nargs)
                DEREF(t2);
        }
 
+       if (the_result == NULL)
+               the_result = "";
+
        return make_string(the_result, strlen(the_result));
 }
 
diff --git a/debug.c b/debug.c
index d53b9b8..d6bb0bd 100644
--- a/debug.c
+++ b/debug.c
@@ -2403,9 +2403,11 @@ func:
                if ((b = set_breakpoint_at(rp, rp->source_line, false)) == NULL)
                        fprintf(out_fp, _("cannot set breakpoint in function 
`%s'\n"),
                                                func->vname);
-               else if (temporary)
-                       b->flags |= BP_TEMP;
-               lineno = b->bpi->source_line;
+               else {
+                       if (temporary)
+                               b->flags |= BP_TEMP;
+                       lineno = b->bpi->source_line;
+               }
                break;
 
        default:
@@ -4605,10 +4607,10 @@ enlarge_buffer:
                        }
 
                        if (nchar > 0) {        /* non-empty commands list */
-                               nchar += (strlen("commands ") + 20 + 
strlen("end") + 1); /* 20 for cnum (an int) */
-                               if (nchar > buflen - bl) {
-                                       buflen = bl + nchar;
-                                       erealloc(buf, char *, buflen + 3, 
"serialize_list");
+                               nchar += (strlen("commands ") + 20/*cnum*/ + 
1/*CSEP*/ + strlen("end") + 1/*FSEP*/);
+                               if (nchar >= buflen - bl) {
+                                       buflen = bl + nchar + 1/*RSEP*/;
+                                       erealloc(buf, char *, buflen + 1, 
"serialize_list");
                                }
                                nchar = sprintf(buf + bl, "commands %d", cnum);
                                bl += nchar;
@@ -4634,8 +4636,8 @@ enlarge_buffer:
                                nchar = strlen("end");  /* end of 'commands' */
                                memcpy(buf + bl, "end", nchar);
                                bl += nchar;
+                               buf[bl++] = FSEP;               /* field */
                        }
-                       buf[bl++] = FSEP;               /* field */
                        buf[bl++] = RSEP;               /* record */
                        buf[bl] = '\0';
 
@@ -4643,9 +4645,9 @@ enlarge_buffer:
                        if (cndn->expr) {
                                bl--;   /* undo RSEP from above */
                                nchar = strlen(cndn->expr);
-                               if (nchar > buflen - bl) {
-                                       buflen = bl + nchar;
-                                       erealloc(buf, char *, buflen + 3, 
"serialize_list");
+                               if (nchar + 1/*FSEP*/ >= buflen - bl) {
+                                       buflen = bl + nchar + 1/*FSEP*/ + 
1/*RSEP*/;
+                                       erealloc(buf, char *, buflen + 1, 
"serialize_list");
                                }
                                memcpy(buf + bl, cndn->expr, nchar);
                                bl += nchar;
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 86e6032..8314168 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -126,13 +126,16 @@ static long long
 get_inode(const char *fname)
 {
        HANDLE fh;
+       BOOL ok;
        BY_HANDLE_FILE_INFORMATION info;
 
        fh = CreateFile(fname, 0, 0, NULL, OPEN_EXISTING,
                        FILE_FLAG_BACKUP_SEMANTICS, NULL);
        if (fh == INVALID_HANDLE_VALUE)
                return 0;
-       if (GetFileInformationByHandle(fh, &info)) {
+       ok = GetFileInformationByHandle(fh, &info);
+       CloseHandle(fh);
+       if (ok) {
                long long inode = info.nFileIndexHigh;
 
                inode <<= 32;
@@ -403,7 +406,8 @@ fill_stat_array(const char *name, awk_array_t array, struct 
stat *sbuf)
        array_set_numeric(array, "gid", sbuf->st_gid);
        array_set_numeric(array, "size", sbuf->st_size);
 #ifdef __MINGW32__
-       array_set_numeric(array, "blocks", (sbuf->st_size + 4095) / 4096);
+       array_set_numeric(array, "blocks", (double)((sbuf->st_size +
+               device_blocksize() - 1) / device_blocksize()));
 #else
        array_set_numeric(array, "blocks", sbuf->st_blocks);
 #endif
@@ -568,6 +572,7 @@ init_filefuncs(void)
 
 #ifndef __MINGW32__
        /* at least right now, only FTS needs initializing */
+#define FTS_NON_RECURSIVE      FTS_STOP        /* Don't step into directories. 
 */
        static struct flagtab {
                const char *name;
                int value;
@@ -579,7 +584,7 @@ init_filefuncs(void)
                ENTRY(FTS_PHYSICAL),
                ENTRY(FTS_SEEDOT),
                ENTRY(FTS_XDEV),
-               ENTRY(FTS_SKIP),
+               {"FTS_SKIP", FTS_NON_RECURSIVE},
                { NULL, 0 }
        };
 
@@ -836,7 +841,7 @@ do_fts(int nargs, awk_value_t *result, struct awk_ext_func 
*unused)
        int ret = -1;
        static const int mask = (
                  FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOCHDIR | FTS_PHYSICAL
-               | FTS_SEEDOT | FTS_XDEV | FTS_SKIP);
+               | FTS_SEEDOT | FTS_XDEV | FTS_NON_RECURSIVE);
 
        assert(result != NULL);
        fts_errors = 0;         /* ensure a fresh start */
@@ -886,6 +891,9 @@ do_fts(int nargs, awk_value_t *result, struct awk_ext_func 
*unused)
        }
        flags &= mask;  /* turn off anything else */
 
+       if (flags & FTS_NON_RECURSIVE)
+               flags |= FTS_NOCHDIR;
+
        /* make pathvector */
        count = path_array->count + 1;
        ezalloc(pathvector, char **, count * sizeof(char *), "do_fts");
@@ -900,8 +908,11 @@ do_fts(int nargs, awk_value_t *result, struct awk_ext_func 
*unused)
        assert(clear_array(dest.array_cookie));
 
        /* let's do it! */
-       if ((hierarchy = fts_open(pathvector, flags, NULL)) != NULL) {
-               process(hierarchy, dest.array_cookie, (flags & FTS_SEEDOT) != 
0, (flags & FTS_SKIP) != 0);
+       hierarchy = fts_open(pathvector, flags & ~FTS_NON_RECURSIVE, NULL);
+       if (hierarchy != NULL) {
+               process(hierarchy, dest.array_cookie,
+                       (flags & FTS_SEEDOT) != 0,
+                       (flags & FTS_NON_RECURSIVE) != 0);
                fts_close(hierarchy);
 
                if (fts_errors == 0)
diff --git a/extension/gawkfts.c b/extension/gawkfts.c
index c7fbc17..2e7ab68 100644
--- a/extension/gawkfts.c
+++ b/extension/gawkfts.c
@@ -228,7 +228,7 @@ fts_open(char * const *argv, int options,
         * so that everything about the "current" node is ignored.
         */
        if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL)
-               goto mem3;
+               goto mem4;
        sp->fts_cur->fts_link = root;
        sp->fts_cur->fts_info = FTS_INIT;
 
@@ -252,6 +252,8 @@ fts_open(char * const *argv, int options,
 
        return (sp);
 
+mem4:   if (sp->fts_array != NULL)
+               free(sp->fts_array);
 mem3:  fts_lfree(root);
        fts_free(parent);
 mem2:  free(sp->fts_path);
@@ -916,6 +918,7 @@ mem1:                               saved_errno = errno;
            (cur->fts_level == FTS_ROOTLEVEL ?
            FCHDIR(sp, sp->fts_rfd) :
            fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) {
+               fts_lfree(head);
                cur->fts_info = FTS_ERR;
                SET(FTS_STOP);
                return (NULL);
diff --git a/extension/readdir.c b/extension/readdir.c
index cc1cd50..fb73975 100644
--- a/extension/readdir.c
+++ b/extension/readdir.c
@@ -144,6 +144,7 @@ get_inode(struct dirent *entry, const char *dirname)
 #ifdef __MINGW32__
        char fname[PATH_MAX];
        HANDLE fh;
+       BOOL ok;
        BY_HANDLE_FILE_INFORMATION info;
 
        sprintf(fname, "%s\\%s", dirname, entry->d_name);
@@ -151,7 +152,9 @@ get_inode(struct dirent *entry, const char *dirname)
                        FILE_FLAG_BACKUP_SEMANTICS, NULL);
        if (fh == INVALID_HANDLE_VALUE)
                return 0;
-       if (GetFileInformationByHandle(fh, &info)) {
+       ok = GetFileInformationByHandle(fh, &info);
+       CloseHandle(fh);
+       if (ok) {
                long long inode = info.nFileIndexHigh;
 
                inode <<= 32;
diff --git a/extension/rwarray0.c b/extension/rwarray0.c
index 5298bea..72a376c 100644
--- a/extension/rwarray0.c
+++ b/extension/rwarray0.c
@@ -425,7 +425,7 @@ read_value(int fd, awk_value_t *value)
        if (code == 2) {
                awk_array_t array = create_array();
 
-               if (read_array(fd, array) != 0)
+               if (! read_array(fd, array))
                        return awk_false;
 
                /* hook into value */
diff --git a/io.c b/io.c
index f954d6e..7c69fcf 100644
--- a/io.c
+++ b/io.c
@@ -2681,8 +2681,8 @@ gawk_popen(const char *cmd, struct redirect *rp)
                close(p[0]);
                fatal(_("close of pipe failed: %s"), strerror(errno));
        }
-#endif
        os_close_on_exec(p[0], cmd, "pipe", "from");
+#endif
        if ((BINMODE & BINMODE_INPUT) != 0)
                os_setbinmode(p[0], O_BINARY);
        rp->iop = iop_alloc(p[0], cmd, 0);
diff --git a/node.c b/node.c
index c99af12..bcb9a4a 100644
--- a/node.c
+++ b/node.c
@@ -304,6 +304,7 @@ r_dupnode(NODE *n)
        assert(n->type == Node_val);
 
 #ifdef GAWKDEBUG
+       /* Do the same as in awk.h:dupnode().  */
        if ((n->flags & MALLOC) != 0) {
                n->valref++;
                return n;
@@ -496,20 +497,14 @@ void
 r_unref(NODE *tmp)
 {
 #ifdef GAWKDEBUG
-       if (tmp == NULL)
+       /* Do the same as in awk.h:unref().  */
+       assert(tmp == NULL || tmp->valref > 0);
+       if (tmp == NULL || --tmp->valref > 0)
                return;
-       if ((tmp->flags & MALLOC) != 0) {
-               if (tmp->valref > 1) {
-                       tmp->valref--;
-                       return;
-               }
-               if ((tmp->flags & STRCUR) != 0)
-                       efree(tmp->stptr);
-       }
-#else
+#endif
+
        if ((tmp->flags & (MALLOC|STRCUR)) == (MALLOC|STRCUR))
                efree(tmp->stptr);
-#endif
 
        mpfr_unset(tmp);
 
@@ -615,7 +610,7 @@ parse_escape(const char **string_ptr)
                start = *string_ptr;
                for (i = j = 0; j < 2; j++) {
                        /* do outside test to avoid multiple side effects */
-                       c = *(*string_ptr)++;
+                       c = (unsigned char) *(*string_ptr)++;
                        if (isxdigit(c)) {
                                i *= 16;
                                if (isdigit(c))
@@ -629,8 +624,8 @@ parse_escape(const char **string_ptr)
                                break;
                        }
                }
-               if (do_lint && j > 2)
-                       lintwarn(_("hex escape \\x%.*s of %d characters 
probably not interpreted the way you expect"), j, start, j);
+               if (do_lint && j == 2 && isxdigit((unsigned 
char)*(*string_ptr)))
+                       lintwarn(_("hex escape \\x%.*s of %d characters 
probably not interpreted the way you expect"), 3, start, 3);
                return i;
        case '\\':
        case '"':
@@ -1018,7 +1013,7 @@ void init_btowc_cache()
 {
        int i;
 
-       for (i = 0; i < 255; i++) {
+       for (i = 0; i <= 255; i++) {
                btowc_cache[i] = btowc(i);
        }
 }
diff --git a/test/Gentests b/test/Gentests
index 78833f0..392cbf2 100755
--- a/test/Gentests
+++ b/test/Gentests
@@ -16,7 +16,7 @@ BEGIN {
        Locale["EN"] = "en_US.UTF-8"
        Locale["FR"] = "fr_FR.UTF-8"
        Locale["GR"] = "el_GR.iso88597"
-       Locale["JA"] = "ja_JP.UTF-8"
+       Locale["JP"] = "ja_JP.UTF-8"
        Locale["RU"] = "ru_RU.UTF-8"
 }
 

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             | 27 +++++++++++++++++++++++++++
 awk.h                 |  8 ++++++--
 awkgram.c             |  6 +++---
 awkgram.y             |  6 +++---
 builtin.c             |  3 +++
 debug.c               | 28 +++++++++++++++-------------
 extension/ChangeLog   | 21 +++++++++++++++++++++
 extension/filefuncs.c | 23 +++++++++++++++++------
 extension/gawkfts.c   |  5 ++++-
 extension/readdir.c   |  5 ++++-
 extension/rwarray0.c  |  2 +-
 io.c                  |  2 +-
 missing_d/ChangeLog   |  6 ++++++
 missing_d/fnmatch.c   |  7 +++++--
 msg.c                 |  9 ++-------
 node.c                | 25 ++++++++++---------------
 pc/Makefile.tst       |  2 +-
 test/ChangeLog        |  6 ++++++
 test/Gentests         |  2 +-
 test/Makefile.in      |  2 +-
 test/Maketests        |  2 +-
 21 files changed, 138 insertions(+), 59 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]