Move strptime polyfill to string_util
This commit is contained in:
committed by
Andrew Gaul
parent
e5f6f112db
commit
581f5c0356
@ -32,11 +32,6 @@
|
||||
#include "s3fs.h"
|
||||
#include "string_util.h"
|
||||
|
||||
// Use the polyfill in MSYS2 environment
|
||||
#ifdef __MSYS__
|
||||
#include "strptime.h"
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Global variables
|
||||
//-------------------------------------------------------------------
|
||||
@ -74,6 +69,24 @@ template<> std::string str(struct timespec value) {
|
||||
// Functions
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#ifdef __MSYS__
|
||||
/*
|
||||
* Polyfill for strptime function
|
||||
*
|
||||
* This source code is from https://gist.github.com/jeremyfromearth/5694aa3a66714254752179ecf3c95582 .
|
||||
*/
|
||||
char* strptime(const char* s, const char* f, struct tm* tm)
|
||||
{
|
||||
std::istringstream input(s);
|
||||
input.imbue(std::locale(setlocale(LC_ALL, nullptr)));
|
||||
input >> std::get_time(tm, f);
|
||||
if (input.fail()) {
|
||||
return nullptr;
|
||||
}
|
||||
return (char*)(s + input.tellg());
|
||||
}
|
||||
#endif
|
||||
|
||||
bool s3fs_strtoofft(off_t* value, const char* str, int base)
|
||||
{
|
||||
if(value == NULL || str == NULL){
|
||||
|
||||
Reference in New Issue
Block a user