summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Romani <fromani@gmail.com>2014-07-06 15:46:31 +0200
committerSebastian Dröge <sebastian@centricular.com>2023-04-12 21:13:51 +0300
commitada3b11382b0514cebb178e0754c20e37c1a08be (patch)
tree485e02186bbe6b4e8df8a2c3700a55ce20c31af6
parent4d1cee7b0d5ff28e504765590ca800d0febbc84c (diff)
downloadorc-ada3b11382b0514cebb178e0754c20e37c1a08be.tar.gz
parser: extract function to handle .init
Part-of: <https://gitlab.freedesktop.org/gstreamer/orc/-/merge_requests/30>
-rw-r--r--orc/orcparse.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/orc/orcparse.c b/orc/orcparse.c
index 2fbb842..6ef13ed 100644
--- a/orc/orcparse.c
+++ b/orc/orcparse.c
@@ -92,6 +92,7 @@ static void orc_parse_sanity_check (OrcParser *parser, OrcProgram *program);
static int orc_parse_handle_legacy (OrcParser *parser, const OrcLine *line);
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_directive (OrcParser *parser, const OrcLine *line);
static int orc_parse_handle_opcode (OrcParser *parser, const OrcLine *line);
@@ -431,15 +432,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], ".init") == 0) {
- free (parser->init_function);
- parser->init_function = NULL;
- if (n_tokens < 2) {
- orc_parse_add_error (parser, ".init without function name");
- } else {
- parser->init_function = strdup (token[1]);
- }
- } else if (strcmp (token[0], ".flags") == 0) {
+ if (strcmp (token[0], ".flags") == 0) {
int i;
for(i=1;i<n_tokens;i++){
if (!strcmp (token[i], "2d")) {
@@ -650,11 +643,28 @@ orc_parse_handle_backup (OrcParser *parser, const OrcLine *line)
}
static int
+orc_parse_handle_init (OrcParser *parser, const OrcLine *line)
+{
+ free (parser->init_function);
+ parser->init_function = NULL;
+
+ if (line->n_tokens < 2) {
+ orc_parse_add_error (parser, ".init without function name");
+ return 0;
+ }
+
+ parser->init_function = strdup (line->tokens[1]);
+
+ return 1;
+}
+
+static int
orc_parse_handle_directive (OrcParser *parser, const OrcLine *line)
{
static const OrcDirective dirs[] = {
{ ".function", orc_parse_handle_function },
{ ".backup", orc_parse_handle_backup },
+ { ".init", orc_parse_handle_init },
{ NULL, NULL }
};
int i;