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

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