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

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