From: Paul Eggert Date: Wed, 13 Aug 2003 23:44:25 +0000 (+0000) Subject: Fix typo in previous change; it mishandled the case when line_end was X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2b344270759434edb9c0ef94e9f2b2811582208;p=pspp Fix typo in previous change; it mishandled the case when line_end was neither a space nor NUL. --- diff --git a/lib/exclude.c b/lib/exclude.c index ffe136f871..7c038b23e4 100644 --- a/lib/exclude.c +++ b/lib/exclude.c @@ -267,21 +267,25 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int), e = errno; buf = xrealloc (buf, buf_count + 1); + buf[buf_count] = line_end; + lim = buf + buf_count + ! (buf_count == 0 || buf[buf_count - 1] == line_end); + pattern = buf; - for (pattern = p = buf, lim = buf + buf_count; p <= lim; p++) - if (p < lim ? *p == line_end : buf < p && p[-1]) + for (p = buf; p < lim; p++) + if (*p == line_end) { + char *pattern_end = p; + if (is_space (line_end)) { - char *pattern_end = p; for (; ; pattern_end--) if (pattern_end == pattern) goto next_pattern; else if (! is_space (pattern_end[-1])) break; - *pattern_end = '\0'; } + *pattern_end = '\0'; (*add_func) (ex, pattern, options); next_pattern: