diff --git a/src/Makedefs.upx b/src/Makedefs.upx index a2a5aea1..e30e05dc 100644 --- a/src/Makedefs.upx +++ b/src/Makedefs.upx @@ -141,7 +141,6 @@ include $(srcdir)/Makedefs.gcc ifeq ($(arch),i386) CCARCH += -march=i386 -mcpu=i686 endif -DEFS += '-DUPX_CONFIG_H="config_h/linux.h"' DEFS += -D_FILE_OFFSET_BITS=64 LDLIBS += -lmcheck ##CFLAGS_WERROR = -Werror @@ -173,7 +172,6 @@ ifeq ($(WITH_ZLIB),1) LDLIBS += -lz endif -DEFS += '-DUPX_CONFIG_H="config_h/linux.h"' CFLAGS = $(CFLAGS_WERROR) ifeq ($(DEBUG),1) CFLAGS += -g -O0 @@ -193,7 +191,6 @@ ifeq ($(target),cross-m68k-linux) include $(srcdir)/Makedefs.gcc CC = m68k-linux-gcc CXX = m68k-linux-g++ -DEFS += '-DUPX_CONFIG_H="config_h/linux.h"' ##LDLIBS += -lmcheck endif # cross-m68k-linux @@ -204,7 +201,6 @@ endif # cross-m68k-linux ifeq ($(target),sparc-sun-solaris) include $(srcdir)/Makedefs.gcc -DEFS += '-DUPX_CONFIG_H="config_h/sparc_sun_solaris28.h"' endif diff --git a/src/bele.h b/src/bele.h index e80a85ae..c08513a5 100644 --- a/src/bele.h +++ b/src/bele.h @@ -93,7 +93,7 @@ inline void set_be32(void *bb, unsigned v) inline unsigned get_le16(const void *bb) { -#if defined(__i386__) +#if (ACC_ARCH_IA32) return * (const unsigned short *) bb; #else const upx_bytep b = (const upx_bytep) bb; @@ -106,7 +106,7 @@ inline unsigned get_le16(const void *bb) inline void set_le16(void *bb, unsigned v) { -#if defined(__i386__) +#if (ACC_ARCH_IA32) (* (unsigned short *) bb) = (unsigned short) (v & 0xffff); #else upx_bytep b = (upx_bytep) bb; @@ -137,7 +137,7 @@ inline void set_le24(void *bb, unsigned v) inline unsigned get_le32(const void *bb) { -#if defined(__i386__) +#if (ACC_ARCH_IA32) return * (const unsigned *) bb; #else const upx_bytep b = (const upx_bytep) bb; @@ -152,7 +152,7 @@ inline unsigned get_le32(const void *bb) inline void set_le32(void *bb, unsigned v) { -#if defined(__i386__) +#if (ACC_ARCH_IA32) (* (unsigned *) bb) = v; #else upx_bytep b = (upx_bytep) bb; @@ -354,7 +354,7 @@ int le32_compare_signed(const void *e1, const void *e2); // just for testing... -#if 0 && defined(__i386__) && defined(__GNUC_VERSION_HEX__) +#if 0 && defined(__GNUC_VERSION_HEX__) && (ACC_ARCH_IA32) # if (__GNUC_VERSION_HEX__ >= 0x030200) typedef unsigned short LE16_unaligned __attribute__((__packed__,__aligned__(1))); typedef unsigned int LE32_unaligned __attribute__((__packed__,__aligned__(1))); diff --git a/src/c_screen.cpp b/src/c_screen.cpp index 7b2e43bd..73e23ef5 100644 --- a/src/c_screen.cpp +++ b/src/c_screen.cpp @@ -130,7 +130,7 @@ static int init(FILE *f, int o, int now) if (!screen) screen = do_construct(screen_djgpp2_construct(),fd); #endif -#if defined(__MFX_WIN32) +#if (ACC_OS_WIN32) if (!screen) screen = do_construct(screen_win32_construct(),fd); #endif diff --git a/src/conf.h b/src/conf.h index 854ea167..ad905054 100644 --- a/src/conf.h +++ b/src/conf.h @@ -29,26 +29,73 @@ #ifndef __UPX_CONF_H #define __UPX_CONF_H +#include "version.h" + + +/************************************************************************* +// ACC +**************************************************************************/ + #if 0 && defined(__EMX__) # include #endif -#if defined(UPX_CONFIG_H) -# include UPX_CONFIG_H +#if 0 && defined(UPX_CONFIG_HEADER) +# define ACC_CONFIG_HEADER UPX_CONFIG_HEADER +#endif +#include "acc/acc.h" + + +#if defined(__BORLANDC__) +# if (__BORLANDC__ < 0x550) +# error "need Borland C++ 5.5 or newer" +# endif +# define __UPX_CDECL __cdecl +# define SIGTYPEENTRY __cdecl +#elif defined(__DMC__) +# define __UPX_CDECL __cdecl +# define SIGTYPEENTRY __cdecl +#elif defined(__INTEL_COMPILER) +# if (__INTEL_COMPILER < 700) +# error "need Intel C++ 7.0 or newer" +# endif +# if defined(_WIN32) +# define __UPX_CDECL __cdecl +# define SIGTYPEENTRY __cdecl +# elif defined(__linux__) +# pragma warning(error: 424) // #424: extra ";" ignored +# pragma warning(disable: 193) // #193: zero used for undefined preprocessing identifier +# pragma warning(disable: 810) // #810: conversion from "A" to "B" may lose significant bits +# pragma warning(disable: 981) // #981: operands are evaluated in unspecified order +# pragma warning(disable: 1418) // #1418: external definition with no prior declaration +# else +# error "untested platform" +# endif +#elif defined(_MSC_VER) +# if (_MSC_VER < 1100) +# error "need Visual C++ 5.0 or newer" +# endif +# define __UPX_CDECL __cdecl +# define SIGTYPEENTRY __cdecl +# pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B' +# pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated +# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated +# pragma warning(disable: 4514) // W4: 'function' : unreferenced inline function has been removed +# pragma warning(disable: 4710) // W4: 'function': function not inlined +#elif defined(__WATCOMC__) +# if (__WATCOMC__ < 1100) +# error "need Watcom C++ 11.0c or newer" +# endif +# define __UPX_CDECL __cdecl +# if defined(__cplusplus) +# pragma warning 656 9 // w5: define this function inside its class definition (may improve code quality) +# endif #endif -#if defined(HAVE_STDINT_H) -# if !defined(__STDC_LIMIT_MACROS) -# define __STDC_LIMIT_MACROS 1 -# endif -# if !defined(__STDC_CONSTANT_MACROS) -# define __STDC_CONSTANT_MACROS 1 -# endif -# include -#endif -#include -#include "version.h" -#include "tailor.h" + +/************************************************************************* +// +**************************************************************************/ // upx_int64l is int_least64_t in terminology #if !defined(upx_int64l) @@ -69,11 +116,6 @@ # endif #endif -#if !defined(__i386__) -# if defined(__386__) || defined(_M_IX86) -# define __i386__ 1 -# endif -#endif #if defined(__linux__) && !defined(__unix__) # define __unix__ 1 #endif @@ -129,46 +171,30 @@ // system includes **************************************************************************/ -#if !defined(NO_SYS_TYPES_H) -# include -#endif - -#define NDEBUG -#undef NDEBUG -#include - -#include -#include -#include #include #include #include -#include -#include -#if !defined(NO_FCNTL_H) +#if defined(HAVE_ERRNO_H) +# include +#endif +#if defined(HAVE_FCNTL_H) # include #endif -#if !defined(NO_SYS_STAT_H) -# include -#endif -#if defined(HAVE_IO_H) && !defined(NO_IO_H) +#if defined(HAVE_IO_H) # include #endif -#if defined(HAVE_DOS_H) && !defined(NO_DOS_H) +#if defined(HAVE_DOS_H) # include #endif -#if defined(HAVE_MALLOC_H) && !defined(NO_MALLOC_H) +#if defined(HAVE_MALLOC_H) # include #endif -#if defined(HAVE_ALLOCA_H) && !defined(NO_ALLOCA_H) +#if defined(HAVE_ALLOCA_H) # include #endif #if defined(HAVE_SIGNAL_H) # include #endif -#if defined(HAVE_UNISTD_H) -# include -#endif #if defined(TIME_WITH_SYS_TIME) # include # include @@ -217,6 +243,10 @@ #endif +#undef NDEBUG +#include + + /************************************************************************* // portab **************************************************************************/ @@ -351,7 +381,7 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int); #undef __attribute_packed #if defined(__GNUC__) || defined(__INTEL_COMPILER) -# if 1 && defined(__i386__) +# if (1 && ACC_ARCH_IA32) # define __attribute_packed # else # define __attribute_packed __attribute__((__packed__,__aligned__(1))) @@ -393,23 +423,16 @@ typedef RETSIGTYPE (SIGTYPEENTRY *sig_type)(int); # undef USE_SETMODE #endif +#ifndef OPTIONS_VAR +# define OPTIONS_VAR "UPX" +#endif + /************************************************************************* // memory util **************************************************************************/ -#undef UNUSED -#if 1 -# define UNUSED(var) ((void) &(var)) -#elif 1 && defined(__GNUC__) -# define UNUSED(var) { typedef int __upx_unused[sizeof(var) ? 1 : -1]; } -#elif 0 -# define UNUSED(var) do { } while (!sizeof(var)) -#elif defined(__BORLANDC__) -# define UNUSED(parm) ((void)(parm)) -#else -# define UNUSED(parm) (parm = parm) -#endif +#define UNUSED ACC_UNUSED #define TABLESIZE(table) ((sizeof(table)/sizeof((table)[0]))) diff --git a/src/console.h b/src/console.h index cbaae696..94f9bacd 100644 --- a/src/console.h +++ b/src/console.h @@ -59,7 +59,7 @@ # define USE_SCREEN #endif -#if 1 && defined(__MFX_WIN32) +#if (1 && ACC_OS_WIN32) # define USE_SCREEN #endif diff --git a/src/mem.cpp b/src/mem.cpp index 45562492..5e54a5a8 100644 --- a/src/mem.cpp +++ b/src/mem.cpp @@ -116,7 +116,7 @@ void MemBuffer::allocForUncompression(unsigned uncompressed_size, unsigned extra unsigned size = uncompressed_size + extra; // size += 512; // 512 safety bytes // INFO: 3 bytes are the allowed overrun for the i386 asm_fast decompressors -#if defined(__i386__) +#if (ACC_ARCH_IA32) size += 3; #endif alloc(size); diff --git a/src/mygetopt.cpp b/src/mygetopt.cpp index ec5a17a9..1737d037 100644 --- a/src/mygetopt.cpp +++ b/src/mygetopt.cpp @@ -21,11 +21,8 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "tailor.h" -#ifndef EOF #include #include -#endif #undef progname #if 1 @@ -66,8 +63,6 @@ static const char *my_progname(const char *argv0) #define optind mfx_optind #define opterr mfx_opterr #define optopt mfx_optopt -#define my_index strchr -#define my_strlen strlen #undef BAD_OPTION /* For communication from `getopt' to the caller. @@ -394,15 +389,10 @@ static int _getopt_internal (int argc, char **argv, const char *optstring, int indfound = 0; int needexact = 0; -#if defined(DOSISH) /* allow `--option#value' because you cannout assign a '=' to an environment variable under DOS command.com */ while (*s && *s != '=' && * s != '#') s++; -#else - while (*s && *s != '=') - s++; -#endif /* Test all options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; @@ -411,7 +401,7 @@ static int _getopt_internal (int argc, char **argv, const char *optstring, { if (p->has_arg & 0x10) needexact = 1; - if ((unsigned) (s - nextchar) == my_strlen (p->name)) + if ((unsigned) (s - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -436,7 +426,7 @@ static int _getopt_internal (int argc, char **argv, const char *optstring, if (opterr) fprintf (stderr, "%s: unrecognized option `%s'\n", progname(argv[0]), argv[optind]); - nextchar += my_strlen (nextchar); + nextchar += strlen (nextchar); optind++; return BAD_OPTION; } @@ -445,7 +435,7 @@ static int _getopt_internal (int argc, char **argv, const char *optstring, if (opterr) fprintf (stderr, "%s: option `%s' is ambiguous\n", progname(argv[0]), argv[optind]); - nextchar += my_strlen (nextchar); + nextchar += strlen (nextchar); optind++; return BAD_OPTION; } @@ -478,7 +468,7 @@ static int _getopt_internal (int argc, char **argv, const char *optstring, "%s: option `%c%s' doesn't allow an argument\n", progname(argv[0]), argv[optind - 1][0], pfound->name); } - nextchar += my_strlen (nextchar); + nextchar += strlen (nextchar); return BAD_OPTION; } } @@ -496,11 +486,11 @@ static int _getopt_internal (int argc, char **argv, const char *optstring, fprintf (stderr, "%s: option `--%s%s' requires an argument\n", progname(argv[0]), pfound->name, (pfound->has_arg & 0x20) ? "=" : ""); - nextchar += my_strlen (nextchar); + nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : BAD_OPTION; } } - nextchar += my_strlen (nextchar); + nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) @@ -518,7 +508,7 @@ static int _getopt_internal (int argc, char **argv, const char *optstring, #ifdef GETOPT_COMPAT || argv[optind][0] == '+' #endif /* GETOPT_COMPAT */ - || my_index (optstring, *nextchar) == NULL) + || strchr (optstring, *nextchar) == NULL) { if (opterr) { @@ -542,7 +532,7 @@ static int _getopt_internal (int argc, char **argv, const char *optstring, { char c = *nextchar++; - const char *temp = my_index (optstring, c); + const char *temp = strchr (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') diff --git a/src/p_wcle.cpp b/src/p_wcle.cpp index 9692e4ad..da25f94d 100644 --- a/src/p_wcle.cpp +++ b/src/p_wcle.cpp @@ -277,7 +277,7 @@ void PackWcle::preprocessFixups() if (jc == 0) { // FIXME: implement this - thowCantPack("files without relocations are not supported"); + throwCantPack("files without relocations are not supported"); } ByteArray(rl, jc); diff --git a/src/s_win32.cpp b/src/s_win32.cpp index b71b09d9..acaf49df 100644 --- a/src/s_win32.cpp +++ b/src/s_win32.cpp @@ -28,7 +28,7 @@ #include "conf.h" -#if defined(USE_SCREEN) && defined(__MFX_WIN32) +#if defined(USE_SCREEN) && (ACC_OS_WIN32 || ACC_OS_WIN64) #include "screen.h" @@ -520,7 +520,7 @@ screen_t *screen_win32_construct(void) } -#endif /* defined(USE_SCREEN) && defined(__MFX_WIN32) */ +#endif /* defined(USE_SCREEN) && (ACC_OS_WIN32 || ACC_OS_WIN64) */ /* diff --git a/src/tailor.h b/src/tailor.h deleted file mode 100644 index 136e2579..00000000 --- a/src/tailor.h +++ /dev/null @@ -1,249 +0,0 @@ -/* tailor.h -- - - This file is part of the UPX executable compressor. - - Copyright (C) 1996-2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2003 Laszlo Molnar - All Rights Reserved. - - UPX and the UCL library are free software; you can redistribute them - and/or modify them under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer Laszlo Molnar - - */ - - -#if defined(__CYGWIN32__) && !defined(__CYGWIN__) -# define __CYGWIN__ __CYGWIN32__ -#endif - - -/************************************************************************* -// -**************************************************************************/ - -#if !defined(__MFX_DOS) && !defined(__MFX_WIN) && !defined(__MFX_OS2) -#if !defined(__MFX_TOS) && !defined(__MFX_PALMOS) -# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) -# define __MFX_WIN -# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) -# define __MFX_WIN -# elif defined(__CYGWIN__) || defined(__MINGW32__) -# define __MFX_WIN -# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__) -# define __MFX_WIN -# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS) -# define __MFX_DOS -# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2) -# define __MFX_OS2 -# elif defined(__TOS__) || defined(__atarist__) -# define __MFX_TOS -# endif -#endif -#endif - -#if defined(__MFX_DOS) && !defined(__MFX_DOS16) && !defined(__MFX_DOS32) -# define __MFX_DOS32 -#endif -#if defined(__MFX_WIN) && !defined(__MFX_WIN16) && !defined(__MFX_WIN32) -# define __MFX_WIN32 -#endif - -#if !defined(DOSISH) -# if defined(__MFX_DOS) || defined(__MFX_WIN) -# define DOSISH -# elif defined(__MFX_OS2) || defined(__EMX__) -# define DOSISH -# elif defined(__MFX_TOS) -# define DOSISH -# endif -#endif - -#if defined(DOSISH) -# define HAVE_SIGNAL_H 1 -# define HAVE_CTIME 1 -# define HAVE_FILENO 1 -# define HAVE_GMTIME 1 -# define HAVE_LOCALTIME 1 -# define HAVE_MEMCMP 1 -# define HAVE_MEMCPY 1 -# define HAVE_MEMMOVE 1 -# define HAVE_MEMSET 1 -# define HAVE_SETMODE 1 -# define HAVE_STRCHR 1 -# define HAVE_STRDUP 1 -# define HAVE_STRFTIME 1 -# if defined(__CYGWIN__) -# define HAVE_STRCASECMP 1 -# define HAVE_STRNCASECMP 1 -# else -# define HAVE_STRICMP 1 -# define HAVE_STRNICMP 1 -# endif -# if !defined(DIR_SEP) -# define DIR_SEP "/\\" -# endif -# if !defined(fn_tolower) -# define fn_tolower(x) tolower(((unsigned char)(x))) -# endif -# undef __UNIX__ -# undef UNIX -# undef __unix__ -# undef unix -#endif - -#if defined(__DJGPP__) || defined(__EMX__) || defined(__CYGWIN__) -# define TIME_WITH_SYS_TIME 1 -# define HAVE_IO_H 1 -# define HAVE_UNISTD_H 1 -# define HAVE_UTIME_H 1 -# define HAVE_MODE_T 1 -# define HAVE_CHMOD 1 -# define HAVE_GETTIMEOFDAY 1 -# define HAVE_UTIME 1 -#elif defined(__MINGW32__) -# define TIME_WITH_SYS_TIME 1 -# define HAVE_CONIO_H 1 -# define HAVE_IO_H 1 -# define HAVE_SHARE_H 1 -# define HAVE_UNISTD_H 1 -# define HAVE_SYS_UTIME_H 1 -# define HAVE_MODE_T 1 -# define HAVE_CHMOD 1 -# define HAVE_UTIME 1 -#elif defined(__MINT__) -# undef HAVE_SETMODE -# define TIME_WITH_SYS_TIME 1 -# define HAVE_UNISTD_H 1 -# define HAVE_UTIME_H 1 -# define HAVE_CHMOD 1 -# define HAVE_CHOWN 1 -# define HAVE_UTIME 1 -#elif defined(__BORLANDC__) -# if (__BORLANDC__ < 0x551) -# error "need Borland C++ 5.5.1 or newer" -# endif -# define __UPX_CDECL __cdecl -# define SIGTYPEENTRY __cdecl -# define HAVE_CONIO_H 1 -# define HAVE_IO_H 1 -# define HAVE_MALLOC_H 1 -# define HAVE_CHMOD 1 -# define HAVE_SHARE_H 1 -# define HAVE_UTIME_H 1 -# define HAVE_UTIME 1 -# define HAVE_VSNPRINTF 1 -# define vsnprintf _vsnprintf -#elif defined(__DMC__) -# define __UPX_CDECL __cdecl -# define SIGTYPEENTRY __cdecl -# define HAVE_IO_H 1 -# define HAVE_MALLOC_H 1 -# define HAVE_UTIME_H 1 -# define HAVE_MODE_T 1 -# define HAVE_CHMOD 1 -# define HAVE_UTIME 1 -#elif defined(__INTEL_COMPILER) -# if (__INTEL_COMPILER < 700) -# error "need Intel C++ 7.0 or newer" -# endif -# if defined(_WIN32) -# define __UPX_CDECL __cdecl -# define SIGTYPEENTRY __cdecl -# define HAVE_CONIO_H 1 -# define HAVE_IO_H 1 -# define HAVE_MALLOC_H 1 -# define HAVE_SHARE_H 1 -# define HAVE_SYS_UTIME_H 1 -# define HAVE_CHMOD 1 -# define HAVE_UTIME 1 -# define HAVE_VSNPRINTF 1 -# define vsnprintf _vsnprintf -# elif defined(__linux__) -# pragma warning(error: 424) // #424: extra ";" ignored -# pragma warning(disable: 193) // #193: zero used for undefined preprocessing identifier - -# pragma warning(disable: 810) // #810: conversion from "A" to "B" may lose significant bits -# pragma warning(disable: 981) // #981: operands are evaluated in unspecified order -# pragma warning(disable: 1418) // #1418: external definition with no prior declaration -# else -# error "untested platform" -# endif -#elif defined(_MSC_VER) -# if (_MSC_VER < 1100) -# error "need Visual C++ 5.0 or newer" -# endif -# define __UPX_CDECL __cdecl -# define SIGTYPEENTRY __cdecl -# define HAVE_CONIO_H 1 -# define HAVE_IO_H 1 -# define HAVE_MALLOC_H 1 -# define HAVE_CHMOD 1 -# if (_MSC_VER >= 1000) -# define HAVE_SHARE_H 1 -# define HAVE_SYS_UTIME_H 1 -# define HAVE_UTIME 1 -# define HAVE_VSNPRINTF 1 -# define vsnprintf _vsnprintf -# pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B' -# pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated -# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated -# pragma warning(disable: 4514) // W4: 'function' : unreferenced inline function has been removed -# pragma warning(disable: 4710) // W4: 'function': function not inlined -# endif -#elif defined(__WATCOMC__) -# if (__WATCOMC__ < 1100) -# error "need Watcom C++ 11.0c or newer" -# define NO_BOOL 1 -# endif -# define __UPX_CDECL __cdecl -# define HAVE_IO_H 1 -# define HAVE_SYS_UTIME_H 1 -# define HAVE_CHMOD 1 -# define HAVE_UTIME 1 -# define HAVE_VSNPRINTF 1 -# define vsnprintf _vsnprintf -# if defined(__cplusplus) -# pragma warning 656 9 // w5: define this function inside its class definition (may improve code quality) -# endif -#endif - -#if defined(__MFX_DOS) -# define HAVE_DOS_H 1 -#endif - - -/************************************************************************* -// -**************************************************************************/ - -#ifndef DIR_SEP -# define DIR_SEP "/" -#endif - -#ifndef OPTIONS_VAR -# define OPTIONS_VAR "UPX" -#endif - -#ifndef fn_tolower -# define fn_tolower(x) (x) -#endif - - -/* -vi:ts=4:et -*/ - diff --git a/src/util.cpp b/src/util.cpp index 4e1395e2..be4a92f6 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -238,16 +238,22 @@ int upx_tolower(int c) // filename util **************************************************************************/ -static const char dir_sep[] = DIR_SEP; +#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_TOS || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) +static const char dir_sep[] = "/\\"; +#define fn_is_drive(s) (s[0] && s[1] == ':') #define fn_is_sep(c) (strchr(dir_sep,c) != NULL) +#define fn_skip_drive(s) (fn_is_drive(s) ? (s) + 2 : (s)) +#define fn_tolower(c) (tolower(((unsigned char)(c)))) -#if defined(DOSISH) -#define fn_is_drive(n) (n[0] && n[1] == ':') -#define fn_skip_drive(n) (fn_is_drive(n) ? (n) + 2 : (n)) #else -#define fn_is_drive(n) (0) -#define fn_skip_drive(n) (n) + +static const char dir_sep[] = "/"; +#define fn_is_drive(s) (0) +#define fn_is_sep(c) ((c) == '/') +#define fn_skip_drive(s) (s) +#define fn_tolower(c) (c) + #endif @@ -324,7 +330,7 @@ int fn_strcmp(const char *n1, const char *n2) bool fn_is_same_file(const char *n1, const char *n2) { /* very simple... */ - if (fn_strcmp(n1,n2) == 0) + if (fn_strcmp(n1, n2) == 0) return 1; return 0; } diff --git a/src/work.cpp b/src/work.cpp index 7d0484f4..cc78d077 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -35,7 +35,7 @@ #if defined(__DJGPP__) # define USE_FTIME -#elif defined(__MFX_WIN32) && defined(_MSC_VER) +#elif defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64)) # define USE__FUTIME #elif defined(HAVE_UTIME) # define USE_UTIME