#199 Fix for getopt(). Use src/getopt_win32 code instead of libc/getopt()
This commit is contained in:
committed by
Luis Díaz Más
parent
a4a0516dc4
commit
185d0e9482
+1
-1
@@ -201,7 +201,7 @@ endif
|
||||
# **********************************************************************
|
||||
# Compilation shortcuts
|
||||
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c
|
||||
COMPILE.c = $(CC) $(CFLAGS) $(CPPFLAGS) -c
|
||||
COMPILE.c = $(CC) $(CFLAGS) -c
|
||||
# LINK.cc does not need $(LIBS), libtool's dark magic takes care of that
|
||||
# when linking a binary with a libtool library.
|
||||
LINK.cc = $(CXX) $(LDFLAGS)
|
||||
|
||||
+1
-7
@@ -324,9 +324,7 @@ if(EXIV2_BUILD_EXIV2_COMMAND)
|
||||
target_sources(exiv2 PRIVATE localtime.c)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
target_sources(exiv2 PRIVATE getopt_win32.c)
|
||||
endif()
|
||||
target_sources(exiv2 PRIVATE getopt_win32.c)
|
||||
install(TARGETS exiv2 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
@@ -335,10 +333,6 @@ if(NOT EXV_HAVE_TIMEGM )
|
||||
target_sources(exiv2lib PRIVATE localtime.c)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
target_sources(exiv2lib PRIVATE getopt_win32.c)
|
||||
endif()
|
||||
|
||||
# ******************************************************************************
|
||||
# Man page
|
||||
install( FILES exiv2.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 )
|
||||
|
||||
+5
-8
@@ -139,8 +139,7 @@ CCSRC += asfvideo.cpp \
|
||||
utilsvideo.cpp
|
||||
endif
|
||||
|
||||
# C source files to this list
|
||||
EXIVCSRC =
|
||||
# C source files
|
||||
ifndef HAVE_TIMEGM
|
||||
CSRC = localtime.c
|
||||
endif
|
||||
@@ -149,9 +148,7 @@ endif
|
||||
EXIV2MAIN = exiv2.cpp
|
||||
EXIV2SRC = actions.cpp \
|
||||
utils.cpp
|
||||
|
||||
# C source files for the Exiv2 application
|
||||
EXIVCSRC =
|
||||
EXIVCSRC = getopt_win32.c
|
||||
|
||||
# ******************************************************************************
|
||||
# Library
|
||||
@@ -184,7 +181,7 @@ OBJ = $(CCOBJ) $(COBJ)
|
||||
LOBJ = $(CCLOBJ) $(CLOBJ)
|
||||
|
||||
EXIV2OBJ = $(EXIV2MAIN:.cpp=.o) $(EXIV2SRC:.cpp=.o)
|
||||
EXIV2COBJ = $(EXIVCSRC:.c=.o)
|
||||
EXIVCOBJ = $(EXIVCSRC:.c=.o)
|
||||
EXIV2EXE = $(EXIV2MAIN:.cpp=$(EXEEXT))
|
||||
|
||||
ifdef DEP_TRACKING
|
||||
@@ -253,9 +250,9 @@ lib: $(OBJ)
|
||||
$(BINARY): %: %.o lib
|
||||
@$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $(LIBRARY) $@.o -rpath $(libdir)
|
||||
|
||||
$(EXIV2EXE): lib $(EXIV2OBJ) $(EXIV2COBJ)
|
||||
$(EXIV2EXE): lib $(EXIV2OBJ) $(EXIVCOBJ)
|
||||
mkdir -pv ../bin 2>&1 > /dev/null
|
||||
@$(LIBTOOL) --mode=link $(LINK.cc) -o ../bin/$@ $(LIBRARY) $(EXIV2OBJ) $(EXIV2COBJ) -rpath $(libdir)
|
||||
@$(LIBTOOL) --mode=link $(LINK.cc) -o ../bin/$@ $(LIBRARY) $(EXIV2OBJ) $(EXIVCOBJ) -rpath $(libdir)
|
||||
|
||||
install-header:
|
||||
$(INSTALL_DIRS) $(DESTDIR)$(incdir)
|
||||
|
||||
@@ -194,6 +194,10 @@ permute_args(panonopt_start, panonopt_end, opt_end, nargv)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __GETOPT_DEFINE_ARGV__
|
||||
char * const *__argv;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* getopt_internal --
|
||||
* Parse argc/argv argument vector. Called by user level routines.
|
||||
@@ -205,6 +209,11 @@ getopt_internal(nargc, nargv, options)
|
||||
char * const *nargv;
|
||||
const char *options;
|
||||
{
|
||||
|
||||
#ifdef __GETOPT_DEFINE_ARGV__
|
||||
__argv=nargv;
|
||||
#endif
|
||||
|
||||
char *oli; /* option letter list index */
|
||||
int optchar;
|
||||
|
||||
|
||||
@@ -38,6 +38,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW__) && !defined(_MSC_VER)
|
||||
// the symbol __argv (and __argc and __progname and __env) are defined in Windows environments
|
||||
// for *ix environments, __argv is declared here, defined: getopt_win32.c, init'd: getopt_internal()
|
||||
#define __GETOPT_DEFINE_ARGV__
|
||||
extern char * const *__argv;
|
||||
#endif
|
||||
|
||||
extern int opterr; /* if error message should be printed */
|
||||
extern int optind; /* index into parent argv vector */
|
||||
extern int optopt; /* character checked for validity */
|
||||
|
||||
+3
-6
@@ -28,18 +28,15 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
// + standard includes
|
||||
#if defined(_MSC_VER) || defined(__MINGW__)
|
||||
# include "getopt_win32.h"
|
||||
#endif
|
||||
#include "getopt_win32.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
// + standard includes
|
||||
#ifdef EXV_HAVE_UNISTD_H
|
||||
# include <unistd.h> // for getopt(), stat()
|
||||
# include <unistd.h> // for stat()
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
Reference in New Issue
Block a user