]> granicus.if.org Git - yasm/commitdiff
Fix bug in [1737]. Using a valid environment variable after a non-existent
authorPeter Johnson <peter@tortall.net>
Sat, 20 Jan 2007 05:52:32 +0000 (05:52 -0000)
committerPeter Johnson <peter@tortall.net>
Sat, 20 Jan 2007 05:52:32 +0000 (05:52 -0000)
one would result in the part of the string prior to the non-existent one
getting dropped.

svn path=/trunk/yasm/; revision=1738

modules/preprocs/nasm/nasm-pp.c

index b643a9f990c530f32c1cc5afff37f26eeaae4b07..c1ca6a8037c88bd5b8de03fbc815229702d15279 100644 (file)
@@ -1296,9 +1296,9 @@ inc_fopen(char *file, char **newname)
      * intact, if ENVVAR is not set in the environment.
      */
     pb = file;
+    p1 = pb;
     for (;;) {
        char *env;
-       p1 = pb;
        while (*p1 != '\0' && *p1 != '%')
            p1++;
        if (*p1 == '\0')
@@ -1318,7 +1318,7 @@ inc_fopen(char *file, char **newname)
            error(ERR_WARNING, "environment variable `%s' does not exist",
                  p1+1);
            *p2 = '%';
-           pb = p2+1;
+           p1 = p2+1;
            continue;
        }
        /* need to expand */
@@ -1331,6 +1331,7 @@ inc_fopen(char *file, char **newname)
        strcat(file2, pb);
        strcat(file2, env);
        pb = p2+1;
+       p1 = pb;
     }
     /* add tail end; string is long enough that we don't need to realloc */
     if (file2)