diff options
author | Francesco Romani <fromani@gmail.com> | 2014-07-06 15:54:49 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2023-04-12 21:19:49 +0300 |
commit | b7d52f835013eddd90d1bb58c739cdf80cd0224d (patch) | |
tree | bac06577b3bec44b70c8b2464de3d470164abbda | |
parent | 8023d43b7457d2133bbd19f1ca5779e3fb4a1daf (diff) | |
download | orc-b7d52f835013eddd90d1bb58c739cdf80cd0224d.tar.gz |
parser: extract function to handle .m
Part-of: <https://gitlab.freedesktop.org/gstreamer/orc/-/merge_requests/30>
-rw-r--r-- | orc/orcparse.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/orc/orcparse.c b/orc/orcparse.c index 32e1e49..d001ec1 100644 --- a/orc/orcparse.c +++ b/orc/orcparse.c @@ -95,6 +95,7 @@ static int orc_parse_handle_function (OrcParser *parser, const OrcLine *line); static int orc_parse_handle_init (OrcParser *parser, const OrcLine *line); static int orc_parse_handle_flags (OrcParser *parser, const OrcLine *line); static int orc_parse_handle_dotn (OrcParser *parser, const OrcLine *line); +static int orc_parse_handle_dotm (OrcParser *parser, const OrcLine *line); static int orc_parse_handle_directive (OrcParser *parser, const OrcLine *line); static int orc_parse_handle_opcode (OrcParser *parser, const OrcLine *line); @@ -434,15 +435,7 @@ orc_parse_handle_legacy (OrcParser *parser, const OrcLine *line) const char **token = (const char **)(line->tokens); int n_tokens = line->n_tokens; - if (strcmp (token[0], ".m") == 0) { - if (n_tokens < 2) { - orc_parse_add_error (parser, "line %d: .m without value\n", - parser->line_number); - } else { - int size = strtol (token[1], NULL, 0); - orc_program_set_constant_m (parser->program, size); - } - } else if (strcmp (token[0], ".source") == 0) { + if (strcmp (token[0], ".source") == 0) { if (n_tokens < 3) { orc_parse_add_error (parser, "line %d: .source without size or identifier\n", parser->line_number); @@ -673,6 +666,23 @@ orc_parse_handle_dotn (OrcParser *parser, const OrcLine *line) } static int +orc_parse_handle_dotm (OrcParser *parser, const OrcLine *line) +{ + int size; + + if (line->n_tokens < 2) { + orc_parse_add_error (parser, "line %d: .m without value\n", + parser->line_number); + return 0; + } + + size = strtol (line->tokens[1], NULL, 0); + orc_program_set_constant_m (parser->program, size); + + return 1; +} + +static int orc_parse_handle_directive (OrcParser *parser, const OrcLine *line) { static const OrcDirective dirs[] = { @@ -681,6 +691,7 @@ orc_parse_handle_directive (OrcParser *parser, const OrcLine *line) { ".init", orc_parse_handle_init }, { ".flags", orc_parse_handle_flags }, { ".n", orc_parse_handle_dotn }, + { ".m", orc_parse_handle_dotm }, { NULL, NULL } }; int i; |