]> git.vpit.fr Git - perl/modules/re-engine-Hooks.git/blobdiff - Hooks.xs
No trailing whitespace
[perl/modules/re-engine-Hooks.git] / Hooks.xs
index eddf6ad62bbeac7ebc1e97bad99b2d24426faf3e..ef0c5082bdecc69867f59c85ad19932c0158edc9 100644 (file)
--- a/Hooks.xs
+++ b/Hooks.xs
@@ -58,8 +58,7 @@ STATIC SV *reh_hint(pTHX) {
 
 typedef struct reh_action {
  struct reh_action *next;
- reh_comp_hook      comp;
- reh_exec_hook      exec;
+ reh_config         cbs;
  const char        *key;
  STRLEN             klen;
 } reh_action;
@@ -73,7 +72,7 @@ STATIC perl_mutex reh_action_list_mutex;
 #endif /* USE_ITHREADS */
 
 #undef reh_register
-void reh_register(pTHX_ const char *key, reh_comp_hook comp, reh_exec_hook exec) {
+void reh_register(pTHX_ const char *key, reh_config *cfg) {
  reh_action *a;
  char       *key_dup;
  STRLEN      i, len;
@@ -87,8 +86,7 @@ void reh_register(pTHX_ const char *key, reh_comp_hook comp, reh_exec_hook exec)
  key_dup[len] = '\0';
 
  a       = PerlMemShared_malloc(sizeof *a);
- a->comp = comp;
- a->exec = exec;
+ a->cbs  = *cfg;
  a->key  = key_dup;
  a->klen = len;
 
@@ -115,11 +113,11 @@ void reh_call_comp_hook(pTHX_ regexp *rx, regnode *node) {
   REH_UNLOCK(&reh_action_list_mutex);
 
   for (; a; a = a->next) {
-   if (a->comp) {
+   if (a->cbs.comp) {
     char *p = strstr(keys, a->key);
 
     if (p && (p + a->klen <= keys + len) && p[a->klen] == ' ')
-     a->comp(aTHX_ rx, node);
+     a->cbs.comp(aTHX_ rx, node);
    }
   }
  }
@@ -138,11 +136,11 @@ void reh_call_exec_hook(pTHX_ regexp *rx, regnode *node, regmatch_info *reginfo,
   REH_UNLOCK(&reh_action_list_mutex);
 
   for (; a; a = a->next) {
-   if (a->exec) {
+   if (a->cbs.exec) {
     char *p = strstr(keys, a->key);
 
     if (p && (p + a->klen <= keys + len) && p[a->klen] == ' ')
-     a->exec(aTHX_ rx, node, reginfo, st);
+     a->cbs.exec(aTHX_ rx, node, reginfo, st);
    }
   }
  }
@@ -202,12 +200,12 @@ reh_re_compile(pTHX_ SV * const pattern, U32 flags)
  return RX;
 }
 
-const struct regexp_engine reh_regexp_engine = { 
- reh_re_compile, 
- reh_regexec, 
- reh_re_intuit_start, 
- reh_re_intuit_string, 
- reh_regfree, 
+const struct regexp_engine reh_regexp_engine = {
+ reh_re_compile,
+ reh_regexec,
+ reh_re_intuit_start,
+ reh_re_intuit_string,
+ reh_regfree,
  reh_reg_numbered_buff_fetch,
  reh_reg_numbered_buff_store,
  reh_reg_numbered_buff_length,
@@ -215,7 +213,7 @@ const struct regexp_engine reh_regexp_engine = {
  reh_reg_named_buff_iter,
  reh_reg_qr_package,
 #if defined(USE_ITHREADS)
- reh_regdupe 
+ reh_regdupe
 #endif
 };
 
@@ -230,6 +228,8 @@ BOOT:
 #ifdef USE_ITHREADS
  MUTEX_INIT(&reh_action_list_mutex);
 #endif
+
+ PERL_HASH(reh_hash, __PACKAGE__, __PACKAGE_LEN__);
 }
 
 void