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

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