summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-10-08 10:21:47 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-10-08 10:21:47 +0300
commit3c4daf4e10892a471111a95f62d99d660ab24552 (patch)
treeb181a8e5ea093127f938d101afd5c8793cee57dc
parent62988ea2ac1f845e30c3986bfc9bf4620693682a (diff)
parente86f9bcc463370f27f005439c2d8bb73a0caafbd (diff)
downloadgawk-3c4daf4e10892a471111a95f62d99d660ab24552.tar.gz
Merge branch 'gawk-4.1-stable'
-rw-r--r--ChangeLog4
-rw-r--r--dfa.c45
-rw-r--r--extension/ChangeLog5
-rw-r--r--extension/inplace.c5
4 files changed, 44 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 38f06eed..93f0ed40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2014-10-08 Arnold D. Robbins <arnold@skeeve.com>
+
+ * dfa.c: Sync wit GNU grep.
+
2014-10-05 Arnold D. Robbins <arnold@skeeve.com>
* profile.c (pprint): Fix typo in header. Sheesh.
diff --git a/dfa.c b/dfa.c
index 6179a3d3..f810a262 100644
--- a/dfa.c
+++ b/dfa.c
@@ -3420,11 +3420,38 @@ dfaexec_main (struct dfa *d, char const *begin, char *end,
goto done;
}
- /* Can match with a multibyte character (and multi character
- collating element). Transition table might be updated. */
- s = transit_state (d, s, &p, (unsigned char *) end);
- mbp = p;
- trans = d->trans;
+ /* The following code is used twice.
+ Use a macro to avoid the risk that they diverge. */
+#define State_transition() \
+ do { \
+ /* Can match with a multibyte character (and multi-character \
+ collating element). Transition table might be updated. */ \
+ s = transit_state (d, s, &p, (unsigned char *) end); \
+ \
+ /* If previous character is newline after a transition \
+ for ANYCHAR or MBCSET in non-UTF8 multibyte locales, \
+ check whether current position is beyond the end of \
+ the input buffer. Also, transit to initial state if \
+ !ALLOW_NL, even if RE_DOT_NEWLINE is set. */ \
+ if (p[-1] == eol) \
+ { \
+ if ((char *) p > end) \
+ { \
+ p = NULL; \
+ goto done; \
+ } \
+ \
+ nlcount++; \
+ \
+ if (!allow_nl) \
+ s = 0; \
+ } \
+ \
+ mbp = p; \
+ trans = d->trans; \
+ } while (0)
+
+ State_transition();
}
}
else
@@ -3467,13 +3494,7 @@ dfaexec_main (struct dfa *d, char const *begin, char *end,
s1 = s;
if (multibyte)
- {
- /* Can match with a multibyte character (and multicharacter
- collating element). Transition table might be updated. */
- s = transit_state (d, s, &p, (unsigned char *) end);
- mbp = p;
- trans = d->trans;
- }
+ State_transition();
else
s = d->fails[s][*p++];
continue;
diff --git a/extension/ChangeLog b/extension/ChangeLog
index c54d3b25..3fee967f 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,8 @@
+2014-10-08 Arnold D. Robbins <arnold@skeeve.com>
+
+ * inplace.c (do_inplace_begin): Use a cast to void in front
+ of the second call to chown to avoid compiler warnings from clang.
+
2014-09-29 Arnold D. Robbins <arnold@skeeve.com>
* filefuncs.c: Minor edits to sync with documentation.
diff --git a/extension/inplace.c b/extension/inplace.c
index e2f8b73f..8a7375c4 100644
--- a/extension/inplace.c
+++ b/extension/inplace.c
@@ -171,9 +171,8 @@ do_inplace_begin(int nargs, awk_value_t *result)
/* N.B. chown/chmod should be more portable than fchown/fchmod */
if (chown(state.tname, sbuf.st_uid, sbuf.st_gid) < 0)
- /* checking chown here shuts up the compiler. bleah */
- if (chown(state.tname, -1, sbuf.st_gid) < 0)
- ;
+ (void) chown(state.tname, -1, sbuf.st_gid);
+
if (chmod(state.tname, sbuf.st_mode) < 0)
fatal(ext_id, _("inplace_begin: chmod failed (%s)"),
strerror(errno));