From 587a9b4c106c188a9546ac9483b597fef7243a67 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 22 Oct 2014 13:48:45 +0200 Subject: Formatting / fussiness --- libcrystfel/src/events.c | 52 +++++++++++++++++++----------------------------- libcrystfel/src/stream.c | 23 +++++++++++---------- 2 files changed, 32 insertions(+), 43 deletions(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/events.c b/libcrystfel/src/events.c index c9cc1ece..6e52f6cd 100644 --- a/libcrystfel/src/events.c +++ b/libcrystfel/src/events.c @@ -253,7 +253,7 @@ char *get_event_string(struct event *ev) char *new_ret_string; int ret_string_len; - if ( ev == NULL ) return "null event"; + if ( ev == NULL ) return "(none)"; if ( ev->path_length != 0 ) { @@ -265,8 +265,8 @@ char *get_event_string(struct event *ev) for ( pi=1; pipath_length; pi++ ) { new_ret_string = realloc(ret_string, - (ret_string_len+1+strlen(ev->path_entries[pi])) - *sizeof(char)); + (ret_string_len+1+strlen(ev->path_entries[pi])) + * sizeof(char)); if ( new_ret_string == NULL ) { return NULL; } @@ -360,15 +360,8 @@ struct event *get_event_from_event_string(char *ev_string) char *sep; char *start; - ev = initialize_event(); - if ( ev == NULL ) { - return NULL; - } - ev_sep = strstr(ev_string, "//"); - if ( ev_sep == NULL ) { - return NULL; - } + if ( ev_sep == NULL ) return NULL; strncpy(buf_path, ev_string, ev_sep-ev_string); buf_path[ev_sep-ev_string] = '\0'; @@ -376,6 +369,9 @@ struct event *get_event_from_event_string(char *ev_string) strncpy(buf_dim, ev_sep+2, strlen(ev_sep)-2); buf_dim[strlen(ev_sep)-2] = '\0'; + ev = initialize_event(); + if ( ev == NULL ) return NULL; + if ( strlen(buf_path) !=0 ) { do { @@ -398,11 +394,11 @@ struct event *get_event_from_event_string(char *ev_string) push_path_entry_to_event(ev, buf); } + } while (sep); } - if ( strlen(buf_dim) !=0 ) { start = buf_dim; @@ -438,19 +434,17 @@ struct event *get_event_from_event_string(char *ev_string) int push_path_entry_to_event(struct event *ev, const char *entry) { - char **new_path_entries; + char **new_path_entries; - new_path_entries = realloc(ev->path_entries, - (1+ev->path_length)*sizeof(char *)); - if ( new_path_entries == NULL ) { - return 1; - } + new_path_entries = realloc(ev->path_entries, + (1+ev->path_length)*sizeof(char *)); + if ( new_path_entries == NULL ) return 1; - ev->path_entries = new_path_entries; - ev->path_entries[ev->path_length] = strdup(entry); - ev->path_length += 1; + ev->path_entries = new_path_entries; + ev->path_entries[ev->path_length] = strdup(entry); + ev->path_length += 1; - return 0; + return 0; } @@ -459,10 +453,8 @@ int push_dim_entry_to_event(struct event *ev, int entry) int *new_dim_entries; new_dim_entries = realloc(ev->dim_entries, - (1+ev->dim_length)*sizeof(int)); - if ( new_dim_entries == NULL ) { - return 1; - } + (1+ev->dim_length)*sizeof(int)); + if ( new_dim_entries == NULL ) return 1; ev->dim_entries = new_dim_entries; ev->dim_entries[ev->dim_length] = entry; @@ -476,9 +468,7 @@ int pop_path_entry_from_event(struct event *ev) { char **new_path_entries; - if ( ev->path_length == 0 ) { - return 1; - } + if ( ev->path_length == 0 ) return 1; free(ev->path_entries[ev->path_length-1]); @@ -491,9 +481,7 @@ int pop_path_entry_from_event(struct event *ev) new_path_entries = realloc(ev->path_entries, (ev->path_length-1)*sizeof(char *)); - if ( new_path_entries == NULL) { - return 1; - } + if ( new_path_entries == NULL ) return 1; ev->path_entries = new_path_entries; ev->path_length = ev->path_length-1; diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 3be9dae5..7ce0c5c4 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -312,7 +312,8 @@ static RefList *read_stream_reflections_2_1(FILE *fh) if ( strcmp(line, REFLECTION_END_MARKER) == 0 ) return out; r = sscanf(line, "%i %i %i %f %s %f %i %f %f", - &h, &k, &l, &intensity, phs, &sigma, &cts, &fs, &ss); + &h, &k, &l, &intensity, phs, &sigma, &cts, + &fs, &ss); if ( (r != 9) && (!first) ) { reflist_free(out); return NULL; @@ -396,8 +397,8 @@ static void write_stream_reflections_2_2(FILE *fh, RefList *list) Reflection *refl; RefListIterator *iter; - fprintf(fh, " h k l I sigma(I) peak background" - " fs/px ss/px\n"); + fprintf(fh, " h k l I sigma(I) " + "peak background fs/px ss/px\n"); for ( refl = first_refl(list, &iter); refl != NULL; @@ -418,9 +419,9 @@ static void write_stream_reflections_2_2(FILE *fh, RefList *list) /* Reflections with redundancy = 0 are not written */ if ( get_redundancy(refl) == 0 ) continue; - fprintf(fh, - "%4i %4i %4i %10.2f %10.2f %10.2f %10.2f %6.1f %6.1f\n", - h, k, l, intensity, esd_i, pk, bg, fs, ss); + fprintf(fh, "%4i %4i %4i %10.2f %10.2f %10.2f %10.2f" + " %6.1f %6.1f\n", + h, k, l, intensity, esd_i, pk, bg, fs, ss); } } @@ -462,16 +463,15 @@ static void write_stream_reflections_2_1(FILE *fh, RefList *list) strncpy(phs, " -", 15); } - fprintf(fh, - "%3i %3i %3i %10.2f %s %10.2f %7i %6.1f %6.1f\n", - h, k, l, intensity, phs, esd_i, red, fs, ss); + fprintf(fh, "%3i %3i %3i %10.2f %s %10.2f %7i %6.1f %6.1f\n", + h, k, l, intensity, phs, esd_i, red, fs, ss); } } static void write_stream_reflections_2_3(FILE *fh, RefList *list, - struct image *image) + struct image *image) { Reflection *refl; RefListIterator *iter; @@ -835,7 +835,8 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf) /* The reflection list format in the stream diverges * after 2.2 */ if ( AT_LEAST_VERSION(st, 2, 3) ) { - reflist = read_stream_reflections_2_3(st->fh, image->det); + reflist = read_stream_reflections_2_3(st->fh, + image->det); } else if ( AT_LEAST_VERSION(st, 2, 2) ) { reflist = read_stream_reflections_2_2(st->fh); } else { -- cgit v1.2.3