summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordevzero2000 <devzero2000>2010-11-29 13:44:28 +0000
committerdevzero2000 <devzero2000>2010-11-29 13:44:28 +0000
commit9a89a5356a11b29f19d98db585088cebd6965904 (patch)
tree1bd3d4366a438e3946395dfc7f6fd76881053a16
parentc81c1d87f776719c8ae134184b84642a26051567 (diff)
downloadlibpopt-9a89a5356a11b29f19d98db585088cebd6965904.tar.gz
Get built with MSVC, though tests are failing
Merge 7581f1dfcd792dbcfad4ea51b3d2abcf8432e786 from Matt Arsenault <arsenm2@rpi.edu> git://github.com/arsenm/POPT.git master branch
-rw-r--r--lookup3.c2
-rw-r--r--popt.c6
-rw-r--r--popthelp.c2
-rw-r--r--system.h102
-rw-r--r--test2.c8
5 files changed, 79 insertions, 41 deletions
diff --git a/lookup3.c b/lookup3.c
index 0584c39..36f43e5 100644
--- a/lookup3.c
+++ b/lookup3.c
@@ -48,7 +48,7 @@
static const union _dbswap {
const uint32_t ui;
const unsigned char uc[4];
-} endian = { .ui = 0x11223344 };
+} endian = { 0x11223344 };
# define HASH_LITTLE_ENDIAN (endian.uc[0] == (unsigned char) 0x44)
# define HASH_BIG_ENDIAN (endian.uc[0] == (unsigned char) 0x11)
/*@=redef@*/
diff --git a/popt.c b/popt.c
index 7613240..e799c65 100644
--- a/popt.c
+++ b/popt.c
@@ -10,17 +10,13 @@
#include "system.h"
-#if defined(__LCLINT__)
-#ifndef _MSC_VER
+#if defined(__LCLINT__) && !defined(_MSC_VER)
/*@-declundef -exportheader @*/
extern long long int strtoll(const char *nptr, /*@null@*/ char **endptr,
int base)
/*@modifies *endptr@*/;
/*@=declundef =exportheader @*/
-#else
- #define strtoll _strtoi64
-#endif /* _MSC_VER */
#endif /* defined(__LCLINT__) */
#ifdef HAVE_FLOAT_H
diff --git a/popthelp.c b/popthelp.c
index a50722a..ed21221 100644
--- a/popthelp.c
+++ b/popthelp.c
@@ -10,7 +10,7 @@
#include "system.h"
-#define POPT_USE_TIOCGWINSZ
+//#define POPT_USE_TIOCGWINSZ
#ifdef POPT_USE_TIOCGWINSZ
#include <sys/ioctl.h>
#endif
diff --git a/system.h b/system.h
index 29d106c..fda85ad 100644
--- a/system.h
+++ b/system.h
@@ -6,6 +6,11 @@
#include "config.h"
#endif
+#ifdef _MSC_VER
+#define _CRT_SECURE_NO_WARNINGS 1
+#endif
+
+
#if defined (__GLIBC__) && defined(__LCLINT__)
/*@-declundef@*/
/*@unchecked@*/
@@ -17,6 +22,7 @@ extern __const __int32_t *__ctype_toupper;
#include <ctype.h>
+
#ifdef __GNUC__
# undef alloca
# define alloca __builtin_alloca
@@ -31,36 +37,6 @@ char *alloca ();
# endif
#endif
-#if defined(_MSC_VER) || defined(__STDC__)
-# define inline __inline
-#endif /* _MSC_VER */
-
-#ifdef _MSC_VER
-/* missing unistd.h stuff */
-
-#define F_OK 0
-#define R_OK 4
-#define W_OK 2
-#define X_OK 1
-
-#define srandom srand
-#define random rand
-#define access _access
-
-/* Pretend to be root to replace these */
-inline int setuid(int) { return 1; }
-inline int getuid(void) { return 0; }
-
-inline int seteuid(int) { return 1; }
-inline int geteuid(void) { return 0; }
-
-inline int setgid(int) { return 1; }
-inline int getgid(void) { return 0; }
-
-inline int setegid(int) { return 1; }
-
-#endif
-
/* XXX isspace(3) has i18n encoding signednesss issues on Solaris. */
#define _isspaceptr(_chp) isspace((int)(*(unsigned char *)(_chp)))
@@ -83,6 +59,7 @@ inline int setegid(int) { return 1; }
#ifdef _MSC_VER
#include <io.h>
+#include <malloc.h>
#endif
#ifdef __NeXT
@@ -91,6 +68,71 @@ inline int setegid(int) { return 1; }
#include <libc.h>
#endif
+
+#if defined(_MSC_VER) || defined(__STDC__)
+# define inline __inline
+#endif /* _MSC_VER */
+
+
+#ifdef _MSC_VER
+
+#define F_OK 0
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+
+#define S_IRWXG 00000070
+#define S_IRWXO 00000007
+#define S_ISUID 00040000
+#define S_ISGID 00020000
+#define S_ISVTX 00010000
+
+
+// CHECKME
+#define S_IWGRP 00000020
+#define S_IWOTH 00000002
+
+#define S_ISREG(m) ((m)&_S_IFREG)
+
+
+/* Documentation claims these are in limits.h, but it seems to be a lie */
+#define FLT_MIN 1.175494351e-38F
+#define FLT_MAX 3.402823466e+38F
+
+typedef int uid_t;
+
+#ifdef _WIN64
+typedef __int64 ssize_t;
+#else
+typedef int ssize_t;
+#endif /* _WIN64 */
+
+#define srandom srand
+#define random rand
+#define access _access
+#define strdup _strdup
+#define execvp _execvp
+#define strtoll _strtoi64
+#define read _read
+#define open _open
+#define close _close
+#define lseek _lseek
+
+/* Pretend to be root to replace these */
+inline int setuid(int x) { return 1; }
+inline int getuid(void) { return 0; }
+
+inline int seteuid(int x) { return 1; }
+inline int geteuid(void) { return 0; }
+
+inline int setgid(int x) { return 1; }
+inline int getgid(void) { return 0; }
+
+inline int setegid(int x) { return 1; }
+
+#endif /* _MSC_VER */
+
+
/*@-incondefs@*/
/*@mayexit@*/ /*@only@*/ /*@out@*/ /*@unused@*/
void * xmalloc (size_t size)
diff --git a/test2.c b/test2.c
index a4bc26b..d0e4729 100644
--- a/test2.c
+++ b/test2.c
@@ -1,12 +1,12 @@
/*
- Popt Library Test Program Number Too
-
+ Popt Library Test Program Number Too
+
--> "a real world test of popt bugs" <--
Copyright (C) 1999 US Interactive, Inc.
This program can be used under the GPL or LGPL at your
- whim as long as this Copyright remains attached.
+ whim as long as this Copyright remains attached.
*/
#include "system.h"
@@ -45,7 +45,7 @@ char *dayphone = NULL;
char *fax = NULL;
-int
+int
main(int argc, const char ** argv) {
poptContext optCon; /* context for parsing command-line options */