aboutsummaryrefslogtreecommitdiff
path: root/src/partialator.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2015-08-31 13:44:05 +0200
committerThomas White <taw@physics.org>2015-08-31 13:44:05 +0200
commit63a06127735849268fb6e1e6495c7537e8be5a0d (patch)
tree7ef5f1b790efb260410842c3b121a01155ae6224 /src/partialator.c
parent9b9fa1f6d8d3155357f03db0670fae01e45d4339 (diff)
partialator: Fix handling of multi-event files in --custom-split
Diffstat (limited to 'src/partialator.c')
-rw-r--r--src/partialator.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/partialator.c b/src/partialator.c
index 591478af..2e3c3477 100644
--- a/src/partialator.c
+++ b/src/partialator.c
@@ -343,37 +343,45 @@ static struct custom_split *load_custom_split(const char *filename)
char *rval;
char line[1024];
- int i;
char *fn;
- struct event *ev;
char *evs;
+ char *ds;
char *id;
+ int n;
+ char **bits;
rval = fgets(line, 1023, fh);
if ( rval == NULL ) break;
chomp(line);
notrail(line);
-
- for ( i=strlen(line); i>0; i-- ) {
- if ( (line[i] == ' ') || (line[i]=='\t') ) break;
- }
- if ( i == 0 ) {
+ n = assplode(line, " \t,", &bits, ASSPLODE_NONE);
+ if ( n < 2 ) {
ERROR("Badly formatted line '%s'\n", line);
return NULL;
}
- i++;
- fn = strndup(line, i);
- ev = get_event_from_event_string(line);
- evs = get_event_string(ev);
- notrail(fn);
+ if ( n == 3 ) {
+ /* Filename, event, dataset */
+ fn = bits[0];
+ evs = bits[1];
+ ds = bits[2];
+ } else {
+ fn = bits[0];
+ evs = get_event_string(NULL);
+ ds = bits[1];
+ }
+ free(bits);
+
id = malloc(strlen(fn) + strlen(evs) + 2);
strcpy(id, fn);
strcat(id, " ");
strcat(id, evs);
- add_to_csplit(csplit, id, line+i);
+ add_to_csplit(csplit, id, ds);
free(id);
+ free(fn);
+ free(evs);
+ free(ds);
} while ( 1 );