diff options
author | Thomas White <taw@physics.org> | 2020-07-01 11:02:08 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:44 +0200 |
commit | 9ff36c70a7a27fb6fd86068483a47d9efb606245 (patch) | |
tree | 610b207d1f5e7f5a7486d821911a29cef87022bf /libcrystfel/src/image-hdf5.c | |
parent | a7f04b7da219da2efddaaec826eafa286975aa3d (diff) |
Handle event expansion even for single-event files
Diffstat (limited to 'libcrystfel/src/image-hdf5.c')
-rw-r--r-- | libcrystfel/src/image-hdf5.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c index ccd0bb92..43b20bdf 100644 --- a/libcrystfel/src/image-hdf5.c +++ b/libcrystfel/src/image-hdf5.c @@ -1192,7 +1192,11 @@ static int add_to_list(struct ev_list *list, char *ev_str) static char *demunge_event(const char *orig) { size_t len = strlen(orig); - char *slash = malloc(len+3); + char *slash; + + if ( len == 0 ) return strdup("//"); + + slash = malloc(len+3); if ( slash == NULL ) return NULL; strcpy(slash, orig+1); strcat(slash, "//"); @@ -1490,8 +1494,6 @@ char **image_hdf5_expand_frames(const DataTemplate *dtempl, int *placeholder_sizes; int n_placeholder_dims; int j; - char **evs_this_path; - int n_evs_this_path; struct panel_template *p = &dtempl->panels[0]; path = substitute_path(path_evs[i], p->data); @@ -1545,19 +1547,32 @@ char **image_hdf5_expand_frames(const DataTemplate *dtempl, /* Path event ID ends with //, but expand_dims will * add a slash. So, remove one slash */ - path_evs[i][strlen(path_evs[i])-1] = '\0'; - evs_this_path = expand_dims(placeholder_sizes, - n_placeholder_dims, - path_evs[i], - &n_evs_this_path); - - for ( j=0; j<n_evs_this_path; j++ ) { - add_to_list(&full_evs, evs_this_path[j]); - free(evs_this_path[j]); + if ( n_placeholder_dims > 0 ) { + + char **evs_this_path; + int n_evs_this_path; + + path_evs[i][strlen(path_evs[i])-1] = '\0'; + evs_this_path = expand_dims(placeholder_sizes, + n_placeholder_dims, + path_evs[i], + &n_evs_this_path); + + for ( j=0; j<n_evs_this_path; j++ ) { + add_to_list(&full_evs, evs_this_path[j]); + free(evs_this_path[j]); + } + + free(evs_this_path); + + } else { + + /* Easy case with no dims to expand */ + add_to_list(&full_evs, path_evs[i]); + } free(placeholder_sizes); - free(evs_this_path); free(path); free(path_evs[i]); |