Explorar o código

Backport from xs.

default %!s(int64=3) %!d(string=hai) anos
pai
achega
3d5cf0f069
Modificáronse 2 ficheiros con 12 adicións e 20 borrados
  1. 11 19
      xs_io.h
  2. 1 1
      xs_version.h

+ 11 - 19
xs_io.h

@@ -4,31 +4,13 @@
 
 
 #define _XS_IO_H
 #define _XS_IO_H
 
 
-d_char *xs_readall(FILE *f);
 d_char *xs_readline(FILE *f);
 d_char *xs_readline(FILE *f);
 d_char *xs_read(FILE *f, int *size);
 d_char *xs_read(FILE *f, int *size);
+d_char *xs_readall(FILE *f);
 
 
 
 
 #ifdef XS_IMPLEMENTATION
 #ifdef XS_IMPLEMENTATION
 
 
-d_char *xs_readall(FILE *f)
-/* reads the rest of the file into a string */
-{
-    d_char *s;
-    char tmp[1024];
-
-    errno = 0;
-
-    /* create the new string */
-    s = xs_str_new(NULL);
-
-    while (fgets(tmp, sizeof(tmp), f))
-        s = xs_str_cat(s, tmp);
-
-    return s;
-}
-
-
 d_char *xs_readline(FILE *f)
 d_char *xs_readline(FILE *f)
 /* reads a line from a file */
 /* reads a line from a file */
 {
 {
@@ -93,6 +75,16 @@ d_char *xs_read(FILE *f, int *sz)
     return s;
     return s;
 }
 }
 
 
+
+d_char *xs_readall(FILE *f)
+/* reads the rest of the file into a string */
+{
+    int size = 0xfffffff;
+
+    return xs_read(f, &size);
+}
+
+
 #endif /* XS_IMPLEMENTATION */
 #endif /* XS_IMPLEMENTATION */
 
 
 #endif /* _XS_IO_H */
 #endif /* _XS_IO_H */

+ 1 - 1
xs_version.h

@@ -1 +1 @@
-/* d1bebf4154dd42f20c981f65325b33eadacfb1d8 */
+/* 2d6bb8fdf48f1c9ccfce76600eb1d729edce7bef */