Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(933)

Side by Side Diff: fusl/src/time/getdate.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/time/ftime.c ('k') | fusl/src/time/gettimeofday.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <time.h>
2 #include <pthread.h>
3 #include <errno.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6
7 int getdate_err;
8
9 struct tm *getdate(const char *s)
10 {
11 static struct tm tmbuf;
12 struct tm *ret = 0;
13 char *datemsk = getenv("DATEMSK");
14 FILE *f = 0;
15 char fmt[100], *p;
16 int cs;
17
18 pthread_setcancelstate(PTHREAD_CANCEL_DEFERRED, &cs);
19
20 if (!datemsk) {
21 getdate_err = 1;
22 goto out;
23 }
24
25 f = fopen(datemsk, "rbe");
26 if (!f) {
27 if (errno == ENOMEM) getdate_err = 6;
28 else getdate_err = 2;
29 goto out;
30 }
31
32 while (fgets(fmt, sizeof fmt, f)) {
33 p = strptime(s, fmt, &tmbuf);
34 if (p && !*p) {
35 ret = &tmbuf;
36 goto out;
37 }
38 }
39
40 getdate_err = 7;
41 out:
42 if (f) fclose(f);
43 pthread_setcancelstate(cs, 0);
44 return ret;
45 }
OLDNEW
« no previous file with comments | « fusl/src/time/ftime.c ('k') | fusl/src/time/gettimeofday.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698