Before this turns into an unreadable mess, follow PEP 7 by using

hard tab indents in C code.
This commit is contained in:
Tim Peters 2004-10-12 21:38:22 +00:00
parent 25b38c8969
commit f3250b0b0b

View file

@ -147,8 +147,8 @@ static PyObject *
sp_GetStdHandle(PyObject* self, PyObject* args)
{
HANDLE handle;
int std_handle;
if (! PyArg_ParseTuple(args, "i:GetStdHandle", &std_handle))
return NULL;
@ -189,17 +189,25 @@ sp_DuplicateHandle(PyObject* self, PyObject* args)
int desired_access;
int inherit_handle;
int options = 0;
if (! PyArg_ParseTuple(args, "lllii|i:DuplicateHandle",
&source_process_handle, &source_handle,
&source_process_handle,
&source_handle,
&target_process_handle,
&desired_access, &inherit_handle, &options))
&desired_access,
&inherit_handle,
&options))
return NULL;
Py_BEGIN_ALLOW_THREADS
result = DuplicateHandle(
(HANDLE) source_process_handle, (HANDLE) source_handle,
(HANDLE) target_process_handle, &target_handle, desired_access,
inherit_handle, options
(HANDLE) source_process_handle,
(HANDLE) source_handle,
(HANDLE) target_process_handle,
&target_handle,
desired_access,
inherit_handle,
options
);
Py_END_ALLOW_THREADS
@ -218,6 +226,7 @@ sp_CreatePipe(PyObject* self, PyObject* args)
PyObject* pipe_attributes; /* ignored */
int size;
if (! PyArg_ParseTuple(args, "Oi:CreatePipe", &pipe_attributes, &size))
return NULL;
@ -229,8 +238,7 @@ sp_CreatePipe(PyObject* self, PyObject* args)
return PyErr_SetFromWindowsErr(GetLastError());
return Py_BuildValue(
"NN", sp_handle_new(read_pipe), sp_handle_new(write_pipe)
);
"NN", sp_handle_new(read_pipe), sp_handle_new(write_pipe));
}
/* helpers for createprocess */
@ -239,6 +247,7 @@ static int
getint(PyObject* obj, char* name)
{
PyObject* value;
value = PyObject_GetAttrString(obj, name);
if (! value) {
PyErr_Clear(); /* FIXME: propagate error? */
@ -251,6 +260,7 @@ static HANDLE
gethandle(PyObject* obj, char* name)
{
sp_handle_object* value;
value = (sp_handle_object*) PyObject_GetAttrString(obj, name);
if (! value) {
PyErr_Clear(); /* FIXME: propagate error? */
@ -271,11 +281,9 @@ getenvironment(PyObject* environment)
char* p;
/* convert environment dictionary to windows enviroment string */
if (! PyMapping_Check(environment)) {
PyErr_SetString(
PyExc_TypeError, "environment must be dictionary or None"
);
PyExc_TypeError, "environment must be dictionary or None");
return NULL;
}
@ -296,27 +304,31 @@ getenvironment(PyObject* environment)
int ksize, vsize, totalsize;
PyObject* key = PyList_GET_ITEM(keys, i);
PyObject* value = PyList_GET_ITEM(values, i);
if (! PyString_Check(key) || ! PyString_Check(value)) {
PyErr_SetString(
PyExc_TypeError, "environment can only contain strings"
);
PyErr_SetString(PyExc_TypeError,
"environment can only contain strings");
goto error;
}
ksize = PyString_GET_SIZE(key);
vsize = PyString_GET_SIZE(value);
totalsize = (p - PyString_AS_STRING(out)) + ksize + 1 + vsize + 1 + 1;
totalsize = (p - PyString_AS_STRING(out)) + ksize + 1 +
vsize + 1 + 1;
if (totalsize > PyString_GET_SIZE(out)) {
int offset = p - PyString_AS_STRING(out);
_PyString_Resize(&out, totalsize + 1024);
p = PyString_AS_STRING(out) + offset;
}
memcpy(p, PyString_AS_STRING(key), ksize); p += ksize; *p++ = '=';
memcpy(p, PyString_AS_STRING(value), vsize); p += vsize; *p++ = '\0';
memcpy(p, PyString_AS_STRING(key), ksize);
p += ksize;
*p++ = '=';
memcpy(p, PyString_AS_STRING(value), vsize);
p += vsize;
*p++ = '\0';
}
/* add trailing null byte */
*p++ = '\0';
_PyString_Resize(&out, p - PyString_AS_STRING(out));
/* PyObject_Print(out, stdout, 0); */
@ -347,11 +359,17 @@ sp_CreateProcess(PyObject* self, PyObject* args)
PyObject* env_mapping;
char* current_directory;
PyObject* startup_info;
if (! PyArg_ParseTuple(args, "zzOOiiOzO:CreateProcess",
&application_name, &command_line,
&process_attributes, &thread_attributes,
&inherit_handles, &creation_flags,
&env_mapping, &current_directory, &startup_info))
&application_name,
&command_line,
&process_attributes,
&thread_attributes,
&inherit_handles,
&creation_flags,
&env_mapping,
&current_directory,
&startup_info))
return NULL;
ZeroMemory(&si, sizeof(si));
@ -372,11 +390,16 @@ sp_CreateProcess(PyObject* self, PyObject* args)
}
Py_BEGIN_ALLOW_THREADS
result = CreateProcess(
application_name, command_line, NULL, NULL, inherit_handles,
creation_flags, environment ? PyString_AS_STRING(environment) : NULL,
current_directory, &si, &pi
);
result = CreateProcess(application_name,
command_line,
NULL,
NULL,
inherit_handles,
creation_flags,
environment ? PyString_AS_STRING(environment) : NULL,
current_directory,
&si,
&pi);
Py_END_ALLOW_THREADS
Py_XDECREF(environment);
@ -384,10 +407,11 @@ sp_CreateProcess(PyObject* self, PyObject* args)
if (! result)
return PyErr_SetFromWindowsErr(GetLastError());
return Py_BuildValue(
"NNii", sp_handle_new(pi.hProcess), sp_handle_new(pi.hThread),
pi.dwProcessId, pi.dwThreadId
);
return Py_BuildValue("NNii",
sp_handle_new(pi.hProcess),
sp_handle_new(pi.hThread),
pi.dwProcessId,
pi.dwThreadId);
}
static PyObject *
@ -416,7 +440,8 @@ sp_WaitForSingleObject(PyObject* self, PyObject* args)
long handle;
int milliseconds;
if (! PyArg_ParseTuple(args, "li:WaitForSingleObject",
&handle, &milliseconds))
&handle,
&milliseconds))
return NULL;
Py_BEGIN_ALLOW_THREADS