ogajduse / rpms / texlive

Forked from rpms/texlive 6 years ago
Clone
d0bdd61
--- latexpand.old	2015-12-14 14:23:11.624505410 -0500
d0bdd61
+++ latexpand	2015-12-14 14:37:45.196569657 -0500
d0bdd61
@@ -123,7 +123,7 @@ sub process_file
d0bdd61
 		# ignored by LaTeX, but we don't allow anything before
d0bdd61
 		# to avoid e.g. \verb|\end{document}| from terminating
d0bdd61
 		# the file.
d0bdd61
-		if (!$keep_comments && $line =~ /^[ \t]*\\end{document}/) {
d0bdd61
+		if (!$keep_comments && $line =~ /^[ \t]*\\end\{document}/) {
d0bdd61
 			last;
d0bdd61
 		}
d0bdd61
 	}
d0bdd61
@@ -133,7 +133,8 @@ sub process_file
d0bdd61
 
d0bdd61
 sub process_line
d0bdd61
 {
d0bdd61
-	my ($_, $prefix, $file) = @_;
d0bdd61
+	my ($line, $prefix, $file) = @_;
d0bdd61
+	$_ = $line;
d0bdd61
 	# Consider \makeatletter only in preamble, because we do want
d0bdd61
 	# to warn on \someCommand{\makeatletter\command@with@arobase}.
d0bdd61
 	if ($in_preamble && /^[^%]*\\makeatletter/) {
d0bdd61
@@ -203,7 +204,7 @@ sub process_line
d0bdd61
 	if ($expand_usepackage) {
d0bdd61
 		# Don't bother with before and after text, we just require the
d0bdd61
 		# usepackage to be alone on its line.
d0bdd61
-		if (my ($package_name) = /^\s*\\usepackage{([^}]*)}\s*(%.*)?$/) {
d0bdd61
+		if (my ($package_name) = /^\s*\\usepackage\{([^}]*)}\s*(%.*)?$/) {
d0bdd61
 			my $full = find_file($package_name . ".sty", $TEXINPUTS);
d0bdd61
 			if ($full) {
d0bdd61
 				say $prefix . "Found package file: $full\n";
d0bdd61
@@ -216,7 +217,7 @@ sub process_line
d0bdd61
 	}
d0bdd61
 	if ($expand_bbl) {
d0bdd61
 		if (my ($before, $bib_name, $after)
d0bdd61
-			 = /^(.*)\\bibliography{([^}]*)}(.*)$/) {
d0bdd61
+			 = /^(.*)\\bibliography\{([^}]*)}(.*)$/) {
d0bdd61
 			# The BBL file is not necessarily $bib_name.
d0bdd61
 			# Take it from the command-line.
d0bdd61
 			print $before . $nl;
d0bdd61
@@ -233,7 +234,7 @@ sub process_line
d0bdd61
 			print STDERR "$full\n";
d0bdd61
 		}
d0bdd61
 	}
d0bdd61
-	if (/^[ \t]*\\begin{document}/) {
d0bdd61
+	if (/^[ \t]*\\begin\{document}/) {
d0bdd61
 		$in_preamble = 0;
d0bdd61
 		if ($makeatletter) {
d0bdd61
 			print '\makeatletter' . $nl;