From 63a06127735849268fb6e1e6495c7537e8be5a0d Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 31 Aug 2015 13:44:05 +0200 Subject: partialator: Fix handling of multi-event files in --custom-split --- src/partialator.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'src/partialator.c') 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 ); -- cgit v1.2.3