From 1f202022395f00612279d6c8c3015017fb68ec3c Mon Sep 17 00:00:00 2001 From: cuz Date: Mon, 30 Sep 2002 19:32:33 +0000 Subject: [PATCH] Ignore also cr's on input. This allows to compile sources with DOS/Windows line separators on unix systems. git-svn-id: svn://svn.cc65.org/cc65/trunk@1419 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/input.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc65/input.c b/src/cc65/input.c index 6db7df5f8..cff63bcfc 100644 --- a/src/cc65/input.c +++ b/src/cc65/input.c @@ -383,11 +383,14 @@ int NextLine (void) /* We got a new line */ ++Input->Line; - /* Remove the trailing newline if we have one */ + /* Remove the trailing cr/lf if we have one. We will ignore both, cr + * and lf on all systems since this enables us to compile DOS/Windows + * stuff also on unix systems (where fgets does not remove the cr). + */ Part = strlen (line + Len); Start = Len; Len += Part; - while (Len > 0 && line [Len-1] == '\n') { + while (Len > 0 && (line[Len-1] == '\n' || line[Len-1] == '\r')) { --Len; } line [Len] = '\0';