From: Jim Meyering Date: Sat, 1 May 1993 19:45:14 +0000 (+0000) Subject: GNU text utilities X-Git-Tag: TEXTUTILS-1_4_1 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=a30822e27b04c1e10ed0ba39e76e8df7367ab369;p=gnulib.git GNU text utilities --- diff --git a/lib/regex.c b/lib/regex.c index eda11b535..032b4d022 100644 --- a/lib/regex.c +++ b/lib/regex.c @@ -1,5 +1,5 @@ /* Extended regular expression matching and search library, - version 0.11. + version 0.12. (Implements POSIX draft P10003.2/D11.2, except for internationalization features.) @@ -127,7 +127,18 @@ init_syntax_once () /* isalpha etc. are used for the character classes. */ #include -#ifndef isascii +/* Jim Meyering writes: + + "... Some ctype macros are valid only for character codes that + isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when + using /bin/cc or gcc but without giving an ansi option). So, all + ctype uses should be through macros like ISPRINT... If + STDC_HEADERS is defined, then autoconf has verified that the ctype + macros don't need to be guarded with references to isascii. ... + Defining isascii to 1 should let any compiler worth its salt + eliminate the && through constant folding." */ +#if ! defined (isascii) || defined (STDC_HEADERS) +#undef isascii #define isascii(c) 1 #endif @@ -1302,6 +1313,7 @@ regex_compile (pattern, size, syntax, bufp) the `*'. Do we have to do something analogous here for null bytes, because of RE_DOT_NOT_NULL? */ if (TRANSLATE (*(p - 2)) == TRANSLATE ('.') + && zero_times_ok && p < pend && TRANSLATE (*p) == TRANSLATE ('\n') && !(syntax & RE_DOT_NEWLINE)) { /* We have .*\n. */ @@ -1612,6 +1624,10 @@ regex_compile (pattern, size, syntax, bufp) fixup_alt_jump = 0; laststart = 0; begalt = b; + /* If we've reached MAX_REGNUM groups, then this open + won't actually generate any code, so we'll have to + clear pending_exact explicitly. */ + pending_exact = 0; break; @@ -1661,6 +1677,10 @@ regex_compile (pattern, size, syntax, bufp) : 0; laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset; this_group_regnum = COMPILE_STACK_TOP.regnum; + /* If we've reached MAX_REGNUM groups, then this open + won't actually generate any code, so we'll have to + clear pending_exact explicitly. */ + pending_exact = 0; /* We're at the end of the group, so now we know how many groups were inside this one. */ @@ -2930,7 +2950,8 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop) inside the loop. */ if (translate) while (range > lim - && !fastmap[(unsigned char) translate[*d++]]) + && !fastmap[(unsigned char) + translate[(unsigned char) *d++]]) range--; else while (range > lim && !fastmap[(unsigned char) *d++]) @@ -3453,7 +3474,11 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) } } else - assert (bufp->regs_allocated == REGS_FIXED); + { + /* These braces fend off a "empty body in an else-statement" + warning under GCC when assert expands to nothing. */ + assert (bufp->regs_allocated == REGS_FIXED); + } /* Convert the pointer data in `regstart' and `regend' to indices. Register zero has to be set differently, @@ -4880,6 +4905,13 @@ regerror (errcode, preg, errbuf, errbuf_size) Dump core so we can fix it. */ abort (); + msg = re_error_msg[errcode]; + + /* POSIX doesn't require that we do anything in this case, but why + not be nice. */ + if (! msg) + msg = "Success"; + msg_size = strlen (msg) + 1; /* Includes the null. */ if (errbuf_size != 0) diff --git a/lib/regex.h b/lib/regex.h index 0840861da..408dd2103 100644 --- a/lib/regex.h +++ b/lib/regex.h @@ -1,7 +1,7 @@ /* Definitions for data structures and routines for the regular - expression library, version 0.11. + expression library, version 0.12. - Copyright (C) 1985, 89, 90, 91, 92 Free Software Foundation, Inc. + Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993 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