Branch: Tag:

2014-12-04

2014-12-04 19:23:32 by Per Hedbor <ph@opera.com>

Check the real range for strings when getting their type.

As an example:

| Pike v7.9 release 5 running Hilfe v3.5 (Incremental Pike Frontend)
| > typeof("foo");
| (1) Result: string(102..111)

7784:    case T_STRING:    type_stack_mark();    if (s->u.string->len) { -  /* FIXME: Could be extended to detect 7-bit strings, etc. */ -  if (s->u.string->size_shift == 2) { -  push_int_type(MIN_INT32, MAX_INT32); +  INT32 min, max; +  check_string_range( s->u.string, 0, &min, &max ); +  push_int_type(min, max);    } else { -  push_int_type(0, (1<<(8 << s->u.string->size_shift)) - 1); -  } -  } else { +     push_type(T_ZERO);    }    push_type(T_STRING);