1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

eventids2.c: reduce size

* ext/ripper/eventids2.c (token_assoc): reduce size.  unsigned
  short can hold 65535 at least.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-10-28 02:53:24 +00:00
parent d3dc67350a
commit b5524d9f8a
2 changed files with 11 additions and 5 deletions

View file

@ -125,11 +125,13 @@ ripper_init_eventids2(void)
set_id2(CHAR);
}
STATIC_ASSERT(k__END___range, k__END__ < SHRT_MAX);
STATIC_ASSERT(ripper_scanner_ids_size, sizeof(ripper_scanner_ids) < SHRT_MAX);
#define O(member) (int)offsetof(ripper_scanner_ids_t, ripper_id_##member)
static const struct token_assoc {
int token;
int id_offset;
unsigned short token;
unsigned short id_offset;
} token_to_eventid[] = {
{' ', O(words_sep)},
{'!', O(op)},

View file

@ -149,9 +149,13 @@ def read_ids1_with_locations(path)
end
def read_ids2(path)
File.open(path) {|f|
return f.read.scan(/ID\s+ripper_id_(\w+)/).flatten.uniq.sort
}
src = File.open(path) {|f| f.read}
ids2 = src.scan(/ID\s+ripper_id_(\w+)/).flatten.uniq.sort
diff = src.scan(/set_id2\((\w+)\);/).flatten - ids2
unless diff.empty?
abort "missing scanner IDs: #{diff}"
end
return ids2
end
main