Mercurial > hg > xemacs-beta
diff src/search.c @ 5041:efaa6cd845e5
add regexp-debugging
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-15 Ben Wing <ben@xemacs.org>
* regex.c:
* regex.c (DEBUG_FAIL_PRINT1):
* regex.c (PUSH_FAILURE_POINT):
* regex.c (POP_FAILURE_POINT):
* regex.c (regex_compile):
* regex.c (re_match_2_internal):
* regex.h:
* search.c:
* search.c (search_buffer):
* search.c (debug_regexps_changed):
* search.c (vars_of_search):
Add an internal variable debug_regexps and a corresponding Lisp
variable `debug-regexps' that takes a list of areas in which to
display debugging info about regex compilation and matching
(currently three areas exist). Use existing debugging code
already in regex.c and modify it so that it recognizes the
debug_regexps variable and the flags in it.
Rename variable `debug-xemacs-searches' to just `debug-searches',
consistent with other debug vars.
tests/ChangeLog addition:
2010-02-15 Ben Wing <ben@xemacs.org>
* automated/search-tests.el (let):
* automated/search-tests.el (boundp):
debug-xemacs-searches renamed to debug-searches.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 15 Feb 2010 21:51:22 -0600 |
parents | 2ade80e8c640 |
children | 99f8ebc082d9 |
line wrap: on
line diff
--- a/src/search.c Wed Feb 10 07:25:19 2010 -0600 +++ b/src/search.c Mon Feb 15 21:51:22 2010 -0600 @@ -1,7 +1,7 @@ /* String search routines for XEmacs. Copyright (C) 1985, 1986, 1987, 1992-1995 Free Software Foundation, Inc. Copyright (C) 1995 Sun Microsystems, Inc. - Copyright (C) 2001, 2002 Ben Wing. + Copyright (C) 2001, 2002, 2010 Ben Wing. This file is part of XEmacs. @@ -50,10 +50,17 @@ #ifdef DEBUG_XEMACS /* Used in tests/automated/case-tests.el if available. */ -Fixnum debug_xemacs_searches; +Fixnum debug_searches; + +/* Declare as int rather than Bitflags because it's used by regex.c, which + may be used outside of XEmacs (e.g. etags.c). */ +int debug_regexps; +Lisp_Object Vdebug_regexps; Lisp_Object Qsearch_algorithm_used, Qboyer_moore, Qsimple_search; +Lisp_Object Qcompilation, Qfailure_point, Qmatching; + #endif /* If the regexp is non-nil, then the buffer contains the compiled form @@ -1461,7 +1468,7 @@ if (!checked) { #ifdef DEBUG_XEMACS - if (debug_xemacs_searches) + if (debug_searches) { Lisp_Symbol *sym = XSYMBOL (Qsearch_algorithm_used); sym->value = Qnil; @@ -1527,7 +1534,7 @@ pat = base_pat = patbuf; #ifdef DEBUG_XEMACS - if (debug_xemacs_searches) + if (debug_searches) { Lisp_Symbol *sym = XSYMBOL (Qsearch_algorithm_used); sym->value = boyer_moore_ok ? Qboyer_moore : Qsimple_search; @@ -3333,6 +3340,35 @@ } +#ifdef DEBUG_XEMACS + +static int +debug_regexps_changed (Lisp_Object UNUSED (sym), Lisp_Object *val, + Lisp_Object UNUSED (in_object), + int UNUSED (flags)) +{ + int newval = 0; + + EXTERNAL_LIST_LOOP_2 (elt, *val) + { + CHECK_SYMBOL (elt); + if (EQ (elt, Qcompilation)) + newval |= RE_DEBUG_COMPILATION; + else if (EQ (elt, Qfailure_point)) + newval |= RE_DEBUG_FAILURE_POINT; + else if (EQ (elt, Qmatching)) + newval |= RE_DEBUG_MATCHING; + else + invalid_argument + ("Expected `compilation', `failure-point' or `matching'", elt); + } + debug_regexps = newval; + return 0; +} + +#endif /* DEBUG_XEMACS */ + + /************************************************************************/ /* initialization */ /************************************************************************/ @@ -3421,10 +3457,26 @@ DEFSYMBOL (Qboyer_moore); DEFSYMBOL (Qsimple_search); - DEFVAR_INT ("debug-xemacs-searches", &debug_xemacs_searches /* + DEFSYMBOL (Qcompilation); + DEFSYMBOL (Qfailure_point); + DEFSYMBOL (Qmatching); + + DEFVAR_INT ("debug-searches", &debug_searches /* If non-zero, bind `search-algorithm-used' to `boyer-moore' or `simple-search', depending on the algorithm used for each search. Used for testing. */ ); - debug_xemacs_searches = 0; -#endif + debug_searches = 0; + + DEFVAR_LISP_MAGIC ("debug-regexps", &Vdebug_regexps, /* +List of areas to display debug info about during regexp operation. +The following areas are recognized: + +`compilation' Display the result of compiling a regexp. +`failure-point' Display info about failure points reached. +`matching' Display info about the process of matching a regex against + text. +*/ debug_regexps_changed); + Vdebug_regexps = Qnil; + debug_regexps = 0; +#endif /* DEBUG_XEMACS */ }