aboutsummaryrefslogtreecommitdiff
path: root/read_config_file.c
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2012-01-06 17:48:29 +0100
committerPetr Machata <pmachata@redhat.com>2012-08-29 19:02:06 +0200
commiteff655b78f3f5d9119faa93461787192cf57dab0 (patch)
treee169ef2e9d83a16642d76854c7f77896bbe930f5 /read_config_file.c
parentf6ec08afb96292fd3c802c1f633d8de249664c72 (diff)
downloadltrace-eff655b78f3f5d9119faa93461787192cf57dab0.tar.gz
Add parse_char
Diffstat (limited to 'read_config_file.c')
-rw-r--r--read_config_file.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/read_config_file.c b/read_config_file.c
index a4d67a5..b7110fb 100644
--- a/read_config_file.c
+++ b/read_config_file.c
@@ -224,6 +224,19 @@ check_int(long l)
return 0;
}
+static int
+parse_char(char **str, char expected)
+{
+ if (**str != expected) {
+ report_error(filename, line_no,
+ "expected '%c', got '%c'", expected, **str);
+ return -1;
+ }
+
+ ++*str;
+ return 0;
+}
+
/*
* Input:
* argN : The value of argument #N, counting from 1
@@ -336,14 +349,8 @@ parse_typedef(char **str) {
// Skip = sign
eat_spaces(str);
- if (**str != '=') {
- output_line(0,
- "Syntax error in `%s', line %d: expected '=', got '%c'",
- filename, line_no, **str);
- error_count++;
+ if (parse_char(str, '=') < 0)
return;
- }
- (*str)++;
eat_spaces(str);
// Parse the type
@@ -362,9 +369,8 @@ static int
parse_struct(char **str, struct arg_type_info *info)
{
eat_spaces(str);
- if (**str != '(')
+ if (parse_char(str, '(') < 0)
return -1;
- ++*str;
eat_spaces(str); // Empty arg list with whitespace inside
@@ -373,13 +379,13 @@ parse_struct(char **str, struct arg_type_info *info)
while (1) {
eat_spaces(str);
if (**str == 0 || **str == ')') {
- ++*str;
+ parse_char(str, ')');
return 0;
}
/* Field delimiter. */
if (type_struct_size(info) > 0)
- ++*str;
+ parse_char(str, ',');
eat_spaces(str);
int own = 0;