diff options
| -rw-r--r-- | sdep.c | 12 |
1 files changed, 9 insertions, 3 deletions
| @@ -1,6 +1,5 @@ | |||
| 1 | /* See LICENSE file for copyright and license details. */ | 1 | /* See LICENSE file for copyright and license details. */ |
| 2 | 2 | ||
| 3 | #include <ctype.h> | ||
| 4 | #include <stdio.h> | 3 | #include <stdio.h> |
| 5 | #include <stdlib.h> | 4 | #include <stdlib.h> |
| 6 | #include <string.h> | 5 | #include <string.h> |
| @@ -54,6 +53,7 @@ static int compare_event(const void *, const void *); | |||
| 54 | static Options default_op(void); | 53 | static Options default_op(void); |
| 55 | static int events_in_range(EventList *, Options, Event *); | 54 | static int events_in_range(EventList *, Options, Event *); |
| 56 | static char *format_line(Event, Options, char *); | 55 | static char *format_line(Event, Options, char *); |
| 56 | static int is_space(char); | ||
| 57 | static void read_input(Options, EventList *); | 57 | static void read_input(Options, EventList *); |
| 58 | static Options read_op(int, char *[]); | 58 | static Options read_op(int, char *[]); |
| 59 | static char *strtrim(char *); | 59 | static char *strtrim(char *); |
| @@ -156,6 +156,12 @@ format_line(Event ev, Options op, char *out) | |||
| 156 | return out; | 156 | return out; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | static int | ||
| 160 | is_space(char c) | ||
| 161 | { | ||
| 162 | return c == ' ' || c == '\t'; | ||
| 163 | } | ||
| 164 | |||
| 159 | static void | 165 | static void |
| 160 | read_input(Options op, EventList *evlist) | 166 | read_input(Options op, EventList *evlist) |
| 161 | { | 167 | { |
| @@ -221,8 +227,8 @@ strtrim(char *t) | |||
| 221 | { | 227 | { |
| 222 | char *s; | 228 | char *s; |
| 223 | 229 | ||
| 224 | for (s = &t[strlen(t)-1]; s != t && isspace(*s); *s = '\0', s--); | 230 | for (s = &t[strlen(t)-1]; s != t && is_space(*s); *s = '\0', s--); |
| 225 | for (; *t != '\0' && isspace(*t); t++); | 231 | for (; *t != '\0' && is_space(*t); t++); |
| 226 | 232 | ||
| 227 | return t; | 233 | return t; |
| 228 | } | 234 | } |
