Move C standard library pxd files to libc package
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Wed, 10 Mar 2010 08:07:07 +0000 (09:07 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Wed, 10 Mar 2010 08:07:07 +0000 (09:07 +0100)
--HG--
rename : Cython/Includes/stdio.pxd => Cython/Includes/libc/stdio.pxd
rename : Cython/Includes/stdlib.pxd => Cython/Includes/libc/stdlib.pxd

Cython/Includes/libc/__init__.pyx [new file with mode: 0644]
Cython/Includes/libc/stdio.pxd [new file with mode: 0644]
Cython/Includes/libc/stdlib.pxd [new file with mode: 0644]
Cython/Includes/stdio.pxd
Cython/Includes/stdlib.pxd
tests/run/libc_stdlib.pyx [new file with mode: 0644]

diff --git a/Cython/Includes/libc/__init__.pyx b/Cython/Includes/libc/__init__.pyx
new file mode 100644 (file)
index 0000000..fa81ada
--- /dev/null
@@ -0,0 +1 @@
+# empty file
diff --git a/Cython/Includes/libc/stdio.pxd b/Cython/Includes/libc/stdio.pxd
new file mode 100644 (file)
index 0000000..cc57410
--- /dev/null
@@ -0,0 +1,9 @@
+cdef extern from "stdio.h" nogil:
+    ctypedef struct FILE
+    int printf(char *format, ...)
+    int fprintf(FILE *stream, char *format, ...)
+    int sprintf(char *str, char *format, ...)
+    FILE *fopen(char *path, char *mode)
+    int fclose(FILE *strea)
+    cdef FILE *stdout
+    int scanf(char *format, ...)
diff --git a/Cython/Includes/libc/stdlib.pxd b/Cython/Includes/libc/stdlib.pxd
new file mode 100644 (file)
index 0000000..40192d1
--- /dev/null
@@ -0,0 +1,7 @@
+
+cdef extern from "stdlib.h" nogil:
+    void free(void *ptr)
+    void *malloc(size_t size)
+    void *realloc(void *ptr, size_t size)
+    size_t strlen(char *s)
+    char *strcpy(char *dest, char *src)
index cc574105f40fbacd47824afe947a6e6adfa4563a..f4af328d8f7dc90ac06d6b1841af82a5b8f5d744 100644 (file)
@@ -1,9 +1,2 @@
-cdef extern from "stdio.h" nogil:
-    ctypedef struct FILE
-    int printf(char *format, ...)
-    int fprintf(FILE *stream, char *format, ...)
-    int sprintf(char *str, char *format, ...)
-    FILE *fopen(char *path, char *mode)
-    int fclose(FILE *strea)
-    cdef FILE *stdout
-    int scanf(char *format, ...)
+# Present for backwards compatability
+from libc.stdio cimport *
index 40192d1352a7f26341ca7cd08aee0c77fb1f3834..0d2ce8eb3565e5c2ce20a85ad02a78be978a9bc6 100644 (file)
@@ -1,7 +1,2 @@
-
-cdef extern from "stdlib.h" nogil:
-    void free(void *ptr)
-    void *malloc(size_t size)
-    void *realloc(void *ptr, size_t size)
-    size_t strlen(char *s)
-    char *strcpy(char *dest, char *src)
+# Present for backwards compatability
+from libc.stdlib cimport *
diff --git a/tests/run/libc_stdlib.pyx b/tests/run/libc_stdlib.pyx
new file mode 100644 (file)
index 0000000..ee88ac8
--- /dev/null
@@ -0,0 +1,11 @@
+"""
+>>> f()
+'hello'
+"""
+
+from libc.stdio cimport sprintf
+
+def f():
+    cdef char buf[10]
+    sprintf(buf, b'hello')
+    return str((<object>buf).decode('ASCII'))