From: Pavel Roskin <proski@gnu.org>
To: linux-sparse@vger.kernel.org
Subject: [RFC PATCH] Handling multiple -include directives
Date: Fri, 22 Dec 2006 02:06:29 -0500 [thread overview]
Message-ID: <1166771189.18955.10.camel@dv> (raw)
Hello!
sparse doesn't handle multiple -include directives. Variables "include"
and "include_fd" have file scope in lib.c. The file for inclusion is
processed only once in sparse_initial() after the command line has been
processed.
It seems to me that the existing add_pre_buffer() mechanism can be used
instead. I'm just a bit worried why it wasn't done like this in the
first place.
---
Handle multiple -include directives
Signed-off-by: Pavel Roskin <proski@gnu.org>
---
lib.c | 26 ++++++--------------------
1 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/lib.c b/lib.c
index 51c415d..3ea3bde 100644
--- a/lib.c
+++ b/lib.c
@@ -191,8 +191,6 @@ int Wenum_mismatch = 1;
int Wdo_while = 1;
int Wuninitialized = 1;
int preprocess_only;
-char *include;
-int include_fd = -1;
void add_pre_buffer(const char *fmt, ...)
@@ -266,21 +264,15 @@ static char **handle_switch_i(char *arg, char **next)
{
if (*next && !strcmp(arg, "include")) {
char *name = *++next;
- int fd = open(name, O_RDONLY);
-
- include_fd = fd;
- include = name;
- if (fd < 0)
- perror(name);
+ if (!name)
+ die("missing argument for -include option");
+ add_pre_buffer("#include \"%s\"\n", name);
}
if (*next && !strcmp(arg, "imacros")) {
char *name = *++next;
- int fd = open(name, O_RDONLY);
-
- include_fd = fd;
- include = name;
- if (fd < 0)
- perror(name);
+ if (!name)
+ die("missing argument for -include option");
+ add_pre_buffer("#include \"%s\"\n", name);
}
else if (*next && !strcmp(arg, "isystem")) {
char *path = *++next;
@@ -624,12 +616,6 @@ static struct symbol_list *sparse_initial(void)
{
struct token *token;
- // Prepend any "include" file to the stream.
- // We're in global scope, it will affect all files!
- token = NULL;
- if (include_fd >= 0)
- token = tokenize(include, include_fd, NULL, includepath);
-
// Prepend the initial built-in stream
token = tokenize_buffer(pre_buffer, pre_buffer_size, token);
return sparse_tokenstream(token);
--
Regards,
Pavel Roskin
next reply other threads:[~2006-12-22 7:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-22 7:06 Pavel Roskin [this message]
2006-12-22 7:36 ` [RFC PATCH] Handling multiple -include directives Pavel Roskin
2006-12-22 9:47 ` Christopher Li
2006-12-22 22:27 ` Pavel Roskin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1166771189.18955.10.camel@dv \
--to=proski@gnu.org \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).