]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Sat, 14 Mar 1998 09:27:24 +0000 (09:27 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sat, 14 Mar 1998 09:27:24 +0000 (09:27 +0000)
1998-03-14 00:52  Tim Waugh  <tim@cyberelk.demon.co.uk>

* posix/wordexp.c (parse_param): Perform field-splitting after
expanding positional parameter.

* posix/wordexp-tst.sh: Test that field-splitting is performed
after expanding positional parameter.

* posix/wordexp.c (parse_param): Fixed memory leak in
field-splitting after parameter expansion.

1998-03-14  Ulrich Drepper  <drepper@cygnus.com>

* locale/programs/linereader.c (lr_token): Return EOF token at
EOF.
(get_toplvl_escape): Correctly terminate loop at EOF.
Patch by Cristian Gafton <gafton@redhat.com>.

ChangeLog
locale/programs/linereader.c
localedata/ChangeLog
localedata/locales/ru_RU
posix/wordexp-tst.sh
posix/wordexp.c
string/bits/string2.h

index 8f4a14ba85987d40c6c89f8650da870e720bcc4e..a9445895e5472eff8587f316562ac7a1ec052f4e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+1998-03-14 00:52  Tim Waugh  <tim@cyberelk.demon.co.uk>
+
+       * posix/wordexp.c (parse_param): Perform field-splitting after
+       expanding positional parameter.
+
+       * posix/wordexp-tst.sh: Test that field-splitting is performed
+       after expanding positional parameter.
+
+       * posix/wordexp.c (parse_param): Fixed memory leak in
+       field-splitting after parameter expansion.
+
+1998-03-14  Ulrich Drepper  <drepper@cygnus.com>
+
+       * locale/programs/linereader.c (lr_token): Return EOF token at
+       EOF.
+       (get_toplvl_escape): Correctly terminate loop at EOF.
+       Patch by Cristian Gafton <gafton@redhat.com>.
+
 1998-03-13 16:55  Ulrich Drepper  <drepper@cygnus.com>
 
        * string/tester.c (test_strpbrk): Add more strpbrk tests.
index 83679b765575ec544d6e0bee6b4e4e6c66d841f2..8da5c5330fabccff53403ccd0bb40dba24f021ff 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
 
@@ -159,6 +159,12 @@ lr_token (struct linereader *lr, const struct charset_t *charset)
        {
          ch = lr_getc (lr);
 
+         if (ch == EOF)
+           {
+             lr->token.tok = tok_eof;
+             return &lr->token;
+           };
+
          if (ch == '\n')
            {
              lr->token.tok = tok_eol;
@@ -283,7 +289,7 @@ get_toplvl_escape (struct linereader *lr)
        esc_error:
          lr->token.val.str.start = &lr->buf[start_idx];
 
-         while (ch != EOF || !isspace (ch))
+         while (ch != EOF && !isspace (ch))
            ch = lr_getc (lr);
          lr->token.val.str.len = lr->idx - start_idx;
 
index 05b3b0b1632cae61c08859b75d93a4b92795b866..34e95cdfe476596626736b75e63f25663c1ea141 100644 (file)
@@ -1,3 +1,8 @@
+1998-03-14  Ulrich Drepper  <drepper@cygnus.com>
+
+       * locales/ru_RU: Correct last patch.
+       Patch by Cristian Gafton <gafton@redhat.com>.
+
 1998-03-11  Ulrich Drepper  <drepper@cygnus.com>
 
        * locales/de_DE: Use common german data and time format not ISO
index d898f63eec6f74d261f08d23a52e9010cacc1c1f..56755ca3166cd35ae52b7b2954204b9dc980c12b 100644 (file)
@@ -2134,18 +2134,18 @@ abday   "<V=><s=><k=>";/
         "<C%><t=><v=>";/
         "<P=><t=><n=>";/
         "<S=><u=><b=>"
-mon     "<JA><n=><v=><a=><r=><%'>";/
-       "<F=><e=><v=><r=><a=><l=><%'>";/
+mon     "<JA><n=><v=><a=><r=><ja>";/
+        "<F=><e=><v=><r=><a=><l=><ja>";/
         "<M=><a=><r=><t=>";/
-        "<A=><p=><r=><e=><l=><%'>";/
+        "<A=><p=><r=><e=><l=><ja>";/
         "<M=><a=><j=>";/
-        "<I=><ju><n=><%'>";/
-        "<I=><ju><l=><%'>";/
-        "<A=><v=><g=><u=><s=><t=>";/
-        "<S=><e=><n=><t=><ja><b=><r=><%'>";/
-        "<O=><k=><t=><ja><b=><r=><%'>";/
-        "<N=><o=><ja><b=><r=><%'>";/
-        "<D=><e=><k=><a=><b=><r=><%'>"
+        "<I=><ju><n=><ja>";/
+        "<I=><ju><l=><ja>";/
+        "<A=><v=><g=><u=><s=><t=><a=>";/
+        "<S=><e=><n=><t=><ja><b=><r=><ja>";/
+        "<O=><k=><t=><ja><b=><r=><ja>";/
+        "<N=><o=><ja><b=><r=><ja>";/
+        "<D=><e=><k=><a=><b=><r=><ja>"
 abmon   "<JA><n=><v=>";/
         "<F=><e=><v=>";/
         "<M=><a=><r=>";/
index e341e6435dfab6bc722ca880ff5a2bb8f6efc9d0..a5445f1ee62799218a3cac8caa52040374dd3c1b 100755 (executable)
@@ -61,11 +61,13 @@ we_wordv[0] = "5"
 EOF
 
 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
-${common_objpfx}posix/wordexp-test '$2 ${3}' 2nd 3rd > ${testout}6
-cat <<"EOF" | cmp - ${testout}6 || failed=1
+${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
+cat <<"EOF" | cmp - ${testout}7 || failed=1
 wordexp returned 0
 we_wordv[0] = "2nd"
 we_wordv[1] = "3rd"
+we_wordv[2] = "4"
+we_wordv[3] = "th"
 EOF
 
 exit $failed
index 0c89e02234bf14a31adbb1523da66b95f170d94c..5e0e985006db20f3d5cd2ab4a8f57039849f1804 100644 (file)
@@ -1018,6 +1018,7 @@ parse_param (char **word, size_t *word_length, size_t *max_length,
   int colon_seen = 0;
   int depth = 0;
   int seen_hash = 0;
+  int free_value = 0;
   int error;
 
   for (; words[*offset]; ++(*offset))
@@ -1285,7 +1286,6 @@ envsubst:
       if (isdigit(*env))
        {
          int n = *env - '0';
-         char *param;
 
          free (env);
          if (n >= __libc_argc)
@@ -1293,12 +1293,8 @@ envsubst:
            return 0;
 
          /* Replace with the appropriate positional parameter */
-         param = __strdup (__libc_argv[n]);
-         if (!param)
-           return WRDE_NOSPACE;
-
-         *word = w_addstr (*word, word_length, max_length, param);
-         return *word ? 0 : WRDE_NOSPACE;
+         value = __libc_argv[n];
+         goto maybe_fieldsplit;
        }
       /* Is it `$$' ? */
       else if (*env == '$')
@@ -1347,6 +1343,7 @@ envsubst:
                }
            }
 
+         free_value = 1;
          if (value)
            goto maybe_fieldsplit;
 
@@ -1666,31 +1663,42 @@ envsubst:
       return *word ? 0 : WRDE_NOSPACE;
     }
 
-
  maybe_fieldsplit:
   if (quoted || !pwordexp)
     {
       /* Quoted - no field split */
       *word = w_addstr (*word, word_length, max_length, value);
+      if (free_value)
+       free (value);
+
       return *word ? 0 : WRDE_NOSPACE;
     }
   else
     {
       /* Need to field-split */
-      char *field_begin = value;
+      char *value_copy = __strdup (value); /* Don't modify value */
+      char *field_begin = value_copy;
       int seen_nonws_ifs = 0;
 
+      if (free_value)
+       free (value);
+
+      if (value_copy == NULL)
+       return WRDE_NOSPACE;
+
       do
        {
          char *field_end = field_begin;
          char *next_field;
-         char ch;
 
          /* If this isn't the first field, start a new word */
-         if (field_begin != value)
+         if (field_begin != value_copy)
            {
              if (w_addword (pwordexp, *word) == WRDE_NOSPACE)
-               return WRDE_NOSPACE;
+               {
+                 free (value_copy);
+                 return WRDE_NOSPACE;
+               }
 
              *word = NULL;
              *word_length = *max_length = 0;
@@ -1710,8 +1718,7 @@ envsubst:
            field_end++;
 
          /* Set up pointer to the character after end of field */
-         ch = *field_end;
-         next_field = ch ? field_end : NULL;
+         next_field = *field_end ? field_end : NULL;
 
          /* Skip whitespace IFS after the field */
          while (next_field && *next_field && strchr (ifs_white, *next_field))
@@ -1729,13 +1736,19 @@ envsubst:
          *field_end = 0;
 
          /* Tag a copy onto the current word */
-         *word = w_addstr (*word, word_length, max_length,
-                           __strdup (field_begin));
+         *word = w_addstr (*word, word_length, max_length, field_begin);
+
          if (*word == NULL)
-           return WRDE_NOSPACE;
+           {
+             free (value_copy);
+             return WRDE_NOSPACE;
+           }
 
          field_begin = next_field;
-       } while (seen_nonws_ifs || (field_begin && *field_begin));
+       }
+      while (seen_nonws_ifs || (field_begin != NULL && *field_begin));
+
+      free (value_copy);
     }
 
   return 0;
index 45c6112b55a0f6c79bff223af313f72acd39f815..3104f949baae50ad5f778bd522d8331bd3590bee 100644 (file)
@@ -840,7 +840,7 @@ __strsep_g (char **__s, __const char *__reject)
   register char *__retval = *__s;
   if (__retval == NULL || *__retval == '\0')
     return NULL;
-  if ((*__s = strpbrk (__retval, __reject)) != '\0')
+  if ((*__s = strpbrk (__retval, __reject)) != NULL)
     *(*__s)++ = '\0';
   return __retval;
 }