On Mon, 17 Jan 2005, Sam Ravnborg wrote:
>
> Something like this.
> First cut - it seems to work but rather untested.
Looks good to me. But since you seem to do more testing, I'll just wait
for that before committing, and yes, it would be good to have a better
"current_c_file" setup.
Maybe just make that path be another "const char *" as part of "struct
stream" (initialized once, at stream setup time), and then just do
includepath[0] = stream->path;
at each include. Instead of the full "strcpy + strrchr" thing.
Bonus points for making it lazy instead (ie initialize "stream->path" to
NULL, and then have a small helper function to set includepath, something
like
static void set_stream_include_path(struct stream *stream)
{
const char *path = stream->path;
if (!path) {
const char *p = strrchr(stream->name, '/');
path = "";
if (p) {
int len = p - stream->name + 1;
char *m = malloc(len+1);
/* This includes the final "/" */
memcpy(m, stream->name, len);
m[len] = 0;
path = m;
}
stream->path = path;
}
includepath[0] = path;
}
which should do ok (with a bit of testing, of course, I probably got
some fencepost error in all those games).
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html