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

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