PERFORCE change 159137 for review
Gabor Kovesdan
gabor at FreeBSD.org
Thu Mar 12 13:54:54 PDT 2009
http://perforce.freebsd.org/chv.cgi?CH=159137
Change 159137 by gabor at gabor_server on 2009/03/12 20:54:10
- Stricter checking after stroull()
- Use libc messages through errno where possible
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#84 edit
.. //depot/projects/soc2008/gabor_textproc/grep/nls/C.msg#8 edit
.. //depot/projects/soc2008/gabor_textproc/grep/nls/es_ES.ISO8859-1.msg#1 add
.. //depot/projects/soc2008/gabor_textproc/grep/nls/hu_HU.ISO8859-2.msg#7 edit
.. //depot/projects/soc2008/gabor_textproc/grep/nls/pt_BR.ISO8859-1.msg#7 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#84 (text+ko) ====
@@ -70,11 +70,9 @@
/* 5*/ "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n",
/* 6*/ "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n",
/* 7*/ "\t[--null] [pattern] [file ...]\n",
-/* 8*/ "value out of range",
-/* 9*/ "context out of range",
+/* 8*/ "unknown --binary-files option",
+/* 9*/ "Binary file %s matches\n"
/*10*/ "%s (BSD grep) %s\n",
-/*11*/ "unknown --binary-files option",
-/*12*/ "Binary file %s matches\n"
};
/* Flags passed to regcomp() and regexec() */
@@ -375,8 +373,10 @@
case '5': case '6': case '7': case '8': case '9':
if (newarg || !isdigit(lastc))
Aflag = 0;
- else if (Aflag > LLONG_MAX / 10)
- errx(2, getstr(9));
+ else if (Aflag > LLONG_MAX / 10) {
+ errno = ERANGE;
+ err(2, NULL);
+ }
Aflag = Bflag = (Aflag * 10) + (c - '0');
break;
case 'C':
@@ -388,8 +388,13 @@
case 'A':
case 'B':
l = strtoull(optarg, &ep, 10);
- if ((errno == ERANGE) && (l == ULLONG_MAX))
- errx(2, getstr(9));
+ if (((errno == ERANGE) && (l == ULLONG_MAX)) ||
+ ((errno == EINVAL) && (l == 0)))
+ err(2, NULL);
+ else if (ep[0] != '\0') {
+ errno = EINVAL;
+ err(2, NULL);
+ }
if (c == 'A')
Aflag = l;
else if (c == 'B')
@@ -416,8 +421,10 @@
dirbehave = DIR_RECURSE;
} else if (strcmp("skip", optarg) == 0)
dirbehave = DIR_SKIP;
- else if (strcmp("read", optarg) != 0)
- errx(2, getstr(8));
+ else if (strcmp("read", optarg) != 0) {
+ errno = EINVAL;
+ err(2, NULL);
+ }
break;
case 'E':
grepbehave = GREP_EXTENDED;
@@ -464,9 +471,14 @@
break;
case 'm':
mflag++;
- mcount = strtoull(optarg, (char **)NULL, 10);
- if ((errno == ERANGE) && (mcount == ULLONG_MAX))
- err(2, getstr(8));
+ mcount = strtoull(optarg, &ep, 10);
+ if (((errno == ERANGE) && (mcount == ULLONG_MAX)) ||
+ ((errno == EINVAL) && (mcount == 0)))
+ err(2, NULL);
+ else if (ep[0] != '\0') {
+ errno = EINVAL;
+ err(2, NULL);
+ }
break;
case 'n':
nflag = 1;
==== //depot/projects/soc2008/gabor_textproc/grep/nls/C.msg#8 (text+ko) ====
@@ -9,8 +9,6 @@
5 "\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n"
6 "\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n"
7 "\t[--null] [pattern] [file ...]\n"
-8 "value out of range"
-9 "context out of range"
+8 "unknown --binary-files option"
+9 "Binary file %s matches\n"
10 "%s (BSD grep) %s\n"
-11 "unknown --binary-files option"
-12 "Binary file %s matches\n"
==== //depot/projects/soc2008/gabor_textproc/grep/nls/hu_HU.ISO8859-2.msg#7 (text+ko) ====
@@ -9,8 +9,6 @@
5 "\t[-e minta] [-f fájl] [--binary-files=érték] [--color=mikor]\n"
6 "\t[--context[=szám]] [--directories=mûvelet] [--label] [--line-buffered]\n"
7 "\t[--null] [minta] [fájl ...]\n"
-8 "az érték a megengedett tartományon kívül esik"
-9 "a kontextus a megengedett tartományon kívül esik"
+8 "ismeretlen --binary-files opció"
+9 "%s bináris fájl illeszkedik\n"
10 "%s (BSD grep) %s\n"
-11 "ismeretlen --binary-files opció"
-12 "%s bináris fájl illeszkedik\n"
==== //depot/projects/soc2008/gabor_textproc/grep/nls/pt_BR.ISO8859-1.msg#7 (text+ko) ====
@@ -9,8 +9,6 @@
5 "\t[-e padrão] [-f arquivo] [--binary-files=valor] [--color=quando]\n"
6 "\t[--context[=num]] [--directories=ação] [--label] [--line-buffered]\n"
7 "\t[--null] [padrão] [arquivo ...]\n"
-8 "el valor está fora da escala"
-9 "contexto está fora da escala"
+8 "opcão não conhecida de --binary-files"
+9 "arquivo binário %s casa com o padrão\n"
10 "%s (BSD grep) %s\n"
-11 "opcão não conhecida de --binary-files"
-12 "arquivo binário %s casa com o padrão\n"
More information about the p4-projects
mailing list