[hackers] [scc] [cc1] Move print of #line to cpp || Roberto E. Vargas Caballero
commit 44882dc0000b32dc3cded163d0318995a753150e
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Feb 24 19:53:02 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Feb 24 19:55:49 2017 +0100
[cc1] Move print of #line to cpp
When cc1 is working with -E it has to control the current line
number and emit #line directives when there is a discrepancy,
and it was done directly in moreinput(), but this is a job that
is better done in a funciton located in cpp.c, specially near
of outcpp(), because both functions are going to generate the
output at the same time.
diff --git a/cc1/cc1.h b/cc1/cc1.h
index 23d51cb..1ae5724 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -456,6 +456,7 @@ extern void incdir(char *dir);
extern void outcpp(void);
extern void defdefine(char *macro, char *val, char *source);
extern void undefmacro(char *s);
+extern void ppragmaln(void);
/* builtin.c */
extern void ibuilts(void);
diff --git a/cc1/cpp.c b/cc1/cpp.c
index 9ce036d..79ddc01 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -781,6 +781,27 @@ error:
}
void
+ppragmaln(void)
+{
+ static char file[FILENAME_MAX];
+ static unsigned nline;
+ char *s;
+ int i;
+
+ putchar('\n');
+ if (strcmp(file, filenam)) {
+ strcpy(file, filenam);
+ s = "#line %u %s\n";
+ } else if (nline+1 != lineno) {
+ s = "#line %u\n";
+ } else {
+ s = "";
+ }
+ nline = lineno;
+ printf(s, nline, file);
+}
+
+void
outcpp(void)
{
char c, *s, *t;
diff --git a/cc1/lex.c b/cc1/lex.c
index 448a7c1..a6ef332 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -304,23 +304,8 @@ repeat:
}
}
- if (onlycpp && !wasexpand) {
- static char file[FILENAME_MAX];
- static unsigned nline;
- char *s;
-
- putchar('\n');
- if (strcmp(file, filenam)) {
- strcpy(file, filenam);
- s = "#line %u %s\n";
- } else if (nline+1 != lineno) {
- s = "#line %u\n";
- } else {
- s = "";
- }
- nline = lineno;
- printf(s, nline, file);
- }
+ if (onlycpp && !wasexpand)
+ ppragmaln();
return 1;
}
Received on Fri Feb 24 2017 - 19:56:14 CET
This archive was generated by hypermail 2.3.0
: Fri Feb 24 2017 - 20:00:23 CET