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

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