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

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