[hackers] [scc] Emit #lines when it is needed in the cpp output || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 5 Oct 2015 22:03:38 +0200 (CEST)

commit 1dc58d5e18fc688f2eb7cb6590e3241a31e511f9
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Oct 5 21:49:51 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Oct 5 21:59:06 2015 +0200

    Emit #lines when it is needed in the cpp output

diff --git a/cc1/cpp.c b/cc1/cpp.c
index a3b6395..ca4f47a 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -758,5 +758,6 @@ outcpp(void)
                         }
                 }
         }
+ putchar('\n');
 }
 
diff --git a/cc1/lex.c b/cc1/lex.c
index 36a0c60..b8a246b 100644
--- a/cc1/lex.c
+++ b/cc1/lex.c
_AT_@ -215,6 +215,10 @@ repeat:
 bool
 moreinput(void)
 {
+ static char file[FILENAME_MAX];
+ static unsigned nline;
+ char *s;
+
 repeat:
         if (!readline())
                 return 0;
_AT_@ -226,8 +230,19 @@ repeat:
                 goto repeat;
         }
 
- if (onlycpp)
+ if (onlycpp) {
                 putchar('\n');
+ if (strcmp(file, input->fname)) {
+ strcpy(file, input->fname);
+ s = "#line %u %s\n";
+ } else if (nline+1 != input->nline) {
+ s = "#line %u\n";
+ } else {
+ s = "";
+ }
+ nline = input->nline;
+ printf(s, nline, file);
+ }
         input->begin = input->p;
         return 1;
 }
Received on Mon Oct 05 2015 - 22:03:38 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 05 2015 - 22:12:11 CEST