diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/ChangeLog | 8 | ||||
-rw-r--r-- | helpers/chlistref.awk | 31 | ||||
-rw-r--r-- | helpers/testdfa.c | 31 |
3 files changed, 57 insertions, 13 deletions
diff --git a/helpers/ChangeLog b/helpers/ChangeLog index 17624c3f..a5bbafb1 100644 --- a/helpers/ChangeLog +++ b/helpers/ChangeLog @@ -1,3 +1,11 @@ +2014-09-04 Arnold D. Robbins <arnold@skeeve.com> + + * chlistref.awk: New file. Finds @ref{} to non-chapters. + +2014-06-08 Arnold D. Robbins <arnold@skeeve.com> + + * testdfa.c: Minor improvements. + 2014-04-08 Arnold D. Robbins <arnold@skeeve.com> * 4.1.1: Release tar ball made. diff --git a/helpers/chlistref.awk b/helpers/chlistref.awk new file mode 100644 index 00000000..49f63f59 --- /dev/null +++ b/helpers/chlistref.awk @@ -0,0 +1,31 @@ +BEGIN { + chapters["Getting Started"]++ + chapters["Invoking Gawk"]++ + chapters["Regexp"]++ + chapters["Reading Files"]++ + chapters["Printing"]++ + chapters["Expressions"]++ + chapters["Patterns and Actions"]++ + chapters["Arrays"]++ + chapters["Functions"]++ + chapters["Library Functions"]++ + chapters["Sample Programs"]++ + chapters["Advanced Features"]++ + chapters["Internationalization"]++ + chapters["Debugger"]++ + chapters["Arbitrary Precision Arithmetic"]++ + chapters["Dynamic Extensions"]++ + chapters["Language History"]++ + chapters["Installation"]++ + chapters["Notes"]++ + chapters["Basic Concepts"]++ + + Pattern = ".*@ref\\{([^}]+)\\},.*" +} + +$0 ~ Pattern { + ref = gensub(Pattern, "\\1", 1, $0) + if (! (ref in chapters)) + printf("%s:%d: %s\n", FILENAME, FNR, $0) +} + diff --git a/helpers/testdfa.c b/helpers/testdfa.c index 813acaab..25a229a2 100644 --- a/helpers/testdfa.c +++ b/helpers/testdfa.c @@ -40,14 +40,16 @@ #include <sys/stat.h> +#undef _Noreturn #define _Noreturn +#define _GL_ATTRIBUTE_PURE #include "dfa.h" const char *regexflags2str(int flags); char *databuf(int fd); const char * reflags2str(int flagval); int parse_escape(const char **string_ptr); -char *setup_pattern(const char *pattern, size_t len); +char *setup_pattern(const char *pattern, size_t *len); char casetable[]; reg_syntax_t syn; @@ -126,10 +128,10 @@ int main(int argc, char **argv) printf("Ignorecase: %s\nSyntax: %s\n", (ignorecase ? "true" : "false"), reflags2str(syn)); - printf("Pattern: /%s/\n", pattern); + printf("Pattern: /%s/, len = %d\n", pattern, len); - pattern = setup_pattern(pattern, len); - len = strlen(pattern); + pattern = setup_pattern(pattern, & len); + printf("After setup_pattern(), len = %d\n", len); pat.fastmap = (char *) malloc(256); if (pat.fastmap == NULL) { @@ -191,7 +193,10 @@ int main(int argc, char **argv) &count, &try_backref); data[len] = save; - printf("dfaexec returned %p (%.3s)\n", place, place); + if (place == NULL) + printf("dfaexec returned NULL\n"); + else + printf("dfaexec returned %d (%.3s)\n", place - data, place); /* release storage */ regfree(& pat); @@ -363,7 +368,7 @@ r_fatal(const char *mesg, ...) /* setup_pattern --- do what gawk does with the pattern string */ char * -setup_pattern(const char *pattern, size_t len) +setup_pattern(const char *pattern, size_t *len) { size_t is_multibyte = 0; int c, c2; @@ -377,7 +382,7 @@ setup_pattern(const char *pattern, size_t len) memset(& mbs, 0, sizeof(mbs)); src = pattern; - end = pattern + len; + end = pattern + *len; /* Handle escaped characters first. */ @@ -387,19 +392,19 @@ setup_pattern(const char *pattern, size_t len) * from that. */ if (buf == NULL) { - buf = (char *) malloc(len + 2); + 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); + 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; + buflen = *len; } dest = buf; @@ -487,7 +492,7 @@ setup_pattern(const char *pattern, size_t len) } /* while */ *dest = '\0'; - len = dest - buf; + *len = dest - buf; return buf; } |