diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-02-16 09:44:01 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-02-16 09:44:01 -0500 |
commit | 4d477302e1fc73d50e462fdc9e67a2ded9e38885 (patch) | |
tree | e62e3b7860d840aa20f53500c5a7b305b5957a84 | |
parent | e6dc364b1d6530bcc30de99e73e39e6e3d45361d (diff) |
parse-events: Add strim() to allow whitespace in filter event names
Adde strim() to remove leading and trailing whitespace from the event
and system names being passed into the filter.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | parse-filter.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/parse-filter.c b/parse-filter.c index 15b3d16..aab642c 100644 --- a/parse-filter.c +++ b/parse-filter.c | |||
@@ -50,6 +50,30 @@ static void show_error(char **error_str, const char *fmt, ...) | |||
50 | va_end(ap); | 50 | va_end(ap); |
51 | } | 51 | } |
52 | 52 | ||
53 | static char *strim(char *string) | ||
54 | { | ||
55 | char *ret; | ||
56 | |||
57 | if (!string) | ||
58 | return NULL; | ||
59 | while (*string) { | ||
60 | if (!isspace(*string)) | ||
61 | break; | ||
62 | string++; | ||
63 | } | ||
64 | ret = string; | ||
65 | |||
66 | string = ret + strlen(ret) - 1; | ||
67 | while (string > ret) { | ||
68 | if (!isspace(*string)) | ||
69 | break; | ||
70 | string--; | ||
71 | } | ||
72 | string[1] = 0; | ||
73 | |||
74 | return ret; | ||
75 | } | ||
76 | |||
53 | static void free_token(char *token) | 77 | static void free_token(char *token) |
54 | { | 78 | { |
55 | pevent_free_token(token); | 79 | pevent_free_token(token); |
@@ -704,7 +728,7 @@ int pevent_filter_add_filter_str(struct event_filter *filter, | |||
704 | } | 728 | } |
705 | 729 | ||
706 | /* Find this event */ | 730 | /* Find this event */ |
707 | ret = find_event(pevent, &events, sys_name, event_name); | 731 | ret = find_event(pevent, &events, strim(sys_name), strim(event_name)); |
708 | if (ret < 0) { | 732 | if (ret < 0) { |
709 | if (event_name) | 733 | if (event_name) |
710 | show_error(error_str, | 734 | show_error(error_str, |