From a32b73adbce16e0eddd0e31e283589887158dd49 Mon Sep 17 00:00:00 2001 From: "Vladimir S. FONOV" Date: Mon, 24 Feb 2025 14:22:15 -0500 Subject: [PATCH] MINC 2025-02-24 (3b8d9c7e) Code extracted from: https://github.com/BIC-MNI/libminc.git at commit 3b8d9c7edb313bb33419338f3de89e4fc1aaf14f (master). --- CMakeLists.txt | 12 ++++++------ libcommon/ParseArgv.c | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23c73cd360a..6366d2cb882 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -438,11 +438,11 @@ SET(LIBMINC_STATIC_LIBRARIES ${LIBMINC_LIBRARY_STATIC} ${HDF5_LIBRARY} ${NIFTI_L SET(LIBMINC_STATIC_LIBRARIES_CONFIG ${LIBMINC_LIBRARY_STATIC} ${HDF5_LIBRARY_NAME} ${NIFTI_LIBRARIES} ${ZLIB_LIBRARY_NAME}) IF(UNIX) - SET(LIBMINC_LIBRARIES ${LIBMINC_LIBRARIES} m dl ${RT_LIBRARY}) - SET(LIBMINC_STATIC_LIBRARIES ${LIBMINC_STATIC_LIBRARIES} m dl ${RT_LIBRARY}) + SET(LIBMINC_LIBRARIES ${LIBMINC_LIBRARIES} m ${CMAKE_DL_LIBS} ${RT_LIBRARY}) + SET(LIBMINC_STATIC_LIBRARIES ${LIBMINC_STATIC_LIBRARIES} m ${CMAKE_DL_LIBS} ${RT_LIBRARY}) - SET(LIBMINC_LIBRARIES_CONFIG ${LIBMINC_LIBRARIES_CONFIG} m dl ${RT_LIBRARY_NAME}) - SET(LIBMINC_STATIC_LIBRARIES_CONFIG ${LIBMINC_STATIC_LIBRARIES_CONFIG} m dl ${RT_LIBRARY_NAME}) + SET(LIBMINC_LIBRARIES_CONFIG ${LIBMINC_LIBRARIES_CONFIG} m ${CMAKE_DL_LIBS} ${RT_LIBRARY_NAME}) + SET(LIBMINC_STATIC_LIBRARIES_CONFIG ${LIBMINC_STATIC_LIBRARIES_CONFIG} m ${CMAKE_DL_LIBS} ${RT_LIBRARY_NAME}) ENDIF(UNIX) SET(minc_LIB_SRCS ${minc2_LIB_SRCS} ${minc_common_SRCS}) @@ -482,11 +482,11 @@ ENDIF() EXPORT(TARGETS ${LIBMINC_LIBRARY} FILE "${LIBMINC_EXPORTED_TARGETS}.cmake") IF(UNIX) - TARGET_LINK_LIBRARIES(${LIBMINC_LIBRARY} m dl ) + TARGET_LINK_LIBRARIES(${LIBMINC_LIBRARY} m ${CMAKE_DL_LIBS} ) IF(LIBMINC_BUILD_SHARED_LIBS) ADD_LIBRARY(${LIBMINC_LIBRARY_STATIC} STATIC ${minc_LIB_SRCS} ${minc_HEADERS} ${volume_io_LIB_SRCS} ${volume_io_HEADERS} ) - TARGET_LINK_LIBRARIES(${LIBMINC_LIBRARY_STATIC} ${HDF5_LIBRARY} ${NIFTI_LIBRARIES} ${ZLIB_LIBRARY} ${RT_LIBRARY} m dl ) + TARGET_LINK_LIBRARIES(${LIBMINC_LIBRARY_STATIC} ${HDF5_LIBRARY} ${NIFTI_LIBRARIES} ${ZLIB_LIBRARY} ${RT_LIBRARY} m ${CMAKE_DL_LIBS} ) IF(LIBMINC_MINC1_SUPPORT) TARGET_LINK_LIBRARIES(${LIBMINC_LIBRARY} ${NETCDF_LIBRARY}) ENDIF(LIBMINC_MINC1_SUPPORT) diff --git a/libcommon/ParseArgv.c b/libcommon/ParseArgv.c index 260f5745fae..47cfe716398 100644 --- a/libcommon/ParseArgv.c +++ b/libcommon/ParseArgv.c @@ -111,6 +111,16 @@ ParseLong(const char *argPtr, char **endPtr) * Process an argv array according to a table of expected * command-line options. See the manual page for more details. * + * argcPtr: Number of arguments in argv. Modified to hold # args left in argv + * at end. + * + * argv: Array of arguments. Modified to hold those that couldn't be processed + * here. + * + * argTable: Array of option descriptions + * + * flags: Or'ed combination of various flag bits, such as ARGV_NO_DEFAULTS. + * * Results: * The return value is a Boolean value with non-zero indicating an * error. @@ -126,14 +136,7 @@ ParseLong(const char *argPtr, char **endPtr) */ int -ParseArgv(argcPtr, argv, argTable, flags) - int *argcPtr; /* Number of arguments in argv. Modified - * to hold # args left in argv at end. */ - char **argv; /* Array of arguments. Modified to hold - * those that couldn't be processed here. */ - ArgvInfo *argTable; /* Array of option descriptions */ - int flags; /* Or'ed combination of various flag bits, - * such as ARGV_NO_DEFAULTS. */ +ParseArgv(int *argcPtr, char **argv, ArgvInfo *argTable, int flags) { ArgvInfo *infoPtr; /* Pointer to the current entry in the @@ -315,7 +318,8 @@ ParseArgv(argcPtr, argv, argTable, flags) } break; case ARGV_FUNC: { - int (*handlerProc)() = (int (*)())(uintptr_t)infoPtr->src; + typedef int (*handlerProcType)(void*, const char*, char*); + handlerProcType handlerProc = (handlerProcType)(uintptr_t)infoPtr->src; if ((*handlerProc)(infoPtr->dst, infoPtr->key, argv[srcIndex])) { @@ -325,7 +329,8 @@ ParseArgv(argcPtr, argv, argTable, flags) break; } case ARGV_GENFUNC: { - int (*handlerProc)() = (int (*)())(uintptr_t)infoPtr->src; + typedef int (*handlerProcType)(void*, const char*, int, char**); + handlerProcType handlerProc = (handlerProcType)(uintptr_t)infoPtr->src; argc = (*handlerProc)(infoPtr->dst, infoPtr->key, argc, argv+srcIndex);