argv_ref patch 25: allow NUL in quote and comment delimiters
Eric Blake <[email protected]>
| Newsgroups | gmane.comp.gnu.m4.patches |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Next in the series, this time to handle embedded NUL in quote and comment syntax. Quotes and comments were already tracking length, but there were a number of places that were assuming they did not contain NUL or which required a NUL terminator instead of using the length. The patch doesn't use any more memory, and in some cases can use slightly less (where a NUL terminator is now omitted); and I didn't notice any obvious speed differences. In the process of fixing this, I also simplified quite a bit of obstack printing code by using obstack_printf. Thus, I split things for the master branch into output cleanup and embedded NUL handling. The port to master branch was not trivial, because I had to consider the interaction with the new changesyntax. 2008-06-18 Eric Blake <[email protected]> Stage 25: Handle embedded NUL in changequote and changecom. Track quote and comment delimiters by length, to allow embedded NUL. Convert macro tracing and other locations to use obstack_printf rather than hand-rolled equivalents. Ensure that embedded NUL in trace output does not truncate the trace string. Memory impact: none. Speed impact: none noticed. * m4/gnulib-cache.m4: Import obstack-printf-posix module. * src/m4.h (ntoa): Remove declaration. (DEBUG_PRINT1, DEBUG_PRINT3, MESSAGE, DEBUG_MESSAGE1) (DEBUG_MESSAGE2): Delete, now that these macros are unused. (debug_message_prefix): Rename... (debug_message): ...and add parameters. (set_quotes, set_comment): Add parameters. * src/debug.c (debug_message_prefix): Rename... (debug_message): ...and use obstack_printf. (trace_format): Delete. (trace_header): Adjust caller. * src/input.c (init_argv_token, input_init): Handle embedded NUL in comments and quotes. (match_input, MATCH, set_quotes, set_comment): Add parameter. (set_quote_age): Adjust heuristic for safe quote. (push_file, pop_input, next_token, peek_token): Adjust callers. * src/freeze.c (produce_frozen_state, reload_frozen_state): Handle embedded NUL in quotes and comments. * src/builtin.h (ntoa): Make static. (shipout_int, m4_eval, m4_maketemp): Use obstack_printf. (m4_dumpdef): Avoid truncating output on embedded NUL. (m4_changequote, m4_changecom): Handle embedded NUL. * src/format.c (expand_format): Use obstack_printf. * src/output.c (m4_tmpname, divert_text): Likewise. * src/path.c (m4_path_search): Adjust caller. * doc/m4.texinfo (Using frozen files): Enhance test. * examples/null.m4: Likewise. * examples/null.out: Update expected output. * examples/null.err: Likewise. - -- Don't work too hard, make some time for fun as well! Eric Blake [email protected] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkhZDZsACgkQ84KuGfSFAYAxYACfaVz5M0VOLDcxiecG82tpJ6RX N64AoJKXGjVqiFNuA22L1hS7BNW+C+6y =/TOY -----END PGP SIGNATURE----- _______________________________________________ M4-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch359
(text/plain, 89.9 KB) - not displayed