pike.git / src / pike_search.c

version» Context lines:

pike.git/src/pike_search.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information.   */      /* New memory searcher functions */      #include "global.h" - #include "stuff.h" +    #include "mapping.h"   #include "object.h"   #include "pike_memory.h"   #include "stralloc.h"   #include "interpret.h"   #include "pike_error.h"   #include "module_support.h"   #include "pike_macros.h"   #include "pike_search.h" - #include "bignum.h" +       ptrdiff_t pike_search_struct_offset;   #define OB2MSEARCH(O) ((struct pike_mem_searcher *)((O)->storage+pike_search_struct_offset))   #define THIS_MSEARCH ((struct pike_mem_searcher *)(Pike_fp->current_storage))      /* NB: We use the least significant bit of memsearch_cache_threshold    * to indicate whether we are at MIN_MEMSEARCH_THRESHOLD or not.    */   #define MIN_MEMSEARCH_THRESHOLD 128   static int memsearch_cache_threshold;
pike.git/src/pike_search.c:64:   #if PIKE_BYTEORDER == 4321   #define GENERIC_GET4_CHARS(PTR) \    ( ((PTR)[0] << 24) + ( (PTR)[1] << 16 ) +( (PTR)[2] << 8 ) + (PTR)[3] )   #else /* PIKE_BYTEORDER != 4321 */   #define GENERIC_GET4_CHARS(PTR) \    ( ((PTR)[3] << 24) + ( (PTR)[2] << 16 ) +( (PTR)[1] << 8 ) + (PTR)[0] )   #endif /* PIKE_BYTEORDER == 4321 */      #define HUBBE_ALIGN0(q) q=(p_wchar0 *)(PTR_TO_INT(q) & ~(sizeof(INT32) - 1))   #define GET_4_ALIGNED_CHARS0(PTR) (*(INT32 *)(PTR)) - #define GET_4_UNALIGNED_CHARS0(PTR) EXTRACT_INT(PTR) + #define GET_4_UNALIGNED_CHARS0(PTR) (INT32)get_unaligned32(PTR)      #define HUBBE_ALIGN1(q)   #define GET_4_ALIGNED_CHARS1 GENERIC_GET4_CHARS   #define GET_4_UNALIGNED_CHARS1 GENERIC_GET4_CHARS      #define HUBBE_ALIGN2(q)   #define GET_4_ALIGNED_CHARS2 GENERIC_GET4_CHARS   #define GET_4_UNALIGNED_CHARS2 GENERIC_GET4_CHARS      
pike.git/src/pike_search.c:135:    case 0:    init_memsearch0(s,(p_wchar0*)needle.ptr, needlelen, max_haystacklen);    return;    case 1:    init_memsearch1(s,(p_wchar1*)needle.ptr, needlelen, max_haystacklen);    return;    case 2:    init_memsearch2(s,(p_wchar2*)needle.ptr, needlelen, max_haystacklen);    return;    } - #ifdef PIKE_DEBUG -  Pike_fatal("Illegal shift\n"); - #endif +    }      PMOD_EXPORT SearchMojt compile_memsearcher(PCHARP needle,    ptrdiff_t needlelen,    int max_haystacklen,    struct pike_string *hashkey)   {    switch(needle.shift)    { -  default: - #ifdef PIKE_DEBUG -  Pike_fatal("Illegal shift\n"); +     case 0: - #endif +     return compile_memsearcher0((p_wchar0*)needle.ptr, needlelen, max_haystacklen,hashkey);    case 1:    return compile_memsearcher1((p_wchar1*)needle.ptr, needlelen, max_haystacklen,hashkey);    case 2:    return compile_memsearcher2((p_wchar2*)needle.ptr, needlelen, max_haystacklen,hashkey);    } -  /* NOTREACHED */ +  UNREACHABLE();   }      PMOD_EXPORT SearchMojt simple_compile_memsearcher(struct pike_string *str)   {    return compile_memsearcher(MKPCHARP_STR(str),    str->len,    0x7fffffff,    str);   }   
pike.git/src/pike_search.c:189:    (ptrdiff_t)haystacklen);    return (char *) tmp.mojt.vtab->func0(tmp.mojt.data, (p_wchar0 *) haystack,    (ptrdiff_t)haystacklen);    /* No free required - Hubbe */   }      void init_pike_searching(void)   {    start_new_program();    pike_search_struct_offset=ADD_STORAGE(struct pike_mem_searcher); -  MAP_VARIABLE("__s", tStr, 0, +  PIKE_MAP_VARIABLE("__s",    pike_search_struct_offset + OFFSETOF(pike_mem_searcher,s), -  PIKE_T_STRING); +  tStr, PIKE_T_STRING, 0);    pike_search_program=end_program();    add_program_constant("Search",pike_search_program,ID_PROTECTED);       memsearch_cache=allocate_mapping(10);    memsearch_cache->data->flags |= MAPPING_FLAG_WEAK;   }      void exit_pike_searching(void)   {    if(pike_search_program)    {    free_program(pike_search_program);    pike_search_program=0;    }    if(memsearch_cache)    {    free_mapping(memsearch_cache);    memsearch_cache=0;    }   }