Commit e920f0d3 authored by Martin v. Löwis's avatar Martin v. Löwis

Reformulate 42903 using an if statement.

parent df44ab7b
...@@ -1640,7 +1640,7 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -1640,7 +1640,7 @@ posix_listdir(PyObject *self, PyObject *args)
PyObject *d, *v; PyObject *d, *v;
HANDLE hFindFile; HANDLE hFindFile;
BOOL result = FALSE; BOOL result;
WIN32_FIND_DATA FileData; WIN32_FIND_DATA FileData;
/* MAX_PATH characters could mean a bigger encoded string */ /* MAX_PATH characters could mean a bigger encoded string */
char namebuf[MAX_PATH*2+5]; char namebuf[MAX_PATH*2+5];
...@@ -1675,11 +1675,9 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -1675,11 +1675,9 @@ posix_listdir(PyObject *self, PyObject *args)
return win32_error_unicode("FindFirstFileW", wnamebuf); return win32_error_unicode("FindFirstFileW", wnamebuf);
} }
do { do {
if (wFileData.cFileName[0] == L'.' && /* Skip over . and .. */
(wFileData.cFileName[1] == L'\0' || if (wcscmp(wFileData.cFileName, L".") != 0 &&
wFileData.cFileName[1] == L'.' && wcscmp(wFileData.cFileName, L"..") != 0) {
wFileData.cFileName[2] == L'\0'))
goto loop_w;
v = PyUnicode_FromUnicode(wFileData.cFileName, wcslen(wFileData.cFileName)); v = PyUnicode_FromUnicode(wFileData.cFileName, wcslen(wFileData.cFileName));
if (v == NULL) { if (v == NULL) {
Py_DECREF(d); Py_DECREF(d);
...@@ -1693,7 +1691,7 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -1693,7 +1691,7 @@ posix_listdir(PyObject *self, PyObject *args)
break; break;
} }
Py_DECREF(v); Py_DECREF(v);
loop_w: }
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
result = FindNextFileW(hFindFile, &wFileData); result = FindNextFileW(hFindFile, &wFileData);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
...@@ -1733,11 +1731,9 @@ loop_w: ...@@ -1733,11 +1731,9 @@ loop_w:
return win32_error("FindFirstFile", namebuf); return win32_error("FindFirstFile", namebuf);
} }
do { do {
if (FileData.cFileName[0] == '.' && /* Skip over . and .. */
(FileData.cFileName[1] == '\0' || if (strcmp(FileData.cFileName, ".") != 0 &&
FileData.cFileName[1] == '.' && strcmp(FileData.cFileName, "..") != 0) {
FileData.cFileName[2] == '\0'))
goto loop_a;
v = PyString_FromString(FileData.cFileName); v = PyString_FromString(FileData.cFileName);
if (v == NULL) { if (v == NULL) {
Py_DECREF(d); Py_DECREF(d);
...@@ -1751,7 +1747,7 @@ loop_w: ...@@ -1751,7 +1747,7 @@ loop_w:
break; break;
} }
Py_DECREF(v); Py_DECREF(v);
loop_a: }
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
result = FindNextFile(hFindFile, &FileData); result = FindNextFile(hFindFile, &FileData);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment