Add whitespace stripping to parser
This commit is contained in:
parent
e9d29f4792
commit
1b6343e474
5 changed files with 121 additions and 89 deletions
|
|
@ -7,7 +7,7 @@ build_target libiso8601 || return 1
|
|||
if [ -z ${tests_BUILT} ]
|
||||
then
|
||||
LIBS="${libiso8601} "
|
||||
EXTRAS="" # @TODO@ libs, cflags
|
||||
EXTRAS="-D_GNU_SOURCE"
|
||||
|
||||
echo "Building test programs..."
|
||||
do_cmd mkdir -p obj/tests || return 1
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ int do_date(const char* str)
|
|||
char buf[100], buf2[100], buf3[100], buf4[100];
|
||||
|
||||
if(iso8601_parse(str, &earliest, &latest, &details)) {
|
||||
perror("iso8601_parse");
|
||||
fputs("Failed to parse date.\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,8 @@ int do_date(const char* str)
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
int ret = 0, i;
|
||||
char buf[100];
|
||||
char* buf = 0;
|
||||
size_t buf_size;
|
||||
|
||||
if(argc == 2 && !strcmp(argv[1], "--print-summary")) {
|
||||
printf("One line summary.\n");
|
||||
|
|
@ -68,7 +69,7 @@ int main(int argc, char* argv[])
|
|||
if(argc == 1) {
|
||||
while(!feof(stdin)) {
|
||||
printf("date >> ");
|
||||
scanf("%s", buf);
|
||||
if(getline(&buf, &buf_size, stdin) < 1) continue;
|
||||
do_date(buf);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue