[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] fix for bug43450
|
Bug 43450 - Path strings containing backslashes need quoting by hand
The user needs to input strings in whatever manner necessary for their
build tools to work. If that means quoting them, then quote them.
However, if the user does quote them, then the scanner needs to handle
that when looking for include files:
core:
-modify Scanner.handleInclusion
core.tests:
- added testBug43450 to ManagedBuildTests.java
- added a user include to plugin.xml
tested on windows & linux
-Andrew
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.147
diff -u -r1.147 ChangeLog
--- parser/ChangeLog 1 Oct 2003 13:33:34 -0000 1.147
+++ parser/ChangeLog 1 Oct 2003 14:26:38 -0000
@@ -1,3 +1,6 @@
+2003-10-01 Andrew Niefer
+ bug43450 - Scanner needs to handle include paths that contain quotes
+
2003-09-30 Bogdan Gheorghe
Added CDT log dump in Parser.fetchToken to catch HandleInclusion failures
2003-09-30 John Camelon
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.57
diff -u -r1.57 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 30 Sep 2003 20:42:23 -0000 1.57
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 Oct 2003 14:26:39 -0000
@@ -303,6 +303,16 @@
while (iter.hasNext()) {
File pathFile = (File)iter.next();
+ String path = pathFile.getPath();
+ if( !pathFile.exists() && path.indexOf('\"') != -1 )
+ {
+ StringTokenizer tokenizer = new StringTokenizer(path, "\"" ); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer(path.length() );
+ while( tokenizer.hasMoreTokens() ){
+ buffer.append( tokenizer.nextToken() );
+ }
+ pathFile = new File( buffer.toString() );
+ }
if (pathFile.isDirectory()) {
newPath = pathFile.getPath() + File.separatorChar + fileName;
File includeFile = new File(newPath);
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.128
diff -u -r1.128 ChangeLog
--- ChangeLog 1 Oct 2003 14:25:26 -0000 1.128
+++ ChangeLog 1 Oct 2003 14:42:01 -0000
@@ -1,3 +1,7 @@
+2003-10-01 Andrew Niefer
+ added testBug43450 to ManagedBuildTests.java
+ added a user include to plugin.xml
+
2003-09-30 Sean Evoy
Fix for bug 41826.
Updated the plugin file so that tool specifications have the new attribute
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/plugin.xml,v
retrieving revision 1.14
diff -u -r1.14 plugin.xml
--- plugin.xml 1 Oct 2003 14:25:26 -0000 1.14
+++ plugin.xml 1 Oct 2003 14:42:01 -0000
@@ -200,6 +200,10 @@
value="C:\home\tester/include"
builtIn="false">
</listOptionValue>
+ <listOptionValue
+ value=""../includes""
+ builIn="false">
+ </listOptionValue>
</option>
<option
name="User Objects"
Index: build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java,v
retrieving revision 1.12
diff -u -r1.12 ManagedBuildTests.java
--- build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java 1 Oct 2003 14:25:26 -0000 1.12
+++ build/org/eclipse/cdt/core/build/managed/tests/ManagedBuildTests.java 1 Oct 2003 14:42:01 -0000
@@ -10,6 +10,8 @@
**********************************************************************/
package org.eclipse.cdt.core.build.managed.tests;
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -20,9 +22,16 @@
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.parser.IParser;
+import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ParserFactory;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.core.parser.ParserMode;
+import org.eclipse.cdt.internal.core.parser.NullSourceElementRequestor;
import org.eclipse.cdt.managedbuilder.core.BuildException;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
@@ -34,6 +43,9 @@
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.internal.core.OptionReference;
import org.eclipse.cdt.managedbuilder.internal.core.ToolReference;
+import org.eclipse.cdt.testplugin.FileManager;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
@@ -71,6 +83,7 @@
suite.addTest(new ManagedBuildTests("testTargetBuildArtifact"));
suite.addTest(new ManagedBuildTests("testMakeCommandManipulation"));
suite.addTest(new ManagedBuildTests("testScannerInfoInterface"));
+ suite.addTest(new ManagedBuildTests("testBug43450"));
suite.addTest(new ManagedBuildTests("cleanup"));
return suite;
@@ -154,14 +167,6 @@
* @throws CoreException
*/
public void testScannerInfoInterface(){
- // These are the expected path settings
- final String[] expectedPaths = new String[4];
- // This first path is a built-in, so it will not be manipulated by build manager
- expectedPaths[0] = "/usr/gnu/include";
- expectedPaths[1] = (new Path("/usr/include")).toOSString();
- expectedPaths[2] = (new Path("/opt/gnome/include")).toOSString();
- expectedPaths[3] = (new Path("C:\\home\\tester/include")).toOSString();
-
// Open the test project
IProject project = null;
try {
@@ -170,6 +175,15 @@
fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage());
}
+ //These are the expected path settings
+ final String[] expectedPaths = new String[5];
+ // This first path is a built-in, so it will not be manipulated by build manager
+ expectedPaths[0] = "/usr/gnu/include";
+ expectedPaths[1] = (new Path("/usr/include")).toOSString();
+ expectedPaths[2] = (new Path("/opt/gnome/include")).toOSString();
+ expectedPaths[3] = (new Path("C:\\home\\tester/include")).toOSString();
+ expectedPaths[4] = project.getLocation().append( "Sub Config\\\"..\\includes\"" ).toOSString();
+
// Create a new target in the project based on the sub target
ITarget baseTarget = ManagedBuildManager.getTarget(project, "test.sub");
assertNotNull(baseTarget);
@@ -845,7 +859,7 @@
assertEquals("More Includes", subOpts[2].getName());
assertEquals(IOption.INCLUDE_PATH, subOpts[2].getValueType());
String[] moreIncPath = subOpts[2].getIncludePaths();
- assertEquals(1, moreIncPath.length);
+ assertEquals(2, moreIncPath.length);
assertEquals("C:\\home\\tester/include", moreIncPath[0]);
assertEquals("-I", subOpts[2].getCommand());
// Check the user object option
@@ -954,6 +968,32 @@
public void testThatAlwaysFails() {
assertTrue(false);
+ }
+
+ public void testBug43450 () throws Exception{
+ IProject project = createProject( projectName );
+
+ FileManager fileManager = new FileManager();
+
+ IFolder folder = project.getProject().getFolder( "includes" );
+ if( !folder.exists() ){
+ folder.create( false, true, null );
+ }
+
+ IFile file = project.getProject().getFile( "includes/header.h" );
+ if( !file.exists() ){
+ file.create( new ByteArrayInputStream( "class A { public : static int i; };".getBytes() ), false, null );
+ }
+
+ IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
+ IScannerInfo info = provider.getScannerInformation( project );
+ ISourceElementRequestor callback = new NullSourceElementRequestor();
+
+ IScanner scanner = ParserFactory.createScanner( new StringReader( "#include <header.h>\n int A::i = 1;" ),
+ "TEST", info, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP, callback );
+
+ IParser parser = ParserFactory.createParser( scanner, callback, ParserMode.COMPLETE_PARSE, ParserLanguage.CPP );
+ assertTrue( parser.parse() );
}
}