v2.4.1 fixes
This commit is contained in:
parent
dc349ee357
commit
2d8de59803
@ -94,15 +94,19 @@ namespace G
|
||||
throw DateTime::Error() ;
|
||||
tm_out.tm_isdst = -1 ;
|
||||
}
|
||||
std::time_t mktimelocal( const std::tm & local_tm_in )
|
||||
std::time_t mktime_( std::tm & tm )
|
||||
{
|
||||
struct std::tm tm = local_tm_in ;
|
||||
tm.tm_isdst = -1 ;
|
||||
std::time_t t = std::mktime( &tm ) ;
|
||||
if( t == std::time_t(-1) )
|
||||
throw DateTime::Error() ;
|
||||
return t ;
|
||||
}
|
||||
std::time_t mktimelocal( const std::tm & local_tm_in )
|
||||
{
|
||||
struct std::tm tm = local_tm_in ;
|
||||
return mktime_( tm ) ;
|
||||
}
|
||||
std::time_t mktimeutc( const std::tm & utc_tm_in , std::time_t begin , std::time_t end )
|
||||
{
|
||||
// returns 't' such that std::gmtime(t) gives the target broken-down time -- does
|
||||
@ -226,8 +230,7 @@ bool G::BrokenDownTime::format( char * out , std::size_t out_size , const char *
|
||||
}
|
||||
|
||||
std::tm tm_copy = m_tm ;
|
||||
tm_copy.tm_isdst = -1 ;
|
||||
(void) mktime( &tm_copy ) ; // fill in isdst, wday, yday
|
||||
DateTimeImp::mktime_( tm_copy ) ; // fill in isdst, wday, yday
|
||||
|
||||
return std::strftime( out , out_size , fmt , &tm_copy ) > 0U ;
|
||||
}
|
||||
@ -245,7 +248,7 @@ std::string G::BrokenDownTime::str() const
|
||||
|
||||
std::string G::BrokenDownTime::str( const char * fmt ) const
|
||||
{
|
||||
std::size_t n = std::strlen( fmt ) ;
|
||||
std::size_t n = std::strlen( fmt ) + 1U ;
|
||||
for( const char * p = std::strchr(fmt,'%') ; p && p[1] ; p = std::strchr(p+1,'%') )
|
||||
n += 10U ; // biggest allowed format is eg. %F -> "2001-12-31"
|
||||
|
||||
@ -287,7 +290,9 @@ int G::BrokenDownTime::day() const
|
||||
|
||||
int G::BrokenDownTime::wday() const
|
||||
{
|
||||
return m_tm.tm_wday ;
|
||||
std::tm tm_copy = m_tm ;
|
||||
DateTimeImp::mktime_( tm_copy ) ;
|
||||
return tm_copy.tm_wday ;
|
||||
}
|
||||
|
||||
bool G::BrokenDownTime::sameMinute( const BrokenDownTime & other ) const noexcept
|
||||
|
@ -273,7 +273,7 @@ bool G::File::mkdirsr( const Path & path , int & e , int & limit )
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
return e == 0 ;
|
||||
}
|
||||
|
||||
bool G::File::mkdirs( const Path & path , std::nothrow_t , int limit )
|
||||
|
@ -37,7 +37,7 @@ template <typename T>
|
||||
class G::optional
|
||||
{
|
||||
public:
|
||||
optional() noexcept(noexcept(T())) ;
|
||||
optional() noexcept(noexcept(T())) {}
|
||||
explicit optional( const T & ) ;
|
||||
optional( bool has_value , const T & value ) ; // not in std::optional()
|
||||
void clear() ; // not in std::optional()
|
||||
@ -62,10 +62,6 @@ private:
|
||||
bool m_has_value {false} ;
|
||||
} ;
|
||||
|
||||
template <typename T>
|
||||
G::optional<T>::optional() noexcept(noexcept(T()))
|
||||
= default ;
|
||||
|
||||
template <typename T>
|
||||
G::optional<T>::optional( const T & t ) :
|
||||
m_value(t) ,
|
||||
|
@ -74,9 +74,9 @@ G::StringArray G::OptionParser::parse( const StringArray & args_in , std::size_t
|
||||
else if( isOldOption(arg) ) // eg. "-v"
|
||||
{
|
||||
char c = arg.at(1U) ;
|
||||
if( m_spec.valued(c) && (i+1U) >= args_in.size() )
|
||||
if( m_spec.valued(c) && !m_spec.defaulting(c) && (i+1U) >= args_in.size() )
|
||||
errorNoValue( c ) ;
|
||||
else if( m_spec.valued(c) )
|
||||
else if( m_spec.valued(c) && !m_spec.defaulting(c) )
|
||||
processOption( c , args_in.at(++i) ) ;
|
||||
else
|
||||
processOptionOn( c ) ;
|
||||
@ -121,7 +121,7 @@ void G::OptionParser::processOptionOn( const std::string & name )
|
||||
{
|
||||
if( !m_spec.valid(name) )
|
||||
errorUnknownOption( name ) ;
|
||||
else if( m_spec.valued(name) )
|
||||
else if( m_spec.valued(name) && !m_spec.defaulting(name) )
|
||||
errorNoValue( name ) ;
|
||||
else if( haveSeenOff(name) )
|
||||
errorConflict( name ) ;
|
||||
@ -169,7 +169,7 @@ void G::OptionParser::processOptionOn( char c )
|
||||
std::string name = m_spec.lookup( c ) ;
|
||||
if( !m_spec.valid(name) )
|
||||
errorUnknownOption( c ) ;
|
||||
else if( m_spec.valued(name) )
|
||||
else if( m_spec.valued(name) && !m_spec.defaulting(name) )
|
||||
errorNoValue( c ) ;
|
||||
else if( haveSeenOff(name) )
|
||||
errorConflict( name ) ;
|
||||
|
@ -108,6 +108,11 @@ void G::Options::addOption( Option opt , char sep , char escape )
|
||||
m_list.insert( range.first , opt ) ;
|
||||
}
|
||||
|
||||
bool G::Options::defaulting( char c ) const
|
||||
{
|
||||
return defaulting( lookup(c) ) ;
|
||||
}
|
||||
|
||||
bool G::Options::defaulting( const std::string & name ) const
|
||||
{
|
||||
auto p = find( name ) ;
|
||||
|
@ -128,6 +128,10 @@ public:
|
||||
///< taking its default (empty) value followed by a separate
|
||||
///< argument 'bar'.
|
||||
|
||||
bool defaulting( char ) const ;
|
||||
///< Returns defaulting(lookup()) even though defaulting options
|
||||
///< can never take a value when short-form.
|
||||
|
||||
private:
|
||||
using List = std::vector<Option> ;
|
||||
void parseSpec( const std::string & spec , char , char , char ) ;
|
||||
|
@ -128,7 +128,7 @@ if GCONFIG_WINDOWS
|
||||
UDS_SOURCES = \
|
||||
gaddresslocal_none.cpp
|
||||
|
||||
UDS_EXTRA_DIST =
|
||||
UDS_EXTRA_DIST = \
|
||||
gaddresslocal_unix.cpp
|
||||
|
||||
else
|
||||
@ -136,7 +136,7 @@ else
|
||||
UDS_SOURCES = \
|
||||
gaddresslocal_unix.cpp
|
||||
|
||||
UDS_EXTRA_DIST =
|
||||
UDS_EXTRA_DIST = \
|
||||
gaddresslocal_none.cpp
|
||||
|
||||
endif
|
||||
@ -146,7 +146,7 @@ else
|
||||
UDS_SOURCES = \
|
||||
gaddresslocal_none.cpp
|
||||
|
||||
UDS_EXTRA_DIST =
|
||||
UDS_EXTRA_DIST = \
|
||||
gaddresslocal_unix.cpp
|
||||
|
||||
endif
|
||||
@ -183,7 +183,7 @@ EVENTLOOP_EXTRA_DIST = \
|
||||
geventloop_win32.cpp \
|
||||
geventloophandles.cpp \
|
||||
geventloophandles.h \
|
||||
geventloop_select.cpp
|
||||
geventloop_epoll.cpp
|
||||
|
||||
EVENTLOOP_SOURCES = \
|
||||
geventloop_select.cpp
|
||||
|
Loading…
x
Reference in New Issue
Block a user