diff options
author | Thomas White <taw@physics.org> | 2020-02-04 10:28:16 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-02-04 10:28:16 +0100 |
commit | a9c214f7172a0b8c013ec9ad09a6f107f2d516b4 (patch) | |
tree | a1d8be0e6ae5dde4e140d7bfa4c92bb1d6c3a805 /libcrystfel | |
parent | dd0a1518e481eed9a516278efc4e497d87aa3749 (diff) |
Handle CRLF line terminators in geometry files
This was broken by d62367db8fee57, which was some enabling work for
reading geometry info from streams.
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/detector.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index cefad709..629e13f0 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -1189,7 +1189,7 @@ struct detector *get_detector_geometry(const char *filename, } -struct detector *get_detector_geometry_from_string(const char *string, +struct detector *get_detector_geometry_from_string(const char *string_in, struct beam_params *beam, char **hdf5_peak_path) { @@ -1207,6 +1207,9 @@ struct detector *get_detector_geometry_from_string(const char *string, struct rgc_definition **rgc_defl = NULL; int n_rg_definitions = 0; int n_rgc_definitions = 0; + char *string; + char *string_orig; + size_t len; det = calloc(1, sizeof(struct detector)); if ( det == NULL ) return NULL; @@ -1264,6 +1267,16 @@ struct detector *get_detector_geometry_from_string(const char *string, det->defaults.dim_structure = NULL; strncpy(det->defaults.name, "", 1023); + string = strdup(string_in); + if ( string == NULL ) return NULL; + len = strlen(string); + for ( i=0; i<len; i++ ) { + if ( string_in[i] == '\r' ) string[i] = '\n'; + } + + /* Because 'string' will get modified */ + string_orig = string; + do { int n1, n2; @@ -1718,6 +1731,7 @@ struct detector *get_detector_geometry_from_string(const char *string, } find_min_max_d(det); + free(string_orig); if ( reject ) return NULL; |