Date: Sat, 17 Jul 2010 05:14:21 GMT From: Gabor Kovesdan <gabor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 181077 for review Message-ID: <201007170514.o6H5ELeB076316@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@181077?ac=10 Change 181077 by gabor@gabor_server on 2010/07/17 05:14:09 - Small fix to fastgrep.c: check len > 0 before manipulating the array - Merge $OpenBSD$ tags even if their changes are ignored because they don't suit our implementation decisions but this reflects that the code is up-to-date Obtained from: OpenBSD - Some minor changes to directory traversal, which makes the code more readable - Use limits.h instead of sys/limits.h Obtained from: freegrep - Use switch instead of if's to make that part more readable Affected files ... .. //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#18 edit .. //depot/projects/soc2008/gabor_textproc/grep/file.c#51 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.1#16 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.c#96 edit .. //depot/projects/soc2008/gabor_textproc/grep/grep.h#54 edit .. //depot/projects/soc2008/gabor_textproc/grep/util.c#91 edit Differences ... ==== //depot/projects/soc2008/gabor_textproc/grep/fastgrep.c#18 (text+ko) ==== @@ -92,7 +92,7 @@ fg->reversed = false; /* Remove end-of-line character ('$'). */ - if (pat[fg->len - 1] == '$') { + if (fg->len > 0 && pat[fg->len - 1] == '$') { eol = true; fg->eol = true; fg->len--; ==== //depot/projects/soc2008/gabor_textproc/grep/file.c#51 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.10 2008/10/16 22:56:32 deraadt Exp $ */ +/* $OpenBSD: file.c,v 1.11 2010/07/02 20:48:48 nicm Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav ==== //depot/projects/soc2008/gabor_textproc/grep/grep.1#16 (text+ko) ==== @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.\" $OpenBSD: grep.1,v 1.36 2009/02/08 17:15:10 jmc Exp $ +.\" $OpenBSD: grep.1,v 1.38 2010/04/05 06:30:59 jmc Exp $ .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" ==== //depot/projects/soc2008/gabor_textproc/grep/grep.c#96 (text+ko) ==== @@ -1,3 +1,4 @@ +/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav * Copyright (C) 2008-2009 Gabor Kovesdan <gabor@FreeBSD.org> @@ -28,7 +29,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <sys/limits.h> #include <sys/stat.h> #include <sys/types.h> @@ -36,6 +36,7 @@ #include <err.h> #include <errno.h> #include <getopt.h> +#include <limits.h> #include <libgen.h> #include <locale.h> #include <stdbool.h> ==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#54 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.h,v 1.14 2007/09/02 15:19:32 deraadt Exp $ */ +/* $OpenBSD: grep.h,v 1.15 2010/04/05 03:03:55 tedu Exp $ */ /* $FreeBSD$ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav ==== //depot/projects/soc2008/gabor_textproc/grep/util.c#91 (text+ko) ==== @@ -1,3 +1,5 @@ +/* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */ + /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav * Copyright (C) 2008-2010 Gabor Kovesdan <gabor@FreeBSD.org> @@ -65,12 +67,17 @@ c = fts_flags = 0; - if (linkbehave == LINK_EXPLICIT) + switch(linkbehave) { + case LINK_EXPLICIT: fts_flags = FTS_COMFOLLOW; - if (linkbehave == LINK_SKIP) + break; + case LINK_SKIP: fts_flags = FTS_PHYSICAL; - else + break; + default: fts_flags = FTS_LOGICAL; + + } fts_flags |= FTS_NOSTAT | FTS_NOCHDIR; @@ -79,13 +86,13 @@ while ((p = fts_read(fts)) != NULL) { switch (p->fts_info) { case FTS_DNR: - break; + /* FALLTHROUGH */ case FTS_ERR: errx(2, "%s: %s", p->fts_path, strerror(p->fts_errno)); break; + case FTS_D: + /* FALLTHROUGH */ case FTS_DP: - /* FALLTHROUGH */ - case FTS_D: break; case FTS_DC: /* Print a warning if there is a recursive directory loop */ @@ -119,8 +126,6 @@ break; } } - if (errno) - err(2, "fts_read"); return (c); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007170514.o6H5ELeB076316>