]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Special hack for SunOS4 grep.
authorBruno Haible <bruno@clisp.org>
Tue, 22 Jan 2002 20:42:10 +0000 (20:42 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Jun 2009 23:06:33 +0000 (01:06 +0200)
src/ChangeLog
src/msggrep.c

index c5c5f9ceea1bba6478eea8a0e461d5933d43a5d2..0e0ddaf715152fa23025cf9c481b3f1a2997ad19 100644 (file)
@@ -1,3 +1,7 @@
+2002-01-21  Bruno Haible  <bruno@clisp.org>
+
+       * msggrep.c (main): On SunOS4, don't pass option "-q" to grep.
+
 2002-01-19  Bruno Haible  <bruno@clisp.org>
 
        * msgfmt.c (check_header_entry): Emit error messages including the
index 661269ff22cb0ce697a238cb3da7ad77f91652cf..ad338b8ee21930cfa2266e4bd1d14275a750246e 100644 (file)
@@ -134,7 +134,6 @@ main (argc, argv)
   msgdomain_list_ty *result;
   bool sort_by_filepos = false;
   bool sort_by_msgid = false;
-  size_t i;
 
   /* Set program name for messages.  */
   set_program_name (argv[0]);
@@ -328,14 +327,28 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
     if (grep_args[grep_pass]->nitems > 0)
       {
        string_list_ty *args = grep_args[grep_pass];
+       size_t option_q;
+       size_t i, j;
+
+       /* We use "grep -q" because it is slightly more efficient than
+          "grep".  We pipe grep's output to /dev/null anyway.  But
+          SunOS4's grep program doesn't understand the -q option.  */
+#if (defined (sun) || defined (__sun)) && !defined (__SVR4)
+       option_q = 0;
+#else
+       option_q = 1;
+#endif
 
        grep_argv[grep_pass] =
-         (char **) xmalloc ((2 + args->nitems + 1) * sizeof (char *));
+         (char **) xmalloc ((1 + option_q + args->nitems + 1)
+                            * sizeof (char *));
        grep_argv[grep_pass][0] = (char *) grep_path;
-       grep_argv[grep_pass][1] = "-q";
-       for (i = 2; i <= args->nitems + 1; i++)
-         grep_argv[grep_pass][i] = (char *) args->item[i - 2];
-       grep_argv[grep_pass][i] = NULL;
+       j = 1;
+       if (option_q)
+         grep_argv[grep_pass][j++] = "-q";
+       for (i = 0; i < args->nitems; i++)
+         grep_argv[grep_pass][j++] = (char *) args->item[i];
+       grep_argv[grep_pass][j] = NULL;
       }
 
   /* Select the messages.  */