diff --git a/src/db.c b/src/db.c index 2ea8e38..fda7ac6 100644 --- a/src/db.c +++ b/src/db.c @@ -2873,12 +2873,16 @@ char *fread_string(FILE *fl, const char *error) /* If there is a '~', end the string; else put an "\r\n" over the '\n'. */ /* now only removes trailing ~'s -- Welcor */ point = strchr(tmp, '\0'); - for (point-- ; (*point=='\r' || *point=='\n'); point--); + for (point-- ; (*point=='\r' || *point=='\n') && point > tmp; point--); if (*point=='~') { *point='\0'; done = 1; } else { - *(++point) = '\r'; + if (*point == '\n' || *point == '\r') + *point = '\r'; + else + *(++point) = '\r'; + *(++point) = '\n'; *(++point) = '\0'; }