summaryrefslogtreecommitdiff
path: root/xs_io.h
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-10-17 20:32:47 +0200
committerdefault <nobody@localhost>2022-10-17 20:32:47 +0200
commit3d5cf0f069e0f0e6cf47a8ffc2c515b8db795ad0 (patch)
tree31b8eaf486735c2d5305d994ce5497421c6102ae /xs_io.h
parent50faf7a39928768a537c41a5dd34da600335fff3 (diff)
Backport from xs.
Diffstat (limited to 'xs_io.h')
-rw-r--r--xs_io.h30
1 files changed, 11 insertions, 19 deletions
diff --git a/xs_io.h b/xs_io.h
index 1379a34..9649484 100644
--- a/xs_io.h
+++ b/xs_io.h
@@ -4,31 +4,13 @@
#define _XS_IO_H
-d_char *xs_readall(FILE *f);
d_char *xs_readline(FILE *f);
d_char *xs_read(FILE *f, int *size);
+d_char *xs_readall(FILE *f);
#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)
/* reads a line from a file */
{
@@ -93,6 +75,16 @@ d_char *xs_read(FILE *f, int *sz)
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_IO_H */