home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.1013 < prev    next >
Encoding:
Internet Message Format  |  2013-05-24  |  8.4 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.1013
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.1013
  11. Problem:    New regexp logging is a bit messy.
  12. Solution:   Consistently use #defines, add explanatory comment. (Taro Muraoka)
  13. Files:        src/regexp_nfa.c
  14.  
  15.  
  16. *** ../vim-7.3.1012/src/regexp_nfa.c    2013-05-24 23:10:45.000000000 +0200
  17. --- src/regexp_nfa.c    2013-05-25 12:17:35.000000000 +0200
  18. ***************
  19. *** 5,16 ****
  20.    * This file is included in "regexp.c".
  21.    */
  22.   
  23.   #ifdef DEBUG
  24. ! /* Comment this out to disable log files. They can get pretty big */
  25.   # define ENABLE_LOG
  26. ! # define LOG_NAME "log_nfarun.log"
  27. ! # define NFA_REGEXP_DEBUG_LOG
  28. ! # define NFA_REGEXP_DEBUG_LOG_NAME    "nfa_regexp_debug.log"
  29.   #endif
  30.   
  31.   /* Upper limit allowed for {m,n} repetitions handled by NFA */
  32. --- 5,32 ----
  33.    * This file is included in "regexp.c".
  34.    */
  35.   
  36. + /*
  37. +  * Logging of NFA engine.
  38. +  *
  39. +  * The NFA engine can write four log files:
  40. +  * - Error log: Contains NFA engine's fatal errors.
  41. +  * - Dump log: Contains compiled NFA state machine's information.
  42. +  * - Run log: Contains information of matching procedure.
  43. +  * - Debug log: Contains detailed information of matching procedure. Can be
  44. +  *   disabled by undefining NFA_REGEXP_DEBUG_LOG.
  45. +  * The first one can also be used without debug mode.
  46. +  * The last three are enabled when compiled as debug mode and individually
  47. +  * disabled by commenting them out.
  48. +  * The log files can get quite big!
  49. +  * Do disable all of this when compiling Vim for debugging, undefine DEBUG in
  50. +  * regexp.c
  51. +  */
  52.   #ifdef DEBUG
  53. ! # define NFA_REGEXP_ERROR_LOG    "nfa_regexp_error.log"
  54.   # define ENABLE_LOG
  55. ! # define NFA_REGEXP_DUMP_LOG    "nfa_regexp_dump.log"
  56. ! # define NFA_REGEXP_RUN_LOG    "nfa_regexp_run.log"
  57. ! # define NFA_REGEXP_DEBUG_LOG    "nfa_regexp_debug.log"
  58.   #endif
  59.   
  60.   /* Upper limit allowed for {m,n} repetitions handled by NFA */
  61. ***************
  62. *** 1769,1775 ****
  63.       int *p;
  64.       FILE *f;
  65.   
  66. !     f = fopen("LOG.log", "a");
  67.       if (f != NULL)
  68.       {
  69.       fprintf(f, "\n-------------------------\n");
  70. --- 1785,1791 ----
  71.       int *p;
  72.       FILE *f;
  73.   
  74. !     f = fopen(NFA_REGEXP_DUMP_LOG, "a");
  75.       if (f != NULL)
  76.       {
  77.       fprintf(f, "\n-------------------------\n");
  78. ***************
  79. *** 1827,1833 ****
  80.   nfa_dump(prog)
  81.       nfa_regprog_T *prog;
  82.   {
  83. !     FILE *debugf = fopen("LOG.log", "a");
  84.   
  85.       if (debugf != NULL)
  86.       {
  87. --- 1843,1849 ----
  88.   nfa_dump(prog)
  89.       nfa_regprog_T *prog;
  90.   {
  91. !     FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a");
  92.   
  93.       if (debugf != NULL)
  94.       {
  95. ***************
  96. *** 1994,2007 ****
  97.   
  98.       static void
  99.   st_error(postfix, end, p)
  100. !     int *postfix;
  101. !     int *end;
  102. !     int *p;
  103.   {
  104.       FILE *df;
  105.       int *p2;
  106.   
  107. !     df = fopen("stack.err", "a");
  108.       if (df)
  109.       {
  110.       fprintf(df, "Error popping the stack!\n");
  111. --- 2010,2024 ----
  112.   
  113.       static void
  114.   st_error(postfix, end, p)
  115. !     int *postfix UNUSED;
  116. !     int *end UNUSED;
  117. !     int *p UNUSED;
  118.   {
  119. + #ifdef NFA_REGEXP_ERROR_LOG
  120.       FILE *df;
  121.       int *p2;
  122.   
  123. !     df = fopen(NFA_REGEXP_ERROR_LOG, "a");
  124.       if (df)
  125.       {
  126.       fprintf(df, "Error popping the stack!\n");
  127. ***************
  128. *** 2036,2041 ****
  129. --- 2053,2059 ----
  130.       fprintf(df, "\n--------------------------\n");
  131.       fclose(df);
  132.       }
  133. + #endif
  134.       EMSG(_("E874: (NFA) Could not pop the stack !"));
  135.   }
  136.   
  137. ***************
  138. *** 2148,2155 ****
  139. --- 2166,2175 ----
  140.           }
  141.           e1 = POP();
  142.           e1.start->negated = TRUE;
  143. + #ifdef FEAT_MBYTE
  144.           if (e1.start->c == NFA_COMPOSING)
  145.           e1.start->out1->negated = TRUE;
  146. + #endif
  147.           PUSH(e1);
  148.           break;
  149.   
  150. ***************
  151. *** 2265,2270 ****
  152. --- 2285,2291 ----
  153.           PUSH(frag(s, list1(&s1->out)));
  154.           break;
  155.   
  156. + #ifdef FEAT_MBYTE
  157.       case NFA_COMPOSING:    /* char with composing char */
  158.   #if 0
  159.           /* TODO */
  160. ***************
  161. *** 2274,2279 ****
  162. --- 2295,2301 ----
  163.           }
  164.   #endif
  165.           /* FALLTHROUGH */
  166. + #endif
  167.   
  168.       case NFA_MOPEN + 0:    /* Submatch */
  169.       case NFA_MOPEN + 1:
  170. ***************
  171. *** 2298,2306 ****
  172. --- 2320,2330 ----
  173.           case NFA_NOPEN:
  174.               mclose = NFA_NCLOSE;
  175.               break;
  176. + #ifdef FEAT_MBYTE
  177.           case NFA_COMPOSING:
  178.               mclose = NFA_END_COMPOSING;
  179.               break;
  180. + #endif
  181.           default:
  182.               /* NFA_MOPEN(0) ... NFA_MOPEN(9) */
  183.               mclose = *p + NSUBEXP;
  184. ***************
  185. *** 2336,2344 ****
  186. --- 2360,2370 ----
  187.           goto theend;
  188.           patch(e.out, s1);
  189.   
  190. + #ifdef FEAT_MBYTE
  191.           if (mopen == NFA_COMPOSING)
  192.           /* COMPOSING->out1 = END_COMPOSING */
  193.           patch(list1(&s->out1), s1);
  194. + #endif
  195.   
  196.           PUSH(frag(s, list1(&s1->out)));
  197.           break;
  198. ***************
  199. *** 2802,2809 ****
  200.       thread_T    *t;
  201.       char_u    *old_reginput = NULL;
  202.       char_u    *old_regline = NULL;
  203. -     nfa_state_T    *sta;
  204. -     nfa_state_T *end;
  205.       List    list[3];
  206.       List    *listtbl[2][2];
  207.       List    *ll;
  208. --- 2828,2833 ----
  209. ***************
  210. *** 2813,2825 ****
  211.       List    *neglist;
  212.       int        *listids = NULL;
  213.       int        j = 0;
  214. -     int        len = 0;
  215.   #ifdef NFA_REGEXP_DEBUG_LOG
  216. !     FILE    *debug = fopen(NFA_REGEXP_DEBUG_LOG_NAME, "a");
  217.   
  218.       if (debug == NULL)
  219.       {
  220. !     EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG_NAME);
  221.       return FALSE;
  222.       }
  223.   #endif
  224. --- 2837,2848 ----
  225.       List    *neglist;
  226.       int        *listids = NULL;
  227.       int        j = 0;
  228.   #ifdef NFA_REGEXP_DEBUG_LOG
  229. !     FILE    *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a");
  230.   
  231.       if (debug == NULL)
  232.       {
  233. !     EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG);
  234.       return FALSE;
  235.       }
  236.   #endif
  237. ***************
  238. *** 2836,2842 ****
  239.       vim_memset(list[2].t, 0, size);
  240.   
  241.   #ifdef ENABLE_LOG
  242. !     log_fd = fopen(LOG_NAME, "a");
  243.       if (log_fd != NULL)
  244.       {
  245.       fprintf(log_fd, "**********************************\n");
  246. --- 2859,2865 ----
  247.       vim_memset(list[2].t, 0, size);
  248.   
  249.   #ifdef ENABLE_LOG
  250. !     log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
  251.       if (log_fd != NULL)
  252.       {
  253.       fprintf(log_fd, "**********************************\n");
  254. ***************
  255. *** 3025,3031 ****
  256.           nfa_restore_listids(start, listids);
  257.   
  258.   #ifdef ENABLE_LOG
  259. !         log_fd = fopen(LOG_NAME, "a");
  260.           if (log_fd != NULL)
  261.           {
  262.               fprintf(log_fd, "****************************\n");
  263. --- 3048,3054 ----
  264.           nfa_restore_listids(start, listids);
  265.   
  266.   #ifdef ENABLE_LOG
  267. !         log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
  268.           if (log_fd != NULL)
  269.           {
  270.               fprintf(log_fd, "****************************\n");
  271. ***************
  272. *** 3141,3147 ****
  273.   #ifdef FEAT_MBYTE
  274.           case NFA_COMPOSING:
  275.           {
  276. !         int mc = c;
  277.   
  278.           result = OK;
  279.           sta = t->state->out;
  280. --- 3164,3173 ----
  281.   #ifdef FEAT_MBYTE
  282.           case NFA_COMPOSING:
  283.           {
  284. !         int        mc = c;
  285. !         int        len = 0;
  286. !         nfa_state_T *end;
  287. !         nfa_state_T *sta;
  288.   
  289.           result = OK;
  290.           sta = t->state->out;
  291. ***************
  292. *** 3469,3475 ****
  293.       need_clear_subexpr = TRUE;
  294.   
  295.   #ifdef ENABLE_LOG
  296. !     f = fopen(LOG_NAME, "a");
  297.       if (f != NULL)
  298.       {
  299.       fprintf(f, "\n\n\n\n\n\n\t\t=======================================================\n");
  300. --- 3495,3501 ----
  301.       need_clear_subexpr = TRUE;
  302.   
  303.   #ifdef ENABLE_LOG
  304. !     f = fopen(NFA_REGEXP_RUN_LOG, "a");
  305.       if (f != NULL)
  306.       {
  307.       fprintf(f, "\n\n\n\n\n\n\t\t=======================================================\n");
  308. ***************
  309. *** 3662,3668 ****
  310.        */
  311.   #ifdef ENABLE_LOG
  312.       {
  313. !     FILE *f = fopen(LOG_NAME, "a");
  314.   
  315.       if (f != NULL)
  316.       {
  317. --- 3688,3694 ----
  318.        */
  319.   #ifdef ENABLE_LOG
  320.       {
  321. !     FILE *f = fopen(NFA_REGEXP_RUN_LOG, "a");
  322.   
  323.       if (f != NULL)
  324.       {
  325. *** ../vim-7.3.1012/src/version.c    2013-05-24 23:10:45.000000000 +0200
  326. --- src/version.c    2013-05-25 12:06:33.000000000 +0200
  327. ***************
  328. *** 730,731 ****
  329. --- 730,733 ----
  330.   {   /* Add new patch number below this line */
  331. + /**/
  332. +     1013,
  333.   /**/
  334.  
  335. -- 
  336. Scientists decoded the first message from an alien civilization:
  337.         SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
  338. SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
  339. YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
  340. STAR SYSTEMS.  WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
  341. ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
  342. MAXIMUM!  IT REALLY WORKS!
  343.  
  344.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  345. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  346. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  347.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  348.