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

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