gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-985


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-985-g04e37f2
Date: Tue, 25 Oct 2016 20:09:05 +0000 (UTC)

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-4.1-stable has been updated
       via  04e37f2ec691b6ba1f4e4d57e4baaccbcdd305cc (commit)
      from  bfd7df7f6dffcf905c4694d6482c50a3506bd9bd (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=04e37f2ec691b6ba1f4e4d57e4baaccbcdd305cc

commit 04e37f2ec691b6ba1f4e4d57e4baaccbcdd305cc
Author: Arnold D. Robbins <address@hidden>
Date:   Tue Oct 25 23:08:42 2016 +0300

    Restore null elements in paths being same as dot.

diff --git a/ChangeLog b/ChangeLog
index ad1de78..84817fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-10-25         Arnold D. Robbins     <address@hidden>
+
+       * io.c (init_awkpath): Restore documented behavior whereby
+       null elements represent the current directory. Sheesh.
+       Bug reported by "Jun T." <address@hidden>.
+
 2016-09-24  Eli Zaretskii  <address@hidden>
 
        * debug.c (restart) [__MINGW32__]: Cast 2nd argument of execvp to
diff --git a/io.c b/io.c
index 20d9ee2..931dcfe 100644
--- a/io.c
+++ b/io.c
@@ -2598,49 +2598,62 @@ init_awkpath(path_info *pi)
        int len, i;
        int max_path;           /* (# of allocated paths)-1 */
 
-#define INC_PATH 5
-
        pi->max_pathlen = 0;
        if ((path = getenv(pi->envname)) == NULL || *path == '\0')
                path = pi->dfltp[0];
 
-       max_path = INC_PATH;
+       /* count number of separators */
+       for (max_path = 0, p = path; *p; p++)
+               if (*p == envsep)
+                       max_path++;
+
        emalloc(pi->awkpath, char **, (max_path + 1) * sizeof(char *), 
"init_awkpath");
        memset(pi->awkpath, 0, (max_path + 1) * sizeof(char *));
 
-       end = start = path;
+       start = path;
        i = 0;
+
+       if (*path == envsep)    /* null entry at front of path */
+               pi->awkpath[i++] = ".";
+
        while (*start) {
-               while (*end && *end != envsep)
-                       end++;
-               len = end - start;
-               if (len > 0) {
-                       emalloc(p, char *, len + 2, "init_awkpath");
-                       memcpy(p, start, len);
-
-                       /* add directory punctuation if necessary */
-                       if (! isdirpunct(end[-1]))
-                               p[len++] = '/';
-                       p[len] = '\0';
-
-                       if (i == max_path) {
-                               max_path += INC_PATH;
-                               erealloc(pi->awkpath, char **, (max_path + 1) * 
sizeof(char *), "init_awkpath");
-                               memset(pi->awkpath + i, 0, (INC_PATH + 1) * 
sizeof(char *));
-                       }
-                       pi->awkpath[i++] = p;
-                       if (len > pi->max_pathlen)
-                               pi->max_pathlen = len;
+               if (*start == envsep) {
+                       if (start[1] == envsep) {
+                               pi->awkpath[i++] = ".";
+                               if (pi->max_pathlen == 0)
+                                       pi->max_pathlen = 1;
+                               start++;
+                       } else if (start[1] == '\0') {
+                               pi->awkpath[i++] = ".";
+                               if (pi->max_pathlen == 0)
+                                       pi->max_pathlen = 1;
+                               break;
+                       } else
+                               start++;
+               } else {
+                       for (end = start; *end && *end != envsep; end++)
+                               continue;
+
+                       len = end - start;
+                       if (len > 0) {
+                               emalloc(p, char *, len + 2, "init_awkpath");
+                               memcpy(p, start, len);
+
+                               /* add directory punctuation if necessary */
+                               if (! isdirpunct(end[-1]))
+                                       p[len++] = '/';
+                               p[len] = '\0';
+                               pi->awkpath[i++] = p;
+                               if (len > pi->max_pathlen)
+                                       pi->max_pathlen = len;
+
+                               start = end;
+                       } else
+                               start++;
                }
-
-               /* skip one or more envsep char */
-               while (*end && *end == envsep)
-                       end++;
-               start = end;
        }
-       pi->awkpath[i] = NULL;
 
-#undef INC_PATH
+       pi->awkpath[i] = NULL;
 }
 
 /* do_find_source --- search $AWKPATH for file, return NULL if not found */ 

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

Summary of changes:
 ChangeLog |    6 +++++
 io.c      |   75 ++++++++++++++++++++++++++++++++++++-------------------------
 2 files changed, 50 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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