summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2011-10-31 07:40:56 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2011-10-31 07:40:56 (GMT)
commit0d3072e98d9be9cfcdccefd60dbaca2c19e8d889 (patch)
tree51242c3dae4a06b7351d8a4413dfc786a29fff7c /Objects
parenta72e78b3b137f0ba811761b70dec9637e3d2f37d (diff)
downloadcpython-0d3072e98d9be9cfcdccefd60dbaca2c19e8d889.zip
cpython-0d3072e98d9be9cfcdccefd60dbaca2c19e8d889.tar.gz
cpython-0d3072e98d9be9cfcdccefd60dbaca2c19e8d889.tar.bz2
Drop Py_UCS4_ functions. Closes #13246.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c100
-rw-r--r--Objects/uniops.h91
2 files changed, 90 insertions, 101 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6c73779..7147f04 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -14195,16 +14195,96 @@ unicode_iter(PyObject *seq)
return (PyObject *)it;
}
-#define UNIOP(x) Py_UNICODE_##x
-#define UNIOP_t Py_UNICODE
-#include "uniops.h"
-#undef UNIOP
-#undef UNIOP_t
-#define UNIOP(x) Py_UCS4_##x
-#define UNIOP_t Py_UCS4
-#include "uniops.h"
-#undef UNIOP
-#undef UNIOP_t
+
+size_t
+Py_UNICODE_strlen(const Py_UNICODE *u)
+{
+ int res = 0;
+ while(*u++)
+ res++;
+ return res;
+}
+
+Py_UNICODE*
+Py_UNICODE_strcpy(Py_UNICODE *s1, const Py_UNICODE *s2)
+{
+ Py_UNICODE *u = s1;
+ while ((*u++ = *s2++));
+ return s1;
+}
+
+Py_UNICODE*
+Py_UNICODE_strncpy(Py_UNICODE *s1, const Py_UNICODE *s2, size_t n)
+{
+ Py_UNICODE *u = s1;
+ while ((*u++ = *s2++))
+ if (n-- == 0)
+ break;
+ return s1;
+}
+
+Py_UNICODE*
+Py_UNICODE_strcat(Py_UNICODE *s1, const Py_UNICODE *s2)
+{
+ Py_UNICODE *u1 = s1;
+ u1 += Py_UNICODE_strlen(u1);
+ Py_UNICODE_strcpy(u1, s2);
+ return s1;
+}
+
+int
+Py_UNICODE_strcmp(const Py_UNICODE *s1, const Py_UNICODE *s2)
+{
+ while (*s1 && *s2 && *s1 == *s2)
+ s1++, s2++;
+ if (*s1 && *s2)
+ return (*s1 < *s2) ? -1 : +1;
+ if (*s1)
+ return 1;
+ if (*s2)
+ return -1;
+ return 0;
+}
+
+int
+Py_UNICODE_strncmp(const Py_UNICODE *s1, const Py_UNICODE *s2, size_t n)
+{
+ register Py_UNICODE u1, u2;
+ for (; n != 0; n--) {
+ u1 = *s1;
+ u2 = *s2;
+ if (u1 != u2)
+ return (u1 < u2) ? -1 : +1;
+ if (u1 == '\0')
+ return 0;
+ s1++;
+ s2++;
+ }
+ return 0;
+}
+
+Py_UNICODE*
+Py_UNICODE_strchr(const Py_UNICODE *s, Py_UNICODE c)
+{
+ const Py_UNICODE *p;
+ for (p = s; *p; p++)
+ if (*p == c)
+ return (Py_UNICODE*)p;
+ return NULL;
+}
+
+Py_UNICODE*
+Py_UNICODE_strrchr(const Py_UNICODE *s, Py_UNICODE c)
+{
+ const Py_UNICODE *p;
+ p = s + Py_UNICODE_strlen(s);
+ while (p != s) {
+ p--;
+ if (*p == c)
+ return (Py_UNICODE*)p;
+ }
+ return NULL;
+}
Py_UNICODE*
PyUnicode_AsUnicodeCopy(PyObject *unicode)
diff --git a/Objects/uniops.h b/Objects/uniops.h
deleted file mode 100644
index 06a0b4e..0000000
--- a/Objects/uniops.h
+++ /dev/null
@@ -1,91 +0,0 @@
-
-size_t
-UNIOP(strlen)(const UNIOP_t *u)
-{
- int res = 0;
- while(*u++)
- res++;
- return res;
-}
-
-UNIOP_t*
-UNIOP(strcpy)(UNIOP_t *s1, const UNIOP_t *s2)
-{
- UNIOP_t *u = s1;
- while ((*u++ = *s2++));
- return s1;
-}
-
-UNIOP_t*
-UNIOP(strncpy)(UNIOP_t *s1, const UNIOP_t *s2, size_t n)
-{
- UNIOP_t *u = s1;
- while ((*u++ = *s2++))
- if (n-- == 0)
- break;
- return s1;
-}
-
-UNIOP_t*
-UNIOP(strcat)(UNIOP_t *s1, const UNIOP_t *s2)
-{
- UNIOP_t *u1 = s1;
- u1 += UNIOP(strlen(u1));
- UNIOP(strcpy(u1, s2));
- return s1;
-}
-
-int
-UNIOP(strcmp)(const UNIOP_t *s1, const UNIOP_t *s2)
-{
- while (*s1 && *s2 && *s1 == *s2)
- s1++, s2++;
- if (*s1 && *s2)
- return (*s1 < *s2) ? -1 : +1;
- if (*s1)
- return 1;
- if (*s2)
- return -1;
- return 0;
-}
-
-int
-UNIOP(strncmp)(const UNIOP_t *s1, const UNIOP_t *s2, size_t n)
-{
- register UNIOP_t u1, u2;
- for (; n != 0; n--) {
- u1 = *s1;
- u2 = *s2;
- if (u1 != u2)
- return (u1 < u2) ? -1 : +1;
- if (u1 == '\0')
- return 0;
- s1++;
- s2++;
- }
- return 0;
-}
-
-UNIOP_t*
-UNIOP(strchr)(const UNIOP_t *s, UNIOP_t c)
-{
- const UNIOP_t *p;
- for (p = s; *p; p++)
- if (*p == c)
- return (UNIOP_t*)p;
- return NULL;
-}
-
-UNIOP_t*
-UNIOP(strrchr)(const UNIOP_t *s, UNIOP_t c)
-{
- const UNIOP_t *p;
- p = s + UNIOP(strlen)(s);
- while (p != s) {
- p--;
- if (*p == c)
- return (UNIOP_t*)p;
- }
- return NULL;
-}
-