Karsten Hopp 1469c4
To: vim_dev@googlegroups.com
Karsten Hopp 1469c4
Subject: Patch 7.3.1013
Karsten Hopp 1469c4
Fcc: outbox
Karsten Hopp 1469c4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 1469c4
Mime-Version: 1.0
Karsten Hopp 1469c4
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 1469c4
Content-Transfer-Encoding: 8bit
Karsten Hopp 1469c4
------------
Karsten Hopp 1469c4
Karsten Hopp 1469c4
Patch 7.3.1013
Karsten Hopp 1469c4
Problem:    New regexp logging is a bit messy.
Karsten Hopp 1469c4
Solution:   Consistently use #defines, add explanatory comment. (Taro Muraoka)
Karsten Hopp 1469c4
Files:	    src/regexp_nfa.c
Karsten Hopp 1469c4
Karsten Hopp 1469c4
Karsten Hopp 1469c4
*** ../vim-7.3.1012/src/regexp_nfa.c	2013-05-24 23:10:45.000000000 +0200
Karsten Hopp 1469c4
--- src/regexp_nfa.c	2013-05-25 12:17:35.000000000 +0200
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 5,16 ****
Karsten Hopp 1469c4
   * This file is included in "regexp.c".
Karsten Hopp 1469c4
   */
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  #ifdef DEBUG
Karsten Hopp 1469c4
! /* Comment this out to disable log files. They can get pretty big */
Karsten Hopp 1469c4
  # define ENABLE_LOG
Karsten Hopp 1469c4
! # define LOG_NAME "log_nfarun.log"
Karsten Hopp 1469c4
! # define NFA_REGEXP_DEBUG_LOG
Karsten Hopp 1469c4
! # define NFA_REGEXP_DEBUG_LOG_NAME	"nfa_regexp_debug.log"
Karsten Hopp 1469c4
  #endif
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  /* Upper limit allowed for {m,n} repetitions handled by NFA */
Karsten Hopp 1469c4
--- 5,32 ----
Karsten Hopp 1469c4
   * This file is included in "regexp.c".
Karsten Hopp 1469c4
   */
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
+ /*
Karsten Hopp 1469c4
+  * Logging of NFA engine.
Karsten Hopp 1469c4
+  *
Karsten Hopp 1469c4
+  * The NFA engine can write four log files:
Karsten Hopp 1469c4
+  * - Error log: Contains NFA engine's fatal errors.
Karsten Hopp 1469c4
+  * - Dump log: Contains compiled NFA state machine's information.
Karsten Hopp 1469c4
+  * - Run log: Contains information of matching procedure.
Karsten Hopp 1469c4
+  * - Debug log: Contains detailed information of matching procedure. Can be
Karsten Hopp 1469c4
+  *   disabled by undefining NFA_REGEXP_DEBUG_LOG.
Karsten Hopp 1469c4
+  * The first one can also be used without debug mode.
Karsten Hopp 1469c4
+  * The last three are enabled when compiled as debug mode and individually
Karsten Hopp 1469c4
+  * disabled by commenting them out.
Karsten Hopp 1469c4
+  * The log files can get quite big!
Karsten Hopp 1469c4
+  * Do disable all of this when compiling Vim for debugging, undefine DEBUG in
Karsten Hopp 1469c4
+  * regexp.c
Karsten Hopp 1469c4
+  */
Karsten Hopp 1469c4
  #ifdef DEBUG
Karsten Hopp 1469c4
! # define NFA_REGEXP_ERROR_LOG	"nfa_regexp_error.log"
Karsten Hopp 1469c4
  # define ENABLE_LOG
Karsten Hopp 1469c4
! # define NFA_REGEXP_DUMP_LOG	"nfa_regexp_dump.log"
Karsten Hopp 1469c4
! # define NFA_REGEXP_RUN_LOG	"nfa_regexp_run.log"
Karsten Hopp 1469c4
! # define NFA_REGEXP_DEBUG_LOG	"nfa_regexp_debug.log"
Karsten Hopp 1469c4
  #endif
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  /* Upper limit allowed for {m,n} repetitions handled by NFA */
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 1769,1775 ****
Karsten Hopp 1469c4
      int *p;
Karsten Hopp 1469c4
      FILE *f;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
