summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-05 20:42:42 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-05 20:42:42 -0300
commitcb7002960e47960468153249c5d4d6c7a2886981 (patch)
treee24680783232404d3d5cfca277724cc1d5330208
parentea7eb29f627726e12419a4b503a65d8140f4b729 (diff)
downloadeeshow-cb7002960e47960468153249c5d4d6c7a2886981.tar.gz
eeshow-cb7002960e47960468153249c5d4d6c7a2886981.tar.bz2
eeshow-cb7002960e47960468153249c5d4d6c7a2886981.zip
eeshow/ (file_read, vcs_git_read): now pass 0 return from parse()
-rw-r--r--file.c11
-rw-r--r--file.h2
-rw-r--r--git-file.c11
-rw-r--r--git-file.h2
4 files changed, 12 insertions, 14 deletions
diff --git a/file.c b/file.c
index 386149a..2d6aa17 100644
--- a/file.c
+++ b/file.c
@@ -178,25 +178,24 @@ void file_open(struct file *file, const char *name, const struct file *related)
}
-void file_read(struct file *file,
+bool file_read(struct file *file,
bool (*parse)(const struct file *file, void *user, const char *line),
void *user)
{
char buf[1000];
char *nl;
- if (file->vcs) {
- vcs_read(file->vcs, file, parse, user);
- return;
- }
+ if (file->vcs)
+ return vcs_read(file->vcs, file, parse, user);
while (fgets(buf, sizeof(buf), file->file)) {
nl = strchr(buf, '\n');
if (nl)
*nl = 0;
file->lineno++;
if (!parse(file, user, buf))
- break;
+ return 0;
}
+ return 1;
}
diff --git a/file.h b/file.h
index ff28d92..b77e99c 100644
--- a/file.h
+++ b/file.h
@@ -32,7 +32,7 @@ char *file_graft_relative(const char *base, const char *name);
void file_open(struct file *file, const char *name,
const struct file *related);
-void file_read(struct file *file,
+bool file_read(struct file *file,
bool (*parse)(const struct file *file, void *user, const char *line),
void *user);
void file_close(struct file *file);
diff --git a/git-file.c b/git-file.c
index 21810c0..1828d84 100644
--- a/git-file.c
+++ b/git-file.c
@@ -455,7 +455,7 @@ struct vcs_git *vcs_git_open(const char *revision, const char *name,
}
-void vcs_git_read(void *ctx, struct file *file,
+bool vcs_git_read(void *ctx, struct file *file,
bool (*parse)(const struct file *file, void *user, const char *line),
void *user)
{
@@ -467,14 +467,13 @@ void vcs_git_read(void *ctx, struct file *file,
while (p != end) {
nl = memchr(p, '\n', end - p);
file->lineno++;
- if (!nl) {
- send_line(p, end - p, parse, user, file);
- return;
- }
+ if (!nl)
+ return send_line(p, end - p, parse, user, file);
if (!send_line(p, nl - p, parse, user, file))
- return;
+ return 0;
p = nl + 1;
}
+ return 1;
}
diff --git a/git-file.h b/git-file.h
index 7d1b637..220b9fc 100644
--- a/git-file.h
+++ b/git-file.h
@@ -33,7 +33,7 @@ void vcs_git_init(void);
struct vcs_git *vcs_git_open(const char *revision, const char *name,
const struct vcs_git *related);
-void vcs_git_read(void *ctx, struct file *file,
+bool vcs_git_read(void *ctx, struct file *file,
bool (*parse)(const struct file *file, void *user, const char *line),
void *user);
void vcs_git_close(void *ctx);