[pypy-svn] r16685 - in pypy/release/0.7.x/pypy: doc translator/c/src

arigo at codespeak.net arigo at codespeak.net
Fri Aug 26 20:39:23 CEST 2005


Author: arigo
Date: Fri Aug 26 20:39:20 2005
New Revision: 16685

Modified:
   pypy/release/0.7.x/pypy/doc/translation.txt
   pypy/release/0.7.x/pypy/translator/c/src/ll_os.h
Log:
Simplified c/src/ll_os.h, which was more or less the first function written in
this style.  Later we decided to always have zero-terminated strings.



Modified: pypy/release/0.7.x/pypy/doc/translation.txt
==============================================================================
--- pypy/release/0.7.x/pypy/doc/translation.txt	(original)
+++ pypy/release/0.7.x/pypy/doc/translation.txt	Fri Aug 26 20:39:20 2005
@@ -1328,20 +1328,10 @@
 
     int LL_os_open(RPyString *filename, int flag, int mode)
     {
-            char buf[PATH_MAX];
-            int fd, namelen = RPyString_Size(filename);
-            if (namelen >= PATH_MAX) {
-                    RPYTHON_RAISE_OSERROR(ENAMETOOLONG);
-                    return -1;
-            }
-            else {
-                    memcpy(buf, RPyString_AsString(filename), namelen);
-                    buf[namelen] = 0;
-                    fd = open(buf, flag, mode);
-                    if (fd < 0)
-                            RPYTHON_RAISE_OSERROR(errno);
-                    return fd;
-            }
+            int fd = open(RPyString_AsString(filename), flag, mode);
+            if (fd < 0)
+                    RPYTHON_RAISE_OSERROR(errno);
+            return fd;
     }
 
 One test for all this can be found in

Modified: pypy/release/0.7.x/pypy/translator/c/src/ll_os.h
==============================================================================
--- pypy/release/0.7.x/pypy/translator/c/src/ll_os.h	(original)
+++ pypy/release/0.7.x/pypy/translator/c/src/ll_os.h	Fri Aug 26 20:39:20 2005
@@ -39,20 +39,10 @@
 int LL_os_open(RPyString *filename, int flag, int mode)
 {
 	/* XXX unicode_file_names */
-	char buf[PATH_MAX];
-	int fd, namelen = RPyString_Size(filename);
-	if (namelen >= PATH_MAX) {
-		RPYTHON_RAISE_OSERROR(ENAMETOOLONG);
-		return -1;
-	}
-	else {
-		memcpy(buf, RPyString_AsString(filename), namelen);
-		buf[namelen] = 0;
-		fd = open(buf, flag, mode);
-		if (fd < 0)
-			RPYTHON_RAISE_OSERROR(errno);
-		return fd;
-	}
+	int fd = open(RPyString_AsString(filename), flag, mode);
+	if (fd < 0)
+		RPYTHON_RAISE_OSERROR(errno);
+	return fd;
 }
 
 long LL_read_into(int fd, RPyString *buffer)



More information about the Pypy-commit mailing list