~ubuntu-branches/ubuntu/hardy/gnupg/hardy-updates

« back to all changes in this revision

Viewing changes to util/strgutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2006-12-12 15:56:56 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20061212155656-kk00wp4x0uq4tm1y
Tags: upstream-1.4.6
ImportĀ upstreamĀ versionĀ 1.4.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1158
1158
}
1159
1159
#endif
1160
1160
 
1161
 
 
1162
 
#ifndef HAVE_STRSEP
1163
 
/* code taken from glibc-2.2.1/sysdeps/generic/strsep.c */
1164
 
char *
1165
 
strsep (char **stringp, const char *delim)
1166
 
{
1167
 
  char *begin, *end;
1168
 
 
1169
 
  begin = *stringp;
1170
 
  if (begin == NULL)
1171
 
    return NULL;
1172
 
 
1173
 
  /* A frequent case is when the delimiter string contains only one
1174
 
     character.  Here we don't need to call the expensive `strpbrk'
1175
 
     function and instead work using `strchr'.  */
1176
 
  if (delim[0] == '\0' || delim[1] == '\0')
1177
 
    {
1178
 
      char ch = delim[0];
1179
 
 
1180
 
      if (ch == '\0')
1181
 
        end = NULL;
1182
 
      else
1183
 
        {
1184
 
          if (*begin == ch)
1185
 
            end = begin;
1186
 
          else if (*begin == '\0')
1187
 
            end = NULL;
1188
 
          else
1189
 
            end = strchr (begin + 1, ch);
1190
 
        }
1191
 
    }
1192
 
  else
1193
 
    /* Find the end of the token.  */
1194
 
    end = strpbrk (begin, delim);
1195
 
 
1196
 
  if (end)
1197
 
    {
1198
 
      /* Terminate the token and set *STRINGP past NUL character.  */
1199
 
      *end++ = '\0';
1200
 
      *stringp = end;
1201
 
    }
1202
 
  else
1203
 
    /* No more delimiters; this is the last token.  */
1204
 
    *stringp = NULL;
1205
 
 
1206
 
  return begin;
1207
 
}
1208
 
#endif /*HAVE_STRSEP*/
1209
 
 
1210
 
 
1211
1161
#ifndef HAVE_STRLWR
1212
1162
char *
1213
1163
strlwr(char *s)