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

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