Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
5027:22179cd0fe15 | 5041:efaa6cd845e5 |
---|---|
1 /* String search routines for XEmacs. | 1 /* String search routines for XEmacs. |
2 Copyright (C) 1985, 1986, 1987, 1992-1995 Free Software Foundation, Inc. | 2 Copyright (C) 1985, 1986, 1987, 1992-1995 Free Software Foundation, Inc. |
3 Copyright (C) 1995 Sun Microsystems, Inc. | 3 Copyright (C) 1995 Sun Microsystems, Inc. |
4 Copyright (C) 2001, 2002 Ben Wing. | 4 Copyright (C) 2001, 2002, 2010 Ben Wing. |
5 | 5 |
6 This file is part of XEmacs. | 6 This file is part of XEmacs. |
7 | 7 |
8 XEmacs is free software; you can redistribute it and/or modify it | 8 XEmacs is free software; you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License as published by the | 9 under the terms of the GNU General Public License as published by the |
48 #define REGEXP_CACHE_SIZE 20 | 48 #define REGEXP_CACHE_SIZE 20 |
49 | 49 |
50 #ifdef DEBUG_XEMACS | 50 #ifdef DEBUG_XEMACS |
51 | 51 |
52 /* Used in tests/automated/case-tests.el if available. */ | 52 /* Used in tests/automated/case-tests.el if available. */ |
53 Fixnum debug_xemacs_searches; | 53 Fixnum debug_searches; |
54 | |
55 /* Declare as int rather than Bitflags because it's used by regex.c, which | |
56 may be used outside of XEmacs (e.g. etags.c). */ | |
57 int debug_regexps; | |
58 Lisp_Object Vdebug_regexps; | |
54 | 59 |
55 Lisp_Object Qsearch_algorithm_used, Qboyer_moore, Qsimple_search; | 60 Lisp_Object Qsearch_algorithm_used, Qboyer_moore, Qsimple_search; |
61 | |
62 Lisp_Object Qcompilation, Qfailure_point, Qmatching; | |
56 | 63 |
57 #endif | 64 #endif |
58 | 65 |
59 /* If the regexp is non-nil, then the buffer contains the compiled form | 66 /* If the regexp is non-nil, then the buffer contains the compiled form |
60 of that regexp, suitable for searching. */ | 67 of that regexp, suitable for searching. */ |
1459 } while (c != starting_c); | 1466 } while (c != starting_c); |
1460 | 1467 |
1461 if (!checked) | 1468 if (!checked) |
1462 { | 1469 { |
1463 #ifdef DEBUG_XEMACS | 1470 #ifdef DEBUG_XEMACS |
1464 if (debug_xemacs_searches) | 1471 if (debug_searches) |
1465 { | 1472 { |
1466 Lisp_Symbol *sym = XSYMBOL (Qsearch_algorithm_used); | 1473 Lisp_Symbol *sym = XSYMBOL (Qsearch_algorithm_used); |
1467 sym->value = Qnil; | 1474 sym->value = Qnil; |
1468 } | 1475 } |
1469 #endif | 1476 #endif |
1525 #endif /* MULE */ | 1532 #endif /* MULE */ |
1526 len = pat - patbuf; | 1533 len = pat - patbuf; |
1527 pat = base_pat = patbuf; | 1534 pat = base_pat = patbuf; |
1528 | 1535 |
1529 #ifdef DEBUG_XEMACS | 1536 #ifdef DEBUG_XEMACS |
1530 if (debug_xemacs_searches) | 1537 if (debug_searches) |
1531 { | 1538 { |
1532 Lisp_Symbol *sym = XSYMBOL (Qsearch_algorithm_used); | 1539 Lisp_Symbol *sym = XSYMBOL (Qsearch_algorithm_used); |
1533 sym->value = boyer_moore_ok ? Qboyer_moore : Qsimple_search; | 1540 sym->value = boyer_moore_ok ? Qboyer_moore : Qsimple_search; |
1534 } | 1541 } |
1535 #endif | 1542 #endif |
3331 { | 3338 { |
3332 return Qnil; | 3339 return Qnil; |
3333 } | 3340 } |
3334 | 3341 |
3335 | 3342 |
3343 #ifdef DEBUG_XEMACS | |
3344 | |
3345 static int | |
3346 debug_regexps_changed (Lisp_Object UNUSED (sym), Lisp_Object *val, | |
3347 Lisp_Object UNUSED (in_object), | |
3348 int UNUSED (flags)) | |
3349 { | |
3350 int newval = 0; | |
3351 | |
3352 EXTERNAL_LIST_LOOP_2 (elt, *val) | |
3353 { | |
3354 CHECK_SYMBOL (elt); | |
3355 if (EQ (elt, Qcompilation)) | |
3356 newval |= RE_DEBUG_COMPILATION; | |
3357 else if (EQ (elt, Qfailure_point)) | |
3358 newval |= RE_DEBUG_FAILURE_POINT; | |
3359 else if (EQ (elt, Qmatching)) | |
3360 newval |= RE_DEBUG_MATCHING; | |
3361 else | |
3362 invalid_argument | |
3363 ("Expected `compilation', `failure-point' or `matching'", elt); | |
3364 } | |
3365 debug_regexps = newval; | |
3366 return 0; | |
3367 } | |
3368 | |
3369 #endif /* DEBUG_XEMACS */ | |
3370 | |
3371 | |
3336 /************************************************************************/ | 3372 /************************************************************************/ |
3337 /* initialization */ | 3373 /* initialization */ |
3338 /************************************************************************/ | 3374 /************************************************************************/ |
3339 | 3375 |
3340 void | 3376 void |
3419 #ifdef DEBUG_XEMACS | 3455 #ifdef DEBUG_XEMACS |
3420 DEFSYMBOL (Qsearch_algorithm_used); | 3456 DEFSYMBOL (Qsearch_algorithm_used); |
3421 DEFSYMBOL (Qboyer_moore); | 3457 DEFSYMBOL (Qboyer_moore); |
3422 DEFSYMBOL (Qsimple_search); | 3458 DEFSYMBOL (Qsimple_search); |
3423 | 3459 |
3424 DEFVAR_INT ("debug-xemacs-searches", &debug_xemacs_searches /* | 3460 DEFSYMBOL (Qcompilation); |
3461 DEFSYMBOL (Qfailure_point); | |
3462 DEFSYMBOL (Qmatching); | |
3463 | |
3464 DEFVAR_INT ("debug-searches", &debug_searches /* | |
3425 If non-zero, bind `search-algorithm-used' to `boyer-moore' or `simple-search', | 3465 If non-zero, bind `search-algorithm-used' to `boyer-moore' or `simple-search', |
3426 depending on the algorithm used for each search. Used for testing. | 3466 depending on the algorithm used for each search. Used for testing. |
3427 */ ); | 3467 */ ); |
3428 debug_xemacs_searches = 0; | 3468 debug_searches = 0; |
3429 #endif | 3469 |
3430 } | 3470 DEFVAR_LISP_MAGIC ("debug-regexps", &Vdebug_regexps, /* |
3471 List of areas to display debug info about during regexp operation. | |
3472 The following areas are recognized: | |
3473 | |
3474 `compilation' Display the result of compiling a regexp. | |
3475 `failure-point' Display info about failure points reached. | |
3476 `matching' Display info about the process of matching a regex against | |
3477 text. | |
3478 */ debug_regexps_changed); | |
3479 Vdebug_regexps = Qnil; | |
3480 debug_regexps = 0; | |
3481 #endif /* DEBUG_XEMACS */ | |
3482 } |