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