diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2006-04-11 00:50:56 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2006-04-11 00:50:56 +0000 |
commit | 2a124564c75278f0a687205d9a58fdb4fed89096 (patch) | |
tree | fa22bc597fab5c099425f210e76cd999c9133793 /src/expr.c | |
parent | 87bd526828a6718173d86be3d9c2880e9b0f2327 (diff) | |
download | coreutils-2a124564c75278f0a687205d9a58fdb4fed89096.tar.xz |
(docolon): Allocate and use a fastmap.
Don't bother allocating a buffer.
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/expr.c b/src/expr.c index 83a85c4e9..f32d7634e 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1,5 +1,5 @@ /* expr -- evaluate expressions. - Copyright (C) 86, 1991-1997, 1999-2005 Free Software Foundation, Inc. + Copyright (C) 86, 1991-1997, 1999-2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -412,8 +412,8 @@ docolon (VALUE *sv, VALUE *pv) VALUE *v IF_LINT (= NULL); const char *errmsg; struct re_pattern_buffer re_buffer; + char fastmap[UCHAR_MAX + 1]; struct re_registers re_regs; - size_t len; regoff_t matchlen; tostring (sv); @@ -427,14 +427,12 @@ of the basic regular expression is not portable; it is being ignored"), quote (pv->u.s)); } - len = strlen (pv->u.s); - memset (&re_buffer, 0, sizeof (re_buffer)); - memset (&re_regs, 0, sizeof (re_regs)); - re_buffer.buffer = xnmalloc (len, 2); - re_buffer.allocated = 2 * len; + re_buffer.buffer = NULL; + re_buffer.allocated = 0; + re_buffer.fastmap = fastmap; re_buffer.translate = NULL; re_syntax_options = RE_SYNTAX_POSIX_BASIC; - errmsg = re_compile_pattern (pv->u.s, len, &re_buffer); + errmsg = re_compile_pattern (pv->u.s, strlen (pv->u.s), &re_buffer); if (errmsg) error (EXPR_FAILURE, 0, "%s", errmsg); @@ -442,7 +440,7 @@ of the basic regular expression is not portable; it is being ignored"), if (0 <= matchlen) { /* Were \(...\) used? */ - if (re_buffer.re_nsub > 0)/* was (re_regs.start[1] >= 0) */ + if (re_buffer.re_nsub > 0) { sv->u.s[re_regs.end[1]] = '\0'; v = str_value (sv->u.s + re_regs.start[1]); |