>From 65779292d28dd3e57de147dc27db0a125d99b5ed Mon Sep 17 00:00:00 2001
From: Paul Eggert
Date: Sun, 3 Feb 2019 11:46:36 -0800
Subject: [PATCH] grep: parse --color arg independent of locale
This is a better fix for Bug#34285.
* bootstrap.conf (gnulib_modules): Add c-strcase.
* src/grep.c: Include c-strcase.h, not strings.h.
(main): Use c_strcasecmp, not strcasecmp.
---
bootstrap.conf | 1 +
src/grep.c | 17 ++++++++++-------
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index ea3eddf..d453b3e 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -28,6 +28,7 @@ announce-gen
argmatch
c-ctype
c-stack
+c-strcase
closeout
configmake
dfa
diff --git a/src/grep.c b/src/grep.c
index fcc07b8..ef6abb8 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -25,7 +25,6 @@
#include
#include
#include
-#include
#include "system.h"
#include "argmatch.h"
@@ -47,6 +46,7 @@
#include "quote.h"
#include "safe-read.h"
#include "search.h"
+#include "c-strcase.h"
#include "version-etc.h"
#include "xalloc.h"
#include "xbinary-io.h"
@@ -2698,14 +2698,17 @@ main (int argc, char **argv)
case COLOR_OPTION:
if (optarg)
{
- if (!strcasecmp (optarg, "always") || !strcasecmp (optarg, "yes")
- || !strcasecmp (optarg, "force"))
+ if (!c_strcasecmp (optarg, "always")
+ || !c_strcasecmp (optarg, "yes")
+ || !c_strcasecmp (optarg, "force"))
color_option = 1;
- else if (!strcasecmp (optarg, "never") || !strcasecmp (optarg, "no")
- || !strcasecmp (optarg, "none"))
+ else if (!c_strcasecmp (optarg, "never")
+ || !c_strcasecmp (optarg, "no")
+ || !c_strcasecmp (optarg, "none"))
color_option = 0;
- else if (!strcasecmp (optarg, "auto") || !strcasecmp (optarg, "tty")
- || !strcasecmp (optarg, "if-tty"))
+ else if (!c_strcasecmp (optarg, "auto")
+ || !c_strcasecmp (optarg, "tty")
+ || !c_strcasecmp (optarg, "if-tty"))
color_option = 2;
else
show_help = 1;
--
2.17.1