[Python-checkins] cpython: Issue #13772: Mark helper functions as private (static)

victor.stinner python-checkins at python.org
Wed Jun 5 01:59:32 CEST 2013


http://hg.python.org/cpython/rev/d9f3ea27f826
changeset:   84037:d9f3ea27f826
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Jun 05 01:49:17 2013 +0200
summary:
  Issue #13772: Mark helper functions as private (static)

Cleanup also the code to follow the Python coding style (PEP 7).

files:
  Modules/posixmodule.c |  79 ++++++++++++++++--------------
  1 files changed, 43 insertions(+), 36 deletions(-)


diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6720,8 +6720,9 @@
 /* Grab CreateSymbolicLinkW dynamically from kernel32 */
 static DWORD (CALLBACK *Py_CreateSymbolicLinkW)(LPWSTR, LPWSTR, DWORD) = NULL;
 static DWORD (CALLBACK *Py_CreateSymbolicLinkA)(LPSTR, LPSTR, DWORD) = NULL;
+
 static int
-check_CreateSymbolicLink()
+check_CreateSymbolicLink(void)
 {
     HINSTANCE hKernel32;
     /* only recheck */
@@ -6735,55 +6736,57 @@
     return (Py_CreateSymbolicLinkW && Py_CreateSymbolicLinkA);
 }
 
-void _dirnameW(WCHAR *path) {
-    /* Remove the last portion of the path */
-
+/* Remove the last portion of the path */
+static void
+_dirnameW(WCHAR *path)
+{
     WCHAR *ptr;
 
     /* walk the path from the end until a backslash is encountered */
-    for(ptr = path + wcslen(path); ptr != path; ptr--)
-    {
-        if(*ptr == *L"\\" || *ptr == *L"/") {
+    for(ptr = path + wcslen(path); ptr != path; ptr--) {
+        if (*ptr == *L"\\" || *ptr == *L"/")
             break;
-        }
     }
     *ptr = 0;
 }
 
-void _dirnameA(char *path) {
-    /* Remove the last portion of the path */
-
+/* Remove the last portion of the path */
+static void
+_dirnameA(char *path)
+{
     char *ptr;
 
     /* walk the path from the end until a backslash is encountered */
-    for(ptr = path + strlen(path); ptr != path; ptr--)
-    {
-        if(*ptr == '\\' || *ptr == '/') {
+    for(ptr = path + strlen(path); ptr != path; ptr--) {
+        if (*ptr == '\\' || *ptr == '/')
             break;
-        }
     }
     *ptr = 0;
 }
 
-int _is_absW(const WCHAR *path) {
-    /* Is this path absolute? */
-
+/* Is this path absolute? */
+static int
+_is_absW(const WCHAR *path)
+{
     return path[0] == L'\\' || path[0] == L'/' || path[1] == L':';
 
 }
 
-int _is_absA(const char *path) {
-    /* Is this path absolute? */
-
+/* Is this path absolute? */
+static int
+_is_absA(const char *path)
+{
     return path[0] == '\\' || path[0] == '/' || path[1] == ':';
 
 }
 
-void _joinW(WCHAR *dest_path, const WCHAR *root, const WCHAR *rest) {
-    /* join root and rest with a backslash */
+/* join root and rest with a backslash */
+static void
+_joinW(WCHAR *dest_path, const WCHAR *root, const WCHAR *rest)
+{
     size_t root_len;
 
-    if(_is_absW(rest)) {
+    if (_is_absW(rest)) {
         wcscpy(dest_path, rest);
         return;
     }
@@ -6792,17 +6795,19 @@
 
     wcscpy(dest_path, root);
     if(root_len) {
-        dest_path[root_len] = *L"\\";
-        root_len += 1;
+        dest_path[root_len] = L'\\';
+        root_len++;
     }
     wcscpy(dest_path+root_len, rest);
 }
 
-void _joinA(char *dest_path, const char *root, const char *rest) {
-    /* join root and rest with a backslash */
+/* join root and rest with a backslash */
+static void
+_joinA(char *dest_path, const char *root, const char *rest)
+{
     size_t root_len;
 
-    if(_is_absA(rest)) {
+    if (_is_absA(rest)) {
         strcpy(dest_path, rest);
         return;
     }
@@ -6812,14 +6817,15 @@
     strcpy(dest_path, root);
     if(root_len) {
         dest_path[root_len] = '\\';
-        root_len += 1;
+        root_len++;
     }
     strcpy(dest_path+root_len, rest);
 }
 
-int _check_dirW(WCHAR *src, WCHAR *dest)
-{
-    /* Return True if the path at src relative to dest is a directory */
+/* Return True if the path at src relative to dest is a directory */
+static int
+_check_dirW(WCHAR *src, WCHAR *dest)
+{
     WIN32_FILE_ATTRIBUTE_DATA src_info;
     WCHAR dest_parent[MAX_PATH];
     WCHAR src_resolved[MAX_PATH] = L"";
@@ -6835,9 +6841,10 @@
     );
 }
 
-int _check_dirA(char *src, char *dest)
-{
-    /* Return True if the path at src relative to dest is a directory */
+/* Return True if the path at src relative to dest is a directory */
+static int
+_check_dirA(char *src, char *dest)
+{
     WIN32_FILE_ATTRIBUTE_DATA src_info;
     char dest_parent[MAX_PATH];
     char src_resolved[MAX_PATH] = "";

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list