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