sdep

A simple "date+event" line parser
git clone https://git.tronto.net/sdep
Download | Log | Files | Refs | README | LICENSE

commit 449c547e78c9b79ffc1e0c180940b6f117e435a7
parent 650d928cc6164fbf10dc3a32e416737654cd1c2e
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Mon, 15 May 2023 18:03:30 +0200

Removed calls to ctype.h

Diffstat:
Msdep.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sdep.c b/sdep.c @@ -1,6 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -54,6 +53,7 @@ static int compare_event(const void *, const void *); static Options default_op(void); static int events_in_range(EventList *, Options, Event *); static char *format_line(Event, Options, char *); +static int is_space(char); static void read_input(Options, EventList *); static Options read_op(int, char *[]); static char *strtrim(char *); @@ -156,6 +156,12 @@ format_line(Event ev, Options op, char *out) return out; } +static int +is_space(char c) +{ + return c == ' ' || c == '\t'; +} + static void read_input(Options op, EventList *evlist) { @@ -221,8 +227,8 @@ strtrim(char *t) { char *s; - for (s = &t[strlen(t)-1]; s != t && isspace(*s); *s = '\0', s--); - for (; *t != '\0' && isspace(*t); t++); + for (s = &t[strlen(t)-1]; s != t && is_space(*s); *s = '\0', s--); + for (; *t != '\0' && is_space(*t); t++); return t; }