diff --git a/gnulib b/gnulib
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit c6dc8f16f19ceba9556ca82b4adc77e410ac44c2
+Subproject commit c6dc8f16f19ceba9556ca82b4adc77e410ac44c2-dirty
diff --git a/src/dfa.c b/src/dfa.c
index 074a4ec..b35cfd9 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -535,14 +535,24 @@ static int case_fold;
 /* End-of-line byte in data.  */
 static unsigned char eolbyte;
 
+/* Table for anding with d->success. */
+static int sbit[NOTCHAR];
+
 /* Entry point to set syntax options. */
 void
 dfasyntax (reg_syntax_t bits, int fold, unsigned char eol)
 {
+  unsigned int i;
   syntax_bits_set = 1;
   syntax_bits = bits;
   case_fold = fold;
   eolbyte = eol;
+
+  for (i = 0; i < NOTCHAR; ++i)
+    sbit[i] = (IS_WORD_CONSTITUENT(i)) ? 2 : 1;
+  sbit['\n'] = 4;
+  if (eolbyte == 0)
+    sbit[eol] = 4;
 }
 
 /* Set a bit in the charclass for the given wchar_t.  Do nothing if WC
@@ -2549,7 +2559,9 @@ dfastate (int s, struct dfa *d, int trans[])
         state_letter = state;
       for (i = 0; i < NOTCHAR; ++i)
         trans[i] = (IS_WORD_CONSTITUENT(i)) ? state_letter : state;
-      trans[eolbyte] = state_newline;
+      trans['\n'] = state_newline;
+      if (eolbyte == 0)
+	trans[0] = state_newline;
     }
   else
     for (i = 0; i < NOTCHAR; ++i)
@@ -2871,13 +2883,13 @@ match_anychar (struct dfa *d, int s, position pos, int idx)
   mbclen = (mblen_buf[idx] == 0)? 1 : mblen_buf[idx];
 
   /* Check context.  */
-  if (wc == (wchar_t)eolbyte)
+  if (wc == (wchar_t)'\n')
     {
       if (!(syntax_bits & RE_DOT_NEWLINE))
         return 0;
       newline = 1;
     }
-  else if (wc == (wchar_t)'\0')
+  else if (eolbyte == 0 && wc == (wchar_t)'\0')
     {
       if (syntax_bits & RE_DOT_NOT_NULL)
         return 0;
@@ -2920,13 +2932,13 @@ match_mb_charset (struct dfa *d, int s, position pos, int idx)
   wc = inputwcs[idx];
 
   /* Check context.  */
-  if (wc == (wchar_t)eolbyte)
+  if (wc == (wchar_t)'\n')
     {
       if (!(syntax_bits & RE_DOT_NEWLINE))
         return 0;
       newline = 1;
     }
-  else if (wc == (wchar_t)'\0')
+  else if (eolbyte == 0 && wc == (wchar_t)'\0')
     {
       if (syntax_bits & RE_DOT_NOT_NULL)
         return 0;
@@ -3112,6 +3124,7 @@ transit_state (struct dfa *d, int s, unsigned char const **pp)
   position_set follows;
   unsigned char const *p1 = *pp;
   wchar_t wc;
+  bool newline, wordchar;
 
   if (nelem > 0)
     /* This state has (a) multibyte operator(s).
@@ -3154,7 +3167,9 @@ transit_state (struct dfa *d, int s, unsigned char const **pp)
   transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows);
 
   wc = inputwcs[*pp - mbclen - buf_begin];
-  s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc));
+  newline = wc == L'\n' || (eolbyte == 0 && wc == 0);
+  wordchar = iswalnum(wc);
+  s1 = state_index(d, &follows, newline, wordchar);
   realloc_trans_if_necessary(d, s1);
 
   while (*pp - p1 < maxlen)
@@ -3171,7 +3186,9 @@ transit_state (struct dfa *d, int s, unsigned char const **pp)
         }
 
       wc = inputwcs[*pp - mbclen - buf_begin];
-      s1 = state_index(d, &follows, wc == L'\n', iswalnum(wc));
+      newline = wc == L'\n' || (eolbyte == 0 && wc == 0);
+      wordchar = iswalnum(wc);
+      s1 = state_index(d, &follows, newline, wordchar);
       realloc_trans_if_necessary(d, s1);
     }
   free(match_lens);
@@ -3250,18 +3267,6 @@ dfaexec (struct dfa *d, char const *begin, char *end,
                                    into a register. */
   unsigned char eol = eolbyte;	/* Likewise for eolbyte.  */
   unsigned char saved_end;
-  static int sbit[NOTCHAR];	/* Table for anding with d->success. */
-  static int sbit_init;
-
-  if (! sbit_init)
-    {
-      unsigned int i;
-
-      sbit_init = 1;
-      for (i = 0; i < NOTCHAR; ++i)
-        sbit[i] = (IS_WORD_CONSTITUENT(i)) ? 2 : 1;
-      sbit[eol] = 4;
-    }
 
   if (! d->tralloc)
     build_state_zero(d);
