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

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