[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/9] grep: remove one #ifdef
From: |
Paolo Bonzini |
Subject: |
[PATCH 6/9] grep: remove one #ifdef |
Date: |
Fri, 19 Mar 2010 12:36:49 +0100 |
* search.c (GEAcompile) [EGREP_PROGRAM]: Use common code. Inline IF_BK.
---
src/search.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/src/search.c b/src/search.c
index fece394..7b601e0 100644
--- a/src/search.c
+++ b/src/search.c
@@ -315,26 +315,20 @@ GEAcompile (char const *pattern, size_t size,
reg_syntax_t syntax_bits)
static char const line_end_no_bk[] = ")$";
static char const word_beg_no_bk[] = "(^|[^[:alnum:]_])(";
static char const word_end_no_bk[] = ")([^[:alnum:]_]|$)";
-#ifdef EGREP_PROGRAM
-# define IF_BK(x, y) (y)
- char *n = xmalloc (sizeof word_beg_no_bk - 1 + size + sizeof
word_end_no_bk);
-#else
static char const line_beg_bk[] = "^\\(";
static char const line_end_bk[] = "\\)$";
static char const word_beg_bk[] = "\\(^\\|[^[:alnum:]_]\\)\\(";
static char const word_end_bk[] = "\\)\\([^[:alnum:]_]\\|$\\)";
int bk = !(syntax_bits & RE_NO_BK_PARENS);
-# define IF_BK(x, y) ((bk) ? (x) : (y))
char *n = xmalloc (sizeof word_beg_bk - 1 + size + sizeof word_end_bk);
-#endif /* EGREP_PROGRAM */
- strcpy (n, match_lines ? IF_BK(line_beg_bk, line_beg_no_bk)
- : IF_BK(word_beg_bk, word_beg_no_bk));
+ strcpy (n, match_lines ? (bk ? line_beg_bk : line_beg_no_bk)
+ : (bk ? word_beg_bk : word_beg_no_bk));
total = strlen(n);
memcpy (n + total, pattern, size);
total += size;
- strcpy (n + total, match_lines ? IF_BK(line_end_bk, line_end_no_bk)
- : IF_BK(word_end_bk, word_end_no_bk));
+ strcpy (n + total, match_lines ? (bk ? line_end_bk : line_end_no_bk)
+ : (bk ? word_end_bk : word_end_no_bk));
total += strlen (n + total);
pattern = motif = n;
size = total;
--
1.6.6.1
- Re: [PATCH 1/9] grep: remove getpagesize.h, (continued)
- [PATCH 2/9] grep: remove one #ifdef, Paolo Bonzini, 2010/03/19
- [PATCH 3/9] grep: change struct matcher termination, Paolo Bonzini, 2010/03/19
- [PATCH 4/9] grep: make egrep/fgrep use struct matcher, Paolo Bonzini, 2010/03/19
- [PATCH 5/9] grep: eliminate {COMPILE,EXECUTE}_{RET,ARGS,FCT}, Paolo Bonzini, 2010/03/19
- [PATCH 6/9] grep: remove one #ifdef,
Paolo Bonzini <=
- [PATCH 8/9] grep: prepare for libification of *search.c, Paolo Bonzini, 2010/03/19
- [PATCH 9/9] grep: libify *search.c, Paolo Bonzini, 2010/03/19
- [PATCH 7/9] grep: split search.c, Paolo Bonzini, 2010/03/19
- Re: [PATCH 0/9] remove most {,E,F}GREP_PROGRAM occurrences, Jim Meyering, 2010/03/19