shevek / jcpp

The C Preprocessor as a Java library
http://www.anarres.org/projects/jcpp/
Apache License 2.0
106 stars 36 forks source link

Absolute paths in includes #21

Closed iserikov closed 9 years ago

iserikov commented 9 years ago

JCPP cannot handle absolute paths in include directives. They are treated as relative. For example,

include "/home/me/test.h"

will not work. On the other hand

include "/test.h"

will work looking for the file in the current directory.

shevek commented 9 years ago

If you can make up a test case, I'm ready to fix this.

iserikov commented 9 years ago

Hi Shevek,

Run JCPP against the attached test.c on a Linux machine. GCC handles it OK. JCPP does not.

Thank you for integrating the patch as I prefer to stick to the mainline source.

Igor

On Tue, 30 Dec 2014 22:10:27 -0800 Shevek notifications@github.com wrote:

If you can make up a test case, I'm ready to fix this.


Reply to this email directly or view it on GitHub: https://github.com/shevek/jcpp/issues/21#issuecomment-68425622

shevek commented 9 years ago

I think github discarded email attachments in the issue reply, but I'll see if I can construct some.

iserikov commented 9 years ago

include </usr/include/stdio.h>

int main (int argc, char * argv []) { printf ("Hello world!\n"); return 0; }

On Wed, 31 Dec 2014 15:24:27 -0800 Shevek notifications@github.com wrote:

I think github discarded email attachments in the issue reply, but I'll see if I can construct some.


Reply to this email directly or view it on GitHub: https://github.com/shevek/jcpp/issues/21#issuecomment-68474750

shevek commented 9 years ago

I suspect the "correct" answer to this is to throw out jcpp's VFS implementation and use the new java.nio.file code.

shevek commented 9 years ago

Just to confirm, you are on at least Java 1.7?

shevek commented 9 years ago

There's an absolute path patch in #7 too

shevek commented 9 years ago

@ochafik I'm looking at checking whether path is absolute at the top of include(String parent, int line, String name, boolean quoted, boolean next) as if it's absolute, it doesn't matter whether it's quoted or anglebracketed.

iserikov commented 9 years ago

Hi Shevek,

Yes, I am on Java 1.7.

Please do not abandon the VFS interface. I really need it. And, yes, you can place a check for absolute path to the top of your 1st level "include" routine. This should go through VFS as well. You may add something like isAbsolute().

Thanks, Igor

On Wed, 31 Dec 2014 21:42:42 -0800 Shevek notifications@github.com wrote:

I suspect the "correct" answer to this is to throw out jcpp's VFS implementation and use the new java.nio.file code.


Reply to this email directly or view it on GitHub: https://github.com/shevek/jcpp/issues/21#issuecomment-68480823

shevek commented 9 years ago

Will the java.nio.file code (which is a standard VFS interface in the JDK) suffice? Is it possible for you to implement your virtual filesystem using that? Then we can both use things like https://github.com/google/jimfs which is a set of filesystems based on that API.

iserikov commented 9 years ago

Hi Shevek,

That would work. The only requirement is that I should be able to set the file system (as a FileSystem object) explicitly, similar to how it is done now. Going through the schema based FS provider guessing, as JVM normally does, would not work for me.

Thanks, Igor

On Wed, 07 Jan 2015 00:06:16 -0800 Shevek notifications@github.com wrote:

Will the java.nio.file code (which is a standard VFS interface in the JDK) suffice? Is it possible for you to implement your virtual filesystem using that? Then we can both use things like https://github.com/google/jimfs which is a set of filesystems based on that API.


Reply to this email directly or view it on GitHub: https://github.com/shevek/jcpp/issues/21#issuecomment-68990090