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

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