Blame SOURCES/ltrace-0.7.91-parser-ws_after_id.patch

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