{ NULL, 0 }
};
+char *version=VERSION;
+
static enum { NEW, FNEXT, FPREV, UNSEEN } run_mode = NEW;
/*
int j, k;
char *cp, **ap;
- field = getcpy(field);
+ field = mh_xstrdup(field);
/* copied from seq_read.c:seq_init */
for (ap = brkstring(field, " ", "\n"); *ap; ap++) {
}
}
- free(field);
+ mh_free0(&field);
return total;
}
get_msgnums(char *folder, char *sequences[])
{
enum state state;
- struct field f = free_field;
+ struct field f = {{0}};
char *seqfile = concat(toabsdir(folder), "/", mh_seq, (void *)NULL);
FILE *fp = fopen(seqfile, "r");
char *msgnums = NULL, *this_msgnums, *old_msgnums;
for (state = FLD2;;) {
switch (state = m_getfld2(state, &f, fp)) {
+ case LENERR2:
+ state = FLD2;
+ /* FALL */
+
case FLD2:
/*
** if it's in a sequence we want,
*/
if (seq_in_list(f.name, sequences)) {
this_msgnums = trimcpy(f.value);
- if (msgnums == NULL) {
+ if (strlen(this_msgnums) == 0) {
+ free(this_msgnums);
+ continue;
+ } else if (msgnums == NULL) {
msgnums = this_msgnums;
} else {
old_msgnums = msgnums;
msgnums = concat(old_msgnums, " ",
this_msgnums,
- (void *)NULL);
- free(old_msgnums);
- free(this_msgnums);
+ NULL);
+ mh_free0(&old_msgnums);
+ mh_free0(&this_msgnums);
}
}
continue;
if (is_cur || msgnums != NULL) {
if (*b->first == NULL) {
- *b->first = b->node = mh_xmalloc(sizeof(*b->node));
+ *b->first = b->node = mh_xcalloc(1, sizeof(*b->node));
} else {
- b->node->n_next = mh_xmalloc(sizeof(*b->node));
+ b->node->n_next = mh_xcalloc(1, sizeof(*b->node));
b->node = b->node->n_next;
}
b->node->n_name = folder;
while (vfgets(fp, &line) == OK) {
len = strlen(line) - 1;
line[len] = '\0';
- check_folder(getcpy(line), len, &b);
+ check_folder(mh_xstrdup(line), len, &b);
}
fclose(fp);
}
for (i = 0; sequences[i] != NULL; i++) {
len += strlen(sequences[i]) + 1;
}
- result = mh_xmalloc(len + 1);
+ result = mh_xcalloc(len + 1, sizeof(char));
for (i = 0, cp = result; sequences[i] != NULL; i++, cp += len + 1) {
len = strlen(sequences[i]);
} else {
unseen = seq_unseen; /* use default */
}
- dp = getcpy(unseen);
+ dp = mh_xstrdup(unseen);
for (ap = brkstring(dp, " ", "\n"); *ap; ap++) {
sequences[i++] = *ap;
}