Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 2009 15:55:21 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 163496 for review
Message-ID:  <200906041555.n54FtLJJ095672@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=163496

Change 163496 by gabor@gabor_server on 2009/06/04 15:54:54

	- More C99 bool values

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#15 edit
.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#89 edit
.. //depot/projects/soc2008/gabor_textproc/grep/grep.h#52 edit
.. //depot/projects/soc2008/gabor_textproc/grep/util.c#84 edit

Differences ...

==== //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#15 (text+ko) ====

@@ -59,9 +59,9 @@
 
 	/* Initialize. */
 	fg->len = strlen(pat);
-	fg->bol = 0;
-	fg->eol = 0;
-	fg->reversed = 0;
+	fg->bol = false;
+	fg->eol = false;
+	fg->reversed = false;
 
 	fg->pattern = grep_malloc(strlen(pat) + 1);
 	strcpy(fg->pattern, pat);
@@ -80,8 +80,8 @@
 fastcomp(fastgrep_t *fg, const char *pat)
 {
 	unsigned int	 i;
-	int	 bol = 0;
-	int	 eol = 0;
+	bool	 bol = false;
+	bool	 eol = false;
 	int	 shiftPatternLen;
 	int	 hasDot = 0;
 	int	 firstHalfDot = -1;
@@ -90,27 +90,27 @@
 
 	/* Initialize. */
 	fg->len = strlen(pat);
-	fg->bol = 0;
-	fg->eol = 0;
-	fg->reversed = 0;
+	fg->bol = false;
+	fg->eol = false;
+	fg->reversed = false;
 
 	/* Remove end-of-line character ('$'). */
 	if (pat[fg->len - 1] == '$') {
-		eol++;
-		fg->eol = 1;
+		eol = true;
+		fg->eol = true;
 		fg->len--;
 	}
 
 	/* Remove beginning-of-line character ('^'). */
 	if (pat[0] == '^') {
-		bol++;
-		fg->bol = 1;
+		bol = true;
+		fg->bol = true;
 		fg->len--;
 	}
 
 	if (fg->len >= 14 &&
-	    strncmp(pat + fg->bol, "[[:<:]]", 7) == 0 &&
-	    strncmp(pat + fg->bol + fg->len - 7, "[[:>:]]", 7) == 0) {
+	    strncmp(pat + (fg->bol ? 1 : 0), "[[:<:]]", 7) == 0 &&
+	    strncmp(pat + (fg->bol ? 1 : 0) + fg->len - 7, "[[:>:]]", 7) == 0) {
 		fg->len -= 14;
 		/* Word boundary is handled separately in util.c */
 		wflag = true;
@@ -122,7 +122,7 @@
 	 * string respectively.
 	 */
 	fg->pattern = grep_malloc(fg->len + 1);
-	memcpy(fg->pattern, pat + bol + wflag, fg->len);
+	memcpy(fg->pattern, pat + (bol ? 1 : 0) + wflag, fg->len);
 	fg->pattern[fg->len] = '\0';
 
 	/* Look for ways to cheat...er...avoid the full regex engine. */
@@ -156,7 +156,7 @@
 	if ((!(lflag || cflag)) && ((!(bol || eol)) &&
 	    ((lastHalfDot) && ((firstHalfDot < 0) ||
 	    ((fg->len - (lastHalfDot + 1)) < (size_t)firstHalfDot)))) && !oflag && !color) {
-		fg->reversed = 1;
+		fg->reversed = true;
 		hasDot = fg->len - (firstHalfDot < 0 ?
 		    firstLastHalfDot : firstHalfDot) - 1;
 		grep_revstr(fg->pattern, fg->len);

==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#89 (text+ko) ====

@@ -81,7 +81,7 @@
 int		 eflags = REG_STARTEND;
 
 /* Shortcut for matching all cases like empty regex */
-int		 matchall;
+bool		 matchall;
 
 /* Searching patterns */
 unsigned int	 patterns, pattern_sz;
@@ -142,10 +142,10 @@
 };
 
 /* Housekeeping */
-int	 first = 1;	/* flag whether we are processing the first match */
-int	 prev;		/* flag whether or not the previous line matched */
+bool	 first = true;	/* flag whether we are processing the first match */
+bool	 prev;		/* flag whether or not the previous line matched */
 int	 tail;		/* lines left to print */
-int	 notfound;	/* file not found */
+bool	 notfound;	/* file not found */
 
 extern char	*__progname;
 
@@ -224,7 +224,7 @@
 
 	/* Check if we can do a shortcut */
 	if (len == 0 || matchall) {
-		matchall = 1;
+		matchall = true;
 		return;
 	}
 	/* Increase size if necessary */

==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#52 (text+ko) ====

@@ -105,9 +105,9 @@
 	size_t		 len;
 	int		 qsBc[UCHAR_MAX + 1];
 	/* flags */
-	int		 bol;
-	int		 eol;
-	int		 reversed;
+	bool		 bol;
+	bool		 eol;
+	bool		 reversed;
 } fastgrep_t;
 
 /* Flags passed to regcomp() and regexec() */
@@ -122,7 +122,8 @@
 extern char	*color, *label;
 extern int	 grepbehave, binbehave, filebehave, devbehave, dirbehave, linkbehave;
 
-extern int	 first, prev, matchall, tail, notfound;
+extern bool	 matchall, first, prev, notfound;
+extern int	 tail;
 extern unsigned int patterns, epatterns;
 extern char    **pattern;
 extern struct epat *epattern;

==== //depot/projects/soc2008/gabor_textproc/grep/util.c#84 (text+ko) ====

@@ -176,7 +176,7 @@
 		if (!sflag)
 			warn("%s", fn);
 		if (errno == ENOENT)
-			notfound++;
+			notfound = true;
 		return (0);
 	}
 
@@ -348,10 +348,10 @@
 	}
 
 	if (c) {
-		prev++;
-		first = 0;
+		prev = true;
+		first = false;
 	} else
-		prev = 0;
+		prev = false;
 
 	return (c);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906041555.n54FtLJJ095672>