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

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