OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
3.8 KiB

  1. Fri Mar 16 19:18:02 EET 2007 Ville Laurikari <vl@iki.fi>
  2. * Refactoring.
  3. diff -rN -u old-stable/lib/tre-compile.c new-stable/lib/tre-compile.c
  4. --- old-stable/lib/tre-compile.c 2007-11-04 20:27:45.000000000 +0200
  5. +++ new-stable/lib/tre-compile.c 2007-11-04 20:27:45.000000000 +0200
  6. @@ -1,7 +1,7 @@
  7. /*
  8. tre-compile.c - TRE regex compiler
  9. - Copyright (c) 2001-2006 Ville Laurikari <vl@iki.fi>
  10. + Copyright (c) 2001-2007 Ville Laurikari <vl@iki.fi>
  11. This library is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU Lesser General Public
  13. @@ -127,6 +127,30 @@
  14. int next_tag;
  15. } tre_tag_states_t;
  16. +
  17. +/* Go through `regset' and set submatch data for submatches that are
  18. + using this tag. */
  19. +static void
  20. +tre_purge_regset(int *regset, tre_tnfa_t *tnfa, int tag)
  21. +{
  22. + int i;
  23. +
  24. + for (i = 0; regset[i] >= 0; i++)
  25. + {
  26. + int id = regset[i] / 2;
  27. + int start = !(regset[i] % 2);
  28. + DPRINT((" Using tag %d for %s offset of "
  29. + "submatch %d\n", tag,
  30. + start ? "start" : "end", id));
  31. + if (start)
  32. + tnfa->submatch_data[id].so_tag = tag;
  33. + else
  34. + tnfa->submatch_data[id].eo_tag = tag;
  35. + }
  36. + regset[0] = -1;
  37. +}
  38. +
  39. +
  40. /* Adds tags to appropriate locations in the parse tree in `tree', so that
  41. subexpressions marked for submatch addressing can be traced. */
  42. static reg_errcode_t
  43. @@ -281,20 +305,7 @@
  44. minimal_tag = -1;
  45. num_minimals++;
  46. }
  47. - /* Go through the regset and set submatch data for
  48. - submatches that are using this tag. */
  49. - for (i = 0; regset[i] >= 0; i++)
  50. - {
  51. - int id = regset[i] / 2;
  52. - int start = !(regset[i] % 2);
  53. - DPRINT((" Using tag %d for %s offset of "
  54. - "submatch %d\n", tag,
  55. - start ? "start" : "end", id));
  56. - if (start)
  57. - tnfa->submatch_data[id].so_tag = tag;
  58. - else
  59. - tnfa->submatch_data[id].eo_tag = tag;
  60. - }
  61. + tre_purge_regset(regset, tnfa, tag);
  62. }
  63. else
  64. {
  65. @@ -394,20 +405,7 @@
  66. minimal_tag = -1;
  67. num_minimals++;
  68. }
  69. - /* Go through the regset and set submatch data for
  70. - submatches that are using this tag. */
  71. - for (i = 0; regset[i] >= 0; i++)
  72. - {
  73. - int id = regset[i] / 2;
  74. - int start = !(regset[i] % 2);
  75. - DPRINT((" Using tag %d for %s offset of "
  76. - "submatch %d\n", tag,
  77. - start ? "start" : "end", id));
  78. - if (start)
  79. - tnfa->submatch_data[id].so_tag = tag;
  80. - else
  81. - tnfa->submatch_data[id].eo_tag = tag;
  82. - }
  83. + tre_purge_regset(regset, tnfa, tag);
  84. }
  85. DPRINT((" num_tags++\n"));
  86. @@ -479,20 +477,7 @@
  87. minimal_tag = -1;
  88. num_minimals++;
  89. }
  90. - /* Go through the regset and set submatch data for
  91. - submatches that are using this tag. */
  92. - for (i = 0; regset[i] >= 0; i++)
  93. - {
  94. - int id = regset[i] / 2;
  95. - int start = !(regset[i] % 2);
  96. - DPRINT((" Using tag %d for %s offset of "
  97. - "submatch %d\n", tag,
  98. - start ? "start" : "end", id));
  99. - if (start)
  100. - tnfa->submatch_data[id].so_tag = tag;
  101. - else
  102. - tnfa->submatch_data[id].eo_tag = tag;
  103. - }
  104. + tre_purge_regset(regset, tnfa, tag);
  105. }
  106. DPRINT((" num_tags++\n"));
  107. @@ -640,23 +625,7 @@
  108. } /* end while(tre_stack_num_objects(stack) > bottom) */
  109. if (!first_pass)
  110. - {
  111. - int i;
  112. - /* Go through the regset and set submatch data for
  113. - submatches that are using this tag. */
  114. - for (i = 0; regset[i] >= 0; i++)
  115. - {
  116. - int id = regset[i] / 2;
  117. - int start = !(regset[i] % 2);
  118. - DPRINT((" Using tag %d for %s offset of "
  119. - "submatch %d\n", num_tags,
  120. - start ? "start" : "end", id));
  121. - if (start)
  122. - tnfa->submatch_data[id].so_tag = num_tags;
  123. - else
  124. - tnfa->submatch_data[id].eo_tag = num_tags;
  125. - }
  126. - }
  127. + tre_purge_regset(regset, tnfa, tag);
  128. if (!first_pass && minimal_tag >= 0)
  129. {