Modify so that the scanner inserts the <SectN>...</SectN> markup, make sect 3 have...
authorNick Downing <downing.nick@gmail.com>
Sat, 23 Jun 2018 00:58:16 +0000 (10:58 +1000)
committerNick Downing <downing.nick@gmail.com>
Sat, 23 Jun 2018 00:58:16 +0000 (10:58 +1000)
src/main.c
src/parse.c
src/parse.c.patch
src/parse.y
src/scan.c
src/scan.c.patch
src/scan.l
src/stage1scan.c.patch

index e3fd3d4..d31392a 100644 (file)
@@ -167,6 +167,11 @@ int flex_main (int argc, char *argv[])
 
        flexinit (argc, argv);
 
+#if 1
+ extern char *piece[];
+ extern int piece1;
+ piece[piece1++] = strdup("<root><Sect1>");
+#endif
        readin ();
 
        skelout ();
@@ -185,6 +190,12 @@ int flex_main (int argc, char *argv[])
 
        /* Generate the C state transition tables from the DFA. */
        make_tables ();
+#if 1
+ /* at this point flexscan() has been called to copy sect 3 to the output */
+ piece[piece1++] = strdup("</root>");
+ for (i = 0; i < piece1; ++i)
+  fputs(piece[i], stderr);
+#endif
 
        /* Note, flexend does not return.  It exits with its argument
         * as status.
@@ -1476,13 +1487,6 @@ void readin (void)
                pinpoint_message (_("fatal parse error"));
                flexend (1);
        }
-#if 1
- extern char *piece[];
- extern int piece1;
- int i;
- for (i = 0; i < piece1; ++i)
-  fputs(piece[i], stderr);
-#endif
 
        if (syntaxerror)
                flexend (1);
index c120875..7afcc91 100644 (file)
@@ -592,16 +592,16 @@ static const yytype_uint8 yytranslate[] =
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   118,   118,   157,   164,   170,   175,   176,   180,   188,
-     191,   195,   198,   201,   205,   208,   209,   212,   217,   219,
-     223,   225,   227,   231,   237,   242,   246,   258,   296,   320,
-     345,   350,   353,   359,   379,   384,   386,   388,   392,   418,
-     476,   479,   528,   548,   556,   561,   590,   600,   603,   634,
-     651,   676,   685,   693,   701,   732,   749,   771,   813,   831,
-     841,   844,   850,   865,   871,   875,   880,   882,   891,   956,
-     979,   989,   998,  1002,  1006,  1010,  1014,  1018,  1022,  1036,
-    1040,  1044,  1048,  1052,  1067,  1071,  1075,  1079,  1083,  1087,
-    1091,  1095,  1099,  1103,  1107,  1115,  1125,  1143
+       0,   118,   118,   148,   155,   161,   166,   167,   171,   179,
+     182,   186,   189,   192,   196,   199,   200,   203,   208,   210,
+     214,   216,   218,   222,   228,   233,   237,   249,   287,   311,
+     336,   341,   344,   350,   370,   375,   377,   379,   383,   409,
+     467,   470,   519,   539,   547,   552,   581,   591,   594,   625,
+     642,   667,   676,   684,   692,   723,   740,   762,   804,   822,
+     832,   835,   841,   856,   862,   866,   871,   873,   882,   947,
+     970,   980,   989,   993,   997,  1001,  1005,  1009,  1013,  1027,
+    1031,  1035,  1039,  1043,  1058,  1062,  1066,  1070,  1074,  1078,
+    1082,  1086,  1090,  1094,  1098,  1106,  1116,  1134
 };
 #endif
 
@@ -1248,6 +1248,7 @@ int yynerrs;
 extern char piece_temp[];
 extern char *piece[];
 extern int piece0, piece1;
+void insert_piece(int n, const void *str);
 int piece2, piece3;
 static void peek(void) {
  if (yychar == YYEMPTY)
@@ -1259,16 +1260,10 @@ static void peek(void) {
  piece0 += 2;
  piece1 += 2;
 }
-static void insert_piece(int n, const char *str) {
- n += piece2;
- memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
- piece[n] = strdup(str);
- ++piece0;
- ++piece1;
- ++piece3;
-}
-#define insert_before(n, str) insert_piece((n) * 2, str);
-#define insert_after(n, str) insert_piece((n) * 2 + 1, str);
+#define insert_before(n, str) \
+ do { insert_piece(piece2 + (n) * 2, (str)); ++piece3; } while (0)
+#define insert_after(n, str) \
+ do { insert_piece(piece2 + (n) * 2 + 1, (str)); ++piece3; } while (0)
 int
 yyparse (void)
 {
@@ -1542,156 +1537,147 @@ yyreduce:
                                add_action( "ECHO" );
 
                        add_action( ";\n\tYY_BREAK]]\n" );
- peek();
- insert_before(5, "</root>");
- insert_before(5, "</Sect3>");
- insert_after(3, "<Sect3>");
- insert_after(3, "</Sect2>");
- insert_before(3, "<Sect2>");
- insert_after(1, "</Sect1>");
- insert_before(1, "<Sect1>");
- insert_before(0, "<root>");
                        }
-#line 1521 "parse.c" /* yacc.c:1646  */
+#line 1512 "parse.c" /* yacc.c:1646  */
     break;
 
   case 3:
-#line 157 "parse.y" /* yacc.c:1646  */
+#line 148 "parse.y" /* yacc.c:1646  */
     { /* initialize for processing rules */
 
                        /* Create default DFA start condition. */
                        scinstal( "INITIAL", false );
                        }
-#line 1531 "parse.c" /* yacc.c:1646  */
+#line 1522 "parse.c" /* yacc.c:1646  */
     break;
 
   case 4:
-#line 165 "parse.y" /* yacc.c:1646  */
+#line 156 "parse.y" /* yacc.c:1646  */
     {
  insert_after(2, "</Sect1_StartCond>");
  sprintf(piece_temp, "<Sect1_StartCond exclusive=\"%s\">", xcluflg ? "true" : "false");
  insert_before(1, piece_temp);
  }
-#line 1541 "parse.c" /* yacc.c:1646  */
+#line 1532 "parse.c" /* yacc.c:1646  */
     break;
 
   case 5:
-#line 171 "parse.y" /* yacc.c:1646  */
+#line 162 "parse.y" /* yacc.c:1646  */
     {
  insert_after(1, "</Sect1_Options>");
  insert_before(1, "<Sect1_Options>");
  }
-#line 1550 "parse.c" /* yacc.c:1646  */
+#line 1541 "parse.c" /* yacc.c:1646  */
     break;
 
   case 7:
-#line 177 "parse.y" /* yacc.c:1646  */
+#line 168 "parse.y" /* yacc.c:1646  */
     { synerr( _("unknown error processing section 1") ); }
-#line 1556 "parse.c" /* yacc.c:1646  */
+#line 1547 "parse.c" /* yacc.c:1646  */
     break;
 
   case 8:
-#line 181 "parse.y" /* yacc.c:1646  */
+#line 172 "parse.y" /* yacc.c:1646  */
     {
                        check_options();
                        scon_stk = allocate_integer_array( lastsc + 1 );
                        scon_stk_ptr = 0;
                        }
-#line 1566 "parse.c" /* yacc.c:1646  */
+#line 1557 "parse.c" /* yacc.c:1646  */
     break;
 
   case 9:
-#line 189 "parse.y" /* yacc.c:1646  */
+#line 180 "parse.y" /* yacc.c:1646  */
     { xcluflg = false; }
-#line 1572 "parse.c" /* yacc.c:1646  */
+#line 1563 "parse.c" /* yacc.c:1646  */
     break;
 
   case 10:
-#line 192 "parse.y" /* yacc.c:1646  */
+#line 183 "parse.y" /* yacc.c:1646  */
     { xcluflg = true; }
-#line 1578 "parse.c" /* yacc.c:1646  */
+#line 1569 "parse.c" /* yacc.c:1646  */
     break;
 
   case 11:
-#line 196 "parse.y" /* yacc.c:1646  */
+#line 187 "parse.y" /* yacc.c:1646  */
     { scinstal( nmstr, xcluflg ); }
-#line 1584 "parse.c" /* yacc.c:1646  */
+#line 1575 "parse.c" /* yacc.c:1646  */
     break;
 
   case 12:
-#line 199 "parse.y" /* yacc.c:1646  */
+#line 190 "parse.y" /* yacc.c:1646  */
     { scinstal( nmstr, xcluflg ); }
-#line 1590 "parse.c" /* yacc.c:1646  */
+#line 1581 "parse.c" /* yacc.c:1646  */
     break;
 
   case 13:
-#line 202 "parse.y" /* yacc.c:1646  */
+#line 193 "parse.y" /* yacc.c:1646  */
     { synerr( _("bad start condition list") ); }
-#line 1596 "parse.c" /* yacc.c:1646  */
+#line 1587 "parse.c" /* yacc.c:1646  */
     break;
 
   case 17:
-#line 213 "parse.y" /* yacc.c:1646  */
+#line 204 "parse.y" /* yacc.c:1646  */
     {
                        outfilename = xstrdup(nmstr);
                        did_outfilename = 1;
                        }
-#line 1605 "parse.c" /* yacc.c:1646  */
+#line 1596 "parse.c" /* yacc.c:1646  */
     break;
 
   case 18:
-#line 218 "parse.y" /* yacc.c:1646  */
+#line 209 "parse.y" /* yacc.c:1646  */
     { extra_type = xstrdup(nmstr); }
-#line 1611 "parse.c" /* yacc.c:1646  */
+#line 1602 "parse.c" /* yacc.c:1646  */
     break;
 
   case 19:
-#line 220 "parse.y" /* yacc.c:1646  */
+#line 211 "parse.y" /* yacc.c:1646  */
     { prefix = xstrdup(nmstr);
                           if (strchr(prefix, '[') || strchr(prefix, ']'))
                               flexerror(_("Prefix must not contain [ or ]")); }
-#line 1619 "parse.c" /* yacc.c:1646  */
+#line 1610 "parse.c" /* yacc.c:1646  */
     break;
 
   case 20:
-#line 224 "parse.y" /* yacc.c:1646  */
+#line 215 "parse.y" /* yacc.c:1646  */
     { yyclass = xstrdup(nmstr); }
-#line 1625 "parse.c" /* yacc.c:1646  */
+#line 1616 "parse.c" /* yacc.c:1646  */
     break;
 
   case 21:
-#line 226 "parse.y" /* yacc.c:1646  */
+#line 217 "parse.y" /* yacc.c:1646  */
     { headerfilename = xstrdup(nmstr); }
-#line 1631 "parse.c" /* yacc.c:1646  */
+#line 1622 "parse.c" /* yacc.c:1646  */
     break;
 
   case 22:
-#line 228 "parse.y" /* yacc.c:1646  */
+#line 219 "parse.y" /* yacc.c:1646  */
     { tablesext = true; tablesfilename = xstrdup(nmstr); }
-#line 1637 "parse.c" /* yacc.c:1646  */
+#line 1628 "parse.c" /* yacc.c:1646  */
     break;
 
   case 23:
-#line 232 "parse.y" /* yacc.c:1646  */
+#line 223 "parse.y" /* yacc.c:1646  */
     { scon_stk_ptr = (yyvsp[-3]); /*}*/
  peek();
  insert_before(5, "</Sect2_Rule>");
  insert_before(1, "<Sect2_Rule>");
  }
-#line 1647 "parse.c" /* yacc.c:1646  */
+#line 1638 "parse.c" /* yacc.c:1646  */
     break;
 
   case 24:
-#line 238 "parse.y" /* yacc.c:1646  */
+#line 229 "parse.y" /* yacc.c:1646  */
     { scon_stk_ptr = (yyvsp[-3]); /*}*/
  insert_after(4, "</Sect2_CompoundRule>");
  insert_before(1, "<Sect2_CompoundRule>");
  }
-#line 1656 "parse.c" /* yacc.c:1646  */
+#line 1647 "parse.c" /* yacc.c:1646  */
     break;
 
   case 26:
-#line 246 "parse.y" /* yacc.c:1646  */
+#line 237 "parse.y" /* yacc.c:1646  */
     {
                        /* Initialize for a parse of one rule. */
                        trlcontxt = variable_trail_rule = varlength = false;
@@ -1702,11 +1688,11 @@ yyreduce:
 
                        new_rule();
                        }
-#line 1671 "parse.c" /* yacc.c:1646  */
+#line 1662 "parse.c" /* yacc.c:1646  */
     break;
 
   case 27:
-#line 259 "parse.y" /* yacc.c:1646  */
+#line 250 "parse.y" /* yacc.c:1646  */
     {
                        pat = (yyvsp[0]);
                        finish_rule( pat, variable_trail_rule,
@@ -1743,11 +1729,11 @@ yyreduce:
  insert_after(2, "</Sect2_BOLRule>");
  insert_before(1, "<Sect2_BOLRule>");
                        }
-#line 1712 "parse.c" /* yacc.c:1646  */
+#line 1703 "parse.c" /* yacc.c:1646  */
     break;
 
   case 28:
-#line 297 "parse.y" /* yacc.c:1646  */
+#line 288 "parse.y" /* yacc.c:1646  */
     {
                        pat = (yyvsp[0]);
                        finish_rule( pat, variable_trail_rule,
@@ -1770,11 +1756,11 @@ yyreduce:
                                                                pat );
                                }
                        }
-#line 1739 "parse.c" /* yacc.c:1646  */
+#line 1730 "parse.c" /* yacc.c:1646  */
     break;
 
   case 29:
-#line 321 "parse.y" /* yacc.c:1646  */
+#line 312 "parse.y" /* yacc.c:1646  */
     {
                        if ( scon_stk_ptr > 0 )
                                build_eof_action();
@@ -1798,32 +1784,32 @@ yyreduce:
  insert_after(0, "</Sect2_EOFRule>");
  insert_before(0, "<Sect2_EOFRule>");
                        }