!     f = fopen("LOG.log", "a");
Karsten Hopp 1469c4
      if (f != NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
  	fprintf(f, "\n-------------------------\n");
Karsten Hopp 1469c4
--- 1785,1791 ----
Karsten Hopp 1469c4
      int *p;
Karsten Hopp 1469c4
      FILE *f;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
!     f = fopen(NFA_REGEXP_DUMP_LOG, "a");
Karsten Hopp 1469c4
      if (f != NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
  	fprintf(f, "\n-------------------------\n");
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 1827,1833 ****
Karsten Hopp 1469c4
  nfa_dump(prog)
Karsten Hopp 1469c4
      nfa_regprog_T *prog;
Karsten Hopp 1469c4
  {
Karsten Hopp 1469c4
!     FILE *debugf = fopen("LOG.log", "a");
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
      if (debugf != NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
--- 1843,1849 ----
Karsten Hopp 1469c4
  nfa_dump(prog)
Karsten Hopp 1469c4
      nfa_regprog_T *prog;
Karsten Hopp 1469c4
  {
Karsten Hopp 1469c4
!     FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a");
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
      if (debugf != NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 1994,2007 ****
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
      static void
Karsten Hopp 1469c4
  st_error(postfix, end, p)
Karsten Hopp 1469c4
!     int *postfix;
Karsten Hopp 1469c4
!     int *end;
Karsten Hopp 1469c4
!     int *p;
Karsten Hopp 1469c4
  {
Karsten Hopp 1469c4
      FILE *df;
Karsten Hopp 1469c4
      int *p2;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
!     df = fopen("stack.err", "a");
Karsten Hopp 1469c4
      if (df)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
  	fprintf(df, "Error popping the stack!\n");
Karsten Hopp 1469c4
--- 2010,2024 ----
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
      static void
Karsten Hopp 1469c4
  st_error(postfix, end, p)
Karsten Hopp 1469c4
!     int *postfix UNUSED;
Karsten Hopp 1469c4
!     int *end UNUSED;
Karsten Hopp 1469c4
!     int *p UNUSED;
Karsten Hopp 1469c4
  {
Karsten Hopp 1469c4
+ #ifdef NFA_REGEXP_ERROR_LOG
Karsten Hopp 1469c4
      FILE *df;
Karsten Hopp 1469c4
      int *p2;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
!     df = fopen(NFA_REGEXP_ERROR_LOG, "a");
Karsten Hopp 1469c4
      if (df)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
  	fprintf(df, "Error popping the stack!\n");
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2036,2041 ****
Karsten Hopp 1469c4
--- 2053,2059 ----
Karsten Hopp 1469c4
  	fprintf(df, "\n--------------------------\n");
Karsten Hopp 1469c4
  	fclose(df);
Karsten Hopp 1469c4
      }
Karsten Hopp 1469c4
+ #endif
Karsten Hopp 1469c4
      EMSG(_("E874: (NFA) Could not pop the stack !"));
Karsten Hopp 1469c4
  }
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2148,2155 ****
Karsten Hopp 1469c4
--- 2166,2175 ----
Karsten Hopp 1469c4
  	    }
Karsten Hopp 1469c4
  	    e1 = POP();
Karsten Hopp 1469c4
  	    e1.start->negated = TRUE;
Karsten Hopp 1469c4
+ #ifdef FEAT_MBYTE
Karsten Hopp 1469c4
  	    if (e1.start->c == NFA_COMPOSING)
Karsten Hopp 1469c4
  		e1.start->out1->negated = TRUE;
Karsten Hopp 1469c4
+ #endif
Karsten Hopp 1469c4
  	    PUSH(e1);
Karsten Hopp 1469c4
  	    break;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2265,2270 ****
Karsten Hopp 1469c4
--- 2285,2291 ----
Karsten Hopp 1469c4
  	    PUSH(frag(s, list1(&s1->out)));
Karsten Hopp 1469c4
  	    break;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
+ #ifdef FEAT_MBYTE
Karsten Hopp 1469c4
  	case NFA_COMPOSING:	/* char with composing char */
Karsten Hopp 1469c4
  #if 0
Karsten Hopp 1469c4
  	    /* TODO */
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2274,2279 ****
Karsten Hopp 1469c4
--- 2295,2301 ----
Karsten Hopp 1469c4
  	    }
Karsten Hopp 1469c4
  #endif
Karsten Hopp 1469c4
  	    /* FALLTHROUGH */
Karsten Hopp 1469c4
+ #endif
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  	case NFA_MOPEN + 0:	/* Submatch */
Karsten Hopp 1469c4
  	case NFA_MOPEN + 1:
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2298,2306 ****
Karsten Hopp 1469c4
--- 2320,2330 ----
Karsten Hopp 1469c4
  		case NFA_NOPEN:
Karsten Hopp 1469c4
  		    mclose = NFA_NCLOSE;
Karsten Hopp 1469c4
  		    break;
Karsten Hopp 1469c4
+ #ifdef FEAT_MBYTE
Karsten Hopp 1469c4
  		case NFA_COMPOSING:
Karsten Hopp 1469c4
  		    mclose = NFA_END_COMPOSING;
Karsten Hopp 1469c4
  		    break;
Karsten Hopp 1469c4
+ #endif
Karsten Hopp 1469c4
  		default:
Karsten Hopp 1469c4
  		    /* NFA_MOPEN(0) ... NFA_MOPEN(9) */
Karsten Hopp 1469c4
  		    mclose = *p + NSUBEXP;
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2336,2344 ****
Karsten Hopp 1469c4
--- 2360,2370 ----
Karsten Hopp 1469c4
  		goto theend;
Karsten Hopp 1469c4
  	    patch(e.out, s1);
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
+ #ifdef FEAT_MBYTE
Karsten Hopp 1469c4
  	    if (mopen == NFA_COMPOSING)
Karsten Hopp 1469c4
  		/* COMPOSING->out1 = END_COMPOSING */
Karsten Hopp 1469c4
  		patch(list1(&s->out1), s1);
Karsten Hopp 1469c4
+ #endif
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  	    PUSH(frag(s, list1(&s1->out)));
Karsten Hopp 1469c4
  	    break;
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2802,2809 ****
Karsten Hopp 1469c4
      thread_T	*t;
Karsten Hopp 1469c4
      char_u	*old_reginput = NULL;
Karsten Hopp 1469c4
      char_u	*old_regline = NULL;
Karsten Hopp 1469c4
-     nfa_state_T	*sta;
Karsten Hopp 1469c4
-     nfa_state_T *end;
Karsten Hopp 1469c4
      List	list[3];
Karsten Hopp 1469c4
      List	*listtbl[2][2];
Karsten Hopp 1469c4
      List	*ll;
Karsten Hopp 1469c4
--- 2828,2833 ----
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2813,2825 ****
Karsten Hopp 1469c4
      List	*neglist;
Karsten Hopp 1469c4
      int		*listids = NULL;
Karsten Hopp 1469c4
      int		j = 0;
Karsten Hopp 1469c4
-     int		len = 0;
Karsten Hopp 1469c4
  #ifdef NFA_REGEXP_DEBUG_LOG
Karsten Hopp 1469c4
!     FILE	*debug = fopen(NFA_REGEXP_DEBUG_LOG_NAME, "a");
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
      if (debug == NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
! 	EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG_NAME);
Karsten Hopp 1469c4
  	return FALSE;
Karsten Hopp 1469c4
      }
Karsten Hopp 1469c4
  #endif
Karsten Hopp 1469c4
--- 2837,2848 ----
Karsten Hopp 1469c4
      List	*neglist;
Karsten Hopp 1469c4
      int		*listids = NULL;
Karsten Hopp 1469c4
      int		j = 0;
Karsten Hopp 1469c4
  #ifdef NFA_REGEXP_DEBUG_LOG
Karsten Hopp 1469c4
!     FILE	*debug = fopen(NFA_REGEXP_DEBUG_LOG, "a");
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
      if (debug == NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
! 	EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG);
Karsten Hopp 1469c4
  	return FALSE;
Karsten Hopp 1469c4
      }
Karsten Hopp 1469c4
  #endif
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 2836,2842 ****
Karsten Hopp 1469c4
      vim_memset(list[2].t, 0, size);
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  #ifdef ENABLE_LOG
Karsten Hopp 1469c4
!     log_fd = fopen(LOG_NAME, "a");
Karsten Hopp 1469c4
      if (log_fd != NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
  	fprintf(log_fd, "**********************************\n");
Karsten Hopp 1469c4
--- 2859,2865 ----
Karsten Hopp 1469c4
      vim_memset(list[2].t, 0, size);
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  #ifdef ENABLE_LOG
Karsten Hopp 1469c4
!     log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
Karsten Hopp 1469c4
      if (log_fd != NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
  	fprintf(log_fd, "**********************************\n");
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 3025,3031 ****
Karsten Hopp 1469c4
  		nfa_restore_listids(start, listids);
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  #ifdef ENABLE_LOG
Karsten Hopp 1469c4
! 		log_fd = fopen(LOG_NAME, "a");
Karsten Hopp 1469c4
  		if (log_fd != NULL)
Karsten Hopp 1469c4
  		{
Karsten Hopp 1469c4
  		    fprintf(log_fd, "****************************\n");
Karsten Hopp 1469c4
--- 3048,3054 ----
Karsten Hopp 1469c4
  		nfa_restore_listids(start, listids);
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  #ifdef ENABLE_LOG
Karsten Hopp 1469c4
! 		log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
Karsten Hopp 1469c4
  		if (log_fd != NULL)
Karsten Hopp 1469c4
  		{
Karsten Hopp 1469c4
  		    fprintf(log_fd, "****************************\n");
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 3141,3147 ****
Karsten Hopp 1469c4
  #ifdef FEAT_MBYTE
Karsten Hopp 1469c4
  	    case NFA_COMPOSING:
Karsten Hopp 1469c4
  	    {
Karsten Hopp 1469c4
! 		int mc = c;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  		result = OK;
Karsten Hopp 1469c4
  		sta = t->state->out;
Karsten Hopp 1469c4
--- 3164,3173 ----
Karsten Hopp 1469c4
  #ifdef FEAT_MBYTE
Karsten Hopp 1469c4
  	    case NFA_COMPOSING:
Karsten Hopp 1469c4
  	    {
Karsten Hopp 1469c4
! 		int	    mc = c;
Karsten Hopp 1469c4
! 		int	    len = 0;
Karsten Hopp 1469c4
! 		nfa_state_T *end;
Karsten Hopp 1469c4
! 		nfa_state_T *sta;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  		result = OK;
Karsten Hopp 1469c4
  		sta = t->state->out;
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 3469,3475 ****
Karsten Hopp 1469c4
      need_clear_subexpr = TRUE;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  #ifdef ENABLE_LOG
Karsten Hopp 1469c4
!     f = fopen(LOG_NAME, "a");
Karsten Hopp 1469c4
      if (f != NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
  	fprintf(f, "\n\n\n\n\n\n\t\t=======================================================\n");
Karsten Hopp 1469c4
--- 3495,3501 ----
Karsten Hopp 1469c4
      need_clear_subexpr = TRUE;
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  #ifdef ENABLE_LOG
Karsten Hopp 1469c4
!     f = fopen(NFA_REGEXP_RUN_LOG, "a");
Karsten Hopp 1469c4
      if (f != NULL)
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
  	fprintf(f, "\n\n\n\n\n\n\t\t=======================================================\n");
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 3662,3668 ****
Karsten Hopp 1469c4
       */
Karsten Hopp 1469c4
  #ifdef ENABLE_LOG
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
! 	FILE *f = fopen(LOG_NAME, "a");
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  	if (f != NULL)
Karsten Hopp 1469c4
  	{
Karsten Hopp 1469c4
--- 3688,3694 ----
Karsten Hopp 1469c4
       */
Karsten Hopp 1469c4
  #ifdef ENABLE_LOG
Karsten Hopp 1469c4
      {
Karsten Hopp 1469c4
! 	FILE *f = fopen(NFA_REGEXP_RUN_LOG, "a");
Karsten Hopp 1469c4
  
Karsten Hopp 1469c4
  	if (f != NULL)
Karsten Hopp 1469c4
  	{
Karsten Hopp 1469c4
*** ../vim-7.3.1012/src/version.c	2013-05-24 23:10:45.000000000 +0200
Karsten Hopp 1469c4
--- src/version.c	2013-05-25 12:06:33.000000000 +0200
Karsten Hopp 1469c4
***************
Karsten Hopp 1469c4
*** 730,731 ****
Karsten Hopp 1469c4
--- 730,733 ----
Karsten Hopp 1469c4
  {   /* Add new patch number below this line */
Karsten Hopp 1469c4
+ /**/
Karsten Hopp 1469c4
+     1013,
Karsten Hopp 1469c4
  /**/
Karsten Hopp 1469c4
Karsten Hopp 1469c4
-- 
Karsten Hopp 1469c4
Scientists decoded the first message from an alien civilization:
Karsten Hopp 1469c4
        SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
Karsten Hopp 1469c4
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
Karsten Hopp 1469c4
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
Karsten Hopp 1469c4
STAR SYSTEMS.  WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
Karsten Hopp 1469c4
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
Karsten Hopp 1469c4
MAXIMUM!  IT REALLY WORKS!
Karsten Hopp 1469c4
Karsten Hopp 1469c4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 1469c4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 1469c4
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 1469c4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///