Esempio n. 1
0
static unsigned match_pattern(const ci_uint8* p, unsigned len,
			      const char** what)
{
  unsigned l, max = 0;
  unsigned i, off;
  static unsigned patterns[] = {
    0xDEADBEEF,
    0xCABBA9E5,
    0xDECEA5ED,
    0xDEADC0DE,
    0xACCE55ED,
    0xDEFFACED,
  };
  const char* names[] = {
    "deadbeef",
    "cabbages",
    "deceased",
    "deadcode",
    "accessed",
    "defaced ",
  };
  for( i = 0u; i < sizeof(patterns) / sizeof(patterns[0]); ++i ) {
    for( off = 0u; off < 4u; ++off ) {
      l = find_extent(p, len, off, patterns[i]);
      if( l > max ) {
	max = l;
	*what = names[i];
      }
    }
  }
  return max;
}
Esempio n. 2
0
/* Map the function MAP_FUNC(E, DATA) over all innermost extents E
   containing part of the section of TX specified by START, END.
   This function can be (and is) safely longjmp'd through. */
void
map_section_extents(void (*map_func)(Lisp_Extent *x, void *data),
		    Lisp_Extent *root, Pos *start, Pos *end, void *data)
{
    Lisp_Extent *x = find_extent(root, start);
    Pos s_copy = *start, e_copy = *end;
    intptr_t delta = row_delta(x->parent);
    s_copy.row -= delta; e_copy.row -= delta;

    while(x != 0 && PPOS_LESS_P(&x->start, &e_copy))
    {
	if(PPOS_GREATER_P(&x->end, &s_copy))
	{
	    /* Deleting X in here would screw things up..
	       Not much that can be done though. And it shouldn't
	       crash (famous last words..) */
	    map_func(x, data);
	}

	/* Try to work downwards and rightwards as much as possible */
	if(x->first_child != 0)
	{
	    /* Map though X's children as well. */
	    s_copy.row -= x->start.row;
	    e_copy.row -= x->start.row;
	    x = x->first_child;
	}
	else if(x->right_sibling != 0)
	    x = x->right_sibling;
	else if(x->parent != 0)
	{
	    s_copy.row += x->parent->start.row;
	    e_copy.row += x->parent->start.row;
	    x = x->parent->right_sibling;
	}
	else
	    break;
	assert_invariants (x);
    }
}