summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 198b0fb)
raw | patch | inline | side by side (parent: 198b0fb)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sun, 1 May 2005 19:34:56 +0000 (12:34 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Sun, 1 May 2005 19:34:56 +0000 (12:34 -0700) |
And be a bitmore careful about matching: if we don't recognize a word
or a number, we skip the whole thing, rather than trying the next character
in that word/number.
Finally: since ctime() adds the final '\n', don't add another one in test-date.
or a number, we skip the whole thing, rather than trying the next character
in that word/number.
Finally: since ctime() adds the final '\n', don't add another one in test-date.
date.c | patch | blob | history | |
test-date.c | patch | blob | history |
index 5ee4984421f379a1ad45564fcd1ec84b51dc6476..aa4fb3efef5f35d510c14c3a73d497143406f5e7 100644 (file)
--- a/date.c
+++ b/date.c
return i;
}
+static int skip_alpha(const char *date)
+{
+ int i = 0;
+ do {
+ i++;
+ } while (isalpha(date[i]));
+ return i;
+}
+
/*
* Parse month, weekday, or timezone name
*/
}
}
+ if (match_string(date, "PM") == 2) {
+ if (tm->tm_hour > 0 && tm->tm_hour < 12)
+ tm->tm_hour += 12;
+ return 2;
+ }
+
/* BAD CRAP */
- return 0;
+ return skip_alpha(date);
}
static int is_date(int year, int month, int day, struct tm *tm)
* a valid minute. We might want to check that the minutes
* are divisible by 30 or something too.
*/
- if (min >= 60 || n < 3)
- return 0;
+ if (min < 60 && n > 2) {
+ offset = hour*60+min;
+ if (*date == '-')
+ offset = -offset;
- offset = hour*60+min;
- if (*date == '-')
- offset = -offset;
-
- *offp = offset;
+ *offp = offset;
+ }
return end - date;
}
diff --git a/test-date.c b/test-date.c
index 8ec41c3118417b3f2e14a84978748ee52b7edd9b..6fe3e28b9d379e1d67287d41aa3697696532fbb4 100644 (file)
--- a/test-date.c
+++ b/test-date.c
memcpy(result, "bad", 4);
parse_date(argv[i], result, sizeof(result));
t = strtoul(result, NULL, 0);
- printf("%s -> %s -> %s\n", argv[i], result, ctime(&t));
+ printf("%s -> %s -> %s", argv[i], result, ctime(&t));
}
return 0;
}