diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index e4d977bafbc04fa2bfedfc2912fc87bed9de8e1e..71f3b3b8741e505fc652e6c74c75972f19211f71 100644 (file)
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
*/
#include "cache.h"
#include "builtin.h"
*/
#include "cache.h"
#include "builtin.h"
-#include "path-list.h"
+#include "string-list.h"
static const char git_mailsplit_usage[] =
static const char git_mailsplit_usage[] =
-"git-mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> <mbox>|<Maildir>...";
+"git mailsplit [-d<prec>] [-f<n>] [-b] -o<directory> [<mbox>|<Maildir>...]";
static int is_from_line(const char *line, int len)
{
static int is_from_line(const char *line, int len)
{
for (;;) {
c = getc(in);
for (;;) {
c = getc(in);
+ if (c == EOF)
+ break;
buf[len++] = c;
buf[len++] = c;
- if (c == EOF || c == '\n' || len + 1 >= size)
+ if (c == '\n' || len + 1 >= size)
break;
}
break;
}
-
- if (c == EOF)
- len--;
buf[len] = '\0';
return len;
buf[len] = '\0';
return len;
exit(1);
}
exit(1);
}
-static int populate_maildir_list(struct path_list *list, const char *path)
+static int populate_maildir_list(struct string_list *list, const char *path)
{
DIR *dir;
struct dirent *dent;
{
DIR *dir;
struct dirent *dent;
if (dent->d_name[0] == '.')
continue;
snprintf(name, sizeof(name), "%s/%s", *sub, dent->d_name);
if (dent->d_name[0] == '.')
continue;
snprintf(name, sizeof(name), "%s/%s", *sub, dent->d_name);
- path_list_insert(name, list);
+ string_list_insert(name, list);
}
closedir(dir);
}
closedir(dir);
char name[PATH_MAX];
int ret = -1;
int i;
char name[PATH_MAX];
int ret = -1;
int i;
- struct path_list list = {NULL, 0, 0, 1};
+ struct string_list list = {NULL, 0, 0, 1};
if (populate_maildir_list(&list, maildir) < 0)
goto out;
for (i = 0; i < list.nr; i++) {
FILE *f;
if (populate_maildir_list(&list, maildir) < 0)
goto out;
for (i = 0; i < list.nr; i++) {
FILE *f;
- snprintf(file, sizeof(file), "%s/%s", maildir, list.items[i].path);
+ snprintf(file, sizeof(file), "%s/%s", maildir, list.items[i].string);
f = fopen(file, "r");
if (!f) {
error("cannot open mail %s (%s)", file, strerror(errno));
f = fopen(file, "r");
if (!f) {
error("cannot open mail %s (%s)", file, strerror(errno));
ret = skip;
out:
ret = skip;
out:
- path_list_clear(&list, 1);
+ string_list_clear(&list, 1);
return ret;
}
return ret;
}