diff options
author | Thomas White <taw@physics.org> | 2018-11-14 13:58:35 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2018-11-14 13:58:35 +0100 |
commit | dabbe320ff1d54d8ad24954b1e391f1b58ec0866 (patch) | |
tree | a0a929e868d12c5b31f41fec0087ae496e92d1d7 /libcrystfel/src/detector.c | |
parent | 565948413b9732ded2f6628704f47cb881da8e48 (diff) |
Clean up set_dim_structure_entry() and parsing of "dimX" in geometry file
Fixes CRYS-212
Diffstat (limited to 'libcrystfel/src/detector.c')
-rw-r--r-- | libcrystfel/src/detector.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index d4d8b768..b44f2d43 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -956,10 +956,25 @@ static int parse_field_for_panel(struct panel *panel, const char *key, reject = 1; } } else if ( strncmp(key, "dim", 3) == 0) { - if ( panel->dim_structure == NULL ) { - panel->dim_structure = initialize_dim_structure(); + int dim_entry; + char *endptr; + if ( key[3] != '\0' ) { + if ( panel->dim_structure == NULL ) { + panel->dim_structure = initialize_dim_structure(); + } + dim_entry = strtoul(key+3, &endptr, 10); + if ( endptr[0] != '\0' ) { + ERROR("Invalid dimension number %s\n", key+3); + } else { + if ( set_dim_structure_entry(panel->dim_structure, + dim_entry, val) ) + { + ERROR("Failed to set dim structure entry\n"); + } + } + } else { + ERROR("'dim' must be followed by a number, e.g. 'dim0'\n"); } - set_dim_structure_entry(panel->dim_structure, key, val); } else { ERROR("Unrecognised field '%s'\n", key); } |