PERFORCE change 159879 for review
Gabor Kovesdan
gabor at FreeBSD.org
Thu Mar 26 15:46:01 PDT 2009
http://perforce.freebsd.org/chv.cgi?CH=159879
Change 159879 by gabor at gabor_server on 2009/03/26 22:45:13
- C99ify bool variables
Affected files ...
.. //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#12 edit
.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#87 edit
.. //depot/projects/soc2008/gabor_textproc/grep/grep.h#48 edit
Differences ...
==== //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#12 (text+ko) ====
@@ -41,6 +41,7 @@
#endif /* not lint */
#include <limits.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
@@ -111,7 +112,7 @@
strncmp(pattern + fg->bol + fg->len - 7, "[[:>:]]", 7) == 0) {
fg->len -= 14;
/* Word boundary is handled separately in util.c */
- wflag = 1;
+ wflag = true;
}
/*
==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#87 (text+ko) ====
@@ -45,6 +45,7 @@
#include <getopt.h>
#include <libgen.h>
#include <locale.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -98,25 +99,25 @@
/* Command-line flags */
unsigned long long Aflag; /* -A x: print x lines trailing each match */
unsigned long long Bflag; /* -B x: print x lines leading each match */
-int Hflag; /* -H: always print file name */
-int Lflag; /* -L: only show names of files with no matches */
-int bflag; /* -b: show block numbers for each match */
-int cflag; /* -c: only show a count of matching lines */
-int hflag; /* -h: don't print filename headers */
-int iflag; /* -i: ignore case */
-int lflag; /* -l: only show names of files with matches */
-int mflag; /* -m x: stop reading the files after x matches */
+bool Hflag; /* -H: always print file name */
+bool Lflag; /* -L: only show names of files with no matches */
+bool bflag; /* -b: show block numbers for each match */
+bool cflag; /* -c: only show a count of matching lines */
+bool hflag; /* -h: don't print filename headers */
+bool iflag; /* -i: ignore case */
+bool lflag; /* -l: only show names of files with matches */
+bool mflag; /* -m x: stop reading the files after x matches */
unsigned long long mcount; /* count for -m */
-int nflag; /* -n: show line numbers in front of matching lines */
-int oflag; /* -o: print only matching part */
-int qflag; /* -q: quiet mode (don't output anything) */
-int sflag; /* -s: silent mode (ignore errors) */
-int vflag; /* -v: only show non-matching lines */
-int wflag; /* -w: pattern must start and end on word boundaries */
-int xflag; /* -x: pattern must match entire line */
-int lbflag; /* --line-buffered */
-int nullflag; /* --null */
-int exclflag; /* --exclude */
+bool nflag; /* -n: show line numbers in front of matching lines */
+bool oflag; /* -o: print only matching part */
+bool qflag; /* -q: quiet mode (don't output anything) */
+bool sflag; /* -s: silent mode (ignore errors) */
+bool vflag; /* -v: only show non-matching lines */
+bool wflag; /* -w: pattern must start and end on word boundaries */
+bool xflag; /* -x: pattern must match entire line */
+bool lbflag; /* --line-buffered */
+bool nullflag; /* --null */
+bool exclflag; /* --exclude */
char *label; /* --label */
char *color; /* --color */
int grepbehave = GREP_BASIC; /* -EFGP: type of the regex */
@@ -406,10 +407,10 @@
binbehave = BINFILE_TEXT;
break;
case 'b':
- bflag = 1;
+ bflag = true;
break;
case 'c':
- cflag = 1;
+ cflag = true;
break;
case 'D':
if (strcmp(optarg, "skip") == 0)
@@ -417,7 +418,7 @@
break;
case 'd':
if (strcmp("recurse", optarg) == 0) {
- Hflag++;
+ Hflag = true;
dirbehave = DIR_RECURSE;
} else if (strcmp("skip", optarg) == 0)
dirbehave = DIR_SKIP;
@@ -444,33 +445,33 @@
grepbehave = GREP_BASIC;
break;
case 'H':
- Hflag++;
+ Hflag = true;
break;
case 'h':
- Hflag = 0;
- hflag = 1;
+ Hflag = false;
+ hflag = true;
break;
case 'I':
binbehave = BINFILE_SKIP;
break;
case 'i':
case 'y':
- iflag = 1;
+ iflag = true;
cflags |= REG_ICASE;
break;
case 'J':
filebehave = FILE_BZIP;
break;
case 'L':
- lflag = 0;
- Lflag = qflag = 1;
+ lflag = false;
+ Lflag = qflag = true;
break;
case 'l':
- Lflag = 0;
- lflag = qflag = 1;
+ Lflag = false;
+ lflag = qflag = true;
break;
case 'm':
- mflag++;
+ mflag = true;
mcount = strtoull(optarg, &ep, 10);
if (((errno == ERANGE) && (mcount == ULLONG_MAX)) ||
((errno == EINVAL) && (mcount == 0)))
@@ -481,19 +482,19 @@
}
break;
case 'n':
- nflag = 1;
+ nflag = true;
break;
case 'O':
linkbehave = LINK_EXPLICIT;
break;
case 'o':
- oflag++;
+ oflag = true;
break;
case 'p':
linkbehave = LINK_SKIP;
break;
case 'q':
- qflag = 1;
+ qflag = true;
break;
case 'S':
linkbehave = LINK_GREP;
@@ -501,10 +502,10 @@
case 'R':
case 'r':
dirbehave = DIR_RECURSE;
- Hflag++;
+ Hflag = true;
break;
case 's':
- sflag = 1;
+ sflag = true;
break;
case 'U':
binbehave = BINFILE_BIN;
@@ -517,13 +518,13 @@
printf(getstr(10), __progname, VERSION);
exit(0);
case 'v':
- vflag = 1;
+ vflag = true;
break;
case 'w':
- wflag = 1;
+ wflag = true;
break;
case 'x':
- xflag = 1;
+ xflag = true;
break;
case 'Z':
filebehave = FILE_GZIP;
@@ -554,25 +555,25 @@
label = optarg;
break;
case LINEBUF_OPT:
- lbflag = 1;
+ lbflag = true;
break;
case NULL_OPT:
- nullflag = 1;
+ nullflag = true;
break;
case R_INCLUDE_OPT:
- exclflag = 1;
+ exclflag = true;
add_epattern(basename(optarg), strlen(basename(optarg)), FILE_PAT, INCL_PAT);
break;
case R_EXCLUDE_OPT:
- exclflag = 1;
+ exclflag = true;
add_epattern(basename(optarg), strlen(basename(optarg)), FILE_PAT, EXCL_PAT);
break;
case R_DINCLUDE_OPT:
- exclflag = 1;
+ exclflag = true;
add_epattern(basename(optarg), strlen(basename(optarg)), DIR_PAT, INCL_PAT);
break;
case R_DEXCLUDE_OPT:
- exclflag = 1;
+ exclflag = true;
add_epattern(basename(optarg), strlen(basename(optarg)), DIR_PAT, EXCL_PAT);
break;
case HELP_OPT:
@@ -636,7 +637,7 @@
setlinebuf(stdout);
if ((aargc == 0 || aargc == 1) && !Hflag)
- hflag = 1;
+ hflag = true;
if (aargc == 0)
exit(!procfile("-"));
==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#48 (text+ko) ====
@@ -30,6 +30,7 @@
#include <bzlib.h>
#include <limits.h>
#include <regex.h>
+#include <stdbool.h>
#include <stdio.h>
#include <zlib.h>
@@ -113,10 +114,10 @@
extern int cflags, eflags;
/* Command line flags */
-extern int Eflag, Fflag, Gflag, Hflag, Lflag,
+extern bool Eflag, Fflag, Gflag, Hflag, Lflag,
bflag, cflag, hflag, iflag, lflag, mflag, nflag, oflag,
qflag, sflag, vflag, wflag, xflag;
-extern int nullflag, exclflag;
+extern bool nullflag, exclflag;
extern unsigned long long Aflag, Bflag, mcount;
extern char *color, *label;
extern int grepbehave, binbehave, filebehave, devbehave, dirbehave, linkbehave;
More information about the p4-projects
mailing list