diff options
author | Thomas White <taw@physics.org> | 2020-07-01 16:34:59 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:44 +0200 |
commit | 6e1a971e9d0ed372a2c6066d84b90f4a61ee88b5 (patch) | |
tree | 7e5509a755dd593b22331a4a70905ccea3585815 /libcrystfel | |
parent | efe55592b5579be2d57823f84a610c431e386b07 (diff) |
Factorise num_path_placeholders
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/image-hdf5.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c index 767ef6ab..3e2b17fb 100644 --- a/libcrystfel/src/image-hdf5.c +++ b/libcrystfel/src/image-hdf5.c @@ -204,6 +204,19 @@ int *read_dim_parts(const char *ev_orig, int *pn_dvals) } +static int num_path_placeholders(const char *pattern) +{ + size_t l, i; + int n_pl_exp = 0; + + l = strlen(pattern); + for ( i=0; i<l; i++ ) { + if ( pattern[i] == '%' ) n_pl_exp++; + } + return n_pl_exp; +} + + /* ev = abc/def/ghi//5/2/7 * pattern = /data/%/somewhere/%/%/data * output = /data/abc/somewhere/def/ghi/data @@ -215,7 +228,7 @@ char *substitute_path(const char *ev, const char *pattern) char **plvals; int n_plvals; int n_pl_exp; - size_t l, total_len; + size_t total_len; int i; char *subs; const char *start; @@ -229,11 +242,7 @@ char *substitute_path(const char *ev, const char *pattern) plvals = read_path_parts(ev, &n_plvals); if ( plvals == NULL ) return NULL; - l = strlen(pattern); - n_pl_exp = 0; - for ( i=0; i<l; i++ ) { - if ( pattern[i] == '%' ) n_pl_exp++; - } + n_pl_exp = num_path_placeholders(pattern); if ( n_plvals != n_pl_exp ) { ERROR("Wrong number of path placeholders: " |