mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-17 16:19:18 +03:00
add strptime compatability
This commit is contained in:
parent
6c466c985f
commit
1a3ee6090d
@ -38,6 +38,8 @@
|
||||
#include <time.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
|
@ -38,6 +38,14 @@ char *strndup(const char *s, size_t n);
|
||||
char *strcasestr(const char *haystack, const char *needle);
|
||||
#endif
|
||||
|
||||
#if (defined(riscos) || defined(_WIN32))
|
||||
#undef HAVE_STRPTIME
|
||||
#define strptime nsc_time_strptime
|
||||
char *nsc_time_strptime(const char *s, const char *format, struct tm *tm);
|
||||
#else
|
||||
#define HAVE_STRPTIME
|
||||
#endif
|
||||
|
||||
/* For some reason, UnixLib defines this unconditionally.
|
||||
* Assume we're using UnixLib if building for RISC OS. */
|
||||
#if ((defined(_GNU_SOURCE) && !defined(__APPLE__)) || defined(riscos))
|
||||
|
@ -560,4 +560,31 @@ int inet_pton(int af, const char *src, void *dst)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRPTIME
|
||||
|
||||
/**
|
||||
* naff strptime implementation for risc os and windows.
|
||||
*
|
||||
* @warning only supports %s format
|
||||
*/
|
||||
char *nsc_time_strptime(const char *s, const char *format, struct tm *tm)
|
||||
{
|
||||
time_t esecs;
|
||||
struct tm *gtm;
|
||||
char *endptr;
|
||||
|
||||
if ((format[0] != '%') || (format[1] != 's')) {
|
||||
return NULL
|
||||
}
|
||||
|
||||
esecs = (time_t)strtoll(a, &endptr, 10);
|
||||
|
||||
gtm = gmtime(esecs);
|
||||
*tm = *gtm;
|
||||
|
||||
return endptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user