-#line 1767 "parse.c" /* yacc.c:1646  */
+#line 1758 "parse.c" /* yacc.c:1646  */
     break;
 
   case 30:
-#line 346 "parse.y" /* yacc.c:1646  */
+#line 337 "parse.y" /* yacc.c:1646  */
     { synerr( _("unrecognized rule") ); }
-#line 1773 "parse.c" /* yacc.c:1646  */
+#line 1764 "parse.c" /* yacc.c:1646  */
     break;
 
   case 31:
-#line 350 "parse.y" /* yacc.c:1646  */
+#line 341 "parse.y" /* yacc.c:1646  */
     { (yyval) = scon_stk_ptr; }
-#line 1779 "parse.c" /* yacc.c:1646  */
+#line 1770 "parse.c" /* yacc.c:1646  */
     break;
 
   case 32:
-#line 354 "parse.y" /* yacc.c:1646  */
+#line 345 "parse.y" /* yacc.c:1646  */
     { (yyval) = (yyvsp[-2]); /*}*/
  insert_after(3, "</StartCond>");
  insert_before(0, "<StartCond>");
  }
-#line 1788 "parse.c" /* yacc.c:1646  */
+#line 1779 "parse.c" /* yacc.c:1646  */
     break;
 
   case 33:
-#line 360 "parse.y" /* yacc.c:1646  */
+#line 351 "parse.y" /* yacc.c:1646  */
     {
                        (yyval) = scon_stk_ptr;
 
@@ -1841,25 +1827,25 @@ yyreduce:
  insert_after(2, "</StartCondWild>");
  insert_before(0, "<StartCondWild>");
                        }
-#line 1810 "parse.c" /* yacc.c:1646  */
+#line 1801 "parse.c" /* yacc.c:1646  */
     break;
 
   case 34:
-#line 379 "parse.y" /* yacc.c:1646  */
+#line 370 "parse.y" /* yacc.c:1646  */
     { (yyval) = scon_stk_ptr; /*}*/
  insert_before(0, "<StartCondNone />");
  }
-#line 1818 "parse.c" /* yacc.c:1646  */
+#line 1809 "parse.c" /* yacc.c:1646  */
     break;
 
   case 37:
-#line 389 "parse.y" /* yacc.c:1646  */
+#line 380 "parse.y" /* yacc.c:1646  */
     { synerr( _("bad start condition list") ); }
-#line 1824 "parse.c" /* yacc.c:1646  */
+#line 1815 "parse.c" /* yacc.c:1646  */
     break;
 
   case 38:
-#line 393 "parse.y" /* yacc.c:1646  */
+#line 384 "parse.y" /* yacc.c:1646  */
     {
                        if ( (scnum = sclookup( nmstr )) == 0 )
                                format_pinpoint_message(
@@ -1880,11 +1866,11 @@ yyreduce:
                                        scon_stk[++scon_stk_ptr] = scnum;
                                }
                        }
-#line 1849 "parse.c" /* yacc.c:1646  */
+#line 1840 "parse.c" /* yacc.c:1646  */
     break;
 
   case 39:
-#line 419 "parse.y" /* yacc.c:1646  */
+#line 410 "parse.y" /* yacc.c:1646  */
     {
                        if ( transchar[lastst[(yyvsp[0])]] != SYM_EPSILON )
                                /* Provide final transition \now/ so it
@@ -1941,17 +1927,17 @@ yyreduce:
  insert_after(2, "</RegexSequence>");
  insert_before(0, "<RegexSequence>");
                        }
-#line 1910 "parse.c" /* yacc.c:1646  */
+#line 1901 "parse.c" /* yacc.c:1646  */
     break;
 
   case 40:
-#line 477 "parse.y" /* yacc.c:1646  */
+#line 468 "parse.y" /* yacc.c:1646  */
     { synerr( _("trailing context used twice") ); }
-#line 1916 "parse.c" /* yacc.c:1646  */
+#line 1907 "parse.c" /* yacc.c:1646  */
     break;
 
   case 41:
-#line 480 "parse.y" /* yacc.c:1646  */
+#line 471 "parse.y" /* yacc.c:1646  */
     {
                        headcnt = 0;
                        trailcnt = 1;
@@ -1999,11 +1985,11 @@ yyreduce:
  insert_before(0, "<RegexGroup>");
  insert_before(0, "<RegexSequence>");
                        }
-#line 1968 "parse.c" /* yacc.c:1646  */
+#line 1959 "parse.c" /* yacc.c:1646  */
     break;
 
   case 42:
-#line 529 "parse.y" /* yacc.c:1646  */
+#line 520 "parse.y" /* yacc.c:1646  */
     {
                        (yyval) = (yyvsp[0]);
 
@@ -2020,28 +2006,28 @@ yyreduce:
  insert_after(0, "</RegexGroup>");
  insert_before(0, "<RegexGroup>");
                        }
-#line 1989 "parse.c" /* yacc.c:1646  */
+#line 1980 "parse.c" /* yacc.c:1646  */
     break;
 
   case 43:
-#line 549 "parse.y" /* yacc.c:1646  */
+#line 540 "parse.y" /* yacc.c:1646  */
     {
                        varlength = true;
                        (yyval) = mkor( (yyvsp[-2]), (yyvsp[0]) );
  insert_after(2, "</RegexOr>");
  insert_before(0, "<RegexOr>");
                        }
-#line 2000 "parse.c" /* yacc.c:1646  */
+#line 1991 "parse.c" /* yacc.c:1646  */
     break;
 
   case 44:
-#line 557 "parse.y" /* yacc.c:1646  */
+#line 548 "parse.y" /* yacc.c:1646  */
     { (yyval) = (yyvsp[0]); }
-#line 2006 "parse.c" /* yacc.c:1646  */
+#line 1997 "parse.c" /* yacc.c:1646  */
     break;
 
   case 45:
-#line 562 "parse.y" /* yacc.c:1646  */
+#line 553 "parse.y" /* yacc.c:1646  */
     {
                        /* This rule is written separately so the
                         * reduction will occur before the trailing
@@ -2068,11 +2054,11 @@ yyreduce:
  insert_after(0, "</RegexGroup>");
  insert_before(0, "<RegexGroup>");
                        }
-#line 2037 "parse.c" /* yacc.c:1646  */
+#line 2028 "parse.c" /* yacc.c:1646  */
     break;
 
   case 46:
-#line 591 "parse.y" /* yacc.c:1646  */
+#line 582 "parse.y" /* yacc.c:1646  */
     {
                        /* This is where concatenation of adjacent patterns
                         * gets done.
@@ -2081,17 +2067,17 @@ yyreduce:
  insert_after(1, "</RegexSequence>");
  insert_before(0, "<RegexSequence>");
                        }
-#line 2050 "parse.c" /* yacc.c:1646  */
+#line 2041 "parse.c" /* yacc.c:1646  */
     break;
 
   case 47:
-#line 601 "parse.y" /* yacc.c:1646  */
+#line 592 "parse.y" /* yacc.c:1646  */
     { (yyval) = (yyvsp[0]); }
-#line 2056 "parse.c" /* yacc.c:1646  */
+#line 2047 "parse.c" /* yacc.c:1646  */
     break;
 
   case 48:
-#line 604 "parse.y" /* yacc.c:1646  */
+#line 595 "parse.y" /* yacc.c:1646  */
     {
                        varlength = true;
 
@@ -2121,11 +2107,11 @@ yyreduce:
  sprintf(piece_temp, "<RegexRepeat count0=\"%d\" count1=\"%d\">", (yyvsp[-3]), (yyvsp[-1]));
  insert_before(0, piece_temp);
                        }
-#line 2090 "parse.c" /* yacc.c:1646  */
+#line 2081 "parse.c" /* yacc.c:1646  */
     break;
 
   case 49:
-#line 635 "parse.y" /* yacc.c:1646  */
+#line 626 "parse.y" /* yacc.c:1646  */
     {
                        varlength = true;
 
@@ -2141,11 +2127,11 @@ yyreduce:
  sprintf(piece_temp, "<RegexRepeat count0=\"%d\" count1=\"-1\">", (yyvsp[-2]));
  insert_before(0, piece_temp);
                        }
-#line 2110 "parse.c" /* yacc.c:1646  */
+#line 2101 "parse.c" /* yacc.c:1646  */
     break;
 
   case 50:
-#line 652 "parse.y" /* yacc.c:1646  */
+#line 643 "parse.y" /* yacc.c:1646  */
     {
                        /* The series could be something like "(foo)",
                         * in which case we have no idea what its length
@@ -2167,11 +2153,11 @@ yyreduce:
  sprintf(piece_temp, "<RegexRepeat count0=\"%d\" count1=\"%d\">", (yyvsp[-1]), (yyvsp[-1]));
  insert_before(0, piece_temp);
                        }
-#line 2136 "parse.c" /* yacc.c:1646  */
+#line 2127 "parse.c" /* yacc.c:1646  */
     break;
 
   case 51:
-#line 677 "parse.y" /* yacc.c:1646  */
+#line 668 "parse.y" /* yacc.c:1646  */
     {
                        varlength = true;
 
@@ -2179,33 +2165,33 @@ yyreduce:
  insert_after(1, "</RegexRepeat>");
  insert_before(0, "<RegexRepeat count0=\"0\" count1=\"-1\">");
                        }
-#line 2148 "parse.c" /* yacc.c:1646  */
+#line 2139 "parse.c" /* yacc.c:1646  */
     break;
 
   case 52:
-#line 686 "parse.y" /* yacc.c:1646  */
+#line 677 "parse.y" /* yacc.c:1646  */
     {
                        varlength = true;
                        (yyval) = mkposcl( (yyvsp[-1]) );
  insert_after(1, "</RegexRepeat>");
  insert_before(0, "<RegexRepeat count0=\"1\" count1=\"-1\">");
                        }
-#line 2159 "parse.c" /* yacc.c:1646  */
+#line 2150 "parse.c" /* yacc.c:1646  */
     break;
 
   case 53:
-#line 694 "parse.y" /* yacc.c:1646  */
+#line 685 "parse.y" /* yacc.c:1646  */
     {
                        varlength = true;
                        (yyval) = mkopt( (yyvsp[-1]) );
  insert_after(1, "</RegexRepeat>");
  insert_before(0, "<RegexRepeat count0=\"0\" count1=\"1\">");
                        }
-#line 2170 "parse.c" /* yacc.c:1646  */
+#line 2161 "parse.c" /* yacc.c:1646  */
     break;
 
   case 54:
-#line 702 "parse.y" /* yacc.c:1646  */
+#line 693 "parse.y" /* yacc.c:1646  */
     {
                        varlength = true;
 
@@ -2235,11 +2221,11 @@ yyreduce:
  sprintf(piece_temp, "<RegexRepeat count0=\"%d\" count1=\"%d\">", (yyvsp[-3]), (yyvsp[-1]));
  insert_before(0, piece_temp);
                        }
-#line 2204 "parse.c" /* yacc.c:1646  */
+#line 2195 "parse.c" /* yacc.c:1646  */
     break;
 
   case 55:
-#line 733 "parse.y" /* yacc.c:1646  */
+#line 724 "parse.y" /* yacc.c:1646  */
     {
                        varlength = true;
 
@@ -2255,11 +2241,11 @@ yyreduce:
  sprintf(piece_temp, "<RegexRepeat count0=\"%d\" count1=\"-1\">", (yyvsp[-2]));
  insert_before(0, piece_temp);
                        }
-#line 2224 "parse.c" /* yacc.c:1646  */
+#line 2215 "parse.c" /* yacc.c:1646  */
     break;
 
   case 56:
-#line 750 "parse.y" /* yacc.c:1646  */
+#line 741 "parse.y" /* yacc.c:1646  */
     {
                        /* The singleton could be something like "(foo)",
                         * in which case we have no idea what its length
@@ -2280,11 +2266,11 @@ yyreduce:
  sprintf(piece_temp, "<RegexRepeat count0=\"%d\" count1=\"%d\">", (yyvsp[-1]), (yyvsp[-1]));
  insert_before(0, piece_temp);
                        }
-#line 2249 "parse.c" /* yacc.c:1646  */
+#line 2240 "parse.c" /* yacc.c:1646  */
     break;
 
   case 57:
-#line 772 "parse.y" /* yacc.c:1646  */
+#line 763 "parse.y" /* yacc.c:1646  */
     {
                        if ( ! madeany )
                                {
@@ -2325,11 +2311,11 @@ yyreduce:
  insert_before(0, "<RegexCharacter char_set=\"0 10 11 256\">");
  }
                        }
-#line 2294 "parse.c" /* yacc.c:1646  */
+#line 2285 "parse.c" /* yacc.c:1646  */
     break;
 
   case 58:
-#line 814 "parse.y" /* yacc.c:1646  */
+#line 805 "parse.y" /* yacc.c:1646  */
     {
                                /* Sort characters for fast searching.
                                 */
@@ -2346,11 +2332,11 @@ yyreduce:
 
                        (yyval) = mkstate( -(yyvsp[0]) );
                        }
-#line 2315 "parse.c" /* yacc.c:1646  */
+#line 2306 "parse.c" /* yacc.c:1646  */
     break;
 
   case 59:
-#line 832 "parse.y" /* yacc.c:1646  */
+#line 823 "parse.y" /* yacc.c:1646  */
     {
                        ++rulelen;
 
@@ -2359,26 +2345,26 @@ yyreduce:
 
                        (yyval) = mkstate( -(yyvsp[0]) );
                        }
-#line 2328 "parse.c" /* yacc.c:1646  */
+#line 2319 "parse.c" /* yacc.c:1646  */
     break;
 
   case 60:
-#line 842 "parse.y" /* yacc.c:1646  */
+#line 833 "parse.y" /* yacc.c:1646  */
     { (yyval) = (yyvsp[-1]); }
-#line 2334 "parse.c" /* yacc.c:1646  */
+#line 2325 "parse.c" /* yacc.c:1646  */
     break;
 
   case 61:
-#line 845 "parse.y" /* yacc.c:1646  */
+#line 836 "parse.y" /* yacc.c:1646  */
     { (yyval) = (yyvsp[-1]); /*}*/
  insert_after(2, "</RegexGroup>");
  insert_before(0, "<RegexGroup>");
  }
-#line 2343 "parse.c" /* yacc.c:1646  */
+#line 2334 "parse.c" /* yacc.c:1646  */
     break;
 
   case 62:
-#line 851 "parse.y" /* yacc.c:1646  */
+#line 842 "parse.y" /* yacc.c:1646  */
     {
                        ++rulelen;
 
@@ -2391,48 +2377,48 @@ yyreduce:
             else
                 (yyval) = mkstate( (yyvsp[0]) );
                        }
-#line 2360 "parse.c" /* yacc.c:1646  */
+#line 2351 "parse.c" /* yacc.c:1646  */
     break;
 
   case 63:
-#line 865 "parse.y" /* yacc.c:1646  */
+#line 856 "parse.y" /* yacc.c:1646  */
     { (yyval) = ccl_set_diff  ((yyvsp[-2]), (yyvsp[0])); /*}*/
  insert_after(2, "</RegexCharacterAnd>");
  insert_after(2, "</RegexCharacterNot>");
  insert_before(2, "<RegexCharacterNot>");
  insert_before(0, "<RegexCharacterAnd>");
  }
-#line 2371 "parse.c" /* yacc.c:1646  */
+#line 2362 "parse.c" /* yacc.c:1646  */
     break;
 
   case 64:
-#line 871 "parse.y" /* yacc.c:1646  */
+#line 862 "parse.y" /* yacc.c:1646  */
     { (yyval) = ccl_set_union ((yyvsp[-2]), (yyvsp[0])); /*}*/
  insert_after(2, "</RegexCharacterOr>");
  insert_before(0, "<RegexCharacterOr>");
  }
-#line 2380 "parse.c" /* yacc.c:1646  */
+#line 2371 "parse.c" /* yacc.c:1646  */
     break;
 
   case 66:
-#line 880 "parse.y" /* yacc.c:1646  */
+#line 871 "parse.y" /* yacc.c:1646  */
     { (yyval) = (yyvsp[-1]); }
-#line 2386 "parse.c" /* yacc.c:1646  */
+#line 2377 "parse.c" /* yacc.c:1646  */
     break;
 
   case 67:
-#line 883 "parse.y" /* yacc.c:1646  */
+#line 874 "parse.y" /* yacc.c:1646  */
     {
                        cclnegate( (yyvsp[-1]) );
                        (yyval) = (yyvsp[-1]);
  insert_after(2, "</RegexCharacterNot>");
  insert_before(1, "<RegexCharacterNot>");
                        }
-#line 2397 "parse.c" /* yacc.c:1646  */
+#line 2388 "parse.c" /* yacc.c:1646  */
     break;
 
   case 68:
-#line 892 "parse.y" /* yacc.c:1646  */
+#line 883 "parse.y" /* yacc.c:1646  */
     {
 
                        if (sf_case_ins())
@@ -2496,11 +2482,11 @@ yyreduce:
  insert_before(1, piece_temp);
  insert_before(0, "<RegexCharacterOr>");
                        }
-#line 2465 "parse.c" /* yacc.c:1646  */
+#line 2456 "parse.c" /* yacc.c:1646  */
     break;
 
   case 69:
-#line 957 "parse.y" /* yacc.c:1646  */
+#line 948 "parse.y" /* yacc.c:1646  */
     {
                        ccladd( (yyvsp[-1]), (yyvsp[0]) );
                        cclsorted = cclsorted && ((yyvsp[0]) > lastchar);
@@ -2522,11 +2508,11 @@ yyreduce:
  insert_before(1, piece_temp);
  insert_before(0, "<RegexCharacterOr>");
                        }
-#line 2491 "parse.c" /* yacc.c:1646  */
+#line 2482 "parse.c" /* yacc.c:1646  */
     break;
 
   case 70:
-#line 980 "parse.y" /* yacc.c:1646  */
+#line 971 "parse.y" /* yacc.c:1646  */
     {
                        /* Too hard to properly maintain cclsorted. */
                        cclsorted = false;
@@ -2534,76 +2520,76 @@ yyreduce:
  insert_after(1, "</RegexCharacterOr>");
  insert_before(0, "<RegexCharacterOr>");
                        }
-#line 2503 "parse.c" /* yacc.c:1646  */
+#line 2494 "parse.c" /* yacc.c:1646  */
     break;
 
   case 71:
-#line 989 "parse.y" /* yacc.c:1646  */
+#line 980 "parse.y" /* yacc.c:1646  */
     {
                        cclsorted = true;
                        lastchar = 0;
                        currccl = (yyval) = cclinit();
  insert_before(0, "<RegexCharacter char_set=\"\" />");
                        }
-#line 2514 "parse.c" /* yacc.c:1646  */
+#line 2505 "parse.c" /* yacc.c:1646  */
     break;
 
   case 72:
-#line 998 "parse.y" /* yacc.c:1646  */
+#line 989 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(isalnum); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"48 58 65 91 97 123\">");
  }
-#line 2523 "parse.c" /* yacc.c:1646  */
+#line 2514 "parse.c" /* yacc.c:1646  */
     break;
 
   case 73:
-#line 1002 "parse.y" /* yacc.c:1646  */
+#line 993 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(isalpha); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"65 91 97 123\">");
  }
-#line 2532 "parse.c" /* yacc.c:1646  */
+#line 2523 "parse.c" /* yacc.c:1646  */
     break;
 
   case 74:
-#line 1006 "parse.y" /* yacc.c:1646  */
+#line 997 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(IS_BLANK); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"9 14 32 33\">");
  }
-#line 2541 "parse.c" /* yacc.c:1646  */
+#line 2532 "parse.c" /* yacc.c:1646  */
     break;
 
   case 75:
-#line 1010 "parse.y" /* yacc.c:1646  */
+#line 1001 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(iscntrl); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 32\">");
  }
-#line 2550 "parse.c" /* yacc.c:1646  */
+#line 2541 "parse.c" /* yacc.c:1646  */
     break;
 
   case 76:
-#line 1014 "parse.y" /* yacc.c:1646  */
+#line 1005 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(isdigit); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"48 58\">");
  }
