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

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