in files containing patterns to exclude.
 2003-08-13  Paul Eggert  <eggert@twinsun.com>
 
+       * exclude.c: Include <ctype.h>
+       (IN_CTYPE_DOMAIN): New macro.
+       (is_space): New fn.
+       (add_exclude_file): If LINE_END is a space, ignore trailing spaces
+       and empty lines.
+
        * argp-help.c, argp-parse.c, config.charset, getopt.h:
        Undo previous (whitespace-only) change.
 
 
 
 #include <stdbool.h>
 
+#include <ctype.h>
 #include <errno.h>
 #ifndef errno
 extern int errno;
 # define SIZE_MAX ((size_t) -1)
 #endif
 
+#if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
+# define IN_CTYPE_DOMAIN(c) true
+#else
+# define IN_CTYPE_DOMAIN(c) isascii (c)
+#endif
+
+static inline bool
+is_space (unsigned char c)
+{
+  return IN_CTYPE_DOMAIN (c) && isspace (c);
+}
+
 /* Verify a requirement at compile-time (unlike assert, which is runtime).  */
 #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
 
 }
 
 /* Use ADD_FUNC to append to EX the patterns in FILENAME, each with
-   OPTIONS.  LINE_END terminates each pattern in the file.  Return -1
-   on failure, 0 on success.  */
+   OPTIONS.  LINE_END terminates each pattern in the file.  If
+   LINE_END is a space character, ignore trailing spaces and empty
+   lines in FILE.  Return -1 on failure, 0 on success.  */
 
 int
 add_exclude_file (void (*add_func) (struct exclude *, char const *, int),
   for (pattern = p = buf, lim = buf + buf_count;  p <= lim;  p++)
     if (p < lim ? *p == line_end : buf < p && p[-1])
       {
-       *p = '\0';
+       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';
+         }
+
        (*add_func) (ex, pattern, options);
+
+      next_pattern:
        pattern = p + 1;
       }
 
 
 2003-08-13  Paul Eggert  <eggert@twinsun.com>
 
+       * exclude.m4 (gl_EXCLUDE): Require AC_C_INLINE, AC_HEADER_STDC.
+       Check for isascii.
+
        * gettext.m4, iconv.m4, intdiv0.m4, inttypes-pri.m4, lib-link.m4,
        lib-prefix.m4, longdouble.m4, po.m4, progtest.m4, signed.m4:
        Undo previous (whitespace-only) change.
 
-# exclude.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# exclude.m4 serial 2
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
 AC_DEFUN([gl_EXCLUDE],
 [
   dnl Prerequisites of lib/exclude.c.
+  AC_REQUIRE([AC_C_INLINE])
+  AC_REQUIRE([AC_HEADER_STDC])
   AC_CHECK_HEADERS_ONCE(stdlib.h string.h strings.h)
+  AC_CHECK_FUNCS_ONCE(isascii)
 ])