Commit df067c9ab68dd4913a1591f048d9baf4f1c8d09c

Authored by Jay Berkenbilt
1 parent 2538d844

Add autoconf test for localtime_r

autofiles.sums
1 -715dae6d625977752bf7ddf7e386a2dc6ada04b8e56c6f0e7a3f7dcc9bad3209 configure.ac 1 +cabe87703520d63bbb0ea3e069c3488fd8b43667ae29c2ee5bffffaf20321002 configure.ac
2 d3f9ee6f6f0846888d9a10fd3dad2e4b1258be84205426cf04d7cef02d61dad7 aclocal.m4 2 d3f9ee6f6f0846888d9a10fd3dad2e4b1258be84205426cf04d7cef02d61dad7 aclocal.m4
3 -d12e9b7b928e7b2b9d4ffbc2af170392421376e60e40d07bdeee6a7252be8f6e libqpdf/qpdf/qpdf-config.h.in 3 +3ed561073f0d5c9899e2120e006a7da5ec6bffb80268da1b962cd4f893b89982 libqpdf/qpdf/qpdf-config.h.in
4 5297971a0ef90bcd5563eb3f7127a032bb76d3ae2af7258bf13479caf8983a60 m4/ax_cxx_compile_stdcxx.m4 4 5297971a0ef90bcd5563eb3f7127a032bb76d3ae2af7258bf13479caf8983a60 m4/ax_cxx_compile_stdcxx.m4
5 35bc5c645dc42d47f2daeea06f8f3e767c8a1aee6a35eb2b4854fd2ce66c3413 m4/ax_random_device.m4 5 35bc5c645dc42d47f2daeea06f8f3e767c8a1aee6a35eb2b4854fd2ce66c3413 m4/ax_random_device.m4
6 1451e63710701b5f00a668f3a79b435015ef2e63547f0ad0ce8c8c062d53b599 m4/libtool.m4 6 1451e63710701b5f00a668f3a79b435015ef2e63547f0ad0ce8c8c062d53b599 m4/libtool.m4
configure
@@ -17474,24 +17474,13 @@ $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h @@ -17474,24 +17474,13 @@ $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h
17474 17474
17475 fi 17475 fi
17476 17476
17477 -for ac_func in fseeko64 17477 +for ac_func in fseeko64 random localtime_r
17478 do : 17478 do :
17479 - ac_fn_c_check_func "$LINENO" "fseeko64" "ac_cv_func_fseeko64"  
17480 -if test "x$ac_cv_func_fseeko64" = xyes; then : 17479 + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
  17480 +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
  17481 +if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
17481 cat >>confdefs.h <<_ACEOF 17482 cat >>confdefs.h <<_ACEOF
17482 -#define HAVE_FSEEKO64 1  
17483 -_ACEOF  
17484 -  
17485 -fi  
17486 -done  
17487 -  
17488 -  
17489 -for ac_func in random  
17490 -do :  
17491 - ac_fn_c_check_func "$LINENO" "random" "ac_cv_func_random"  
17492 -if test "x$ac_cv_func_random" = xyes; then :  
17493 - cat >>confdefs.h <<_ACEOF  
17494 -#define HAVE_RANDOM 1 17483 +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
17495 _ACEOF 17484 _ACEOF
17496 17485
17497 fi 17486 fi
configure.ac
@@ -310,9 +310,7 @@ AC_ARG_WITH(large-file-test-path, @@ -310,9 +310,7 @@ AC_ARG_WITH(large-file-test-path,
310 310
311 AC_SYS_LARGEFILE 311 AC_SYS_LARGEFILE
312 AC_FUNC_FSEEKO 312 AC_FUNC_FSEEKO
313 -AC_CHECK_FUNCS([fseeko64])  
314 -  
315 -AC_CHECK_FUNCS(random) 313 +AC_CHECK_FUNCS([fseeko64 random localtime_r])
316 314
317 # Check if LD supports linker scripts, and define conditional 315 # Check if LD supports linker scripts, and define conditional
318 # HAVE_LD_VERSION_SCRIPT if so. This functionality is currently 316 # HAVE_LD_VERSION_SCRIPT if so. This functionality is currently
libqpdf/QUtil.cc
@@ -844,7 +844,11 @@ QUtil::get_current_qpdf_time() @@ -844,7 +844,11 @@ QUtil::get_current_qpdf_time()
844 struct tm ltime; 844 struct tm ltime;
845 time_t now = time(0); 845 time_t now = time(0);
846 tzset(); 846 tzset();
  847 +#ifdef HAVE_LOCALTIME_R
847 localtime_r(&now, &ltime); 848 localtime_r(&now, &ltime);
  849 +#else
  850 + ltime = *localtime(&now);
  851 +#endif
848 return QPDFTime(static_cast<int>(ltime.tm_year + 1900), 852 return QPDFTime(static_cast<int>(ltime.tm_year + 1900),
849 static_cast<int>(ltime.tm_mon + 1), 853 static_cast<int>(ltime.tm_mon + 1),
850 static_cast<int>(ltime.tm_mday), 854 static_cast<int>(ltime.tm_mday),
libqpdf/qpdf/qpdf-config.h.in
@@ -21,6 +21,9 @@ @@ -21,6 +21,9 @@
21 /* Define to 1 if you have the <inttypes.h> header file. */ 21 /* Define to 1 if you have the <inttypes.h> header file. */
22 #undef HAVE_INTTYPES_H 22 #undef HAVE_INTTYPES_H
23 23
  24 +/* Define to 1 if you have the `localtime_r' function. */
  25 +#undef HAVE_LOCALTIME_R
  26 +
24 /* Define to 1 if you have the <memory.h> header file. */ 27 /* Define to 1 if you have the <memory.h> header file. */
25 #undef HAVE_MEMORY_H 28 #undef HAVE_MEMORY_H
26 29