diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/ChangeLog | 16 | ||||
-rw-r--r-- | helpers/testdfa.c | 53 | ||||
-rw-r--r-- | helpers/testnet.c | 8 |
3 files changed, 45 insertions, 32 deletions
diff --git a/helpers/ChangeLog b/helpers/ChangeLog index d27fc555..d29071e3 100644 --- a/helpers/ChangeLog +++ b/helpers/ChangeLog @@ -1,3 +1,11 @@ +2016-10-23 Arnold D. Robbins <arnold@skeeve.com> + + * General: Remove trailing whitespace from all relevant files. + +2016-09-08 Paul Eggert <eggert@cs.ucla.edu> + + * testdfa.c: Adjust to DFA API changes. + 2016-08-25 Arnold D. Robbins <arnold@skeeve.com> * 4.1.4: Release tar ball made. @@ -37,6 +45,14 @@ * 4.1.2: Release tar ball made. +2015-04-09 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * testdfa.c (setup_pattern): Rationalize buffer size computations. + +2014-12-18 Arnold D. Robbins <arnold@skeeve.com> + + * testdfa.c (setup_pattern): Do not waste a byte at the end of a string. + 2014-09-04 Arnold D. Robbins <arnold@skeeve.com> * chlistref.awk: New file. Finds @ref{} to non-chapters. diff --git a/helpers/testdfa.c b/helpers/testdfa.c index 1e144bd7..72b97907 100644 --- a/helpers/testdfa.c +++ b/helpers/testdfa.c @@ -2,22 +2,22 @@ * testdfa.c --- abstracted from gawk. */ -/* +/* * Copyright (C) 1986, 1988, 1989, 1991-2013 the Free Software Foundation, Inc. - * + * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. - * + * * GAWK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * GAWK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -44,6 +44,7 @@ #define _Noreturn #define _GL_ATTRIBUTE_PURE #include "dfa.h" +#include "localeinfo.h" const char *regexflags2str(int flags); char *databuf(int fd); @@ -71,7 +72,8 @@ void usage(const char *myname) int main(int argc, char **argv) { - int c, ret, try_backref; + int c, ret; + bool try_backref; struct re_pattern_buffer pat; struct re_registers regs; struct dfa *dfareg; @@ -84,6 +86,7 @@ int main(int argc, char **argv) char save; size_t count = 0; char *place; + struct localeinfo localeinfo; if (argc < 2) usage(argv[0]); @@ -158,7 +161,6 @@ int main(int argc, char **argv) dfa_syn = syn; if (ignorecase) dfa_syn |= RE_ICASE; - dfasyntax(dfa_syn, ignorecase, '\n'); re_set_syntax(syn); if ((rerr = re_compile_pattern(pattern, len, & pat)) != NULL) { @@ -171,6 +173,10 @@ int main(int argc, char **argv) pat.newline_anchor = false; /* don't get \n in middle of string */ dfareg = dfaalloc(); + init_localeinfo(&localeinfo); + dfasyntax(dfareg, &localeinfo, dfa_syn, + ignorecase ? DFA_CASE_FOLD : 0); + printf("Calling dfacomp(%s, %d, %p, true)\n", pattern, (int) len, dfareg); @@ -372,10 +378,10 @@ setup_pattern(const char *pattern, size_t *len) { size_t is_multibyte = 0; int c, c2; - size_t buflen = 0; + size_t buflen; mbstate_t mbs; bool has_anchor = false; - char *buf = NULL; + char *buf; char *dest; const char *src, *end; @@ -389,23 +395,14 @@ setup_pattern(const char *pattern, size_t *len) /* * Build a copy of the string (in buf) with the * escaped characters translated, and generate the regex - * from that. + * from that. */ + buf = (char *) malloc(*len + 1); if (buf == NULL) { - buf = (char *) malloc(*len + 2); - if (buf == NULL) { - fprintf(stderr, "%s: malloc failed\n", __func__); - exit(EXIT_FAILURE); - } - buflen = *len; - } else if (*len > buflen) { - buf = (char *) realloc(buf, *len + 2); - if (buf == NULL) { - fprintf(stderr, "%s: realloc failed\n", __func__); - exit(EXIT_FAILURE); - } - buflen = *len; + fprintf(stderr, "%s: malloc failed\n", __func__); + exit(EXIT_FAILURE); } + buflen = *len; dest = buf; while (src < end) { @@ -502,16 +499,16 @@ setup_pattern(const char *pattern, size_t *len) * * Parse a C escape sequence. STRING_PTR points to a variable containing a * pointer to the string to parse. That pointer is updated past the - * characters we use. The value of the escape sequence is returned. + * characters we use. The value of the escape sequence is returned. * * A negative value means the sequence \ newline was seen, which is supposed to - * be equivalent to nothing at all. + * be equivalent to nothing at all. * * If \ is followed by a null character, we return a negative value and leave - * the string pointer pointing at the null character. + * the string pointer pointing at the null character. * * If \ is followed by 000, we return 0 and leave the string pointer after the - * zeros. A value of 0 does not mean end of string. + * zeros. A value of 0 does not mean end of string. * * POSIX doesn't allow \x. */ @@ -600,7 +597,7 @@ parse_escape(const char **string_ptr) #ifdef C #undef C #endif -#define C(c) ((char)c) +#define C(c) ((char)c) /* * This table is used by the regexp routines to do case independent * matching. Basically, every ascii character maps to itself, except diff --git a/helpers/testnet.c b/helpers/testnet.c index feda38b4..cbe2d97e 100644 --- a/helpers/testnet.c +++ b/helpers/testnet.c @@ -220,9 +220,9 @@ devopen(const char *name, const char *mode) localpname = cp; while (*cp != '/' && *cp != '\0') cp++; - /* + /* * Require a port, let them explicitly put 0 if - * they don't care. + * they don't care. */ if (*cp != '/' || cp == localpname) { fprintf(stderr, _("special file name `%s' is incomplete"), name); @@ -241,7 +241,7 @@ devopen(const char *name, const char *mode) cp++; hostname = cp; while (*cp != '/' && *cp != '\0') - cp++; + cp++; if (*cp != '/' || cp == hostname) { *localpnamelastcharp = '/'; fprintf(stderr, _("must supply a remote hostname to `/inet'")); @@ -278,7 +278,7 @@ devopen(const char *name, const char *mode) char *cp, *end; unsigned long count = 0; char *ms2; - + first_time = false; if ((cp = getenv("GAWK_SOCK_RETRIES")) != NULL) { count = strtoul(cp, & end, 10); |