|
|
920d6f |
From 2e9f9f1f5d0fb223b109429b9c904504b7f638e2 Mon Sep 17 00:00:00 2001
|
|
|
920d6f |
From: Petr Machata <pmachata@redhat.com>
|
|
|
920d6f |
Date: Fri, 8 Aug 2014 16:53:41 +0200
|
|
|
920d6f |
Subject: [PATCH] In config files, allow whitespace between identifier and
|
|
|
920d6f |
opening paren
|
|
|
920d6f |
|
|
|
920d6f |
---
|
|
|
920d6f |
read_config_file.c | 61 ++++++--------------------------
|
|
|
920d6f |
testsuite/ltrace.main/parameters2.exp | 14 +++++++-
|
|
|
920d6f |
2 files changed, 25 insertions(+), 50 deletions(-)
|
|
|
920d6f |
|
|
|
920d6f |
diff --git a/read_config_file.c b/read_config_file.c
|
|
|
920d6f |
index ea3ab88..05ff283 100644
|
|
|
920d6f |
--- a/read_config_file.c
|
|
|
920d6f |
+++ b/read_config_file.c
|
|
|
920d6f |
@@ -1,6 +1,6 @@
|
|
|
920d6f |
/*
|
|
|
920d6f |
* This file is part of ltrace.
|
|
|
920d6f |
- * Copyright (C) 2011,2012,2013 Petr Machata, Red Hat Inc.
|
|
|
920d6f |
+ * Copyright (C) 2011,2012,2013,2014 Petr Machata, Red Hat Inc.
|
|
|
920d6f |
* Copyright (C) 1998,1999,2003,2007,2008,2009 Juan Cespedes
|
|
|
920d6f |
* Copyright (C) 2006 Ian Wienand
|
|
|
920d6f |
* Copyright (C) 2006 Steve Fink
|
|
|
920d6f |
@@ -168,38 +168,6 @@ parse_ident(struct locus *loc, char **str)
|
|
|
920d6f |
return xstrndup(ident, *str - ident);
|
|
|
920d6f |
}
|
|
|
920d6f |
|
|
|
920d6f |
-/*
|
|
|
920d6f |
- Returns position in string at the left parenthesis which starts the
|
|
|
920d6f |
- function's argument signature. Returns NULL on error.
|
|
|
920d6f |
-*/
|
|
|
920d6f |
-static char *
|
|
|
920d6f |
-start_of_arg_sig(char *str) {
|
|
|
920d6f |
- char *pos;
|
|
|
920d6f |
- int stacked = 0;
|
|
|
920d6f |
-
|
|
|
920d6f |
- if (!strlen(str))
|
|
|
920d6f |
- return NULL;
|
|
|
920d6f |
-
|
|
|
920d6f |
- pos = &str[strlen(str)];
|
|
|
920d6f |
- do {
|
|
|
920d6f |
- pos--;
|
|
|
920d6f |
- if (pos < str)
|
|
|
920d6f |
- return NULL;
|
|
|
920d6f |
- while ((pos > str) && (*pos != ')') && (*pos != '('))
|
|
|
920d6f |
- pos--;
|
|
|
920d6f |
-
|
|
|
920d6f |
- if (*pos == ')')
|
|
|
920d6f |
- stacked++;
|
|
|
920d6f |
- else if (*pos == '(')
|
|
|
920d6f |
- stacked--;
|
|
|
920d6f |
- else
|
|
|
920d6f |
- return NULL;
|
|
|
920d6f |
-
|
|
|
920d6f |
- } while (stacked > 0);
|
|
|
920d6f |
-
|
|
|
920d6f |
- return (stacked == 0) ? pos : NULL;
|
|
|
920d6f |
-}
|
|
|
920d6f |
-
|
|
|
920d6f |
static int
|
|
|
920d6f |
parse_int(struct locus *loc, char **str, long *ret)
|
|
|
920d6f |
{
|
|
|
920d6f |
@@ -1110,7 +1078,6 @@ static int
|
|
|
920d6f |
process_line(struct protolib *plib, struct locus *loc, char *buf)
|
|
|
920d6f |
{
|
|
|
920d6f |
char *str = buf;
|
|
|
920d6f |
- char *tmp;
|
|
|
920d6f |
|
|
|
920d6f |
debug(3, "Reading line %d of `%s'", loc->line_no, loc->filename);
|
|
|
920d6f |
eat_spaces(&str);
|
|
|
920d6f |
@@ -1148,22 +1115,13 @@ process_line(struct protolib *plib, struct locus *loc, char *buf)
|
|
|
920d6f |
debug(4, " return_type = %d", fun.return_info->type);
|
|
|
920d6f |
|
|
|
920d6f |
eat_spaces(&str);
|
|
|
920d6f |
- tmp = start_of_arg_sig(str);
|
|
|
920d6f |
- if (tmp == NULL) {
|
|
|
920d6f |
- report_error(loc->filename, loc->line_no, "syntax error");
|
|
|
920d6f |
+ proto_name = parse_ident(loc, &str);
|
|
|
920d6f |
+ if (proto_name == NULL)
|
|
|
920d6f |
goto err;
|
|
|
920d6f |
- }
|
|
|
920d6f |
- *tmp = '\0';
|
|
|
920d6f |
|
|
|
920d6f |
- proto_name = strdup(str);
|
|
|
920d6f |
- if (proto_name == NULL) {
|
|
|
920d6f |
- oom:
|
|
|
920d6f |
- report_error(loc->filename, loc->line_no,
|
|
|
920d6f |
- "%s", strerror(errno));
|
|
|
920d6f |
+ eat_spaces(&str);
|
|
|
920d6f |
+ if (parse_char(loc, &str, '(') < 0)
|
|
|
920d6f |
goto err;
|
|
|
920d6f |
- }
|
|
|
920d6f |
-
|
|
|
920d6f |
- str = tmp + 1;
|
|
|
920d6f |
debug(3, " name = %s", proto_name);
|
|
|
920d6f |
|
|
|
920d6f |
struct param *extra_param = NULL;
|
|
|
920d6f |
@@ -1177,8 +1135,13 @@ process_line(struct protolib *plib, struct locus *loc, char *buf)
|
|
|
920d6f |
if (have_stop == 0) {
|
|
|
920d6f |
struct param param;
|
|
|
920d6f |
param_init_stop(¶m;;
|
|
|
920d6f |
- if (prototype_push_param(&fun, ¶m) < 0)
|
|
|
920d6f |
- goto oom;
|
|
|
920d6f |
+ if (prototype_push_param(&fun, ¶m) < 0) {
|
|
|
920d6f |
+ oom:
|
|
|
920d6f |
+ report_error(loc->filename,
|
|
|
920d6f |
+ loc->line_no,
|
|
|
920d6f |
+ "%s", strerror(errno));
|
|
|
920d6f |
+ goto err;
|
|
|
920d6f |
+ }
|
|
|
920d6f |
have_stop = 1;
|
|
|
920d6f |
}
|
|
|
920d6f |
str++;
|
|
|
920d6f |
diff --git a/testsuite/ltrace.main/parameters2.exp b/testsuite/ltrace.main/parameters2.exp
|
|
|
920d6f |
index 6318fc5..9850079 100644
|
|
|
920d6f |
--- a/testsuite/ltrace.main/parameters2.exp
|
|
|
920d6f |
+++ b/testsuite/ltrace.main/parameters2.exp
|
|
|
920d6f |
@@ -1,5 +1,5 @@
|
|
|
920d6f |
# This file is part of ltrace.
|
|
|
920d6f |
-# Copyright (C) 2012, 2013 Petr Machata, Red Hat Inc.
|
|
|
920d6f |
+# Copyright (C) 2012, 2013, 2014 Petr Machata, Red Hat Inc.
|
|
|
920d6f |
#
|
|
|
920d6f |
# This program is free software; you can redistribute it and/or
|
|
|
920d6f |
# modify it under the terms of the GNU General Public License as
|
|
|
920d6f |
@@ -259,4 +259,16 @@ ltraceMatch1 [ltraceLibTest {
|
|
|
920d6f |
somefunc();
|
|
|
920d6f |
}] {somefunc\(\) *= nil} == 1
|
|
|
920d6f |
|
|
|
920d6f |
+# Test that spaces in function name make no difference.
|
|
|
920d6f |
+
|
|
|
920d6f |
+ltraceMatch1 [ltraceLibTest {
|
|
|
920d6f |
+ void somefunc ();
|
|
|
920d6f |
+} {
|
|
|
920d6f |
+ void somefunc(void);
|
|
|
920d6f |
+} {
|
|
|
920d6f |
+ void somefunc(void) {}
|
|
|
920d6f |
+} {
|
|
|
920d6f |
+ somefunc();
|
|
|
920d6f |
+}] {somefunc\(\)} == 1
|
|
|
920d6f |
+
|
|
|
920d6f |
ltraceDone
|
|
|
920d6f |
--
|
|
|
920d6f |
1.7.6.5
|
|
|
920d6f |
|