summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/MANIFEST2
-rw-r--r--etc/build.properties2
-rw-r--r--src/java/org/anarres/cpp/Preprocessor.java8
-rw-r--r--src/tests/org/anarres/cpp/JavaFileSystemTestCase.java39
-rw-r--r--src/tests/org/anarres/cpp/PreprocessorTestCase.java17
5 files changed, 47 insertions, 21 deletions
diff --git a/etc/MANIFEST b/etc/MANIFEST
index cca68ec..4355315 100644
--- a/etc/MANIFEST
+++ b/etc/MANIFEST
@@ -1,2 +1,2 @@
-Class-Path: log4j.jar dnsjava-2.0.0.jar
+Class-Path: log4j.jar gnu.getopt.jar
Main-Class: org.anarres.cpp.Main
diff --git a/etc/build.properties b/etc/build.properties
index 3dd17f2..daad657 100644
--- a/etc/build.properties
+++ b/etc/build.properties
@@ -1,4 +1,4 @@
-global.version = 1.2.2
+global.version = 1.2.3
global.name = anarres-cpp
global.dir.arch = ${global.dir.root}/arch
diff --git a/src/java/org/anarres/cpp/Preprocessor.java b/src/java/org/anarres/cpp/Preprocessor.java
index ed8da44..158e5b8 100644
--- a/src/java/org/anarres/cpp/Preprocessor.java
+++ b/src/java/org/anarres/cpp/Preprocessor.java
@@ -984,13 +984,9 @@ public class Preprocessor {
}
/**
- * Handles a include directive.
- *
- * The user may override this to provide alternate semantics
- * for the include directive, for example, creating a Source
- * based on a virtual file system.
+ * Handles an include directive.
*/
- protected void include(String parent, int line,
+ private void include(String parent, int line,
String name, boolean quoted)
throws IOException,
LexerException {
diff --git a/src/tests/org/anarres/cpp/JavaFileSystemTestCase.java b/src/tests/org/anarres/cpp/JavaFileSystemTestCase.java
new file mode 100644
index 0000000..4f68d68
--- /dev/null
+++ b/src/tests/org/anarres/cpp/JavaFileSystemTestCase.java
@@ -0,0 +1,39 @@
+package org.anarres.cpp;
+
+import java.io.*;
+
+import junit.framework.Test;
+
+import static org.anarres.cpp.Token.*;
+
+public class JavaFileSystemTestCase extends BaseTestCase {
+
+ public void testJavaFileSystem() throws Exception {
+ JavaFileSystem fs = new JavaFileSystem();
+ VirtualFile f;
+
+ /* Anyone who has this file on their Unix box is messed up. */
+ f = fs.getFile("/foo/bar baz");
+ try {
+ f.getSource(); /* drop on floor */
+ assertTrue("Got a source for a non-file", f.isFile());
+ }
+ catch (FileNotFoundException e) {
+ assertFalse("Got no source for a file", f.isFile());
+ }
+
+ /* We hope we have this. */
+ f = fs.getFile("/usr/include/stdio.h");
+ try {
+ f.getSource(); /* drop on floor */
+ System.out.println("Opened stdio.h");
+ assertTrue("Got a source for a non-file", f.isFile());
+ }
+ catch (FileNotFoundException e) {
+ System.out.println("Failed to open stdio.h");
+ assertFalse("Got no source for a file", f.isFile());
+ }
+
+ }
+
+}
diff --git a/src/tests/org/anarres/cpp/PreprocessorTestCase.java b/src/tests/org/anarres/cpp/PreprocessorTestCase.java
index a6e202b..ff2bc10 100644
--- a/src/tests/org/anarres/cpp/PreprocessorTestCase.java
+++ b/src/tests/org/anarres/cpp/PreprocessorTestCase.java
@@ -14,24 +14,15 @@ public class PreprocessorTestCase extends BaseTestCase {
final PipedOutputStream po = new PipedOutputStream();
writer = new OutputStreamWriter(po);
- p = new Preprocessor(
+ p = new Preprocessor();
+ p.addInput(
new LexerSource(
new InputStreamReader(
new PipedInputStream(po)
),
true
- ) {
- public File getFile() {
- return new File("test-input");
- }
- }
- ) {
- @Override
- protected void include(String parent, int line,
- String name, boolean quoted) {
- /* XXX Perform a useful assertion. */
- }
- };
+ )
+ );
}
private static class I {