diff --git a/Source/Assembler/Assm-util.c b/Source/Assembler/Assm-util.c index 936c7b1..457e6d7 100644 --- a/Source/Assembler/Assm-util.c +++ b/Source/Assembler/Assm-util.c @@ -309,6 +309,15 @@ int readToken(intermediateElement *currentElement, FILE *file, int *lineNumber) // Step 3: Handle string literals if (c == '"') { while ((c = fgetc(file)) != EOF && c != '"') { + // A STRING MAY HAVE NEWLINES IN IT, and they are as real as any others. Not + // counting them is why every line number after one was short: cosmos.asm has + // thirteen of them and its last label was reported thirteen lines early, which + // makes an error message point at somebody else's code. Counted here, where + // the character is consumed, rather than by scanning the token afterwards - + // the same newline must not be counted twice if this loop ever grows a way out. + if (c == '\n') { + (*lineNumber)++; + } if (i < (int)(sizeof(buffer) - 1)) { buffer[i++] = c; } else {