-#line 2559 "parse.c" /* yacc.c:1646  */
+#line 2550 "parse.c" /* yacc.c:1646  */
     break;
 
   case 77:
-#line 1018 "parse.y" /* yacc.c:1646  */
+#line 1009 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(isgraph); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"33 127\">");
  }
-#line 2568 "parse.c" /* yacc.c:1646  */
+#line 2559 "parse.c" /* yacc.c:1646  */
     break;
 
   case 78:
-#line 1022 "parse.y" /* yacc.c:1646  */
+#line 1013 "parse.y" /* yacc.c:1646  */
     { 
                           CCL_EXPR(islower);
                           if (sf_case_ins())
@@ -2618,47 +2604,47 @@ yyreduce:
  insert_before(0, "<RegexCharacter char_set=\"97 123\">");
  }
                         }
-#line 2587 "parse.c" /* yacc.c:1646  */
+#line 2578 "parse.c" /* yacc.c:1646  */
     break;
 
   case 79:
-#line 1036 "parse.y" /* yacc.c:1646  */
+#line 1027 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(isprint); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"32 127\">");
  }
-#line 2596 "parse.c" /* yacc.c:1646  */
+#line 2587 "parse.c" /* yacc.c:1646  */
     break;
 
   case 80:
-#line 1040 "parse.y" /* yacc.c:1646  */
+#line 1031 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(ispunct); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"33 48 58 65 91 97 123 127\">");
  }
-#line 2605 "parse.c" /* yacc.c:1646  */
+#line 2596 "parse.c" /* yacc.c:1646  */
     break;
 
   case 81:
-#line 1044 "parse.y" /* yacc.c:1646  */
+#line 1035 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(isspace); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"32 33\">");
  }
-#line 2614 "parse.c" /* yacc.c:1646  */
+#line 2605 "parse.c" /* yacc.c:1646  */
     break;
 
   case 82:
-#line 1048 "parse.y" /* yacc.c:1646  */
+#line 1039 "parse.y" /* yacc.c:1646  */
     { CCL_EXPR(isxdigit); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"48 58 65 71 97 103\">");
  }
-#line 2623 "parse.c" /* yacc.c:1646  */
+#line 2614 "parse.c" /* yacc.c:1646  */
     break;
 
   case 83:
-#line 1052 "parse.y" /* yacc.c:1646  */
+#line 1043 "parse.y" /* yacc.c:1646  */
     {
                     CCL_EXPR(isupper);
                     if (sf_case_ins())
@@ -2673,101 +2659,101 @@ yyreduce:
  insert_before(0, "<RegexCharacter char_set=\"65 91\">");
  }
                                }
-#line 2642 "parse.c" /* yacc.c:1646  */
+#line 2633 "parse.c" /* yacc.c:1646  */
     break;
 
   case 84:
-#line 1067 "parse.y" /* yacc.c:1646  */
+#line 1058 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(isalnum); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 48 58 65 91 97 123 256\">");
  }
-#line 2651 "parse.c" /* yacc.c:1646  */
+#line 2642 "parse.c" /* yacc.c:1646  */
     break;
 
   case 85:
-#line 1071 "parse.y" /* yacc.c:1646  */
+#line 1062 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(isalpha); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 65 91 97 123 256\">");
  }
-#line 2660 "parse.c" /* yacc.c:1646  */
+#line 2651 "parse.c" /* yacc.c:1646  */
     break;
 
   case 86:
-#line 1075 "parse.y" /* yacc.c:1646  */
+#line 1066 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(IS_BLANK); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 9 14 32 33 256\">");
  }
-#line 2669 "parse.c" /* yacc.c:1646  */
+#line 2660 "parse.c" /* yacc.c:1646  */
     break;
 
   case 87:
-#line 1079 "parse.y" /* yacc.c:1646  */
+#line 1070 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(iscntrl); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"32 256\">");
  }
-#line 2678 "parse.c" /* yacc.c:1646  */
+#line 2669 "parse.c" /* yacc.c:1646  */
     break;
 
   case 88:
-#line 1083 "parse.y" /* yacc.c:1646  */
+#line 1074 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(isdigit); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 48 58 256\">");
  }
-#line 2687 "parse.c" /* yacc.c:1646  */
+#line 2678 "parse.c" /* yacc.c:1646  */
     break;
 
   case 89:
-#line 1087 "parse.y" /* yacc.c:1646  */
+#line 1078 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(isgraph); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 33 127 256\">");
  }
-#line 2696 "parse.c" /* yacc.c:1646  */
+#line 2687 "parse.c" /* yacc.c:1646  */
     break;
 
   case 90:
-#line 1091 "parse.y" /* yacc.c:1646  */
+#line 1082 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(isprint); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 32 127 256\">");
  }
-#line 2705 "parse.c" /* yacc.c:1646  */
+#line 2696 "parse.c" /* yacc.c:1646  */
     break;
 
   case 91:
-#line 1095 "parse.y" /* yacc.c:1646  */
+#line 1086 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(ispunct); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 33 48 58 65 91 97 123 127 256\">");
  }
-#line 2714 "parse.c" /* yacc.c:1646  */
+#line 2705 "parse.c" /* yacc.c:1646  */
     break;
 
   case 92:
-#line 1099 "parse.y" /* yacc.c:1646  */
+#line 1090 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(isspace); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 32 33 256\">");
  }
-#line 2723 "parse.c" /* yacc.c:1646  */
+#line 2714 "parse.c" /* yacc.c:1646  */
     break;
 
   case 93:
-#line 1103 "parse.y" /* yacc.c:1646  */
+#line 1094 "parse.y" /* yacc.c:1646  */
     { CCL_NEG_EXPR(isxdigit); /*}*/
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 48 58 65 71 97 103 256\">");
  }
-#line 2732 "parse.c" /* yacc.c:1646  */
+#line 2723 "parse.c" /* yacc.c:1646  */
     break;
 
   case 94:
-#line 1107 "parse.y" /* yacc.c:1646  */
+#line 1098 "parse.y" /* yacc.c:1646  */
     { 
                                if ( sf_case_ins() )
                                        lwarn(_("[:^lower:] is ambiguous in case insensitive scanner"));
@@ -2776,11 +2762,11 @@ yyreduce:
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 97 123 256\">");
                                }
-#line 2745 "parse.c" /* yacc.c:1646  */
+#line 2736 "parse.c" /* yacc.c:1646  */
     break;
 
   case 95:
-#line 1115 "parse.y" /* yacc.c:1646  */
+#line 1106 "parse.y" /* yacc.c:1646  */
     {
                                if ( sf_case_ins() )
                                        lwarn(_("[:^upper:] ambiguous in case insensitive scanner"));
@@ -2789,11 +2775,11 @@ yyreduce:
  insert_after(0, "</RegexCharacter>");
  insert_before(0, "<RegexCharacter char_set=\"0 65 91 256\">");
                                }
-#line 2758 "parse.c" /* yacc.c:1646  */
+#line 2749 "parse.c" /* yacc.c:1646  */
     break;
 
   case 96:
-#line 1126 "parse.y" /* yacc.c:1646  */
+#line 1117 "parse.y" /* yacc.c:1646  */
     {
                        if ( (yyvsp[0]) == nlch )
                                rule_has_nl[num_rules] = true;
@@ -2809,19 +2795,19 @@ yyreduce:
  insert_after(1, "</RegexSequence>");
  insert_before(0, "<RegexSequence>");
                        }
-#line 2778 "parse.c" /* yacc.c:1646  */
+#line 2769 "parse.c" /* yacc.c:1646  */
     break;
 
   case 97:
