I have improved logging of NFA regexp engine.
- refine macros for logging.
- add comments for logging.
Please check attached patch.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
# HG changeset patch
# Parent e782f5be8263bed448060c473adaec560ec83aed
diff -r e782f5be8263 -r cca83de64090 src/regexp_nfa.c
--- a/src/regexp_nfa.c Thu May 23 22:43:08 2013 +0200
+++ b/src/regexp_nfa.c Sat May 25 06:03:03 2013 +0900
@@ -5,12 +5,30 @@
* This file is included in "regexp.c".
*/
+/*
+ * Logging of NFA engine:
+ *
+ * NFA engine output four log files. One of them is error log, it is enabled
+ * always. Other three: dump, run and debug logs are enabled when compiled as
+ * debug mode.
+ *
+ * Error log: contains NFA engine's fatal errors.
+ *
+ * Dump log: contains compiled NFA state machine's information. Enabled on
+ * debug mode.
+ *
+ * Run log: contains information of matching procedure. Enabled on debug mode.
+ *
+ * Debug log: contains detailed information of matching procedure. Enabled on
+ * debug mode, but it can be disabled if undefined NFA_REGEXP_DEBUG_LOG.
+ */
+#define NFA_REGEXP_ERROR_LOG "nfa_regexp_error.log"
#ifdef DEBUG
/* Comment this out to disable log files. They can get pretty big */
# define ENABLE_LOG
-# define LOG_NAME "log_nfarun.log"
-# define NFA_REGEXP_DEBUG_LOG
-# define NFA_REGEXP_DEBUG_LOG_NAME "nfa_regexp_debug.log"
+# define NFA_REGEXP_DUMP_LOG "nfa_regexp_dump.log"
+# define NFA_REGEXP_RUN_LOG "nfa_regexp_run.log"
+# define NFA_REGEXP_DEBUG_LOG "nfa_regexp_debug.log"
#endif
/* Upper limit allowed for {m,n} repetitions handled by NFA */
@@ -1815,7 +1833,7 @@
int *p;
FILE *f;
- f = fopen("LOG.log", "a");
+ f = fopen(NFA_REGEXP_DUMP_LOG, "a");
if (f != NULL)
{
fprintf(f, "\n-------------------------\n");
@@ -1873,7 +1891,7 @@
nfa_dump(prog)
nfa_regprog_T *prog;
{
- FILE *debugf = fopen("LOG.log", "a");
+ FILE *debugf = fopen(NFA_REGEXP_DUMP_LOG, "a");
if (debugf != NULL)
{
@@ -2047,7 +2065,7 @@
FILE *df;
int *p2;
- df = fopen("stack.err", "a");
+ df = fopen(NFA_REGEXP_ERROR_LOG, "a");
if (df)
{
fprintf(df, "Error popping the stack!\n");
@@ -2867,11 +2885,11 @@
int j = 0;
int len = 0;
#ifdef NFA_REGEXP_DEBUG_LOG
- FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG_NAME, "a");
+ FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a");
if (debug == NULL)
{
- EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG_NAME);
+ EMSG2(_("(NFA) COULD NOT OPEN %s !"), NFA_REGEXP_DEBUG_LOG);
return FALSE;
}
#endif
@@ -2888,7 +2906,7 @@
vim_memset(list[2].t, 0, size);
#ifdef ENABLE_LOG
- log_fd = fopen(LOG_NAME, "a");
+ log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
if (log_fd != NULL)
{
fprintf(log_fd, "**********************************\n");
@@ -3077,7 +3095,7 @@
nfa_restore_listids(start, listids);
#ifdef ENABLE_LOG
- log_fd = fopen(LOG_NAME, "a");
+ log_fd = fopen(NFA_REGEXP_RUN_LOG, "a");
if (log_fd != NULL)
{
fprintf(log_fd, "****************************\n");
@@ -3509,7 +3527,7 @@
need_clear_subexpr = TRUE;
#ifdef ENABLE_LOG
- f = fopen(LOG_NAME, "a");
+ f = fopen(NFA_REGEXP_RUN_LOG, "a");
if (f != NULL)
{
fprintf(f, "\n\n\n\n\n\n\t\t=======================================================\n");
@@ -3702,7 +3720,7 @@
*/
#ifdef ENABLE_LOG
{
- FILE *f = fopen(LOG_NAME, "a");
+ FILE *f = fopen(NFA_REGEXP_RUN_LOG, "a");
if (f != NULL)
{