preproc, srcfile: much saner handling of %line directives
commitb292748d9f5fc2ac89a75df4b160a1451a767851
authorH. Peter Anvin (Intel) <hpa@zytor.com>
Mon, 15 Jun 2020 03:09:11 +0000 (14 20:09 -0700)
committerH. Peter Anvin (Intel) <hpa@zytor.com>
Mon, 15 Jun 2020 03:09:11 +0000 (14 20:09 -0700)
tree243013d5b5c2efa78eb79166ea8ae94aa74ca5cd
parent4ed23c8f8557db0ed8578a090a0c483cd993c076
preproc, srcfile: much saner handling of %line directives

%line directives really need to be preprocessed early, before normal
directive processing. In particular, they are *not* affected by such
thing as smacro expansion, or deferred into an mmacro expansion.

The %line directive is special because it is explicitly indented to be
inserted by an external preprocessor, which can happen at any point.

For mmacro and rep expansions, store the current file and line for
each expansion line. Similarly, let each istk entry contain such
information.

Don't emit empty lines in preprocessing-only mode when we are
already required to issue a %line directive anyway. This cuts down on
clutter a fair bit.

Quote filenames in %line directives (and accept quoted filenames in
%line directives) if and only if it is necessary for
disambiguation. This is required if:

1. The filename contains control characters;
2. The filename begins or ends with whitespace or a quotation mark;
3. The filename is empty.

Otherwise issue the filename as-is, for backwards compatibility.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
asm/nasm.c
asm/preproc.c
asm/srcfile.c
asm/srcfile.h
travis/test/weirdpaste.i.t