[Cocci] Files included with #include "..." not found in directories specified with -I

Nicolas Palix npalix at diku.dk
Thu Jun 24 10:35:02 CEST 2010



On Thursday 24 June 2010 02:30:45 Josh Triplett wrote:
> In trying to debug a semantic patch, I noticed that spatch failed to
> find some header files included with "..." rather than <...>.
> 
> For example, in Xlib, modules/im/ximcp/imCallbk.c has:
> 
> #include "Xlibint.h"
> #include "Xlcint.h"
> #include "Ximint.h"
> #include "XlcPubI.h"
> 
> These files all exist in directories I've specified with the -I option,
> and I've passed -all_includes.  However, spatch says:
> 
> TYPE: header modules/im/ximcp/Xlibint.h not found
> TYPE: header modules/im/ximcp/Xlcint.h not found
> TYPE: header modules/im/ximcp/Ximint.h not found
> TYPE: header modules/im/ximcp/XlcPubI.h not found
> 
> If I change those includes to use <> rather than "", spatch stops
> complaining.  However, both <> and "" should search the include path; ""
> just searches the directory of the file containing the #include "..."
> first.

The following patch should fix it.

--- coccinelle-0.2.3rc3/cocci.ml	2010-06-19 04:32:04.000000000 +0200
+++ coccinelle-release/cocci.ml	2010-06-24 10:30:18.000000000 +0200
@@ -582,14 +582,18 @@
 		let relpath = Common.join "/" xs in
 		let f = Filename.concat dir (relpath) in
 	      (* for our tests, all the files are flat in the current dir *)
-		if not (Sys.file_exists f) && !Flag_cocci.relax_include_path
-		then
-		  let attempt2 = Filename.concat dir (Common.last xs) in
-		  if not (Sys.file_exists f) && all_includes
+		if (Sys.file_exists f) then
+		  Some f
+		else
+		  if !Flag_cocci.relax_include_path
 		  then
+		    let attempt2 = Filename.concat dir (Common.last xs) in
+		      if not (Sys.file_exists f) && all_includes
+		      then
+			interpret_include_path relpath
+		      else Some attempt2
+		  else
 		    interpret_include_path relpath
-		  else Some attempt2
-		else Some f
 
             | Ast_c.NonLocal xs ->
 		let relpath = Common.join "/" xs in

> 
> - Josh Triplett
> _______________________________________________
> Cocci mailing list
> Cocci at diku.dk
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
> 

-- 
Nicolas Palix
Tel: (+33) 1 44 27 87 25
Tel: (+33) 6 81 07 91 72
Web: http://www.diku.dk/~npalix/


More information about the Cocci mailing list