summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordevzero2000 <devzero2000>2011-09-05 11:26:39 +0000
committerdevzero2000 <devzero2000>2011-09-05 11:26:39 +0000
commit217bada4e58deff154b285569d584241209b613e (patch)
treefead6bb6900189c42c84e2101c298f8341f67f43
parentd9e5032cdf8374f78d832c4127f49c2d728afbee (diff)
downloadlibpopt-217bada4e58deff154b285569d584241209b613e.tar.gz
merge commit 8396019 from git pull request
https://github.com/devzero2000/POPT/pull/2 "Work around missing format for long long in windows; fix warnings" by asenm (Matt Arsenault)
-rw-r--r--CHANGES4
-rw-r--r--popthelp.c2
-rw-r--r--system.h33
-rw-r--r--test1.c4
4 files changed, 29 insertions, 14 deletions
diff --git a/CHANGES b/CHANGES
index 7fe958e..43462bf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,8 @@
1.17 -> 2.0:
+ - devzero2000: merge commit 8396019 from git pull request
+ https://github.com/devzero2000/POPT/pull/2
+ "Work around missing format for long long in windows; fix warnings"
+ by asenm (Matt Arsenault)
- devzero2000: merge commit ea2978d from git pull request
https://github.com/devzero2000/POPT/pull/2
"Fix build with MinGW 32/64 + MSVC" by arsenm
diff --git a/popthelp.c b/popthelp.c
index 0f397e3..b49e0eb 100644
--- a/popthelp.c
+++ b/popthelp.c
@@ -265,7 +265,7 @@ assert(le); /* XXX can't happen */
le += sprintf(le, "%ld", arg.longp[0]);
break;
case POPT_ARG_LONGLONG:
- le += sprintf(le, "%lld", arg.longlongp[0]);
+ le += sprintf(le, "%" LONG_LONG_FORMAT, arg.longlongp[0]);
break;
case POPT_ARG_FLOAT:
{ double aDouble = (double) arg.floatp[0];
diff --git a/system.h b/system.h
index e44e18f..b072656 100644
--- a/system.h
+++ b/system.h
@@ -7,7 +7,6 @@
#endif
-
#if defined (__GLIBC__) && defined(__LCLINT__)
/*@-declundef@*/
/*@unchecked@*/
@@ -54,10 +53,18 @@ char *alloca ();
#include <unistd.h>
#endif
+
+#if !defined(__GNUC__) && !defined(__attribute__)
+#define __attribute__(x)
+#endif
+#define UNUSED(x) x __attribute__((__unused__))
+
+
#ifdef _MSC_VER
# define inline __inline
#endif
+
#if defined(_MSC_VER) || defined(__MINGW32__)
#define _CRT_SECURE_NO_WARNINGS 1
#include <io.h>
@@ -73,6 +80,10 @@ char *alloca ();
#define S_ISGID 00020000
#define S_ISVTX 00010000
+/* I haven't discovered a better way to work around these format
+ specifier problems */
+#define LONG_LONG_FORMAT "I64d"
+
/* CHECKME */
#define S_IWGRP 00000020
@@ -112,17 +123,22 @@ typedef int ssize_t;
#define lseek _lseek
/* Pretend to be root to replace these */
-static inline int setuid(int x) { return 1; }
+static inline int setuid(UNUSED(int x)) { return 1; }
static inline int getuid(void) { return 0; }
-static inline int seteuid(int x) { return 1; }
+static inline int seteuid(UNUSED(int x)) { return 1; }
static inline int geteuid(void) { return 0; }
-static inline int setgid(int x) { return 1; }
+static inline int setgid(UNUSED(int x)) { return 1; }
static inline int getgid(void) { return 0; }
-static inline int setegid(int x) { return 1; }
+static inline int setegid(UNUSED(int x)) { return 1; }
+
+
+#else
+
+#define LONG_LONG_FORMAT "lld"
#endif /* defined(_MSC_VER) || defined(__MINGW32__) */
@@ -186,12 +202,7 @@ static inline char * stpcpy (char *dest, const char * src) {
#define getenv(_s) __secure_getenv(_s)
#endif
-#if !defined(__GNUC__) && !defined(__attribute__)
-#define __attribute__(x)
-#endif
-#define UNUSED(x) x __attribute__((__unused__))
-
/* Include configmake.h autogenerated from Makefile.am */
-
#include "configmake.h"
#include "popt.h"
+
diff --git a/test1.c b/test1.c
index 1f49c3f..4e7e6f9 100644
--- a/test1.c
+++ b/test1.c
@@ -91,7 +91,7 @@ static char * lStr =
"123456789+123456789+123456789+123456789+123456789+ "
"123456789+123456789+123456789+123456789+123456789+ ";
/*@unchecked@*/ /*@null@*/
-static char * nStr = NULL;
+static char * nStr = NULL;
/*@unchecked@*/
static struct poptOption moreCallbackArgs[] = {
@@ -334,7 +334,7 @@ int main(int argc, const char ** argv)
if (aLong != bLong)
fprintf(stdout, " aLong: %ld", aLong);
if (aLongLong != bLongLong)
- fprintf(stdout, " aLongLong: %lld", aLongLong);
+ fprintf(stdout, " aLongLong: %" LONG_LONG_FORMAT, aLongLong);
/*@-realcompare@*/
if (aFloat != bFloat)
fprintf(stdout, " aFloat: %g", (double)aFloat);