summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-05-29 11:45:58 +0200
committerBert <ber.t@gmx.com>2011-05-29 11:45:58 +0200
commitea23115af449e086ba05c9757ad22108944f6ec2 (patch)
treec52e943902632792f24f17c9681cacd2b6a04f01 /util.c
parent2252a0148d11fc988131eb0bf6397453427d67e8 (diff)
downloadnsxiv-ea23115af449e086ba05c9757ad22108944f6ec2.tar.zst
Use getline instead of readline
Diffstat (limited to 'util.c')
-rw-r--r--util.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/util.c b/util.c
index e16de94..3957629 100644
--- a/util.c
+++ b/util.c
@@ -140,7 +140,7 @@ char* absolute_path(const char *filename) {
path = (char*) s_malloc(len);
snprintf(path, len, "%s/%s", dir, basename);
-goto end;
+ goto end;
error:
if (path) {
@@ -297,39 +297,3 @@ int r_mkdir(const char *path) {
return err;
}
-
-char* readline(FILE *stream) {
- size_t len;
- char *buf, *s, *end;
-
- if (!stream || feof(stream) || ferror(stream))
- return NULL;
-
- len = FNAME_LEN;
- s = buf = (char*) s_malloc(len * sizeof(char));
-
- do {
- *s = '\0';
- fgets(s, len - (s - buf), stream);
- if ((end = strchr(s, '\n'))) {
- *end = '\0';
- } else if (strlen(s) + 1 == len - (s - buf)) {
- buf = (char*) s_realloc(buf, 2 * len * sizeof(char));
- s = buf + len - 1;
- len *= 2;
- } else {
- s += strlen(s);
- }
- } while (!end && !feof(stream) && !ferror(stream));
-
- if (ferror(stream)) {
- s = NULL;
- } else {
- s = (char*) s_malloc((strlen(buf) + 1) * sizeof(char));
- strcpy(s, buf);
- }
-
- free(buf);
-
- return s;
-}