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

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