From a9c214f7172a0b8c013ec9ad09a6f107f2d516b4 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 4 Feb 2020 10:28:16 +0100 Subject: Handle CRLF line terminators in geometry files This was broken by d62367db8fee57, which was some enabling work for reading geometry info from streams. --- libcrystfel/src/detector.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libcrystfel') 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