/*
* This file is part of ltrace.
- * Copyright (C) 2011,2012,2013 Petr Machata, Red Hat Inc.
+ * Copyright (C) 2011,2012,2013,2014 Petr Machata, Red Hat Inc.
* Copyright (C) 1998,1999,2003,2007,2008,2009 Juan Cespedes
* Copyright (C) 2006 Ian Wienand
* Copyright (C) 2006 Steve Fink
return xstrndup(ident, *str - ident);
}
-/*
- Returns position in string at the left parenthesis which starts the
- function's argument signature. Returns NULL on error.
-*/
-static char *
-start_of_arg_sig(char *str) {
- char *pos;
- int stacked = 0;
-
- if (!strlen(str))
- return NULL;
-
- pos = &str[strlen(str)];
- do {
- pos--;
- if (pos < str)
- return NULL;
- while ((pos > str) && (*pos != ')') && (*pos != '('))
- pos--;
-
- if (*pos == ')')
- stacked++;
- else if (*pos == '(')
- stacked--;
- else
- return NULL;
-
- } while (stacked > 0);
-
- return (stacked == 0) ? pos : NULL;
-}
-
static int
parse_int(struct locus *loc, char **str, long *ret)
{
process_line(struct protolib *plib, struct locus *loc, char *buf)
{
char *str = buf;
- char *tmp;
debug(3, "Reading line %d of `%s'", loc->line_no, loc->filename);
eat_spaces(&str);
debug(4, " return_type = %d", fun.return_info->type);
eat_spaces(&str);
- tmp = start_of_arg_sig(str);
- if (tmp == NULL) {
- report_error(loc->filename, loc->line_no, "syntax error");
+ proto_name = parse_ident(loc, &str);
+ if (proto_name == NULL)
goto err;
- }
- *tmp = '\0';
- proto_name = strdup(str);
- if (proto_name == NULL) {
- oom:
- report_error(loc->filename, loc->line_no,
- "%s", strerror(errno));
+ eat_spaces(&str);
+ if (parse_char(loc, &str, '(') < 0)
goto err;
- }
-
- str = tmp + 1;
debug(3, " name = %s", proto_name);
int have_stop = 0;
if (have_stop == 0) {
struct param param;
param_init_stop(¶m);
- if (prototype_push_param(&fun, ¶m) < 0)
- goto oom;
+ if (prototype_push_param(&fun, ¶m) < 0) {
+ oom:
+ report_error(loc->filename,
+ loc->line_no,
+ "%s", strerror(errno));
+ return -1;
+ }
have_stop = 1;
}
str++;
# This file is part of ltrace.
-# Copyright (C) 2012, 2013 Petr Machata, Red Hat Inc.
+# Copyright (C) 2012, 2013, 2014 Petr Machata, Red Hat Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
somefunc();
}] {somefunc\(\) *= nil} == 1
+# Test that spaces in function name make no difference.
+
+ltraceMatch1 [ltraceLibTest {
+ void somefunc ();
+} {
+ void somefunc(void);
+} {
+ void somefunc(void) {}
+} {
+ somefunc();
+}] {somefunc\(\)} == 1
+
ltraceDone