-#line 1143 "parse.y" /* yacc.c:1646  */
+#line 1134 "parse.y" /* yacc.c:1646  */
     { (yyval) = mkstate( SYM_EPSILON ); /*}*/
  insert_before(0, "<RegexEmpty />");
  }
-#line 2786 "parse.c" /* yacc.c:1646  */
+#line 2777 "parse.c" /* yacc.c:1646  */
     break;
 
 
-#line 2790 "parse.c" /* yacc.c:1646  */
+#line 2781 "parse.c" /* yacc.c:1646  */
       default: break;
     }
  int i;
@@ -3066,7 +3052,7 @@ yyreturn:
 #endif
   return yyresult;
 }
-#line 1149 "parse.y" /* yacc.c:1906  */
+#line 1140 "parse.y" /* yacc.c:1906  */
 
 
 
index 2e470e2..1d5329f 100644 (file)
@@ -1,12 +1,13 @@
---- parse.c.orig       2018-06-12 19:59:40.261566552 +1000
-+++ parse.c    2018-06-12 20:06:49.217574953 +1000
-@@ -1245,6 +1245,30 @@
+--- parse.c.orig       2018-06-23 10:24:45.780660653 +1000
++++ parse.c    2018-06-23 10:51:33.648592609 +1000
+@@ -1245,6 +1245,25 @@
  | yyparse.  |
  `----------*/
  
 +extern char piece_temp[];
 +extern char *piece[];
 +extern int piece0, piece1;
++void insert_piece(int n, const void *str);
 +int piece2, piece3;
 +static void peek(void) {
 + if (yychar == YYEMPTY)
 + piece0 += 2;
 + piece1 += 2;
 +}
-+static void insert_piece(int n, const char *str) {
-+ n += piece2;
-+ memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
-+ piece[n] = strdup(str);
-+ ++piece0;
-+ ++piece1;
-+ ++piece3;
-+}
-+#define insert_before(n, str) insert_piece((n) * 2, str);
-+#define insert_after(n, str) insert_piece((n) * 2 + 1, str);
++#define insert_before(n, str) \
++ do { insert_piece(piece2 + (n) * 2, (str)); ++piece3; } while (0)
++#define insert_after(n, str) \
++ do { insert_piece(piece2 + (n) * 2 + 1, (str)); ++piece3; } while (0)
  int
  yyparse (void)
  {
-@@ -1465,6 +1489,17 @@
+@@ -1465,6 +1484,17 @@
  yyreduce:
    /* yyn is the number of a rule to reduce with.  */
    yylen = yyr2[yyn];
@@ -49,8 +44,8 @@
  
    /* If YYLEN is nonzero, implement the default value of the action:
       '$$ = $1'.
-@@ -2789,6 +2824,23 @@
- #line 2790 "parse.c" /* yacc.c:1646  */
+@@ -2780,6 +2810,23 @@
+ #line 2781 "parse.c" /* yacc.c:1646  */
        default: break;
      }
 + int i;
index e38bf3c..d7813f1 100644 (file)
@@ -141,15 +141,6 @@ goal               :  initlex sect1 sect1end sect2 initforrule
                                add_action( "ECHO" );
 
                        add_action( ";\n\tYY_BREAK]]\n" );
- peek();
- insert_before(5, "</root>");
- insert_before(5, "</Sect3>");
- insert_after(3, "<Sect3>");
- insert_after(3, "</Sect2>");
- insert_before(3, "<Sect2>");
- insert_after(1, "</Sect1>");
- insert_before(1, "<Sect1>");
- insert_before(0, "<root>");
                        }
                ;
 
index 2b06802..75f7f60 100644 (file)
@@ -27,6 +27,12 @@ char piece_temp[100];
 char *piece[10000];
 int piece0;
 int piece1;
+void insert_piece(int n, const char *str) {
+ memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
+ piece[n] = strdup(str);
+ ++piece0;
+ ++piece1;
+}
 
 /* flex integer type definitions */
 
@@ -2234,7 +2240,7 @@ extern int yylex (void);
 
 /** The main scanner function which does all the work.
  */
-static int real_yylex();
+static int real_yylex(void);
 static void piece_esc(const char *p, size_t n) {
  size_t i, j = 0;
  for (i = 0; i < n; ++i)
@@ -2298,7 +2304,6 @@ YY_DECL
  piece_pack();
 #if 1
  piece_esc(yytext, strlen(yytext));
- ++piece0;
 #else
  size_t n = strlen(yytext);
  if (n) {
@@ -2306,17 +2311,16 @@ YY_DECL
   piece[piece1++] = strdup(piece_temp);
   piece_esc(yytext, n);
   piece[piece1++] = strdup("</token>");
-  piece_pack();
  }
  else {
   sprintf(piece_temp, "<token value=\"%d\" />", result);
   piece[piece1++] = strdup(piece_temp);
-  ++piece0;
  }
 #endif
+ piece_pack();
  return result;
 }
-static int real_yylex()
+static int real_yylex(void)
 {
        register yy_state_type yy_current_state;
        register char *yy_cp, *yy_bp;
@@ -2361,7 +2365,12 @@ static int real_yylex()
                yy_load_buffer_state( );
                }
 
+#if 1
+ /* we do this so that "continue;" in an action works correctly */
+ for (; ; piece_esc(yytext, yy_c_buf_p - yytext))
+#else
        while ( 1 )             /* loops until end-of-file is reached */
+#endif
                {
                (yy_more_len) = 0;
                if ( (yy_more_flag) )
@@ -2485,48 +2494,64 @@ YY_RULE_SETUP
                        mark_defs1();
                        line_directive_out(NULL, 1);
                        BEGIN(SECT2PROLOG);
+#if 1
+ piece[piece1++] = strdup("</Sect1>");
+ piece_pack();
+#if 1
+ piece_esc(yytext, strlen(yytext));
+#else
+ sprintf(piece_temp, "<token value=\"%d\">", SECTEND);
+ piece[piece1++] = strdup(piece_temp);
+ piece_esc(yytext, strlen(yytext));
+ piece[piece1++] = strdup("</token>");
+#endif
+ piece[piece1++] = strdup("<Sect2>");
+ piece_pack();
+ return ~SECTEND;
+#else
                        return SECTEND;
+#endif
                        }
        YY_BREAK
 case 11:
 /* rule 11 can match eol */
 YY_RULE_SETUP
-#line 202 "scan.l"
+#line 218 "scan.l"
 yytext_is_array = false; ++linenum;
        YY_BREAK
 case 12:
 /* rule 12 can match eol */
 YY_RULE_SETUP
-#line 203 "scan.l"
+#line 219 "scan.l"
 yytext_is_array = true; ++linenum;
        YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 205 "scan.l"
+#line 221 "scan.l"
 BEGIN(OPTION); return TOK_OPTION;
        YY_BREAK
 case 14:
 /* rule 14 can match eol */
 YY_RULE_SETUP
-#line 207 "scan.l"
+#line 223 "scan.l"
 ++linenum; /* ignore */
        YY_BREAK
 case 15:
 /* rule 15 can match eol */
 YY_RULE_SETUP
-#line 208 "scan.l"
+#line 224 "scan.l"
 ++linenum;     /* ignore */
        YY_BREAK
 /* xgettext: no-c-format */
 case 16:
 /* rule 16 can match eol */
 YY_RULE_SETUP
-#line 211 "scan.l"
+#line 227 "scan.l"
 synerr( _( "unrecognized '%' directive" ) );
        YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 213 "scan.l"
+#line 229 "scan.l"
 {
                        if(yyleng < MAXLINE)
                         {
@@ -2544,51 +2569,51 @@ YY_RULE_SETUP
        YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 228 "scan.l"
+#line 244 "scan.l"
 RETURNNAME;
        YY_BREAK
 case 19:
 /* rule 19 can match eol */
 YY_RULE_SETUP
-#line 229 "scan.l"
+#line 245 "scan.l"
 ++linenum; /* allows blank lines in section 1 */
        YY_BREAK
 case 20:
 /* rule 20 can match eol */
 YY_RULE_SETUP
-#line 230 "scan.l"
+#line 246 "scan.l"
 ACTION_ECHO; ++linenum; /* maybe end of comment line */
        YY_BREAK
 
 /* */
 case 21:
 YY_RULE_SETUP
-#line 235 "scan.l"
+#line 251 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 236 "scan.l"
+#line 252 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 23:
 /* rule 23 can match eol */
 YY_RULE_SETUP
-#line 238 "scan.l"
+#line 254 "scan.l"
 ++linenum; ACTION_ECHO;
        YY_BREAK
 
 
 case 24:
 YY_RULE_SETUP
-#line 241 "scan.l"
+#line 257 "scan.l"
 add_action("*/]""]"); yy_pop_state();
        YY_BREAK
 
 
 case 25:
 YY_RULE_SETUP
-#line 244 "scan.l"
+#line 260 "scan.l"
 ACTION_ECHO; yy_pop_state();
        YY_BREAK
 
@@ -2596,41 +2621,41 @@ ACTION_ECHO; yy_pop_state();
 /* This is the same as COMMENT, but is discarded rather than output. */
 case 26:
 YY_RULE_SETUP
-#line 249 "scan.l"
+#line 265 "scan.l"
 yy_pop_state();
        YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 250 "scan.l"
+#line 266 "scan.l"
 ;
        YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 251 "scan.l"
+#line 267 "scan.l"
 ;
        YY_BREAK
 case 29:
 /* rule 29 can match eol */
 YY_RULE_SETUP
-#line 252 "scan.l"
+#line 268 "scan.l"
 ++linenum;
        YY_BREAK
 
 
 case 30:
 YY_RULE_SETUP
-#line 256 "scan.l"
+#line 272 "scan.l"
 yy_pop_state();
        YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 257 "scan.l"
+#line 273 "scan.l"
 ;
        YY_BREAK
 case 32:
 /* rule 32 can match eol */
 YY_RULE_SETUP
-#line 258 "scan.l"
+#line 274 "scan.l"
 ++linenum;
        YY_BREAK
 
@@ -2638,17 +2663,17 @@ YY_RULE_SETUP
 case 33:
 /* rule 33 can match eol */
 YY_RULE_SETUP
-#line 262 "scan.l"
+#line 278 "scan.l"
 yy_pop_state();
        YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 263 "scan.l"
+#line 279 "scan.l"
 linenum = myctoi( yytext );
        YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 265 "scan.l"
+#line 281 "scan.l"
 {
                        free(infilename);
                        infilename = xstrdup(yytext + 1);
@@ -2657,19 +2682,19 @@ YY_RULE_SETUP
        YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 270 "scan.l"
+#line 286 "scan.l"
 /* ignore spurious characters */
        YY_BREAK
 
 
 case 37:
 YY_RULE_SETUP
-#line 273 "scan.l"
+#line 289 "scan.l"
 ACTION_ECHO_QSTART;
        YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 274 "scan.l"
+#line 290 "scan.l"
 ACTION_ECHO_QEND;
        YY_BREAK
 
@@ -2677,23 +2702,23 @@ ACTION_ECHO_QEND;
 case 39:
 /* rule 39 can match eol */
 YY_RULE_SETUP
-#line 278 "scan.l"
+#line 294 "scan.l"
 ++linenum; END_CODEBLOCK;
        YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 279 "scan.l"
+#line 295 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 280 "scan.l"
+#line 296 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 42:
 /* rule 42 can match eol */
 YY_RULE_SETUP
-#line 281 "scan.l"
+#line 297 "scan.l"
 {
                        ++linenum;
                        ACTION_ECHO;
@@ -2704,7 +2729,7 @@ YY_RULE_SETUP
 
 case 43:
 YY_RULE_SETUP
-#line 289 "scan.l"
+#line 305 "scan.l"
 {
                 if( --brace_depth == 0){
                     /* TODO: Matched. */
@@ -2715,7 +2740,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 297 "scan.l"
+#line 313 "scan.l"
 {
                 brace_depth++;
                 buf_strnappend(&top_buf, yytext, yyleng);
@@ -2724,7 +2749,7 @@ YY_RULE_SETUP
 case 45:
 /* rule 45 can match eol */
 YY_RULE_SETUP
-#line 302 "scan.l"
+#line 318 "scan.l"
 {
                 ++linenum;
                 buf_strnappend(&top_buf, yytext, yyleng);
@@ -2732,23 +2757,23 @@ YY_RULE_SETUP
        YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 307 "scan.l"
+#line 323 "scan.l"
 buf_strnappend(&top_buf, escaped_qstart, (int) strlen(escaped_qstart));
        YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 308 "scan.l"
+#line 324 "scan.l"
 buf_strnappend(&top_buf, escaped_qend, (int) strlen(escaped_qend));
        YY_BREAK
 case 48:
 YY_RULE_SETUP
-#line 309 "scan.l"
+#line 325 "scan.l"
 {
        buf_strnappend(&top_buf, yytext, yyleng);
     }
        YY_BREAK
 case YY_STATE_EOF(CODEBLOCK_MATCH_BRACE):
-#line 313 "scan.l"
+#line 329 "scan.l"
 {
                 linenum = brace_start_line;
                 synerr(_("Unmatched '{'"));
@@ -2759,12 +2784,12 @@ case YY_STATE_EOF(CODEBLOCK_MATCH_BRACE):
 
 case 49:
 YY_RULE_SETUP
-#line 322 "scan.l"
+#line 338 "scan.l"
 /* separates name and definition */
        YY_BREAK
 case 50:
 YY_RULE_SETUP
-#line 324 "scan.l"
+#line 340 "scan.l"
 {
                        if(yyleng < MAXLINE)
                         {
@@ -2790,7 +2815,7 @@ YY_RULE_SETUP
 case 51:
 /* rule 51 can match eol */
 YY_RULE_SETUP
-#line 346 "scan.l"
+#line 362 "scan.l"
 {
                        if ( ! didadef )
                                synerr( _( "incomplete name definition" ) );
@@ -2803,42 +2828,42 @@ YY_RULE_SETUP
 case 52:
 /* rule 52 can match eol */
 YY_RULE_SETUP
-#line 356 "scan.l"
+#line 372 "scan.l"
 ++linenum; BEGIN(INITIAL);
        YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 357 "scan.l"
+#line 373 "scan.l"
 option_sense = true;
        YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 359 "scan.l"
+#line 375 "scan.l"
 return '=';
        YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 361 "scan.l"
+#line 377 "scan.l"
 option_sense = ! option_sense;
        YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 363 "scan.l"
+#line 379 "scan.l"
 csize = option_sense ? 128 : 256;
        YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 364 "scan.l"
+#line 380 "scan.l"
 csize = option_sense ? 256 : 128;
        YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 366 "scan.l"
+#line 382 "scan.l"
 long_align = option_sense;
        YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 367 "scan.l"
+#line 383 "scan.l"
 {
                        ACTION_M4_IFDEF( "M4""_YY_ALWAYS_INTERACTIVE", option_sense );
             interactive = option_sense;
@@ -2846,64 +2871,64 @@ YY_RULE_SETUP
        YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 371 "scan.l"
+#line 387 "scan.l"
 yytext_is_array = option_sense;
        YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 372 "scan.l"
+#line 388 "scan.l"
 backing_up_report = option_sense;
        YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 373 "scan.l"
+#line 389 "scan.l"
 interactive = ! option_sense;
        YY_BREAK
 case 63:
 YY_RULE_SETUP
-#line 374 "scan.l"
+#line 390 "scan.l"
 bison_bridge_lval = option_sense;
        YY_BREAK
 case 64:
 YY_RULE_SETUP
-#line 375 "scan.l"
+#line 391 "scan.l"
 { if((bison_bridge_lloc = option_sense))
                             bison_bridge_lval = true;
                      }
        YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 378 "scan.l"
+#line 394 "scan.l"
 C_plus_plus = option_sense;
        YY_BREAK
 case 66:
 YY_RULE_SETUP
-#line 379 "scan.l"
+#line 395 "scan.l"
 sf_set_case_ins(!option_sense);
        YY_BREAK
 case 67:
 YY_RULE_SETUP
-#line 380 "scan.l"
+#line 396 "scan.l"
 sf_set_case_ins(option_sense);
        YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 381 "scan.l"
+#line 397 "scan.l"
 ddebug = option_sense;
        YY_BREAK
 case 69:
 YY_RULE_SETUP
-#line 382 "scan.l"
+#line 398 "scan.l"
 spprdflt = ! option_sense;
        YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 383 "scan.l"
+#line 399 "scan.l"
 useecs = option_sense;
        YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 384 "scan.l"
+#line 400 "scan.l"
 {
                        useecs = usemecs = false;
                        use_read = fullspd = true;
@@ -2911,7 +2936,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 72:
 YY_RULE_SETUP
-#line 388 "scan.l"
+#line 404 "scan.l"
 {
                        useecs = usemecs = false;
                        use_read = fulltbl = true;
@@ -2919,32 +2944,32 @@ YY_RULE_SETUP
        YY_BREAK
 case 73:
 YY_RULE_SETUP
-#line 392 "scan.l"
+#line 408 "scan.l"
 ACTION_IFDEF("YY_NO_INPUT", ! option_sense);
        YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 393 "scan.l"
+#line 409 "scan.l"
 interactive = option_sense;
        YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 394 "scan.l"
+#line 410 "scan.l"
 lex_compat = option_sense;
        YY_BREAK
 case 76:
 YY_RULE_SETUP
-#line 395 "scan.l"
+#line 411 "scan.l"
 posix_compat = option_sense;
        YY_BREAK
 case 77:
 YY_RULE_SETUP
-#line 396 "scan.l"
+#line 412 "scan.l"
 gen_line_dirs = option_sense;
        YY_BREAK
 case 78:
 YY_RULE_SETUP
-#line 397 "scan.l"
+#line 413 "scan.l"
 {
                        ACTION_M4_IFDEF( "M4""_YY_MAIN", option_sense);
             /* Override yywrap */
@@ -2954,12 +2979,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 79:
 YY_RULE_SETUP
-#line 403 "scan.l"
+#line 419 "scan.l"
 usemecs = option_sense;
        YY_BREAK
 case 80:
 YY_RULE_SETUP
-#line 404 "scan.l"
+#line 420 "scan.l"
 {
                        ACTION_M4_IFDEF( "M4""_YY_NEVER_INTERACTIVE", option_sense );
             interactive = !option_sense;
@@ -2967,237 +2992,237 @@ YY_RULE_SETUP
        YY_BREAK
 case 81:
 YY_RULE_SETUP
-#line 408 "scan.l"
+#line 424 "scan.l"
 performance_report += option_sense ? 1 : -1;
        YY_BREAK
 case 82:
 YY_RULE_SETUP
-#line 409 "scan.l"
+#line 425 "scan.l"
 yytext_is_array = ! option_sense;
        YY_BREAK
 case 83:
 YY_RULE_SETUP
-#line 410 "scan.l"
+#line 426 "scan.l"
 use_read = option_sense;
        YY_BREAK
 case 84:
 YY_RULE_SETUP
-#line 411 "scan.l"
+#line 427 "scan.l"
 reentrant = option_sense;
        YY_BREAK
 case 85:
 YY_RULE_SETUP
-#line 412 "scan.l"
+#line 428 "scan.l"
 reject_really_used = option_sense;
        YY_BREAK
 case 86:
 YY_RULE_SETUP
-#line 413 "scan.l"
+#line 429 "scan.l"
 ACTION_M4_IFDEF( "M4""_YY_STACK_USED", option_sense );
        YY_BREAK
 case 87:
 YY_RULE_SETUP
-#line 414 "scan.l"
+#line 430 "scan.l"
 do_stdinit = option_sense;
        YY_BREAK
 case 88:
 YY_RULE_SETUP
-#line 415 "scan.l"
+#line 431 "scan.l"
 use_stdout = option_sense;
        YY_BREAK
 case 89:
 YY_RULE_SETUP
-#line 416 "scan.l"
+#line 432 "scan.l"
 ACTION_IFDEF("YY_NO_UNISTD_H", ! option_sense);
        YY_BREAK
 case 90:
 YY_RULE_SETUP
-#line 417 "scan.l"
+#line 433 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_UNPUT", ! option_sense);
        YY_BREAK
 case 91:
 YY_RULE_SETUP
-#line 418 "scan.l"
+#line 434 "scan.l"
 printstats = option_sense;
        YY_BREAK
 case 92:
 YY_RULE_SETUP
-#line 419 "scan.l"
+#line 435 "scan.l"
 nowarn = ! option_sense;
        YY_BREAK
 case 93:
 YY_RULE_SETUP
-#line 420 "scan.l"
+#line 436 "scan.l"
 do_yylineno = option_sense; ACTION_M4_IFDEF("M4""_YY_USE_LINENO", option_sense);
        YY_BREAK
 case 94:
 YY_RULE_SETUP
-#line 421 "scan.l"
+#line 437 "scan.l"
 yymore_really_used = option_sense;
        YY_BREAK
 case 95:
 YY_RULE_SETUP
-#line 422 "scan.l"
+#line 438 "scan.l"
 do_yywrap = option_sense;
        YY_BREAK
 case 96:
 YY_RULE_SETUP
-#line 424 "scan.l"
+#line 440 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_PUSH_STATE", ! option_sense);
        YY_BREAK
 case 97:
 YY_RULE_SETUP
-#line 425 "scan.l"
+#line 441 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_POP_STATE", ! option_sense);
        YY_BREAK
 case 98:
 YY_RULE_SETUP
-#line 426 "scan.l"
+#line 442 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_TOP_STATE", ! option_sense);
        YY_BREAK
 case 99:
 YY_RULE_SETUP
-#line 428 "scan.l"
+#line 444 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BUFFER", ! option_sense);
        YY_BREAK
 case 100:
 YY_RULE_SETUP
-#line 429 "scan.l"
+#line 445 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SCAN_BYTES", ! option_sense);
        YY_BREAK
 case 101:
 YY_RULE_SETUP
-#line 430 "scan.l"
+#line 446 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SCAN_STRING", ! option_sense);
        YY_BREAK
 case 102:
 YY_RULE_SETUP
-#line 432 "scan.l"
+#line 448 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_FLEX_ALLOC", ! option_sense);
        YY_BREAK
 case 103:
 YY_RULE_SETUP
-#line 433 "scan.l"
+#line 449 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_FLEX_REALLOC", ! option_sense);
        YY_BREAK
 case 104:
 YY_RULE_SETUP
-#line 434 "scan.l"
+#line 450 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_FLEX_FREE", ! option_sense);
        YY_BREAK
 case 105:
 YY_RULE_SETUP
-#line 436 "scan.l"
+#line 452 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_DEBUG", ! option_sense);
        YY_BREAK
 case 106:
 YY_RULE_SETUP
-#line 437 "scan.l"
+#line 453 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_DEBUG", ! option_sense);
        YY_BREAK
 case 107:
 YY_RULE_SETUP
-#line 438 "scan.l"
+#line 454 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_EXTRA", ! option_sense);
        YY_BREAK
 case 108:
 YY_RULE_SETUP
-#line 439 "scan.l"
+#line 455 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_EXTRA", ! option_sense);
        YY_BREAK
 case 109:
 YY_RULE_SETUP
-#line 440 "scan.l"
+#line 456 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_LENG", ! option_sense);
        YY_BREAK
 case 110:
 YY_RULE_SETUP
-#line 441 "scan.l"
+#line 457 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_TEXT", ! option_sense);
        YY_BREAK
 case 111:
 YY_RULE_SETUP
-#line 442 "scan.l"
+#line 458 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_LINENO", ! option_sense);
        YY_BREAK
 case 112:
 YY_RULE_SETUP
-#line 443 "scan.l"
+#line 459 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_LINENO", ! option_sense);
        YY_BREAK
 case 113:
 YY_RULE_SETUP
-#line 444 "scan.l"
+#line 460 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_IN", ! option_sense);
        YY_BREAK
 case 114:
 YY_RULE_SETUP
-#line 445 "scan.l"
+#line 461 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_IN", ! option_sense);
        YY_BREAK
 case 115:
 YY_RULE_SETUP
-#line 446 "scan.l"
+#line 462 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_OUT", ! option_sense);
        YY_BREAK
 case 116:
 YY_RULE_SETUP
-#line 447 "scan.l"
+#line 463 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_OUT", ! option_sense);
        YY_BREAK
 case 117:
 YY_RULE_SETUP
-#line 448 "scan.l"
+#line 464 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_LVAL", ! option_sense);
        YY_BREAK
 case 118:
 YY_RULE_SETUP
-#line 449 "scan.l"
+#line 465 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_LVAL", ! option_sense);
        YY_BREAK
 case 119:
 YY_RULE_SETUP
-#line 450 "scan.l"
+#line 466 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_GET_LLOC", ! option_sense);
        YY_BREAK
 case 120:
 YY_RULE_SETUP
-#line 451 "scan.l"
+#line 467 "scan.l"
 ACTION_M4_IFDEF("M4""_YY_NO_SET_LLOC", ! option_sense);
        YY_BREAK
 case 121:
 YY_RULE_SETUP
-#line 453 "scan.l"
+#line 469 "scan.l"
 return TOK_EXTRA_TYPE;
        YY_BREAK
 case 122:
 YY_RULE_SETUP
-#line 454 "scan.l"
+#line 470 "scan.l"
 return TOK_OUTFILE;
        YY_BREAK
 case 123:
 YY_RULE_SETUP
-#line 455 "scan.l"
+#line 471 "scan.l"
 return TOK_PREFIX;
        YY_BREAK
 case 124:
 YY_RULE_SETUP
-#line 456 "scan.l"
+#line 472 "scan.l"
 return TOK_YYCLASS;
        YY_BREAK
 case 125:
 YY_RULE_SETUP
-#line 457 "scan.l"
+#line 473 "scan.l"
 return TOK_HEADER_FILE;
        YY_BREAK
 case 126:
 YY_RULE_SETUP
-#line 458 "scan.l"
+#line 474 "scan.l"
 return TOK_TABLES_FILE;
        YY_BREAK
 case 127:
 YY_RULE_SETUP
-#line 459 "scan.l"
+#line 475 "scan.l"
 {
                     tablesverify = option_sense;
                     if(!tablesext && option_sense)
@@ -3206,7 +3231,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 128:
 YY_RULE_SETUP
-#line 466 "scan.l"
+#line 482 "scan.l"
 {
                        if(yyleng-1 < MAXLINE)
                         {
@@ -3223,7 +3248,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 129:
 YY_RULE_SETUP
-#line 480 "scan.l"
+#line 496 "scan.l"
 {
                        format_synerr( _( "unrecognized %%option: %s" ),
                                yytext );
@@ -3234,28 +3259,28 @@ YY_RULE_SETUP
 case 130:
 /* rule 130 can match eol */
 YY_RULE_SETUP
-#line 487 "scan.l"
+#line 503 "scan.l"
 ++linenum; BEGIN(INITIAL);
        YY_BREAK
 
 case 131:
 YY_RULE_SETUP
-#line 491 "scan.l"
+#line 507 "scan.l"
 ++bracelevel; yyless( 2 );     /* eat only %{ */
        YY_BREAK
 case 132:
 YY_RULE_SETUP
-#line 492 "scan.l"
+#line 508 "scan.l"
 --bracelevel; yyless( 2 );     /* eat only %} */
        YY_BREAK
 case 133:
 YY_RULE_SETUP
-#line 494 "scan.l"
+#line 510 "scan.l"
 START_CODEBLOCK(true); /* indented code in prolog */
        YY_BREAK
 case 134:
 YY_RULE_SETUP
-#line 496 "scan.l"
+#line 512 "scan.l"
 {
         /* non-indented code */
                if ( bracelevel <= 0 ) {
@@ -3271,21 +3296,31 @@ YY_RULE_SETUP
        YY_BREAK
 case 135:
 YY_RULE_SETUP
-#line 509 "scan.l"
+#line 525 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 136:
 /* rule 136 can match eol */
 YY_RULE_SETUP
-#line 510 "scan.l"
+#line 526 "scan.l"
 ++linenum; ACTION_ECHO;
        YY_BREAK
 case YY_STATE_EOF(SECT2PROLOG):
-#line 512 "scan.l"
+#line 528 "scan.l"
 {
                        mark_prolog();
                        sectnum = 0;
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect2>");
+#if 0
+ piece[piece1++] = strdup("<token value=\"0\" />");
+#endif
+ piece_pack();
+ return ~YY_NULL;
+#else
                        yyterminate(); /* to stop the parser */
+#endif
                        }
        YY_BREAK
 
@@ -3293,12 +3328,12 @@ case YY_STATE_EOF(SECT2PROLOG):
 case 137:
 /* rule 137 can match eol */
 YY_RULE_SETUP
-#line 520 "scan.l"
+#line 546 "scan.l"
 ++linenum; /* allow blank lines in section 2 */
        YY_BREAK
 case 138:
 YY_RULE_SETUP
-#line 522 "scan.l"
+#line 548 "scan.l"
 {
                        indented_code = false;
                        doing_codeblock = true;
@@ -3310,7 +3345,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 139:
 YY_RULE_SETUP
-#line 531 "scan.l"
+#line 557 "scan.l"
 {
                         /* Allow "<" to appear in (?x) patterns. */
                         if (!sf_skip_ws())
@@ -3320,12 +3355,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 537 "scan.l"
+#line 563 "scan.l"
 return '^';
        YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 538 "scan.l"
+#line 564 "scan.l"
 BEGIN(QUOTE); return '"';
        YY_BREAK
 case 142:
@@ -3333,7 +3368,7 @@ case 142:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 539 "scan.l"
+#line 565 "scan.l"
 {
                        BEGIN(NUM);
                        if ( lex_compat || posix_compat )
@@ -3348,12 +3383,12 @@ case 143:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 546 "scan.l"
+#line 572 "scan.l"
 return '$';
        YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 548 "scan.l"
+#line 574 "scan.l"
 {
                        bracelevel = 1;
                        BEGIN(PERCENT_BRACE_ACTION);
@@ -3365,14 +3400,13 @@ YY_RULE_SETUP
 #if 1
  piece_pack();
 #if 1
- piece[piece1++] = strdup(yytext);
- ++piece0;
+ piece_esc(yytext, strlen(yytext));
 #else
  piece[piece1++] = strdup("<token value=\"10\">");
- piece[piece1++] = strdup(yytext);
+ piece_esc(yytext, strlen(yytext));
  piece[piece1++] = strdup("</token>");
- piece_pack();
 #endif
+ piece_pack();
  piece[piece1++] = strdup("<PercentBraceAction>");
  return ~'\n';
 #else
@@ -3386,7 +3420,7 @@ YY_RULE_SETUP
 case 145:
 /* rule 145 can match eol */
 YY_RULE_SETUP
-#line 576 "scan.l"
+#line 601 "scan.l"
 {
                         if (sf_skip_ws()){
                             /* We're in the middle of a (?x: ) pattern. */
@@ -3404,7 +3438,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 146:
 YY_RULE_SETUP
-#line 591 "scan.l"
+#line 616 "scan.l"
 {
 
                 if (sf_skip_ws()){
@@ -3423,12 +3457,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 147:
 YY_RULE_SETUP
-#line 607 "scan.l"
+#line 632 "scan.l"
 /* allow indented rules */ ;
        YY_BREAK
 case 148:
 YY_RULE_SETUP
-#line 609 "scan.l"
+#line 634 "scan.l"
 {
             if (sf_skip_ws()){
                 /* We're in the middle of a (?x: ) pattern. */
@@ -3449,14 +3483,13 @@ YY_RULE_SETUP
 #if 1
  piece_pack();
 #if 1
- piece[piece1++] = strdup(yytext);
- ++piece0;
+ piece_esc(yytext, strlen(yytext));
 #else
  piece[piece1++] = strdup("<token value=\"10\">");
- piece[piece1++] = strdup(yytext);
+ piece_esc(yytext, strlen(yytext));
  piece[piece1++] = strdup("</token>");
- piece_pack();
 #endif
+ piece_pack();
  piece[piece1++] = strdup("<Action>");
  return ~'\n';
 #else
@@ -3469,7 +3502,7 @@ YY_RULE_SETUP
 case 149:
 /* rule 149 can match eol */
 YY_RULE_SETUP
-#line 646 "scan.l"
+#line 670 "scan.l"
 {
             if (sf_skip_ws()){
                 /* We're in the middle of a (?x: ) pattern. */
@@ -3492,14 +3525,13 @@ YY_RULE_SETUP
 #if 1
  piece_pack();
 #if 1
- piece[piece1++] = strdup(yytext);
- ++piece0;
+ piece_esc(yytext, strlen(yytext));
 #else
  piece[piece1++] = strdup("<token value=\"10\">");
- piece[piece1++] = strdup(yytext);
+ piece_esc(yytext, strlen(yytext));
  piece[piece1++] = strdup("</token>");
- piece_pack();
 #endif
+ piece_pack();
  piece[piece1++] = strdup("<Action>");
  return ~'\n';
 #else
@@ -3510,26 +3542,41 @@ YY_RULE_SETUP
                        }
        YY_BREAK
 case 150:
-#line 686 "scan.l"
+#line 709 "scan.l"
 case 151:
 YY_RULE_SETUP
-#line 686 "scan.l"
+#line 709 "scan.l"
 return EOF_OP;
        YY_BREAK
 case 152:
 YY_RULE_SETUP
-#line 688 "scan.l"
+#line 711 "scan.l"
 {
                        sectnum = 3;
                        BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3);
                        outn("/* Begin user sect3 */");
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect2>");
+#if 1
+ piece_esc(yytext, strlen(yytext));
+#else
+ piece[piece1++] = strdup("<token value=\"0\">");
+ piece_esc(yytext, strlen(yytext));
+ piece[piece1++] = strdup("</token>");
+#endif
+ piece_pack();
+ piece[piece1++] = strdup("<Sect3>");
+ return ~YY_NULL;
+#else
                        yyterminate(); /* to stop the parser */
+#endif
 
                        }
        YY_BREAK
 case 153:
 YY_RULE_SETUP
-#line 696 "scan.l"
+#line 734 "scan.l"
 {
                        int cclval;
 
@@ -3579,12 +3626,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 154:
 YY_RULE_SETUP
-#line 742 "scan.l"
+#line 780 "scan.l"
 return CCL_OP_DIFF;
        YY_BREAK
 case 155:
 YY_RULE_SETUP
-#line 743 "scan.l"
+#line 781 "scan.l"
 return CCL_OP_UNION;
        YY_BREAK
 /* Check for :space: at the end of the rule so we don't
@@ -3594,7 +3641,7 @@ return CCL_OP_UNION;
 case 156:
 /* rule 156 can match eol */
 YY_RULE_SETUP
-#line 750 "scan.l"
+#line 788 "scan.l"
 {
                        char *nmdefptr;
             int end_is_ws, end_ch;
@@ -3649,7 +3696,7 @@ nmstr[yyleng - 2 - end_is_ws] = '\0';  /* chop trailing brace */
        YY_BREAK
 case 157:
 YY_RULE_SETUP
-#line 802 "scan.l"
+#line 840 "scan.l"
 {
                     if (sf_skip_ws())
                         yy_push_state(COMMENT_DISCARD);
@@ -3662,7 +3709,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 158:
 YY_RULE_SETUP
-#line 812 "scan.l"
+#line 850 "scan.l"
 {
                     if (lex_compat || posix_compat){
                         /* Push back the "?#" and treat it like a normal parens. */
@@ -3676,7 +3723,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 159:
 YY_RULE_SETUP
-#line 822 "scan.l"
+#line 860 "scan.l"
 {
                     sf_push();
                     if (lex_compat || posix_compat)
@@ -3689,12 +3736,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 160:
 YY_RULE_SETUP
-#line 831 "scan.l"
+#line 869 "scan.l"
 sf_push(); return '(';
        YY_BREAK
 case 161:
 YY_RULE_SETUP
-#line 832 "scan.l"
+#line 870 "scan.l"
 {
                     if (_sf_top_ix > 0) {
                         sf_pop();
@@ -3705,30 +3752,48 @@ YY_RULE_SETUP
        YY_BREAK
 case 162:
 YY_RULE_SETUP
-#line 840 "scan.l"
+#line 878 "scan.l"
 return (unsigned char) yytext[0];
        YY_BREAK
 case 163:
 YY_RULE_SETUP
-#line 841 "scan.l"
+#line 879 "scan.l"
 RETURNCHAR;
        YY_BREAK
+/* Nick added this rule for consistency with rest of scanner */
+case YY_STATE_EOF(SECT2):
+#line 882 "scan.l"
+{
+                       sectnum = 0;
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect2>");
+#if 0
+ piece[piece1++] = strdup("<token value=\"0\" />");
+#endif
+ piece_pack();
+ return ~YY_NULL;
+#else
+                       yyterminate(); /* to stop the parser */
+#endif
+                       }
+       YY_BREAK
 
 
 case 164:
 /* rule 164 can match eol */
 YY_RULE_SETUP
-#line 846 "scan.l"
+#line 900 "scan.l"
 ++linenum;     /* Allow blank lines & continuations */
        YY_BREAK
 case 165:
 YY_RULE_SETUP
-#line 847 "scan.l"
+#line 901 "scan.l"
 return (unsigned char) yytext[0];
        YY_BREAK
 case 166:
 YY_RULE_SETUP
-#line 848 "scan.l"
+#line 902 "scan.l"
 BEGIN(SECT2); return '>';
        YY_BREAK
 case 167:
@@ -3736,17 +3801,17 @@ case 167:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 849 "scan.l"
+#line 903 "scan.l"
 BEGIN(CARETISBOL); return '>';
        YY_BREAK
 case 168:
 YY_RULE_SETUP
-#line 850 "scan.l"
+#line 904 "scan.l"
 RETURNNAME;
        YY_BREAK
 case 169:
 YY_RULE_SETUP
-#line 851 "scan.l"
+#line 905 "scan.l"
 {
                        format_synerr( _( "bad <start condition>: %s" ),
                                yytext );
@@ -3755,24 +3820,24 @@ YY_RULE_SETUP
 
 case 170:
 YY_RULE_SETUP
-#line 857 "scan.l"
+#line 911 "scan.l"
 BEGIN(SECT2); return '^';
        YY_BREAK
 
 case 171:
 YY_RULE_SETUP
-#line 861 "scan.l"
+#line 915 "scan.l"
 RETURNCHAR;
        YY_BREAK
 case 172:
 YY_RULE_SETUP
-#line 862 "scan.l"
+#line 916 "scan.l"
 BEGIN(SECT2); return '"';
        YY_BREAK
 case 173:
 /* rule 173 can match eol */
 YY_RULE_SETUP
-#line 864 "scan.l"
+#line 918 "scan.l"
 {
                        synerr( _( "missing quote" ) );
                        BEGIN(SECT2);
@@ -3784,49 +3849,49 @@ YY_RULE_SETUP
 
 case 174:
 YY_RULE_SETUP
-#line 873 "scan.l"
+#line 927 "scan.l"
 BEGIN(SECT2);
        YY_BREAK
 case 175:
 YY_RULE_SETUP
-#line 874 "scan.l"
+#line 928 "scan.l"
 BEGIN(GROUP_MINUS_PARAMS);
        YY_BREAK
 case 176:
 YY_RULE_SETUP
-#line 875 "scan.l"
+#line 929 "scan.l"
 sf_set_case_ins(1);
        YY_BREAK
 case 177:
 YY_RULE_SETUP
-#line 876 "scan.l"
+#line 930 "scan.l"
 sf_set_dot_all(1);
        YY_BREAK
 case 178:
 YY_RULE_SETUP
-#line 877 "scan.l"
+#line 931 "scan.l"
 sf_set_skip_ws(1);
        YY_BREAK
 
 
 case 179:
 YY_RULE_SETUP
-#line 880 "scan.l"
+#line 934 "scan.l"
 BEGIN(SECT2);
        YY_BREAK
 case 180:
 YY_RULE_SETUP
-#line 881 "scan.l"
+#line 935 "scan.l"
 sf_set_case_ins(0);
        YY_BREAK
 case 181:
 YY_RULE_SETUP
-#line 882 "scan.l"
+#line 936 "scan.l"
 sf_set_dot_all(0);
        YY_BREAK
 case 182:
 YY_RULE_SETUP
-#line 883 "scan.l"
+#line 937 "scan.l"
 sf_set_skip_ws(0);
        YY_BREAK
 
@@ -3836,7 +3901,7 @@ case 183:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 887 "scan.l"
+#line 941 "scan.l"
 BEGIN(CCL); return '^';
        YY_BREAK
 case 184:
@@ -3844,12 +3909,12 @@ case 184:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 888 "scan.l"
+#line 942 "scan.l"
 return '^';
        YY_BREAK
 case 185:
 YY_RULE_SETUP
-#line 889 "scan.l"
+#line 943 "scan.l"
 BEGIN(CCL); RETURNCHAR;
        YY_BREAK
 
@@ -3859,23 +3924,23 @@ case 186:
 (yy_c_buf_p) = yy_cp = yy_bp + 1;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 893 "scan.l"
+#line 947 "scan.l"
 return '-';
        YY_BREAK
 case 187:
 YY_RULE_SETUP
-#line 894 "scan.l"
+#line 948 "scan.l"
 RETURNCHAR;
        YY_BREAK
 case 188:
 YY_RULE_SETUP
-#line 895 "scan.l"
+#line 949 "scan.l"
 BEGIN(SECT2); return ']';
        YY_BREAK
 case 189:
 /* rule 189 can match eol */
 YY_RULE_SETUP
-#line 896 "scan.l"
+#line 950 "scan.l"
 {
                        synerr( _( "bad character class" ) );
                        BEGIN(SECT2);
@@ -3886,127 +3951,127 @@ YY_RULE_SETUP
 
 case 190:
 YY_RULE_SETUP
-#line 904 "scan.l"
+#line 958 "scan.l"
 BEGIN(CCL); return CCE_ALNUM;
        YY_BREAK
 case 191:
 YY_RULE_SETUP
-#line 905 "scan.l"
+#line 959 "scan.l"
 BEGIN(CCL); return CCE_ALPHA;
        YY_BREAK
 case 192:
 YY_RULE_SETUP
-#line 906 "scan.l"
+#line 960 "scan.l"
 BEGIN(CCL); return CCE_BLANK;
        YY_BREAK
 case 193:
 YY_RULE_SETUP
-#line 907 "scan.l"
+#line 961 "scan.l"
 BEGIN(CCL); return CCE_CNTRL;
        YY_BREAK
 case 194:
 YY_RULE_SETUP
-#line 908 "scan.l"
+#line 962 "scan.l"
 BEGIN(CCL); return CCE_DIGIT;
        YY_BREAK
 case 195:
 YY_RULE_SETUP
-#line 909 "scan.l"
+#line 963 "scan.l"
 BEGIN(CCL); return CCE_GRAPH;
        YY_BREAK
 case 196:
 YY_RULE_SETUP
-#line 910 "scan.l"
+#line 964 "scan.l"
 BEGIN(CCL); return CCE_LOWER;
        YY_BREAK
 case 197:
 YY_RULE_SETUP
-#line 911 "scan.l"
+#line 965 "scan.l"
 BEGIN(CCL); return CCE_PRINT;
        YY_BREAK
 case 198:
 YY_RULE_SETUP
-#line 912 "scan.l"
+#line 966 "scan.l"
 BEGIN(CCL); return CCE_PUNCT;
        YY_BREAK
 case 199:
 YY_RULE_SETUP
-#line 913 "scan.l"
+#line 967 "scan.l"
 BEGIN(CCL); return CCE_SPACE;
        YY_BREAK
 case 200:
 YY_RULE_SETUP
-#line 914 "scan.l"
+#line 968 "scan.l"
 BEGIN(CCL); return CCE_UPPER;
        YY_BREAK
 case 201:
 YY_RULE_SETUP
-#line 915 "scan.l"
+#line 969 "scan.l"
 BEGIN(CCL); return CCE_XDIGIT;
        YY_BREAK
 case 202:
 YY_RULE_SETUP
-#line 917 "scan.l"
+#line 971 "scan.l"
 BEGIN(CCL); return CCE_NEG_ALNUM;
        YY_BREAK
 case 203:
 YY_RULE_SETUP
-#line 918 "scan.l"
+#line 972 "scan.l"
 BEGIN(CCL); return CCE_NEG_ALPHA;
        YY_BREAK
 case 204:
 YY_RULE_SETUP
-#line 919 "scan.l"
+#line 973 "scan.l"
 BEGIN(CCL); return CCE_NEG_BLANK;
        YY_BREAK
 case 205:
 YY_RULE_SETUP
-#line 920 "scan.l"
+#line 974 "scan.l"
 BEGIN(CCL); return CCE_NEG_CNTRL;
        YY_BREAK
 case 206:
 YY_RULE_SETUP
-#line 921 "scan.l"
+#line 975 "scan.l"
 BEGIN(CCL); return CCE_NEG_DIGIT;
        YY_BREAK
 case 207:
 YY_RULE_SETUP
-#line 922 "scan.l"
+#line 976 "scan.l"
 BEGIN(CCL); return CCE_NEG_GRAPH;
        YY_BREAK
 case 208:
 YY_RULE_SETUP
-#line 923 "scan.l"
+#line 977 "scan.l"
 BEGIN(CCL); return CCE_NEG_LOWER;
        YY_BREAK
 case 209:
 YY_RULE_SETUP
-#line 924 "scan.l"
+#line 978 "scan.l"
 BEGIN(CCL); return CCE_NEG_PRINT;
        YY_BREAK
 case 210:
 YY_RULE_SETUP
-#line 925 "scan.l"
+#line 979 "scan.l"
 BEGIN(CCL); return CCE_NEG_PUNCT;
        YY_BREAK
 case 211:
 YY_RULE_SETUP
-#line 926 "scan.l"
+#line 980 "scan.l"
 BEGIN(CCL); return CCE_NEG_SPACE;
        YY_BREAK
 case 212:
 YY_RULE_SETUP
-#line 927 "scan.l"
+#line 981 "scan.l"
 BEGIN(CCL); return CCE_NEG_UPPER;
        YY_BREAK
 case 213:
 YY_RULE_SETUP
-#line 928 "scan.l"
+#line 982 "scan.l"
 BEGIN(CCL); return CCE_NEG_XDIGIT;
        YY_BREAK
 case 214:
 YY_RULE_SETUP
-#line 929 "scan.l"
+#line 983 "scan.l"
 {
                        format_synerr(
                                _( "bad character class expression: %s" ),
@@ -4018,7 +4083,7 @@ YY_RULE_SETUP
 
 case 215:
 YY_RULE_SETUP
-#line 938 "scan.l"
+#line 992 "scan.l"
 {
                        yylval = myctoi( yytext );
                        return NUMBER;
@@ -4026,12 +4091,12 @@ YY_RULE_SETUP
        YY_BREAK
 case 216:
 YY_RULE_SETUP
-#line 943 "scan.l"
+#line 997 "scan.l"
 return ',';
        YY_BREAK
 case 217:
 YY_RULE_SETUP
-#line 944 "scan.l"
+#line 998 "scan.l"
 {
                        BEGIN(SECT2);
                        if ( lex_compat || posix_compat )
@@ -4042,7 +4107,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 218:
 YY_RULE_SETUP
-#line 952 "scan.l"
+#line 1006 "scan.l"
 {
                        synerr( _( "bad character inside {}'s" ) );
                        BEGIN(SECT2);
@@ -4052,7 +4117,7 @@ YY_RULE_SETUP
 case 219:
 /* rule 219 can match eol */
 YY_RULE_SETUP
-#line 958 "scan.l"
+#line 1012 "scan.l"
 {
                        synerr( _( "missing }" ) );
                        BEGIN(SECT2);
@@ -4064,18 +4129,18 @@ YY_RULE_SETUP
 
 case 220:
 YY_RULE_SETUP
-#line 968 "scan.l"
+#line 1022 "scan.l"
 bracelevel = 0;
        YY_BREAK
 case 221:
 YY_RULE_SETUP
-#line 970 "scan.l"
+#line 1024 "scan.l"
 ACTION_ECHO; yy_push_state( CODE_COMMENT );
        YY_BREAK
 
 case 222:
 YY_RULE_SETUP
-#line 973 "scan.l"
+#line 1027 "scan.l"
 {
             ACTION_ECHO;
             CHECK_REJECT(yytext);
@@ -4083,7 +4148,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 223:
 YY_RULE_SETUP
-#line 977 "scan.l"
+#line 1031 "scan.l"
 {
             ACTION_ECHO;
             CHECK_YYMORE(yytext);
@@ -4092,13 +4157,13 @@ YY_RULE_SETUP
 
 case 224:
 YY_RULE_SETUP
-#line 983 "scan.l"
+#line 1037 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 225:
 /* rule 225 can match eol */
 YY_RULE_SETUP
-#line 984 "scan.l"
+#line 1038 "scan.l"
 {
                ++linenum;
                ACTION_ECHO;
@@ -4117,43 +4182,43 @@ YY_RULE_SETUP
 
 case 226:
 YY_RULE_SETUP
-#line 1001 "scan.l"
+#line 1055 "scan.l"
 ACTION_ECHO; ++bracelevel;
        YY_BREAK
 case 227:
 YY_RULE_SETUP
-#line 1002 "scan.l"
+#line 1056 "scan.l"
 ACTION_ECHO; --bracelevel;
        YY_BREAK
 case 228:
 YY_RULE_SETUP
-#line 1003 "scan.l"
+#line 1057 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 229:
 YY_RULE_SETUP
-#line 1004 "scan.l"
+#line 1058 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 230:
 YY_RULE_SETUP
-#line 1005 "scan.l"
+#line 1059 "scan.l"
 ACTION_ECHO; /* character constant */
        YY_BREAK
 case 231:
 YY_RULE_SETUP
-#line 1006 "scan.l"
+#line 1060 "scan.l"
 ACTION_ECHO; BEGIN(CHARACTER_CONSTANT);
        YY_BREAK
 case 232:
 YY_RULE_SETUP
-#line 1007 "scan.l"
+#line 1061 "scan.l"
 ACTION_ECHO; BEGIN(ACTION_STRING);
        YY_BREAK
 case 233:
 /* rule 233 can match eol */
 YY_RULE_SETUP
-#line 1008 "scan.l"
+#line 1062 "scan.l"
 {
                 ++linenum;
                 ACTION_ECHO;
@@ -4172,31 +4237,31 @@ YY_RULE_SETUP
        YY_BREAK
 case 234:
 YY_RULE_SETUP
-#line 1023 "scan.l"
+#line 1077 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 
 
 case 235:
 YY_RULE_SETUP
-#line 1027 "scan.l"
+#line 1081 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 236:
 YY_RULE_SETUP
-#line 1028 "scan.l"
+#line 1082 "scan.l"
 ACTION_ECHO; BEGIN(ACTION);
        YY_BREAK
 
 
 case 237:
 YY_RULE_SETUP
-#line 1031 "scan.l"
+#line 1085 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 238:
 YY_RULE_SETUP
-#line 1032 "scan.l"
+#line 1086 "scan.l"
 ACTION_ECHO; BEGIN(ACTION);
        YY_BREAK
 
@@ -4204,24 +4269,24 @@ ACTION_ECHO; BEGIN(ACTION);
 case 239:
 /* rule 239 can match eol */
 YY_RULE_SETUP
-#line 1035 "scan.l"
+#line 1089 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 240:
 /* rule 240 can match eol */
 YY_RULE_SETUP
-#line 1036 "scan.l"
+#line 1090 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 case 241:
 /* rule 241 can match eol */
 YY_RULE_SETUP
-#line 1037 "scan.l"
+#line 1091 "scan.l"
 ++linenum; ACTION_ECHO; if (bracelevel <= 0) { BEGIN(SECT2); flush(); if (doing_rule_action) piece[piece1++] = strdup("</Action>"); } else { BEGIN(ACTION); }
        YY_BREAK
 case 242:
 YY_RULE_SETUP
-#line 1038 "scan.l"
+#line 1092 "scan.l"
 ACTION_ECHO;
        YY_BREAK
 
@@ -4231,7 +4296,7 @@ case YY_STATE_EOF(COMMENT_DISCARD):
 case YY_STATE_EOF(ACTION):
 case YY_STATE_EOF(ACTION_STRING):
 case YY_STATE_EOF(CHARACTER_CONSTANT):
-#line 1041 "scan.l"
+#line 1095 "scan.l"
 {
                        synerr( _( "EOF encountered inside an action" ) );
                        yyterminate();
@@ -4240,7 +4305,7 @@ case YY_STATE_EOF(CHARACTER_CONSTANT):
 case YY_STATE_EOF(EXTENDED_COMMENT):
 case YY_STATE_EOF(GROUP_WITH_PARAMS):
 case YY_STATE_EOF(GROUP_MINUS_PARAMS):
-#line 1046 "scan.l"
+#line 1100 "scan.l"
 {
                        synerr( _( "EOF encountered inside pattern" ) );
                        yyterminate();
@@ -4248,7 +4313,7 @@ case YY_STATE_EOF(GROUP_MINUS_PARAMS):
        YY_BREAK
 case 243:
 YY_RULE_SETUP
-#line 1051 "scan.l"
+#line 1105 "scan.l"
 {
                        yylval = myesc( (unsigned char *) yytext );
 
@@ -4261,77 +4326,96 @@ YY_RULE_SETUP
 
 case 244:
 YY_RULE_SETUP
-#line 1061 "scan.l"
+#line 1115 "scan.l"
 fputs(escaped_qstart, yyout);
        YY_BREAK
 case 245:
 YY_RULE_SETUP
-#line 1062 "scan.l"
+#line 1116 "scan.l"
 fputs(escaped_qend, yyout);
        YY_BREAK
 case 246:
 /* rule 246 can match eol */
 YY_RULE_SETUP
-#line 1063 "scan.l"
+#line 1117 "scan.l"
 ECHO;
        YY_BREAK
 case 247:
 YY_RULE_SETUP
-#line 1064 "scan.l"
+#line 1118 "scan.l"
 ECHO;
        YY_BREAK
 case YY_STATE_EOF(SECT3):
-#line 1065 "scan.l"
+#line 1119 "scan.l"
 {
         sectnum = 0;
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect3>");
+#if 0
+ piece[piece1++] = strdup("<token value=\"0\" />");
+#endif
+ piece_pack();
+ return ~YY_NULL;
+#else
         yyterminate();
+#endif
     }
        YY_BREAK
 
 
 case 248:
 YY_RULE_SETUP
-#line 1071 "scan.l"
+#line 1135 "scan.l"
 fprintf(yyout, "[""[%s]""]", escaped_qstart);
        YY_BREAK
 case 249:
 YY_RULE_SETUP
-#line 1072 "scan.l"
+#line 1136 "scan.l"
 fprintf(yyout, "[""[%s]""]", escaped_qend);
        YY_BREAK
 case 250:
 /* rule 250 can match eol */
 YY_RULE_SETUP
-#line 1073 "scan.l"
+#line 1137 "scan.l"
 ECHO;
        YY_BREAK
 case 251:
 YY_RULE_SETUP
-#line 1074 "scan.l"
+#line 1138 "scan.l"
 ECHO;
        YY_BREAK
 case YY_STATE_EOF(SECT3_NOESCAPE):
-#line 1075 "scan.l"
+#line 1139 "scan.l"
 {
        sectnum = 0;
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect3>");
+#if 0
+ piece[piece1++] = strdup("<token value=\"0\" />");
+#endif
+ piece_pack();
+ return ~YY_NULL;
+#else
        yyterminate();
+#endif
     }
        YY_BREAK
 
 case 252:
 /* rule 252 can match eol */
 YY_RULE_SETUP
-#line 1080 "scan.l"
+#line 1154 "scan.l"
 format_synerr( _( "bad character: %s" ), yytext );
        YY_BREAK
 case 253:
 YY_RULE_SETUP
-#line 1082 "scan.l"
+#line 1156 "scan.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
        YY_BREAK
-#line 4232 "scan.c"
+#line 4308 "scan.c"
 case YY_STATE_EOF(INITIAL):
-case YY_STATE_EOF(SECT2):
 case YY_STATE_EOF(CODEBLOCK):
 case YY_STATE_EOF(PICKUPDEF):
 case YY_STATE_EOF(SC):
@@ -4472,7 +4556,6 @@ case YY_STATE_EOF(LINEDIR):
                YY_FATAL_ERROR(
                        "fatal flex scanner internal error--no action found" );
        } /* end of action switch */
- piece_esc(yytext, yy_c_buf_p - yytext);
                } /* end of scanning one token */
 } /* end of yylex */
 
@@ -5384,7 +5467,7 @@ void yyfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 1082 "scan.l"
+#line 1156 "scan.l"
 
 
 
index 65af554..8770d1b 100644 (file)
@@ -1,6 +1,6 @@
---- scan.c.orig        2018-06-22 00:31:53.564909079 +1000
-+++ scan.c     2018-06-22 00:31:53.584909078 +1000
-@@ -23,6 +23,11 @@
+--- scan.c.orig        2018-06-23 10:26:10.768657057 +1000
++++ scan.c     2018-06-23 10:52:51.120589330 +1000
+@@ -23,6 +23,17 @@
  
  /* end standard C headers. */
  
@@ -8,11 +8,17 @@
 +char *piece[10000];
 +int piece0;
 +int piece1;
++void insert_piece(int n, const char *str) {
++ memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
++ piece[n] = strdup(str);
++ ++piece0;
++ ++piece1;
++}
 +
  /* flex integer type definitions */
  
  #ifndef FLEXINT_H
-@@ -185,7 +190,21 @@
+@@ -185,7 +196,21 @@
                } \
        while ( 0 )
  
  
  #ifndef YY_TYPEDEF_YY_SIZE_T
  #define YY_TYPEDEF_YY_SIZE_T
-@@ -2215,8 +2234,90 @@
+@@ -2215,8 +2240,88 @@
  
  /** The main scanner function which does all the work.
   */
-+static int real_yylex();
++static int real_yylex(void);
 +static void piece_esc(const char *p, size_t n) {
 + size_t i, j = 0;
 + for (i = 0; i < n; ++i)
 + piece_pack();
 +#if 1
 + piece_esc(yytext, strlen(yytext));
-+ ++piece0;
 +#else
 + size_t n = strlen(yytext);
 + if (n) {
 +  piece[piece1++] = strdup(piece_temp);
 +  piece_esc(yytext, n);
 +  piece[piece1++] = strdup("</token>");
-+  piece_pack();
 + }
 + else {
 +  sprintf(piece_temp, "<token value=\"%d\" />", result);
 +  piece[piece1++] = strdup(piece_temp);
-+  ++piece0;
 + }
 +#endif
++ piece_pack();
 + return result;
 +}
-+static int real_yylex()
++static int real_yylex(void)
 +{
        register yy_state_type yy_current_state;
        register char *yy_cp, *yy_bp;
        register int yy_act;
-@@ -4371,6 +4472,7 @@
-               YY_FATAL_ERROR(
-                       "fatal flex scanner internal error--no action found" );
-       } /* end of action switch */
-+ piece_esc(yytext, yy_c_buf_p - yytext);
-               } /* end of scanning one token */
- } /* end of yylex */
+@@ -2260,7 +2365,12 @@
+               yy_load_buffer_state( );
+               }
  
++#if 1
++ /* we do this so that "continue;" in an action works correctly */
++ for (; ; piece_esc(yytext, yy_c_buf_p - yytext))
++#else
+       while ( 1 )             /* loops until end-of-file is reached */
++#endif
+               {
+               (yy_more_len) = 0;
+               if ( (yy_more_flag) )
index 2adb21a..bb62473 100644 (file)
@@ -196,7 +196,23 @@ M4QEND      "]""]"
                        mark_defs1();
                        line_directive_out(NULL, 1);
                        BEGIN(SECT2PROLOG);
+#if 1
+ piece[piece1++] = strdup("</Sect1>");
+ piece_pack();
+#if 1
+ piece_esc(yytext, strlen(yytext));
+#else
+ sprintf(piece_temp, "<token value=\"%d\">", SECTEND);
+ piece[piece1++] = strdup(piece_temp);
+ piece_esc(yytext, strlen(yytext));
+ piece[piece1++] = strdup("</token>");
+#endif
+ piece[piece1++] = strdup("<Sect2>");
+ piece_pack();
+ return ~SECTEND;
+#else
                        return SECTEND;
+#endif
                        }
 
        ^"%pointer".*{NL}       yytext_is_array = false; ++linenum;
@@ -512,7 +528,17 @@ M4QEND      "]""]"
        <<EOF>>         {
                        mark_prolog();
                        sectnum = 0;
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect2>");
+#if 0
+ piece[piece1++] = strdup("<token value=\"0\" />");
+#endif
+ piece_pack();
+ return ~YY_NULL;
+#else
                        yyterminate(); /* to stop the parser */
+#endif
                        }
 }
 
@@ -556,14 +582,13 @@ M4QEND      "]""]"
 #if 1
  piece_pack();
 #if 1
- piece[piece1++] = strdup(yytext);
- ++piece0;
+ piece_esc(yytext, strlen(yytext));
 #else
  piece[piece1++] = strdup("<token value=\"10\">");
- piece[piece1++] = strdup(yytext);
+ piece_esc(yytext, strlen(yytext));
  piece[piece1++] = strdup("</token>");
- piece_pack();
 #endif
+ piece_pack();
  piece[piece1++] = strdup("<PercentBraceAction>");
  return ~'\n';
 #else
@@ -626,14 +651,13 @@ M4QEND      "]""]"
 #if 1
  piece_pack();
 #if 1
- piece[piece1++] = strdup(yytext);
- ++piece0;
+ piece_esc(yytext, strlen(yytext));
 #else
  piece[piece1++] = strdup("<token value=\"10\">");
- piece[piece1++] = strdup(yytext);
+ piece_esc(yytext, strlen(yytext));
  piece[piece1++] = strdup("</token>");
- piece_pack();
 #endif
+ piece_pack();
  piece[piece1++] = strdup("<Action>");
  return ~'\n';
 #else
@@ -665,14 +689,13 @@ M4QEND      "]""]"
 #if 1
  piece_pack();
 #if 1
- piece[piece1++] = strdup(yytext);
- ++piece0;
+ piece_esc(yytext, strlen(yytext));
 #else
  piece[piece1++] = strdup("<token value=\"10\">");
- piece[piece1++] = strdup(yytext);
+ piece_esc(yytext, strlen(yytext));
  piece[piece1++] = strdup("</token>");
- piece_pack();
 #endif
+ piece_pack();
  piece[piece1++] = strdup("<Action>");
  return ~'\n';
 #else
@@ -689,7 +712,22 @@ M4QEND      "]""]"
                        sectnum = 3;
                        BEGIN(no_section3_escape ? SECT3_NOESCAPE : SECT3);
                        outn("/* Begin user sect3 */");
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect2>");
+#if 1
+ piece_esc(yytext, strlen(yytext));
+#else
+ piece[piece1++] = strdup("<token value=\"0\">");
+ piece_esc(yytext, strlen(yytext));
+ piece[piece1++] = strdup("</token>");
+#endif
+ piece_pack();
+ piece[piece1++] = strdup("<Sect3>");
+ return ~YY_NULL;
+#else
                        yyterminate(); /* to stop the parser */
+#endif
 
                        }
 
@@ -839,6 +877,22 @@ nmstr[yyleng - 2 - end_is_ws] = '\0';  /* chop trailing brace */
 
        [/|*+?.(){}]    return (unsigned char) yytext[0];
        .               RETURNCHAR;
+
+       /* Nick added this rule for consistency with rest of scanner */
+       <<EOF>>         {
+                       sectnum = 0;
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect2>");
+#if 0
+ piece[piece1++] = strdup("<token value=\"0\" />");
+#endif
+ piece_pack();
+ return ~YY_NULL;
+#else
+                       yyterminate(); /* to stop the parser */
+#endif
+                       }
 }
 
 
@@ -1064,7 +1118,17 @@ nmstr[yyleng - 2 - end_is_ws] = '\0';  /* chop trailing brace */
     [][]         ECHO;
     <<EOF>>      {
         sectnum = 0;
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect3>");
+#if 0
+ piece[piece1++] = strdup("<token value=\"0\" />");
+#endif
+ piece_pack();
+ return ~YY_NULL;
+#else
         yyterminate();
+#endif
     }
 }
 <SECT3_NOESCAPE>{
@@ -1074,7 +1138,17 @@ nmstr[yyleng - 2 - end_is_ws] = '\0';  /* chop trailing brace */
     [][]        ECHO;
     <<EOF>>            {
        sectnum = 0;
+#if 1
+ piece_pack();
+ piece[piece1++] = strdup("</Sect3>");
+#if 0
+ piece[piece1++] = strdup("<token value=\"0\" />");
+#endif
+ piece_pack();
+ return ~YY_NULL;
+#else
        yyterminate();
+#endif
     }
 }
 <*>.|\n                        format_synerr( _( "bad character: %s" ), yytext );
index 1a73e13..fb8c28e 100644 (file)
@@ -1,6 +1,6 @@
---- stage1scan.c.orig  2018-06-12 20:08:31.177576950 +1000
-+++ stage1scan.c       2018-06-12 20:09:46.085578418 +1000
-@@ -24,6 +24,11 @@
+--- stage1scan.c.orig  2018-06-23 10:54:03.460586269 +1000
++++ stage1scan.c       2018-06-23 10:56:11.792580838 +1000
+@@ -24,6 +24,17 @@
  
  /* end standard C headers. */
  
@@ -8,11 +8,17 @@
 +char *piece[10000];
 +int piece0;
 +int piece1;
++void insert_piece(int n, const char *str) {
++ memmove(piece + n + 1, piece + n, (piece1 - n) * sizeof(char *));
++ piece[n] = strdup(str);
++ ++piece0;
++ ++piece1;
++}
 +
  /* flex integer type definitions */
  
  #ifndef FLEXINT_H
-@@ -179,7 +184,21 @@
+@@ -179,7 +190,21 @@
                YY_DO_BEFORE_ACTION; /* set up yytext again */ \
                } \
        while ( 0 )
  
  #ifndef YY_STRUCT_YY_BUFFER_STATE
  #define YY_STRUCT_YY_BUFFER_STATE
-@@ -2192,7 +2211,89 @@
+@@ -2192,8 +2217,88 @@
  
  /** The main scanner function which does all the work.
   */
--YY_DECL
-+static int real_yylex();
++static int real_yylex(void);
 +static void piece_esc(const char *p, size_t n) {
 + size_t i, j = 0;
 + for (i = 0; i < n; ++i)
 + piece[piece0++] = q;
 + piece1 = piece0;
 +}
-+ YY_DECL
-+ {
+ YY_DECL
+ {
 + int result = real_yylex();
 + if (result < 0)
 +  return ~result;
 + piece_pack();
 +#if 1
-+ piece[piece1++] = strdup(piece_temp);
-+ ++piece0;
++ piece_esc(yytext, strlen(yytext));
 +#else
 + size_t n = strlen(yytext);
 + if (n) {
 +  piece[piece1++] = strdup(piece_temp);
 +  piece_esc(yytext, n);
 +  piece[piece1++] = strdup("</token>");
-+  piece_pack();
 + }
 + else {
 +  sprintf(piece_temp, "<token value=\"%d\" />", result);
 +  piece[piece1++] = strdup(piece_temp);
-+  ++piece0;
 + }
 +#endif
++ piece_pack();
 + return result;
 +}
-+static int real_yylex()
- {
++static int real_yylex(void)
++{
        yy_state_type yy_current_state;
        char *yy_cp, *yy_bp;
-@@ -4341,6 +4442,7 @@
-               YY_FATAL_ERROR(
-                       "fatal flex scanner internal error--no action found" );
-       } /* end of action switch */
-+ piece_esc(yytext, yy_c_buf_p - yytext);
-               } /* end of scanning one token */
-       } /* end of user's declarations */
- } /* end of yylex */
+       int yy_act;
+@@ -2239,7 +2344,12 @@
+ #line 2240 "stage1scan.c"
++#if 1
++ /* we do this so that "continue;" in an action works correctly */
++ for (; ; piece_esc(yytext, yy_c_buf_p - yytext))
++#else
+       while ( /*CONSTCOND*/1 )                /* loops until end-of-file is reached */
++#endif
+               {
+               yy_cp = (yy_c_buf_p);