summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Kreen2009-04-28 19:48:08 +0000
committerMarko Kreen2009-04-28 19:48:08 +0000
commit9dd7af55a9bb8e622d1f1913220bdc38e36d2acf (patch)
tree0732a3f0c70b0ace5d59ab9a9514c839d1dced0a
parent6e5c5bffa24fe138c450f65f252dacba318bc262 (diff)
cquoting: compat macros for MSC, minor cleanups
- MSC: macros for 'inline', 'strcasecmp' - Use stdbool.h instead custom enum for 'bool'.
-rw-r--r--python/modules/cquoting.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/python/modules/cquoting.c b/python/modules/cquoting.c
index eb518a3e..700c1d61 100644
--- a/python/modules/cquoting.c
+++ b/python/modules/cquoting.c
@@ -5,13 +5,18 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
+#include <stdbool.h>
+
#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#endif
-typedef enum { false = 0, true = 1 } bool;
+#ifdef _MSC_VER
+#define inline __inline
+#define strcasecmp stricmp
+#endif
/*
* Common buffer management.
@@ -393,14 +398,14 @@ static PyObject *do_dolq(unsigned char *src, Py_ssize_t src_len)
/* src_len >= 2, '$' in start and end */
unsigned char *src_end = src + src_len;
unsigned char *p1 = src + 1, *p2 = src_end - 2;
-
+
while (p1 < src_end && *p1 != '$')
p1++;
while (p2 > src && *p2 != '$')
p2--;
if (p2 <= p1)
goto failed;
-
+
p1++; /* position after '$' */
if ((p1 - src) != (src_end - p2))
@@ -587,7 +592,7 @@ static PyObject *encode_dictlike(PyObject *data)
PyObject *key = NULL, *value = NULL, *tup, *iter;
struct Buf buf;
bool needAmp = false;
-
+
if (!buf_init(&buf, 1024))
return NULL;