X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=src%2Fsearch.c;h=1a5f0a129e7f32997e26af73c10de0bf9a8189d3;hb=56c8b099ccef8240d76c6f88c3f31d86ae22cfba;hp=52271ce6740a0ff3a3143511be7674d3ad7d5724;hpb=f4953fd83622491d51033313ed8994897945d6c0;p=sxemacs diff --git a/src/search.c b/src/search.c index 52271ce..1a5f0a1 100644 --- a/src/search.c +++ b/src/search.c @@ -46,9 +46,11 @@ along with this program. If not, see . */ (!NILP (table) ? TRT_TABLE_OF (table, (Emchar) pos) : pos) #include "elhash.h" +/* Make sure these are ALWAYS powers of 2 */ #define REGEXP_CACHE_SIZE 0x80 #define REGEXP_CACHE_HASH_MASK (REGEXP_CACHE_SIZE-1) #define REGEXP_FASTMAP_SIZE 0400 +#define REGEXP_FASTMAP_MASK (REGEXP_FASTMAP_SIZE-1) #define __REGEXP_DEBUG__(args...) fprintf(stderr, "REGEXP " args) #ifndef REGEXP_DEBUG_FLAG @@ -333,7 +335,7 @@ compile_pattern(Lisp_Object pattern, static void compre_prfun(Lisp_Object obj, Lisp_Object pcfun, int escflag) { - write_fmt_str(pcfun, "#buffer)); if (escflag); } @@ -747,7 +749,7 @@ fast_string_match(Lisp_Object regexp, const Bufbyte * nonreloc, fixup_internal_substring(nonreloc, reloc, offset, &length); - + if (!NILP(reloc)) { if (no_quit) { newnonreloc = XSTRING_DATA(reloc); @@ -1867,9 +1869,9 @@ boyer_moore(struct buffer *buf, Bufbyte * base_pat, Bytecount len, this_translated = 0; } if (ch > REGEXP_FASTMAP_SIZE) - j = ((unsigned char)ch | 0200); + j = ((unsigned char)(ch & REGEXP_FASTMAP_MASK)| 0200); else - j = (unsigned char)ch; + j = (unsigned char)(ch & REGEXP_FASTMAP_MASK); if (i == infinity) stride_for_teases = BM_tab[j]; @@ -1882,9 +1884,9 @@ boyer_moore(struct buffer *buf, Bufbyte * base_pat, Bytecount len, while (1) { ch = TRANSLATE(inverse_trt, ch); if (ch > REGEXP_FASTMAP_SIZE) - j = ((unsigned char)ch | 0200); + j = ((unsigned char)(ch & REGEXP_FASTMAP_MASK) | 0200); else - j = (unsigned char)ch; + j = (unsigned char)(ch & REGEXP_FASTMAP_MASK); /* For all the characters that map into CH, set up simple_translate to map the last byte