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

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