From 51d2fb62eca01314fbf5271040ef81f269fcfeee Mon Sep 17 00:00:00 2001 From: v1j4y Date: Mon, 13 Jun 2022 17:51:24 +0200 Subject: [PATCH] Fixed bug in reading true or false for FAM1. --- src/read2.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/read2.c b/src/read2.c index 28ece1a..53f952a 100644 --- a/src/read2.c +++ b/src/read2.c @@ -1,5 +1,26 @@ #include "read2.h" +/* Compare two strings s1 and s2, assuming s1 is terminated + * by \n or a NULL, and s2 is terminated by a NULL. A match + * returns 1, a non-match returns 0. + */ +int +strcmpst1nl (const char * s1, const char * s2) +{ + char s1c; + do + { + s1c = *s1; + if (s1c == '\n') + s1c = 0; + if (s1c != *s2) + return 0; + s1++; + s2++; + } while (s1c); /* already checked *s2 is equal */ + return 1; +} + void Data_new(FILE* file, Data* dat) { //ata* dat = (Data*)malloc(sizeof(Data)); @@ -34,7 +55,8 @@ void Data_new(FILE* file, Data* dat) { case 6: //dat->FAM1 = to_bool(line); dat->FAM1 = 0; - dat->FAM1 = line && strcmp(line,"true")==0; + //dat->FAM1 = line && strcmp(line,"true")==0; + dat->FAM1 = strcmpst1nl(line,"true"); break; case 7: arrayIdx=0;