diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-07 20:34:26 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-07 20:34:26 +0100 |
commit | 581e39ac203056633a627ad09167adf05753e091 (patch) | |
tree | a33b653b8c0604dc60f794df1d294b9a2de6b666 /parser.cpp | |
parent | a8d7d16fc7b857375337aa730382d225727798a4 (diff) | |
download | sciteco-581e39ac203056633a627ad09167adf05753e091.tar.gz |
check bounds when accessing the transitions table
Diffstat (limited to 'parser.cpp')
-rw-r--r-- | parser.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -33,7 +33,7 @@ macro_execute(const gchar *macro) State::State() { - for (int i = 0; i < MAX_TRANSITIONS; i++) + for (guint i = 0; i < G_N_ELEMENTS(transitions); i++) transitions[i] = NULL; } @@ -64,6 +64,20 @@ State::input(gchar chr) return TRUE; } +State * +State::get_next_state(gchar chr) +{ + State *next = NULL; + guint upper = g_ascii_toupper(chr); + + if (upper < G_N_ELEMENTS(transitions)) + next = transitions[upper]; + if (!next) + next = custom(chr); + + return next; +} + StateStart::StateStart() : State() { transitions['\0'] = this; |