diff options
author | Wim Taymans <wtaymans@redhat.com> | 2014-09-22 10:14:04 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2014-09-22 10:14:04 +0200 |
commit | 9bf0679ede472ef9b1a9bc3365d7fd7ef06f1356 (patch) | |
tree | 61a568f2ad779d2c4be02c8f0c5f641186a3bc6b | |
parent | 697a7db9c60f78de13c4e23d3c16185e4ab53f14 (diff) |
parse: cleanupwork2
Be more elegant in parsing and passing the parameters to
orc_program_append_str_2().
-rw-r--r-- | orc/orcparse.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/orc/orcparse.c b/orc/orcparse.c index 23c4dd1..164fe54 100644 --- a/orc/orcparse.c +++ b/orc/orcparse.c @@ -288,6 +288,7 @@ orc_parse_full (const char *code, OrcProgram ***programs, char **log) if (o) { int n_args = opcode_n_args (o); int i, j; + char *args[4] = { NULL }; if (n_tokens != 1 + offset + n_args) { orc_parse_log (parser, "error: line %d: too %s arguments for %s (expected %d)\n", @@ -304,18 +305,11 @@ orc_parse_full (const char *code, OrcProgram ***programs, char **log) orc_program_add_constant_str (parser->program, opcode_arg_size(o, j), token[i], token[i]); } + args[j] = token[i]; } - if (n_tokens - offset == 5) { - orc_program_append_str_2 (parser->program, token[offset], flags, - token[offset+1], token[offset+2], token[offset+3], token[offset+4]); - } else if (n_tokens - offset == 4) { - orc_program_append_str_2 (parser->program, token[offset], flags, - token[offset+1], token[offset+2], token[offset+3], NULL); - } else { - orc_program_append_str_2 (parser->program, token[offset], flags, - token[offset+1], token[offset+2], NULL, NULL); - } + orc_program_append_str_2 (parser->program, token[offset], flags, + args[0], args[1], args[2], args[3]); } else { orc_parse_log (parser, "error: line %d: unknown opcode: %s\n", parser->line_number, |