⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rx.c

📁 ac3的解码程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#endif{  int x;  unsigned long hash = (unsigned long)rx_bitset_hash;  for (x = rx_bitset_numb_subsets(size) - 1; x >= 0; --x)    hash ^= rx_bitset_subset_val(b, x);  return hash;}RX_DECL RX_subset rx_subset_singletons [RX_subset_bits] = {  0x1,  0x2,  0x4,  0x8,  0x10,  0x20,  0x40,  0x80,  0x100,  0x200,  0x400,  0x800,  0x1000,  0x2000,  0x4000,  0x8000,  0x10000,  0x20000,  0x40000,  0x80000,  0x100000,  0x200000,  0x400000,  0x800000,  0x1000000,  0x2000000,  0x4000000,  0x8000000,  0x10000000,  0x20000000,  0x40000000,  0x80000000};#ifdef RX_DEBUG#ifdef __STDC__static voidprint_cset (struct rx *rx, rx_Bitset cset, FILE * fp)#elsestatic voidprint_cset (rx, cset, fp)     struct rx *rx;     rx_Bitset cset;     FILE * fp;#endif{  int x;  fputc ('[', fp);  for (x = 0; x < rx->local_cset_size; ++x)    if (RX_bitset_member (cset, x))      {	if (isprint(x))	  fputc (x, fp);	else	  fprintf (fp, "\\0%o ", x);      }  fputc (']', fp);}#endif /*  RX_DEBUG */static unsigned long rx_hash_masks[4] ={  0x12488421,  0x96699669,  0xbe7dd7eb,  0xffffffff};/* Hash tables */#ifdef __STDC__RX_DECL struct rx_hash_item * rx_hash_find (struct rx_hash * table,	      unsigned long hash,	      void * value,	      struct rx_hash_rules * rules)#elseRX_DECL struct rx_hash_item * rx_hash_find (table, hash, value, rules)     struct rx_hash * table;     unsigned long hash;     void * value;     struct rx_hash_rules * rules;#endif{  rx_hash_eq eq = rules->eq;  int maskc = 0;  long mask = rx_hash_masks [0];  int bucket = (hash & mask) % 13;  while (table->children [bucket])    {      table = table->children [bucket];      ++maskc;      mask = rx_hash_masks[maskc];      bucket = (hash & mask) % 13;    }  {    struct rx_hash_item * it = table->buckets[bucket];    while (it)      if (eq (it->data, value))	return it;      else	it = it->next_same_hash;  }  return 0;}#ifdef __STDC__RX_DECL struct rx_hash_item *rx_hash_store (struct rx_hash * table,	       unsigned long hash,	       void * value,	       struct rx_hash_rules * rules)#elseRX_DECL struct rx_hash_item *rx_hash_store (table, hash, value, rules)     struct rx_hash * table;     unsigned long hash;     void * value;     struct rx_hash_rules * rules;#endif{  rx_hash_eq eq = rules->eq;  int maskc = 0;  long mask = rx_hash_masks[0];  int bucket = (hash & mask) % 13;  int depth = 0;    while (table->children [bucket])    {      table = table->children [bucket];      ++maskc;      mask = rx_hash_masks[maskc];      bucket = (hash & mask) % 13;      ++depth;    }    {    struct rx_hash_item * it = table->buckets[bucket];    while (it)      if (eq (it->data, value))	return it;      else	it = it->next_same_hash;  }    {    if (   (depth < 3)	&& (table->bucket_size [bucket] >= 4))      {	struct rx_hash * newtab = ((struct rx_hash *)				   rules->hash_alloc (rules));	if (!newtab)	  goto add_to_bucket;	bzero (newtab, sizeof (*newtab));	newtab->parent = table;	{	  struct rx_hash_item * them = table->buckets[bucket];	  unsigned long newmask = rx_hash_masks[maskc + 1];	  while (them)	    {	      struct rx_hash_item * save = them->next_same_hash;	      int new_buck = (them->hash & newmask) % 13;	      them->next_same_hash = newtab->buckets[new_buck];	      newtab->buckets[new_buck] = them;	      them->table = newtab;	      them = save;	      ++newtab->bucket_size[new_buck];	      ++newtab->refs;	    }	  table->refs = (table->refs - table->bucket_size[bucket] + 1);	  table->bucket_size[bucket] = 0;	  table->buckets[bucket] = 0;	  table->children[bucket] = newtab;	  table = newtab;	  bucket = (hash & newmask) % 13;	}      }  } add_to_bucket:  {    struct rx_hash_item  * it = ((struct rx_hash_item *)				 rules->hash_item_alloc (rules, value));    if (!it)      return 0;    it->hash = hash;    it->table = table;    /* DATA and BINDING are to be set in hash_item_alloc */    it->next_same_hash = table->buckets [bucket];    table->buckets[bucket] = it;    ++table->bucket_size [bucket];    ++table->refs;    return it;  }}#ifdef __STDC__RX_DECL voidrx_hash_free (struct rx_hash_item * it, struct rx_hash_rules * rules)#elseRX_DECL voidrx_hash_free (it, rules)     struct rx_hash_item * it;     struct rx_hash_rules * rules;#endif{  if (it)    {      struct rx_hash * table = it->table;      unsigned long hash = it->hash;      int depth = (table->parent		   ? (table->parent->parent		      ? (table->parent->parent->parent			 ? 3			 : 2)		      : 1)		   : 0);      int bucket = (hash & rx_hash_masks [depth]) % 13;      struct rx_hash_item ** pos = &table->buckets [bucket];            while (*pos != it)	pos = &(*pos)->next_same_hash;      *pos = it->next_same_hash;      rules->free_hash_item (it, rules);      --table->bucket_size[bucket];      --table->refs;      while (!table->refs && depth)	{	  struct rx_hash * save = table;	  table = table->parent;	  --depth;	  bucket = (hash & rx_hash_masks [depth]) % 13;	  --table->refs;	  table->children[bucket] = 0;	  rules->free_hash (save, rules);	}    }}#ifdef __STDC__RX_DECL voidrx_free_hash_table (struct rx_hash * tab, rx_hash_freefn freefn,		    struct rx_hash_rules * rules)#elseRX_DECL voidrx_free_hash_table (tab, freefn, rules)     struct rx_hash * tab;     rx_hash_freefn freefn;     struct rx_hash_rules * rules;#endif{  int x;  for (x = 0; x < 13; ++x)    if (tab->children[x])      {	rx_free_hash_table (tab->children[x], freefn, rules);	rules->free_hash (tab->children[x], rules);      }    else      {	struct rx_hash_item * them = tab->buckets[x];	while (them)	  {	    struct rx_hash_item * that = them;	    them = that->next_same_hash;	    freefn (that);	    rules->free_hash_item (that, rules);	  }      }}/* Utilities for manipulating bitset represntations of characters sets. */#ifdef __STDC__RX_DECL rx_Bitsetrx_cset (struct rx *rx)#elseRX_DECL rx_Bitsetrx_cset (rx)     struct rx *rx;#endif{  rx_Bitset b = (rx_Bitset) malloc (rx_sizeof_bitset (rx->local_cset_size));  if (b)    rx_bitset_null (rx->local_cset_size, b);  return b;}#ifdef __STDC__RX_DECL rx_Bitsetrx_copy_cset (struct rx *rx, rx_Bitset a)#elseRX_DECL rx_Bitsetrx_copy_cset (rx, a)     struct rx *rx;     rx_Bitset a;#endif{  rx_Bitset cs = rx_cset (rx);  if (cs)    rx_bitset_union (rx->local_cset_size, cs, a);  return cs;}#ifdef __STDC__RX_DECL voidrx_free_cset (struct rx * rx, rx_Bitset c)#elseRX_DECL voidrx_free_cset (rx, c)     struct rx * rx;     rx_Bitset c;#endif{  if (c)    free ((char *)c);}/* Hash table memory allocation policy for the regexp compiler */#ifdef __STDC__static struct rx_hash *compiler_hash_alloc (struct rx_hash_rules * rules)#elsestatic struct rx_hash *compiler_hash_alloc (rules)     struct rx_hash_rules * rules;#endif{  return (struct rx_hash *)malloc (sizeof (struct rx_hash));}#ifdef __STDC__static struct rx_hash_item *compiler_hash_item_alloc (struct rx_hash_rules * rules, void * value)#elsestatic struct rx_hash_item *compiler_hash_item_alloc (rules, value)     struct rx_hash_rules * rules;     void * value;#endif{  struct rx_hash_item * it;  it = (struct rx_hash_item *)malloc (sizeof (*it));  if (it)    {      it->data = value;      it->binding = 0;    }  return it;}#ifdef __STDC__static voidcompiler_free_hash (struct rx_hash * tab,		    struct rx_hash_rules * rules)#elsestatic voidcompiler_free_hash (tab, rules)     struct rx_hash * tab;     struct rx_hash_rules * rules;#endif{  free ((char *)tab);}#ifdef __STDC__static voidcompiler_free_hash_item (struct rx_hash_item * item,			 struct rx_hash_rules * rules)#elsestatic voidcompiler_free_hash_item (item, rules)     struct rx_hash_item * item;     struct rx_hash_rules * rules;#endif{  free ((char *)item);}/* This page: REXP_NODE (expression tree) structures. */#ifdef __STDC__RX_DECL struct rexp_node *rexp_node (struct rx *rx,	   enum rexp_node_type type)#elseRX_DECL struct rexp_node *rexp_node (rx, type)     struct rx *rx;     enum rexp_node_type type;#endif{  struct rexp_node *n;  n = (struct rexp_node *)malloc (sizeof (*n));  bzero (n, sizeof (*n));  if (n)    n->type = type;  return n;}/* free_rexp_node assumes that the bitset passed to rx_mk_r_cset * can be freed using rx_free_cset. */#ifdef __STDC__RX_DECL struct rexp_node *rx_mk_r_cset (struct rx * rx,	      rx_Bitset b)#elseRX_DECL struct rexp_node *rx_mk_r_cset (rx, b)     struct rx * rx;     rx_Bitset b;#endif{  struct rexp_node * n = rexp_node (rx, r_cset);  if (n)    n->params.cset = b;  return n;}#ifdef __STDC__RX_DECL struct rexp_node *rx_mk_r_concat (struct rx * rx,		struct rexp_node * a,		struct rexp_node * b)#elseRX_DECL struct rexp_node *rx_mk_r_concat (rx, a, b)     struct rx * rx;     struct rexp_node * a;     struct rexp_node * b;#endif{  struct rexp_node * n = rexp_node (rx, r_concat);  if (n)    {      n->params.pair.left = a;      n->params.pair.right = b;    }  return n;}#ifdef __STDC__RX_DECL struct rexp_node *rx_mk_r_alternate (struct rx * rx,		   struct rexp_node * a,		   struct rexp_node * b)#elseRX_DECL struct rexp_node *rx_mk_r_alternate (rx, a, b)     struct rx * rx;     struct rexp_node * a;     struct rexp_node * b;#endif{  struct rexp_node * n = rexp_node (rx, r_alternate);  if (n)    {      n->params.pair.left = a;      n->params.pair.right = b;    }  return n;}#ifdef __STDC__RX_DECL struct rexp_node *rx_mk_r_opt (struct rx * rx,	     struct rexp_node * a)#elseRX_DECL struct rexp_node *rx_mk_r_opt (rx, a)     struct rx * rx;     struct rexp_node * a;#endif{  struct rexp_node * n = rexp_node (rx, r_opt);  if (n)    {      n->params.pair.left = a;      n->params.pair.right = 0;    }  return n;}#ifdef __STDC__RX_DECL struct rexp_node *rx_mk_r_star (struct rx * rx,	      struct rexp_node * a)#elseRX_DECL struct rexp_node *rx_mk_r_star (rx, a)     struct rx * rx;     struct rexp_node * a;#endif{  struct rexp_node * n = rexp_node (rx, r_star);  if (n)    {      n->params.pair.left = a;      n->params.pair.right = 0;    }  return n;}#ifdef __STDC__RX_DECL struct rexp_node *rx_mk_r_2phase_star (struct rx * rx,		     struct rexp_node * a,		     struct rexp_node * b)#elseRX_DECL struct rexp_node *rx_mk_r_2phase_star (rx, a, b)     struct rx * rx;     struct rexp_node * a;     struct rexp_node * b;#endif{  struct rexp_node * n = rexp_node (rx, r_2phase_star);  if (n)    {      n->params.pair.left = a;      n->params.pair.right = b;    }  return n;}#ifdef __STDC__RX_DECL struct rexp_node *rx_mk_r_side_effect (struct rx * rx,		     rx_side_effect a)#elseRX_DECL struct rexp_node *rx_mk_r_side_effect (rx, a)     struct rx * rx;     rx_side_effect a;#endif{  struct rexp_node * n = rexp_node (rx, r_side_effect);  if (n)    {      n->params.side_effect = a;      n->params.pair.right = 0;    }  return n;}#ifdef __STDC__RX_DECL struct rexp_node *rx_mk_r_data  (struct rx * rx,	       void * a)#elseRX_DECL struct rexp_node *rx_mk_r_data  (rx, a)     struct rx * rx;     void * a;#endif{  struct rexp_node * n = rexp_node (rx, r_data);  if (n)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -