diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2019-03-05 19:21:18 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-05 19:21:18 -0800 |
commit | 51f30e064b8e88af8e7d429c5a54c25f28c68b02 (patch) | |
tree | afbe3280c00c72822d713b80e3463391ad9afb3b /upb/json/parser.rl | |
parent | c3e6bb5318065fbefc19607f9e15abd2a256929f (diff) | |
parent | 8b75e5c1197621b29ec2924cdd90f88b1e71ce3b (diff) |
Merge pull request #152 from TeBoring/ruby-fix
Fix the issue for strptime
Diffstat (limited to 'upb/json/parser.rl')
-rw-r--r-- | upb/json/parser.rl | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/upb/json/parser.rl b/upb/json/parser.rl index 70a45cb..2fc5027 100644 --- a/upb/json/parser.rl +++ b/upb/json/parser.rl @@ -19,6 +19,9 @@ ** - handling of keys/escape-sequences/etc that span input buffers. */ +/* Need to define _XOPEN_SOURCE before any include to make strptime work. */ +#define _XOPEN_SOURCE 700 + #include <errno.h> #include <float.h> #include <math.h> @@ -27,10 +30,6 @@ #include <stdlib.h> #include <string.h> -/* Need to define __USE_XOPEN before including time.h to make strptime work. */ -#ifndef __USE_XOPEN -#define __USE_XOPEN -#endif #include <time.h> #include "upb/json/parser.h" @@ -1545,12 +1544,19 @@ static bool end_timestamp_base(upb_json_parser *p, const char *ptr) { memcpy(timestamp_buf + UPB_TIMESTAMP_BASE_SIZE, "GMT", 3); timestamp_buf[UPB_TIMESTAMP_BASE_SIZE + 3] = 0; +#if defined __MINGW32__ || defined __MINGW64__ + upb_status_seterrf( + &p->status, "error parsing timestamp: mingw doesn't support strptime"); + upb_env_reporterror(p->env, &p->status); + return false; +#else /* Parse seconds */ if (strptime(timestamp_buf, "%FT%H:%M:%S%Z", &p->tm) == NULL) { upb_status_seterrf(&p->status, "error parsing timestamp: %s", buf); upb_env_reporterror(p->env, &p->status); return false; } +#endif /* Clean up buffer */ multipart_end(p); |