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

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