Add -I support to etc/texi2pod.pl

Daniel Jacobowitz drow@false.org
Mon Apr 17 19:19:00 GMT 2006


To avoid some trouble involving automake, its strange handling of info
files, and release tarballs (for the upcoming binutils release), I needed
to use -I $(top_srcdir)/../libiberty instead of @include @value{top_srcdir}
to find at-file.texi.

Is this patch OK?  Tested manually.

-- 
Daniel Jacobowitz
CodeSourcery

2006-04-17  Daniel Jacobowitz  <dan@codesourcery.com>

	* texi2pod.pl: Handle -I.

Index: etc/texi2pod.pl
===================================================================
RCS file: /cvs/src/src/etc/texi2pod.pl,v
retrieving revision 1.4
diff -u -p -r1.4 texi2pod.pl
--- etc/texi2pod.pl	21 Oct 2005 23:29:22 -0000	1.4
+++ etc/texi2pod.pl	17 Apr 2006 16:00:32 -0000
@@ -36,6 +36,7 @@ $shift = "";
 $fnno = 1;
 $inf = "";
 $ibase = "";
+@ipath = ();
 
 while ($_ = shift) {
     if (/^-D(.*)$/) {
@@ -51,6 +52,13 @@ while ($_ = shift) {
 	die "flags may only contain letters, digits, hyphens, dashes and underscores\n"
 	    unless $flag =~ /^[a-zA-Z0-9_-]+$/;
 	$defs{$flag} = $value;
+    } elsif (/^-I(.*)$/) {
+	if ($1 ne "") {
+	    $flag = $1;
+	} else {
+	    $flag = shift;
+	}
+        push (@ipath, $flag);
     } elsif (/^-/) {
 	usage();
     } else {
@@ -229,10 +237,12 @@ while(<$inf>) {
 	$inf = gensym();
 	$file = postprocess($1);
 
-	# Try cwd and $ibase.
-	open($inf, "<" . $file) 
-	    or open($inf, "<" . $ibase . "/" . $file)
-		or die "cannot open $file or $ibase/$file: $!\n";
+	# Try cwd and $ibase, then explicit -I paths.
+	$done = 0;
+	foreach $path (".", $ibase, @ipath) {
+	    open($inf, "<" . $path . "/" . $file) and ($done = 1, last);
+	}
+	die "cannot find $file" if !$done;
 	next;
     };
 



More information about the Gcc-patches mailing list