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

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