diff options
author | Francesco Romani <fromani@gmail.com> | 2014-07-06 15:13:57 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2023-04-12 20:04:26 +0300 |
commit | 1df65a82170b703245b63da436735e591af90b83 (patch) | |
tree | 8fbbc5dc4a13f2a8c5637661814b070b65b608fb | |
parent | fb260ec1bb04f90d12145bce1ada3873c98ec765 (diff) | |
download | orc-1df65a82170b703245b63da436735e591af90b83.tar.gz |
parser: add is_directive helper
To improve encapsulation
Part-of: <https://gitlab.freedesktop.org/gstreamer/orc/-/merge_requests/30>
-rw-r--r-- | orc/orcparse.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/orc/orcparse.c b/orc/orcparse.c index 43a41f8..a9fd31b 100644 --- a/orc/orcparse.c +++ b/orc/orcparse.c @@ -65,6 +65,7 @@ static void orc_line_parse_tokens (OrcLine *line); static void orc_line_advance (OrcLine *line); static void orc_line_add_token (OrcLine *line); static int orc_line_has_tokens (const OrcLine *line); +static int orc_line_is_directive (const OrcLine *line); static void orc_parse_add_error_valist (OrcParser *parser, const char *format, va_list args); static void orc_parse_add_error (OrcParser *parser, const char *format, ...); @@ -160,7 +161,7 @@ orc_parse_code (const char *code, OrcProgram ***programs, int *n_programs, n_tokens = line->n_tokens; token = line->tokens; - if (token[0][0] == '.') { + if (orc_line_is_directive (line)) { if (strcmp (token[0], ".function") == 0) { if (n_tokens < 2) { orc_parse_add_error (parser, "line %d: .function without function name\n", @@ -548,6 +549,12 @@ orc_line_parse_tokens (OrcLine *line) } } +static int +orc_line_is_directive (const OrcLine *line) +{ + return line->tokens[0][0] == '.'; +} + static void orc_parse_init (OrcParser *parser, const char *code, int enable_errors) |