summaryrefslogtreecommitdiff
path: root/upb/json/parser.rl
diff options
context:
space:
mode:
Diffstat (limited to 'upb/json/parser.rl')
-rw-r--r--upb/json/parser.rl14
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);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback