mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-16 01:07:11 +00:00
Move strptime polyfill to string_util
This commit is contained in:
parent
e5f6f112db
commit
581f5c0356
@ -63,9 +63,6 @@ endif
|
|||||||
if USE_SSL_NSS
|
if USE_SSL_NSS
|
||||||
s3fs_SOURCES += nss_auth.cpp
|
s3fs_SOURCES += nss_auth.cpp
|
||||||
endif
|
endif
|
||||||
if MSYS
|
|
||||||
s3fs_SOURCES += strptime.cpp
|
|
||||||
endif
|
|
||||||
|
|
||||||
s3fs_LDADD = $(DEPS_LIBS)
|
s3fs_LDADD = $(DEPS_LIBS)
|
||||||
|
|
||||||
@ -84,9 +81,6 @@ endif
|
|||||||
if USE_SSL_NSS
|
if USE_SSL_NSS
|
||||||
test_curl_util_SOURCES += nss_auth.cpp
|
test_curl_util_SOURCES += nss_auth.cpp
|
||||||
endif
|
endif
|
||||||
if MSYS
|
|
||||||
test_curl_util_SOURCES += strptime.cpp
|
|
||||||
endif
|
|
||||||
|
|
||||||
test_curl_util_LDADD = $(DEPS_LIBS)
|
test_curl_util_LDADD = $(DEPS_LIBS)
|
||||||
|
|
||||||
@ -96,14 +90,8 @@ test_page_list_SOURCES = \
|
|||||||
s3fs_logger.cpp \
|
s3fs_logger.cpp \
|
||||||
string_util.cpp \
|
string_util.cpp \
|
||||||
test_page_list.cpp
|
test_page_list.cpp
|
||||||
if MSYS
|
|
||||||
test_page_list_SOURCES += strptime.cpp
|
|
||||||
endif
|
|
||||||
|
|
||||||
test_string_util_SOURCES = string_util.cpp test_string_util.cpp s3fs_logger.cpp
|
test_string_util_SOURCES = string_util.cpp test_string_util.cpp s3fs_logger.cpp
|
||||||
if MSYS
|
|
||||||
test_string_util_SOURCES += strptime.cpp
|
|
||||||
endif
|
|
||||||
|
|
||||||
TESTS = \
|
TESTS = \
|
||||||
test_curl_util \
|
test_curl_util \
|
||||||
|
@ -28,11 +28,6 @@
|
|||||||
#include "metaheader.h"
|
#include "metaheader.h"
|
||||||
#include "string_util.h"
|
#include "string_util.h"
|
||||||
|
|
||||||
// Use the polyfill in MSYS2 environment
|
|
||||||
#ifdef __MSYS__
|
|
||||||
#include "strptime.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Utility functions for convert
|
// Utility functions for convert
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
@ -32,11 +32,6 @@
|
|||||||
#include "s3fs.h"
|
#include "s3fs.h"
|
||||||
#include "string_util.h"
|
#include "string_util.h"
|
||||||
|
|
||||||
// Use the polyfill in MSYS2 environment
|
|
||||||
#ifdef __MSYS__
|
|
||||||
#include "strptime.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Global variables
|
// Global variables
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
@ -74,6 +69,24 @@ template<> std::string str(struct timespec value) {
|
|||||||
// Functions
|
// 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)
|
bool s3fs_strtoofft(off_t* value, const char* str, int base)
|
||||||
{
|
{
|
||||||
if(value == NULL || str == NULL){
|
if(value == NULL || str == NULL){
|
||||||
|
@ -54,6 +54,12 @@ template <class T> std::string str(T value);
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Utilities
|
// Utilities
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
#ifdef __MSYS__
|
||||||
|
//
|
||||||
|
// Polyfill for strptime function.
|
||||||
|
//
|
||||||
|
char* strptime(const char* s, const char* f, struct tm* tm);
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
// Convert string to off_t. Returns false on bad input.
|
// Convert string to off_t. Returns false on bad input.
|
||||||
// Replacement for C++11 std::stoll.
|
// Replacement for C++11 std::stoll.
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Polyfill for strptime function
|
|
||||||
*
|
|
||||||
* This source code is from https://gist.github.com/jeremyfromearth/5694aa3a66714254752179ecf3c95582 .
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <time.h>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include "strptime.h"
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* Polyfill for strptime function
|
|
||||||
*
|
|
||||||
* This source code is from musl library, located at https://git.musl-libc.org/cgit/musl/tree/src/time/strptime.c .
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* musl as a whole is licensed under the following standard MIT license:
|
|
||||||
*
|
|
||||||
* ----------------------------------------------------------------------
|
|
||||||
* Copyright © 2005-2020 Rich Felker, et al.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be
|
|
||||||
* included in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
* ----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef S3FS_STRPTIME_H_
|
|
||||||
#define S3FS_STRPTIME_H_
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <langinfo.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <strings.h>
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
char* strptime(const char* s, const char* f, struct tm* tm);
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue
Block a user