Submitted By: Joe Ciccone Date: 2010-08-03 Initial Package Version: 2.6.3 Upstream Status: Unknown Origin: http://ftp.de.debian.org/debian/pool/main/g/grep/grep_2.6.3-3.debian.tar.bz2 Description: Various fixes from debian for Grep diff -Naur grep-2.6.3.orig/NEWS grep-2.6.3/NEWS --- grep-2.6.3.orig/NEWS 2010-04-02 04:55:33.000000000 -0400 +++ grep-2.6.3/NEWS 2010-08-03 22:11:08.142326516 -0400 @@ -1,5 +1,8 @@ GNU grep NEWS -*- outline -*- + --mmap was meant to be ignored in 2.6.x, but it was instead + removed by mistake. [bug introduced in 2.6] + * Noteworthy changes in release 2.6.3 (2010-04-02) [stable] ** Bug fixes diff -Naur grep-2.6.3.orig/configure grep-2.6.3/configure --- grep-2.6.3.orig/configure 2010-04-02 04:56:49.000000000 -0400 +++ grep-2.6.3/configure 2010-08-03 22:11:08.137850711 -0400 @@ -24372,13 +24372,14 @@ if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" test "$ac_cv_search_pcre_compile" = "none required" || - LIB_PCRE=$ac_cv_search_pcre_compile + LIB="-ldl $LIBS" fi for ac_func in pcre_compile do : ac_fn_c_check_func "$LINENO" "pcre_compile" "ac_cv_func_pcre_compile" if test "x$ac_cv_func_pcre_compile" = x""yes; then : + CPPFLAGS="$CPPFLAGS -DHAVE_DYNAMIC_LIBPCRE" cat >>confdefs.h <<_ACEOF #define HAVE_PCRE_COMPILE 1 _ACEOF diff -Naur grep-2.6.3.orig/doc/grep.in.1 grep-2.6.3/doc/grep.in.1 --- grep-2.6.3.orig/doc/grep.in.1 2010-04-01 04:15:35.000000000 -0400 +++ grep-2.6.3/doc/grep.in.1 2010-08-03 22:11:08.137850711 -0400 @@ -25,7 +25,7 @@ .hy 0 . .SH NAME -grep, egrep, fgrep \- print lines matching a pattern +grep, egrep, fgrep, rgrep \- print lines matching a pattern . .SH SYNOPSIS .B grep @@ -56,10 +56,11 @@ .B grep prints the matching lines. .PP -In addition, two variant programs -.B egrep -and +In addition, three variant programs +.B egrep, .B fgrep +and +.B rgrep are available. .B egrep is the same as @@ -67,6 +68,9 @@ .B fgrep is the same as .BR "grep\ \-F" . +.B rgrep +is the same as +.BR "grep\ \-r" . Direct invocation as either .B egrep or @@ -825,7 +829,7 @@ is not special if it would be the start of an invalid interval specification. For example, the command -.B "grep\ \-E\ '{1'" +.B "grep\ \-E\ \(aq{1\(aq" searches for the two-character string .B {1 instead of reporting a syntax error in the regular expression. @@ -865,7 +869,7 @@ For example, if .B GREP_OPTIONS is -.BR "'\-\^\-binary-files=without-match \-\^\-directories=skip'" , +.BR "\(aq\-\^\-binary-files=without-match \-\^\-directories=skip\(aq" , .B grep behaves as if the two options .B \-\^\-binary\-files=without-match @@ -1160,23 +1164,9 @@ is not set. . .SH "EXIT STATUS" -Normally, the exit status is 0 if selected lines are found and 1 otherwise. -But the exit status is 2 if an error occurred, unless the -.B \-q -or -.B \-\^\-quiet -or -.B \-\^\-silent -option is used and a selected line is found. -Note, however, that \s-1POSIX\s0 only mandates, for programs such as -.BR grep , -.BR cmp , -and -.BR diff , -that the exit status in case of error be greater than 1; -it is therefore advisable, for the sake of portability, -to use logic that tests for this general condition -instead of strict equality with\ 2. +The exit status is 0 if selected lines are found, and 1 if not found. +If an error occurred the exit status is 2. (Note: POSIX error +handling code should check for '2' or greater.) . .SH COPYRIGHT Copyright 1998-2000, 2002, 2005-2010 Free Software Foundation, Inc. diff -Naur grep-2.6.3.orig/po/ca.po grep-2.6.3/po/ca.po --- grep-2.6.3.orig/po/ca.po 2010-04-02 04:57:08.000000000 -0400 +++ grep-2.6.3/po/ca.po 2010-08-03 22:11:08.137850711 -0400 @@ -278,7 +278,7 @@ #: src/main.c:1165 #, c-format msgid "Binary file %s matches\n" -msgstr "Concidència en el fitxer binari %s\n" +msgstr "Coincidència en el fitxer binari %s\n" #: src/main.c:1179 msgid "(standard input)" diff -Naur grep-2.6.3.orig/src/kwset.c grep-2.6.3/src/kwset.c --- grep-2.6.3.orig/src/kwset.c 2010-04-01 04:15:35.000000000 -0400 +++ grep-2.6.3/src/kwset.c 2010-08-03 22:11:08.142326516 -0400 @@ -40,7 +40,7 @@ #ifdef GREP # include "xalloc.h" # undef malloc -# define malloc(s) xmalloc(s) +# define malloc xmalloc #endif #define NCHAR (UCHAR_MAX + 1) diff -Naur grep-2.6.3.orig/src/main.c grep-2.6.3/src/main.c --- grep-2.6.3.orig/src/main.c 2010-04-01 12:52:10.000000000 -0400 +++ grep-2.6.3/src/main.c 2010-08-03 22:11:08.142326516 -0400 @@ -266,6 +266,12 @@ static char const short_options[] = "0123456789A:B:C:D:EFGHIPTUVX:abcd:e:f:hiKLlm:noqRrsuvwxyZz"; +/* Default for `file_list' if no files are given on the command line. */ +static char *stdin_argv[] = +{ + "-", NULL +}; + /* Non-boolean long options that have no corresponding short equivalents. */ enum { @@ -511,7 +517,16 @@ for byte sentinels fore and aft. */ newalloc = newsize + pagesize + 1; - newbuf = bufalloc < newalloc ? xmalloc (bufalloc = newalloc) : buffer; + newbuf = bufalloc < newalloc ? malloc (bufalloc = newalloc) : buffer; + if (newbuf == NULL) + { + int saved_errno = errno; + free (buffer); + bufalloc = ALIGN_TO (INITIAL_BUFSIZE, pagesize) + pagesize + 1; + buffer = xmalloc (bufalloc); + errno = saved_errno; + return 0; + } readbuf = ALIGN_TO (newbuf + 1 + save, pagesize); bufbeg = readbuf - save; memmove (bufbeg, buffer + saved_offset, save); @@ -1739,6 +1754,7 @@ int opt, cc, status; int default_context; FILE *fp; + char **file_list; initialize_main (&argc, &argv); set_program_name (argv[0]); @@ -2061,6 +2077,7 @@ label = optarg; break; + case MMAP_OPTION: case 0: /* long options */ break; @@ -2154,29 +2171,29 @@ if (max_count == 0) exit (EXIT_FAILURE); - if (optind < argc) + file_list = (optind == argc ? stdin_argv : &argv[optind]); + + status = 1; + while (1) { - status = 1; - do - { - char *file = argv[optind]; - if ((included_patterns || excluded_patterns) - && !isdir (file)) - { - if (included_patterns && - ! excluded_file_name (included_patterns, file)) - continue; - if (excluded_patterns && - excluded_file_name (excluded_patterns, file)) - continue; - } - status &= grepfile (strcmp (file, "-") == 0 ? (char *) NULL : file, - &stats_base); - } - while ( ++optind < argc); + char *file = *file_list++; + + if (file == NULL) + break; + + if ((included_patterns || excluded_patterns) + && !isdir (file)) + { + if (included_patterns && + ! excluded_file_name (included_patterns, file)) + continue; + if (excluded_patterns && + excluded_file_name (excluded_patterns, file)) + continue; + } + status &= grepfile (strcmp (file, "-") == 0 + ? (char *) NULL : file, &stats_base); } - else - status = grepfile ((char *) NULL, &stats_base); /* We register via atexit() to test stdout. */ exit (errseen ? EXIT_TROUBLE : status); diff -Naur grep-2.6.3.orig/src/pcresearch.c grep-2.6.3/src/pcresearch.c --- grep-2.6.3.orig/src/pcresearch.c 2010-04-01 04:15:35.000000000 -0400 +++ grep-2.6.3/src/pcresearch.c 2010-08-03 22:11:08.137850711 -0400 @@ -22,8 +22,14 @@ #include "search.h" #if HAVE_PCRE_H # include +# ifdef HAVE_DYNAMIC_LIBPCRE +# include +# endif #elif HAVE_PCRE_PCRE_H # include +# ifdef HAVE_DYNAMIC_LIBPCRE +# include +# endif #endif #if HAVE_LIBPCRE @@ -34,6 +40,50 @@ static pcre_extra *extra; #endif +#ifdef HAVE_DYNAMIC_LIBPCRE + +# define pcre_compile dl_pcre_compile +# define pcre_study dl_pcre_study +# define pcre_exec dl_pcre_exec +# define pcre_maketables dl_pcre_maketables + +static pcre *(*pcre_compile)(const char *pattern, int options, +const char **errptr, int *erroffset, + const unsigned char *tableptr); +static pcre_extra *(*pcre_study)(const pcre *code, int options, + const char **errptr); +static int (*pcre_exec)(const pcre *code, const pcre_extra *extra, + const char *subject, int length, int startoffset, + int options, int *ovector, int ovecsize); +static const unsigned char *(*pcre_maketables)(void); + +static int +map_pcre(void) +{ + void *library; + + if (pcre_maketables) + return 1; + + if (!(library = dlopen("libpcre.so.3", RTLD_NOW))) + return 0; + + if (!(pcre_compile = dlsym(library, "pcre_compile"))) + return 0; + if (!(pcre_study = dlsym(library, "pcre_study"))) + return 0; + if (!(pcre_exec = dlsym(library, "pcre_exec"))) + return 0; + if (!(pcre_maketables = dlsym(library, "pcre_maketables"))) + return 0; + + return 1; +} + +#else +#define map_pcre() (1) +#endif /* HAVE_DYNAMIC_LIBPCRE */ + void Pcompile (char const *pattern, size_t size) { @@ -51,6 +101,10 @@ char const *p; char const *pnul; + if (!map_pcre ()) + error (EXIT_TROUBLE, 0, "%s", + _("The -P option is not supported: libpcre.so.3 is not available")); + /* FIXME: Remove these restrictions. */ if (memchr(pattern, '\n', size)) error (EXIT_TROUBLE, 0, _("the -P option only supports a single pattern"));