summaryrefslogtreecommitdiffstats
path: root/Modules/syslogmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2011-09-28 05:41:54 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2011-09-28 05:41:54 (GMT)
commitd63a3b8beb4a0841cb59fb3515347ccaab34b733 (patch)
tree3b4e3cc63151c5a5a910c3550a190aefaea96ad4 /Modules/syslogmodule.c
parent48d49497c50e79d14e9df9527d766ca3a0a38be5 (diff)
downloadcpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.zip
cpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.tar.gz
cpython-d63a3b8beb4a0841cb59fb3515347ccaab34b733.tar.bz2
Implement PEP 393.
Diffstat (limited to 'Modules/syslogmodule.c')
-rw-r--r--Modules/syslogmodule.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index 5b86963..f6dadf4 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -70,7 +70,7 @@ syslog_get_argv(void)
Py_ssize_t argv_len, scriptlen;
PyObject *scriptobj;
- Py_UNICODE *atslash, *atstart;
+ Py_ssize_t slash;
PyObject *argv = PySys_GetObject("argv");
if (argv == NULL) {
@@ -95,11 +95,13 @@ syslog_get_argv(void)
return(NULL);
}
- atstart = PyUnicode_AS_UNICODE(scriptobj);
- atslash = Py_UNICODE_strrchr(atstart, SEP);
- if (atslash) {
- return(PyUnicode_FromUnicode(atslash + 1,
- scriptlen - (atslash - atstart) - 1));
+ slash = PyUnicode_FindChar(scriptobj, SEP,
+ 0, PyUnicode_GET_LENGTH(scriptobj), -1);
+ if (slash == -2)
+ return NULL;
+ if (slash != -1) {
+ return PyUnicode_Substring(scriptobj, slash,
+ PyUnicode_GET_LENGTH(scriptobj));
} else {
Py_INCREF(scriptobj);
return(scriptobj);