File tree Expand file tree Collapse file tree 4 files changed +40
-3
lines changed
Expand file tree Collapse file tree 4 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 4242 - name : Test
4343 run : ctest --test-dir build --output-on-failure
4444
45+ build-ubuntu-sscanf :
46+ name : Ubuntu (sscanf)
47+ runs-on : ubuntu-latest
48+
49+ steps :
50+ - name : Install dependencies
51+ run : |
52+ sudo apt-get update
53+ sudo apt-get install -y libmbedtls-dev
54+
55+ - name : Checkout
56+ uses : actions/checkout@v4
57+ with :
58+ submodules : recursive
59+ - run : git describe --always --dirty
60+
61+ - name : Configure CMake with sscanf() for date/time
62+ run : |
63+ cmake -B build \
64+ -DCMAKE_BUILD_TYPE="Debug" \
65+ -DTR31_USE_SSCANF_DATETIME=ON
66+
67+ - name : Build
68+ run : cmake --build build -j 4
69+
70+ - name : Test
71+ run : ctest --test-dir build --output-on-failure -j 4
72+
4573 build-ubuntu-legacy-release :
4674 strategy :
4775 fail-fast : false
Original file line number Diff line number Diff line change @@ -93,6 +93,14 @@ else()
9393 # set as cache entry to persist across multiple builds
9494 set (TR31_ENABLE_DATETIME_CONVERSION OFF CACHE INTERNAL "Date/time conversion availability" )
9595endif ()
96+ # option to use sscanf() for date/time parsing even when strptime() is
97+ # available
98+ option (TR31_USE_SSCANF_DATETIME "Use sscanf() for date/time parsing" )
99+ if (HAVE_STRPTIME AND NOT TR31_USE_SSCANF_DATETIME)
100+ message (STATUS "Using strptime() for date/time parsing" )
101+ else ()
102+ message (STATUS "Using sscanf() for date/time parsing" )
103+ endif ()
96104
97105include (GNUInstallDirs) # provides CMAKE_INSTALL_* variables and good defaults for install()
98106
Original file line number Diff line number Diff line change 3333#cmakedefine HAVE_TIMEGM
3434#cmakedefine HAVE_MKGMTIME
3535#cmakedefine TR31_ENABLE_DATETIME_CONVERSION
36+ #cmakedefine TR31_USE_SSCANF_DATETIME
3637
3738#endif
Original file line number Diff line number Diff line change 4040#ifdef HAVE_TIME_H
4141#include <time.h>
4242#endif
43- #ifndef HAVE_STRPTIME
43+ #if !defined( HAVE_STRPTIME ) || defined( TR31_USE_SSCANF_DATETIME )
4444#include <stdio.h> // For sscanf()
4545#endif
4646#endif // TR31_ENABLE_DATETIME_CONVERSION
@@ -512,7 +512,7 @@ static int tr31_opt_block_iso8601_get_string(const struct tr31_opt_ctx_t* opt_bl
512512{
513513#ifdef TR31_ENABLE_DATETIME_CONVERSION
514514 char * iso8601_str ;
515- #ifdef HAVE_STRPTIME
515+ #if defined( HAVE_STRPTIME ) && !defined( TR31_USE_SSCANF_DATETIME )
516516 char * ptr ;
517517#else
518518 int r ;
@@ -537,7 +537,7 @@ static int tr31_opt_block_iso8601_get_string(const struct tr31_opt_ctx_t* opt_bl
537537 // See ANSI X9.143:2021, 6.3.6.13, table 21
538538 // See ANSI X9.143:2021, 6.3.6.14, table 22
539539 memset (& ztm , 0 , sizeof (ztm ));
540- #ifdef HAVE_STRPTIME
540+ #if defined( HAVE_STRPTIME ) && !defined( TR31_USE_SSCANF_DATETIME )
541541 switch (opt_block -> data_length ) {
542542 case 0x13 - 4 : // YYYYMMDDhhmmssZ
543543 ptr = strptime (iso8601_str , "%Y%m%d%H%M%SZ" , & ztm );
You can’t perform that action at this time.
0 commit comments