diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-06-19 20:24:04 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-06-19 20:24:04 +0300 |
commit | 5cb84303090ceeaae218692e849d76bb5f0dce69 (patch) | |
tree | 4c422995d737143137ef8a7fccdf2c183502412e | |
parent | fe3173cd6266b73b5400bcf7dd6862979e64e4df (diff) | |
download | egawk-5cb84303090ceeaae218692e849d76bb5f0dce69.tar.gz egawk-5cb84303090ceeaae218692e849d76bb5f0dce69.tar.bz2 egawk-5cb84303090ceeaae218692e849d76bb5f0dce69.zip |
Add more comments and whitespace for do_sub().
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | builtin.c | 39 |
2 files changed, 28 insertions, 16 deletions
@@ -1,3 +1,8 @@ +2014-06-19 Arnold D. Robbins <arnold@skeeve.com> + + * builtin.c (do_sub): Add more info to leading comment. + Add some whitespace in the code. + 2014-06-08 Arnold D. Robbins <arnold@skeeve.com> * dfa.c: Sync with GNU grep. @@ -2647,23 +2647,28 @@ do_match(int nargs) * 2001 standard: * * sub(ere, repl[, in ]) - * Substitute the string repl in place of the first instance of the extended regular - * expression ERE in string in and return the number of substitutions. An ampersand - * ('&') appearing in the string repl shall be replaced by the string from in that - * matches the ERE. An ampersand preceded with a backslash ('\') shall be - * interpreted as the literal ampersand character. An occurrence of two consecutive - * backslashes shall be interpreted as just a single literal backslash character. Any - * other occurrence of a backslash (for example, preceding any other character) shall - * be treated as a literal backslash character. Note that if repl is a string literal (the - * lexical token STRING; see Grammar (on page 170)), the handling of the - * ampersand character occurs after any lexical processing, including any lexical - * backslash escape sequence processing. If in is specified and it is not an lvalue (see - * Expressions in awk (on page 156)), the behavior is undefined. If in is omitted, awk - * shall use the current record ($0) in its place. + * Substitute the string repl in place of the first instance of the + * extended regular expression ERE in string in and return the number of + * substitutions. An ampersand ('&') appearing in the string repl shall + * be replaced by the string from in that matches the ERE. An ampersand + * preceded with a backslash ('\') shall be interpreted as the literal + * ampersand character. An occurrence of two consecutive backslashes shall + * be interpreted as just a single literal backslash character. Any other + * occurrence of a backslash (for example, preceding any other character) + * shall be treated as a literal backslash character. Note that if repl is a + * string literal (the lexical token STRING; see Grammar (on page 170)), the + * handling of the ampersand character occurs after any lexical processing, + * including any lexical backslash escape sequence processing. If in is + * specified and it is not an lvalue (see Expressions in awk (on page 156)), + * the behavior is undefined. If in is omitted, awk shall use the current + * record ($0) in its place. * - * 11/2010: The text in the 2008 standard is the same as just quoted. However, POSIX behavior - * is now the default. This can change the behavior of awk programs. The old behavior - * is not available. + * 11/2010: The text in the 2008 standard is the same as just quoted. + * However, POSIX behavior is now the default. This can change the behavior + * of awk programs. The old behavior is not available. + * + * 7/2011: Reverted backslash handling to what it used to be. It was in + * gawk for too long. Should have known better. */ /* @@ -2774,9 +2779,11 @@ set_how_many: repl = s->stptr; replend = repl + s->stlen; repllen = replend - repl; + emalloc(buf, char *, buflen + 2, "do_sub"); buf[buflen] = '\0'; buf[buflen + 1] = '\0'; + ampersands = 0; /* |