2009-01-23 Bruno Haible * lib/posix/regex.h (__restrict, __restrict_arr): Remove macros. (_Restrict_, _Restrict_arr_): New macros. From gnulib/lib/regex.h. (regcomp, regexec): Update declarations to use them. * lib/savedir.c (isdir): New declaration. * src/dfa.c (update_mb_len_index): Change argument type to 'char const *'. (match_mb_charset): Cast argument to strncpy. (dfaexec): Add pointer cast. * src/grep.c (parse_grep_colors): Add braces for disambiguation. * src/kwset.c: Include xalloc.h instead of declaring xmalloc manually. diff -r -c3 grep-2.5.4-20090122.bak/lib/posix/regex.h grep-2.5.4-20090122/lib/posix/regex.h *** grep-2.5.4-20090122.bak/lib/posix/regex.h 2007-06-28 21:10:45.000000000 +0200 --- grep-2.5.4-20090122/lib/posix/regex.h 2009-01-23 11:38:42.000000000 +0100 *************** *** 1,6 **** /* Definitions for data structures and routines for the regular expression library, version 0.12. ! Copyright (C) 1985,1989-1993,1995-1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. --- 1,7 ---- /* Definitions for data structures and routines for the regular expression library, version 0.12. ! Copyright (C) 1985,1989-1993,1995-1998, 2000, 2006, 2007, 2009 ! Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. *************** *** 520,548 **** #endif /* GCC 2.95 and later have "__restrict"; C99 compilers have ! "restrict", and "configure" may have defined "restrict". */ ! #ifndef __restrict ! # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) ! # if defined restrict || 199901L <= __STDC_VERSION__ ! # define __restrict restrict ! # else ! # define __restrict ! # endif # endif #endif - /* For now unconditionally define __restrict_arr to expand to nothing. - Ideally we would have a test for the compiler which allows defining - it to restrict. */ - #define __restrict_arr /* POSIX compatibility. */ ! extern int regcomp _RE_ARGS ((regex_t *__restrict __preg, ! const char *__restrict __pattern, int __cflags)); ! extern int regexec _RE_ARGS ((const regex_t *__restrict __preg, ! const char *__restrict __string, size_t __nmatch, ! regmatch_t __pmatch[__restrict_arr], int __eflags)); extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg, --- 521,561 ---- #endif /* GCC 2.95 and later have "__restrict"; C99 compilers have ! "restrict", and "configure" may have defined "restrict". ! Other compilers use __restrict, __restrict__, and _Restrict, and ! 'configure' might #define 'restrict' to those words, so pick a ! different name. */ ! #ifndef _Restrict_ ! # if 199901L <= __STDC_VERSION__ ! # define _Restrict_ restrict ! # elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__) ! # define _Restrict_ __restrict ! # else ! # define _Restrict_ ! # endif ! #endif ! /* gcc 3.1 and up support the [restrict] syntax. Don't trust ! sys/cdefs.h's definition of __restrict_arr, though, as it ! mishandles gcc -ansi -pedantic. */ ! #ifndef _Restrict_arr_ ! # if ((199901L <= __STDC_VERSION__ \ ! || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ ! && !__STRICT_ANSI__)) \ ! && !defined __GNUG__) ! # define _Restrict_arr_ _Restrict_ ! # else ! # define _Restrict_arr_ # endif #endif /* POSIX compatibility. */ ! extern int regcomp _RE_ARGS ((regex_t *_Restrict_ __preg, ! const char *_Restrict_ __pattern, int __cflags)); ! extern int regexec _RE_ARGS ((const regex_t *_Restrict_ __preg, ! const char *_Restrict_ __string, size_t __nmatch, ! regmatch_t __pmatch[_Restrict_arr_], int __eflags)); extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg, diff -r -c3 grep-2.5.4-20090122.bak/lib/savedir.c grep-2.5.4-20090122/lib/savedir.c *** grep-2.5.4-20090122.bak/lib/savedir.c 2007-06-28 21:10:45.000000000 +0200 --- grep-2.5.4-20090122/lib/savedir.c 2009-01-23 11:28:49.000000000 +0100 *************** *** 1,5 **** /* savedir.c -- save the list of files in a directory in a string ! Copyright (C) 1990, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by --- 1,5 ---- /* savedir.c -- save the list of files in a directory in a string ! Copyright (C) 1990, 1997, 1998, 1999, 2000, 2001, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by *************** *** 69,74 **** --- 69,76 ---- #include #include "savedir.h" + extern int isdir (const char *path); + char *path; size_t pathlen; diff -r -c3 grep-2.5.4-20090122.bak/src/dfa.c grep-2.5.4-20090122/src/dfa.c *** grep-2.5.4-20090122.bak/src/dfa.c 2008-02-10 04:16:10.000000000 +0100 --- grep-2.5.4-20090122/src/dfa.c 2009-01-23 11:35:22.000000000 +0100 *************** *** 1,5 **** /* dfa.c - deterministic extended regexp routines for GNU ! Copyright 1988, 1998, 2000, 2002, 2004, 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify --- 1,5 ---- /* dfa.c - deterministic extended regexp routines for GNU ! Copyright 1988, 1998, 2000, 2002, 2004, 2008, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify *************** *** 414,420 **** /* This function update cur_mb_len, and cur_mb_index. p points current lexptr, len is the remaining buffer length. */ static void ! update_mb_len_index (unsigned char const *p, int len) { /* If last character is a part of a multibyte character, we update cur_mb_index. */ --- 414,420 ---- /* This function update cur_mb_len, and cur_mb_index. p points current lexptr, len is the remaining buffer length. */ static void ! update_mb_len_index (char const *p, int len) { /* If last character is a part of a multibyte character, we update cur_mb_index. */ *************** *** 2558,2571 **** goto charset_matched; } ! strncpy(buffer, buf_begin + index, match_len); buffer[match_len] = '\0'; /* match with an equivalent class? */ for (i = 0; inequivs; i++) { op_len = strlen(work_mbc->equivs[i]); ! strncpy(buffer, buf_begin + index, op_len); buffer[op_len] = '\0'; if (strcoll(work_mbc->equivs[i], buffer) == 0) { --- 2558,2571 ---- goto charset_matched; } ! strncpy(buffer, (char const *) (buf_begin + index), match_len); buffer[match_len] = '\0'; /* match with an equivalent class? */ for (i = 0; inequivs; i++) { op_len = strlen(work_mbc->equivs[i]); ! strncpy(buffer, (char const *) (buf_begin + index), op_len); buffer[op_len] = '\0'; if (strcoll(work_mbc->equivs[i], buffer) == 0) { *************** *** 2578,2584 **** for (i = 0; incoll_elems; i++) { op_len = strlen(work_mbc->coll_elems[i]); ! strncpy(buffer, buf_begin + index, op_len); buffer[op_len] = '\0'; if (strcoll(work_mbc->coll_elems[i], buffer) == 0) --- 2578,2584 ---- for (i = 0; incoll_elems; i++) { op_len = strlen(work_mbc->coll_elems[i]); ! strncpy(buffer, (char const *) (buf_begin + index), op_len); buffer[op_len] = '\0'; if (strcoll(work_mbc->coll_elems[i], buffer) == 0) *************** *** 2831,2837 **** if (MB_CUR_MAX > 1) { int remain_bytes, i; ! buf_begin = begin; buf_end = end; /* initialize mblen_buf, and inputwcs. */ --- 2831,2837 ---- if (MB_CUR_MAX > 1) { int remain_bytes, i; ! buf_begin = (unsigned char const *) begin; buf_end = end; /* initialize mblen_buf, and inputwcs. */ diff -r -c3 grep-2.5.4-20090122.bak/src/grep.c grep-2.5.4-20090122/src/grep.c *** grep-2.5.4-20090122.bak/src/grep.c 2009-01-21 04:06:27.000000000 +0100 --- grep-2.5.4-20090122/src/grep.c 2009-01-23 11:30:05.000000000 +0100 *************** *** 1707,1724 **** break; /* If name unknown, go on for forward compatibility. */ if (cap->name) ! if (cap->var) ! { ! if (val) ! *(cap->var) = val; ! else ! error(0, 0, _("In GREP_COLORS=\"%s\", the \"%s\" capacity " ! "needs a value (\"=...\"); skipped."), p, name); ! } ! else if (val) ! error(0, 0, _("In GREP_COLORS=\"%s\", the \"%s\" capacity " ! "is boolean and cannot take a value (\"=%s\"); " ! "skipped."), p, name, val); if (cap->fct) { const char *err_str = cap->fct(); --- 1707,1727 ---- break; /* If name unknown, go on for forward compatibility. */ if (cap->name) ! { ! if (cap->var) ! { ! if (val) ! *(cap->var) = val; ! else ! error(0, 0, _("In GREP_COLORS=\"%s\", the \"%s\" capacity " ! "needs a value (\"=...\"); skipped."), ! p, name); ! } ! else if (val) ! error(0, 0, _("In GREP_COLORS=\"%s\", the \"%s\" capacity " ! "is boolean and cannot take a value (\"=%s\"); " ! "skipped."), p, name, val); ! } if (cap->fct) { const char *err_str = cap->fct(); diff -r -c3 grep-2.5.4-20090122.bak/src/kwset.c grep-2.5.4-20090122/src/kwset.c *** grep-2.5.4-20090122.bak/src/kwset.c 2007-06-28 21:10:46.000000000 +0200 --- grep-2.5.4-20090122/src/kwset.c 2009-01-23 11:33:03.000000000 +0100 *************** *** 1,5 **** /* kwset.c - search for any of a set of keywords. ! Copyright 1989, 1998, 2000, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by --- 1,5 ---- /* kwset.c - search for any of a set of keywords. ! Copyright 1989, 1998, 2000, 2005, 2009 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by *************** *** 37,43 **** #include "obstack.h" #ifdef GREP ! extern char *xmalloc(); # undef malloc # define malloc xmalloc #endif --- 37,43 ---- #include "obstack.h" #ifdef GREP ! # include "xalloc.h" # undef malloc # define malloc xmalloc #endif