From 295169d0054ed934aaac2f694ae007aa5d752719 Mon Sep 17 00:00:00 2001 From: Thomas Flouris Date: Tue, 11 Jul 2017 17:09:54 +0100 Subject: [PATCH] fixed issue with phylip parsing when header (seqs length) ends with CRLF --- src/phylip.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/phylip.c b/src/phylip.c index 3b0bea4..fa3b74d 100644 --- a/src/phylip.c +++ b/src/phylip.c @@ -175,13 +175,14 @@ static int args_getint(const char * arg, int * len) return temp; } -static int whitechar(char c) +static int whitespace(char c) { - if (c == ' ' || c == '\t') return 1; - + if (c == ' ' || c == '\t' || c == '\n' || c == '\r') + return 1; return 0; } + static int parse_header(const char * line, int * seq_count, int * seq_len, @@ -210,7 +211,7 @@ static int parse_header(const char * line, line += len; /* go through all white spaces */ - while (*line && whitechar(*line)) ++line; + while (*line && whitespace(*line)) ++line; /* if end of line then return successfully */ if (!*line) @@ -224,7 +225,7 @@ static int parse_header(const char * line, return 0; /* go through all white spaces */ - while (*line && whitechar(*line)) ++line; + while (*line && whitespace(*line)) ++line; /* if end of line then return successfully */ if (!*line) @@ -233,13 +234,6 @@ static int parse_header(const char * line, return 0; } -static int whitespace(char c) -{ - if (c == ' ' || c == '\t' || c == '\n' || c == '\r') - return 1; - return 0; -} - static char * parse_oneline_sequence(pll_phylip_t * fd, pll_msa_t * msa, char * p,