texlive[50079] trunk: latexpand (20feb19)

commits+karl at tug.org commits+karl at tug.org
Wed Feb 20 23:43:45 CET 2019


Revision: 50079
          http://tug.org/svn/texlive?view=revision&revision=50079
Author:   karl
Date:     2019-02-20 23:43:45 +0100 (Wed, 20 Feb 2019)
Log Message:
-----------
latexpand (20feb19)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/latexpand/latexpand
    trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl
    trunk/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl
    trunk/Master/texmf-dist/doc/support/latexpand/README
    trunk/Master/texmf-dist/doc/support/latexpand/version.txt
    trunk/Master/texmf-dist/scripts/latexpand/latexpand

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexpand/latexpand
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexpand/latexpand	2019-02-20 22:43:27 UTC (rev 50078)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexpand/latexpand	2019-02-20 22:43:45 UTC (rev 50079)
@@ -28,6 +28,8 @@
 my $version;
 my $makeatletter;
 my $inside_import;
+my $in_enc = "bytes";
+my $out_enc = "bytes";
 
 GetOptions (
 	'h' => \$help,
@@ -45,6 +47,8 @@
 	'fatal' => \$fatal,
 	'version' => \$version,
         'makeatletter' => \$makeatletter,
+	'in-encoding=s' => \$in_enc,
+	'out-encoding=s' => \$out_enc,
 ) or pod2usage_wrapper(2);
 version() if $version;
 pod2usage_wrapper(0) if $help;
@@ -76,7 +80,7 @@
 {
 	# $VERSION's value will be substituted by 'make dist', but the
 	# next line won't (the string has to be broken to avoid it).
-	my $VERSION = 'v1.4-1-gb32a776';
+	my $VERSION = 'v1.5';
 	if ($VERSION eq '@LATEXPAND' . '_VERSION@') {
 		my($vol,$dir,$file) = File::Spec->splitpath($0);
 		chdir($dir);
@@ -115,6 +119,8 @@
 my $makeatletter_found;
 my $in_preamble;
 
+use open IN  => ":$in_enc", OUT => ":$out_enc";
+
 foreach my $file (@ARGV)
 {
 	say "processing $file\n";
@@ -159,18 +165,26 @@
 {
 	my ($line, $prefix, $commented_newline, $file) = @_;
 	$_ = $line;
-	if ($$commented_newline && /^\s*$/) {
-		# Deal with:
-		#
-		# Line 1 % comment
-		#
-		# Line 2
-		#
-		# The newline after Line 1 is commented, but we still
-		# want a new paragraph. We strip the comment together
-		# with its newline, but re-add a newline to chnge
-		# paragraph here if needed:
-		print "\n";
+	if ($$commented_newline) {
+		# Leading whitespaces after a comment is ignored.
+		# There's no space in:
+		# Line 1%
+		#    Line 2.
+		# Match just space and tabs (\s would match \n)
+		s/^[ \t]*//;
+		if (/^$/) {
+			# Deal with:
+			#
+			# Line 1 % comment
+			#
+			# Line 2
+			#
+			# The newline after Line 1 is commented, but we still
+			# want a new paragraph. We strip the comment together
+			# with its newline, but re-add a newline to chnge
+			# paragraph here if needed:
+			print "\n";
+		}
 	}
 	$$commented_newline = 0;
 	# Consider \makeatletter only in preamble, because we do want
@@ -187,6 +201,12 @@
 		print STDERR "Warning: $file.\n";
 		print STDERR "Warning: consider using --makeatletter if the result is not compilable.\n";
 	}
+
+        # non-comment is a sequence of:
+        # - escaped character (\\.), including \% and \\
+        # - neither '%' nor '\'.
+        my $NON_COMMENT = '([^\\\\%]|\\\\.)*';
+
 	unless ($keep_comments) {
 		if (!$empty_comments) {
 			# Include \n in pattern to avoid matching
@@ -197,23 +217,26 @@
 				$$commented_newline = 1;
 			}
 
-			# remove only the comment if the line has actual content
-			if (s/([^\\])%.*\n/$1/) {
+			# Special-case commands at end of line. We
+			# don't want "\\foo%\nbar" to become
+			# "\\foobar"
+			if (s/^($NON_COMMENT\\[[:alpha:]@]+)%.*\n/$1 /) {
 				$$commented_newline = 1;
+			} elsif (s/^($NON_COMMENT)%.*\n/$1/) {
+				# remove only the comment if the line has actual content
+				$$commented_newline = 1;
 			}
 		}
 		# Apply the "empty comments" treatment unconditionally
-		# for end-of-files comments not matched above (it
-		# doesn't harm to keep an empty comment sometimes, but
-		# it may harm to leave a real comment if the goal was
-		# to strip them).
-		s/^%.*$/%/;
-		s/([^\\])%.*$/$1%/;
+		# for comments not matched above (it doesn't harm to
+		# keep an empty comment sometimes, but it may harm to
+		# leave a real comment if the goal was to strip them).
+		s/^(([^\\%]|\\.)*)%.*$/$1%/;
 	}
 
 	unless ($keep_includes) {
 		if (my ($before, $ignored, $full_filename, $after)
-		    = /^(([^%]|[^\\]%)*)\\include[{\s]+(.*?)[\s}](.*)$/) {
+		    = /^($NON_COMMENT)\\include[{\s]+(.*?)[\s}](.*)$/) {
 			$full_filename = find_tex_file($full_filename . ".tex");
 			if ($full_filename) {
 				say $prefix . "Found include for file: $full_filename\n";
@@ -231,7 +254,7 @@
 				$_ = "";
 			}
 		} elsif (my ($before, $ignored, $full_filename, $after)
-			 = /^(([^%]|[^\\]%)*)\\input[{\s]+(.*?)[\s}](.*)$/) {
+			 = /^($NON_COMMENT)\\input[{\s]+(.*?)[\s}](.*)$/) {
                         if ($inside_import) {
                               $full_filename = $inside_import . $full_filename;
                         }
@@ -255,7 +278,7 @@
 				$_ = "";
 			}
 		} elsif (my ($before, $ignored, $dir, $full_filename, $after)
-			 = /^(([^%]|[^\\]%)*)\\(?:sub)?import[{\s]+(.*?)[\s}][{\s]+(.*?)[\s}](.*)$/) {
+			 = /^($NON_COMMENT)\\(?:sub)?import[{\s]+(.*?)[\s}][{\s]+(.*?)[\s}](.*)$/) {
                         if ($explain) {
                               print "% dir " . $dir ."\n";
                               print "% full_filename " . $full_filename ."\n";
@@ -290,7 +313,7 @@
 				$_ = "";
 			}
 		} elsif (my ($before, $ignored, $args, $full_filename, $after)
-			 = /^(([^%]|[^\\]%)*)\\includegraphics[\[\s]+(.*?)[\s\]][{\s]+(.*?)[\s}](.*)$/) {
+			 = /^($NON_COMMENT)\\includegraphics[\[\s]+(.*?)[\s\]][{\s]+(.*?)[\s}](.*)$/) {
                         if ($explain) {
                                 print "% inside_import " . $inside_import ."\n";
                                 print "% before " . $before ."\n";
@@ -305,7 +328,7 @@
                                 $_ = "";
                         }
 		} elsif (my ($before, $ignored, $args, $full_filename, $after)
-			 = /^(([^%]|[^\\]%)*)\\lstinputlisting[\[\s]+(.*?)[\s\]][{\s]+(.*?)[\s}](.*)$/) {
+			 = /^($NON_COMMENT)\\lstinputlisting[\[\s]+(.*?)[\s\]][{\s]+(.*?)[\s}](.*)$/) {
                         if ($explain) {
                                 print "% inside_import " . $inside_import ."\n";
                                 print "% before " . $before ."\n";
@@ -461,6 +484,12 @@
 	                 rare cases it may break your document, but it
 	                 may help fixing bad interactions between
 	                 @-commands and inclusion (see BUGS section).
+	--in-encoding FMT, --out-encoding FMT
+			 File encoding used by input and output files.
+			 This uses the same syntax as PerlIO's layers.
+			 Example:
+			 --in-encoding 'encoding(UTF-8)'
+			 The default is 'bytes' and should always work.
 
 =head1 USES
 
@@ -548,4 +577,4 @@
 
 =head1 VERSION
 
-This is latexpand version v1.4-1-gb32a776.
+This is latexpand version v1.5.

Modified: trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl	2019-02-20 22:43:27 UTC (rev 50078)
+++ trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl	2019-02-20 22:43:45 UTC (rev 50079)
@@ -1,12 +1,12 @@
 #!/usr/bin/env perl
-# $Id: tlmgr.pl 49885 2019-01-31 19:27:00Z karl $
+# $Id: tlmgr.pl 49997 2019-02-10 23:50:35Z karl $
 #
 # Copyright 2008-2019 Norbert Preining
 # This file is licensed under the GNU General Public License version 2
 # or any later version.
 
-my $svnrev = '$Revision: 49885 $';
-my $datrev = '$Date: 2019-01-31 11:27:00 -0800 (Thu, 31 Jan 2019) $';
+my $svnrev = '$Revision: 49997 $';
+my $datrev = '$Date: 2019-02-11 00:50:35 +0100 (Mon, 11 Feb 2019) $';
 my $tlmgrrevision;
 my $tlmgrversion;
 my $prg;
@@ -9761,7 +9761,7 @@
 distribution (L<https://tug.org/texlive>) and both are licensed under the
 GNU General Public License Version 2 or later.
 
-$Id: tlmgr.pl 49885 2019-01-31 19:27:00Z karl $
+$Id: tlmgr.pl 49997 2019-02-10 23:50:35Z karl $
 =cut
 
 # test HTML version: pod2html --cachedir=/tmp tlmgr.pl >/tmp/tlmgr.html

Modified: trunk/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl	2019-02-20 22:43:27 UTC (rev 50078)
+++ trunk/Build/source/texk/texlive/linked_scripts/tlshell/tlshell.tcl	2019-02-20 22:43:45 UTC (rev 50079)
@@ -27,8 +27,6 @@
   unset texbin
   unset savedir
   unset dirs
-  # now is a good time to ask tlmgr for the _TL_ name of our platform
-  set ::our_platform [exec tlmgr print-platform]
 }
 
 # declarations and utilities shared with install-tl-gui.tcl
@@ -35,6 +33,9 @@
 set ::instroot [exec kpsewhich -var-value=TEXMFROOT]
 source [file join $::instroot "tlpkg" "tltcl" "tltcl.tcl"]
 
+# now is a good time to ask tlmgr for the _TL_ name of our platform
+set ::our_platform [exec -ignorestderr tlmgr print-platform]
+
 # searchpath and locale:
 # windows: most scripts run via [w]runscript, which adjusts the searchpath
 # for the current process.
@@ -144,7 +145,7 @@
   if {$type eq "yesnocancel"} {
     ttk::button .tlmg.yes -text [__ "Yes"] -command "end_dlg \"yes\" .tlmg"
     ppack .tlmg.yes -in .tlmg.bts -side right
-    ttk::button .tlmg.no -text [__ "no"] -command "end_dlg \"no\" .tlmg"
+    ttk::button .tlmg.no -text [__ "No"] -command "end_dlg \"no\" .tlmg"
     ppack .tlmg.no -in .tlmg.bts -side right
   }
   if {$type eq "yesnocancel" || $type eq "okcancel"} {
@@ -743,7 +744,7 @@
   }
   get_platforms
   set ::have_remote 1
-  .topf.loaded configure -text "Loaded" -foreground black
+  .topf.loaded configure -text [__ "Loaded"] -foreground black
   update_globals
   return 1
 } ; # get_packages_info_remote
@@ -1594,8 +1595,10 @@
     }
   }
   if {[llength $deps] > 0} {
-    set ans [any_message \
-        [__ "Also installing dependencies\n\n$deps.\n\nContinue?"] "okcancel"]
+    set ans \
+        [any_message \
+             [__ "Also installing dependencies\n\n%s" $deps] \
+             "okcancel"]
     if {$ans eq "cancel"} return
   }
   run_cmd "install $todo" 1
@@ -1989,14 +1992,14 @@
   menu .mn.opt
   set inx -1
   incr inx
-  .mn.opt add command -label "[__ "Repositories"]..." \
+  .mn.opt add command -label "[__ "Repositories"] ..." \
       -command repository_dialog
 
   incr inx
-  .mn.opt add cascade -label [__ "Paper"] -menu .mn.opt.paper
+  .mn.opt add cascade -label [__ "Paper ..."] -menu .mn.opt.paper
   incr inx
   menu .mn.opt.paper
-  foreach p [list a4 letter] {
+  foreach p [list A4 letter] {
     .mn.opt.paper add command -label $p -command "set_paper $p"
   }
 
@@ -2013,7 +2016,7 @@
   if {$::tcl_platform(platform) ne "windows"} {
     incr inx
     set ::inx_platforms $inx
-    .mn.opt add command -label "[__ "Platforms"]..." -command platforms_select
+    .mn.opt add command -label "[__ "Platforms"] ..." -command platforms_select
   }
 
   .mn add cascade -label [__ "Help"] -menu .mn.help -underline 0
@@ -2129,7 +2132,7 @@
   pgrid .mrk_rem -in .pkfilter -column 4 -row $rw -sticky ew
   if $::do_restore {
     incr rw
-    ttk::button .mrk_rest -text [__ "Restore from backup..."] -command \
+    ttk::button .mrk_rest -text "[__ "Restore from backup"] ..." -command \
         restore_backups_dialog
     pgrid .mrk_rest -in .pkfilter -column 4 -row $rw -sticky ew
   }
@@ -2162,8 +2165,8 @@
       -yscrollcommand {.pkvsb set}
   .pkglist heading mk -text "" -anchor w
   .pkglist heading name -text [__ "Name"] -anchor w
-  .pkglist heading localrev -text [__ "Local Rev. (ver.)"] -anchor w
-  .pkglist heading remoterev -text [__ "Remote Rev. (ver.)"] -anchor w
+  .pkglist heading localrev -text [__ "Local rev. (ver.)"] -anchor w
+  .pkglist heading remoterev -text [__ "Remote rev. (ver.)"] -anchor w
   .pkglist heading shortdesc -text [__ "Description"] -anchor w
   .pkglist column mk -width [expr {$::cw * 3}] -stretch 0
   .pkglist column name -width [expr {$::cw * 25}] -stretch 1

Modified: trunk/Master/texmf-dist/doc/support/latexpand/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexpand/README	2019-02-20 22:43:27 UTC (rev 50078)
+++ trunk/Master/texmf-dist/doc/support/latexpand/README	2019-02-20 22:43:45 UTC (rev 50079)
@@ -33,6 +33,12 @@
                              rare cases it may break your document, but it
                              may help fixing bad interactions between
                              @-commands and inclusion (see BUGS section).
+            --in-encoding FMT, --out-encoding FMT
+                             File encoding used by input and output files.
+                             This uses the same syntax as PerlIO's layers.
+                             Example:
+                             --in-encoding 'encoding(UTF-8)'
+                             The default is 'bytes' and should always work.
 
 USES
     The most common use of latexpand is to simplify distribution of source
@@ -111,5 +117,5 @@
     https://lacl.fr/~caubert/notes/portabilite-du-tex.html#dependances
 
 VERSION
-    This is latexpand version v1.4-1-gb32a776.
+    This is latexpand version v1.5.
 

Modified: trunk/Master/texmf-dist/doc/support/latexpand/version.txt
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexpand/version.txt	2019-02-20 22:43:27 UTC (rev 50078)
+++ trunk/Master/texmf-dist/doc/support/latexpand/version.txt	2019-02-20 22:43:45 UTC (rev 50079)
@@ -1,2 +1,2 @@
-latexpand version v1.4-1-gb32a776 (b32a776232b22f2ece1ca41628273e16022129d9).
-Committed on Wed Apr 18 15:44:06 2018 +0200.
+latexpand version v1.5 (be890116022866564388af207e11f4b5b962d57d).
+Committed on Sat Feb 16 08:42:38 2019 +0100.

Modified: trunk/Master/texmf-dist/scripts/latexpand/latexpand
===================================================================
--- trunk/Master/texmf-dist/scripts/latexpand/latexpand	2019-02-20 22:43:27 UTC (rev 50078)
+++ trunk/Master/texmf-dist/scripts/latexpand/latexpand	2019-02-20 22:43:45 UTC (rev 50079)
@@ -28,6 +28,8 @@
 my $version;
 my $makeatletter;
 my $inside_import;
+my $in_enc = "bytes";
+my $out_enc = "bytes";
 
 GetOptions (
 	'h' => \$help,
@@ -45,6 +47,8 @@
 	'fatal' => \$fatal,
 	'version' => \$version,
         'makeatletter' => \$makeatletter,
+	'in-encoding=s' => \$in_enc,
+	'out-encoding=s' => \$out_enc,
 ) or pod2usage_wrapper(2);
 version() if $version;
 pod2usage_wrapper(0) if $help;
@@ -76,7 +80,7 @@
 {
 	# $VERSION's value will be substituted by 'make dist', but the
 	# next line won't (the string has to be broken to avoid it).
-	my $VERSION = 'v1.4-1-gb32a776';
+	my $VERSION = 'v1.5';
 	if ($VERSION eq '@LATEXPAND' . '_VERSION@') {
 		my($vol,$dir,$file) = File::Spec->splitpath($0);
 		chdir($dir);
@@ -115,6 +119,8 @@
 my $makeatletter_found;
 my $in_preamble;
 
+use open IN  => ":$in_enc", OUT => ":$out_enc";
+
 foreach my $file (@ARGV)
 {
 	say "processing $file\n";
@@ -159,18 +165,26 @@
 {
 	my ($line, $prefix, $commented_newline, $file) = @_;
 	$_ = $line;
-	if ($$commented_newline && /^\s*$/) {
-		# Deal with:
-		#
-		# Line 1 % comment
-		#
-		# Line 2
-		#
-		# The newline after Line 1 is commented, but we still
-		# want a new paragraph. We strip the comment together
-		# with its newline, but re-add a newline to chnge
-		# paragraph here if needed:
-		print "\n";
+	if ($$commented_newline) {
+		# Leading whitespaces after a comment is ignored.
+		# There's no space in:
+		# Line 1%
+		#    Line 2.
+		# Match just space and tabs (\s would match \n)
+		s/^[ \t]*//;
+		if (/^$/) {
+			# Deal with:
+			#
+			# Line 1 % comment
+			#
+			# Line 2
+			#
+			# The newline after Line 1 is commented, but we still
+			# want a new paragraph. We strip the comment together
+			# with its newline, but re-add a newline to chnge
+			# paragraph here if needed:
+			print "\n";
+		}
 	}
 	$$commented_newline = 0;
 	# Consider \makeatletter only in preamble, because we do want
@@ -187,6 +201,12 @@
 		print STDERR "Warning: $file.\n";
 		print STDERR "Warning: consider using --makeatletter if the result is not compilable.\n";
 	}
+
+        # non-comment is a sequence of:
+        # - escaped character (\\.), including \% and \\
+        # - neither '%' nor '\'.
+        my $NON_COMMENT = '([^\\\\%]|\\\\.)*';
+
 	unless ($keep_comments) {
 		if (!$empty_comments) {
 			# Include \n in pattern to avoid matching
@@ -197,23 +217,26 @@
 				$$commented_newline = 1;
 			}
 
-			# remove only the comment if the line has actual content
-			if (s/([^\\])%.*\n/$1/) {
+			# Special-case commands at end of line. We
+			# don't want "\\foo%\nbar" to become
+			# "\\foobar"
+			if (s/^($NON_COMMENT\\[[:alpha:]@]+)%.*\n/$1 /) {
 				$$commented_newline = 1;
+			} elsif (s/^($NON_COMMENT)%.*\n/$1/) {
+				# remove only the comment if the line has actual content
+				$$commented_newline = 1;
 			}
 		}
 		# Apply the "empty comments" treatment unconditionally
-		# for end-of-files comments not matched above (it
-		# doesn't harm to keep an empty comment sometimes, but
-		# it may harm to leave a real comment if the goal was
-		# to strip them).
-		s/^%.*$/%/;
-		s/([^\\])%.*$/$1%/;
+		# for comments not matched above (it doesn't harm to
+		# keep an empty comment sometimes, but it may harm to
+		# leave a real comment if the goal was to strip them).
+		s/^(([^\\%]|\\.)*)%.*$/$1%/;
 	}
 
 	unless ($keep_includes) {
 		if (my ($before, $ignored, $full_filename, $after)
-		    = /^(([^%]|[^\\]%)*)\\include[{\s]+(.*?)[\s}](.*)$/) {
+		    = /^($NON_COMMENT)\\include[{\s]+(.*?)[\s}](.*)$/) {
 			$full_filename = find_tex_file($full_filename . ".tex");
 			if ($full_filename) {
 				say $prefix . "Found include for file: $full_filename\n";
@@ -231,7 +254,7 @@
 				$_ = "";
 			}
 		} elsif (my ($before, $ignored, $full_filename, $after)
-			 = /^(([^%]|[^\\]%)*)\\input[{\s]+(.*?)[\s}](.*)$/) {
+			 = /^($NON_COMMENT)\\input[{\s]+(.*?)[\s}](.*)$/) {
                         if ($inside_import) {
                               $full_filename = $inside_import . $full_filename;
                         }
@@ -255,7 +278,7 @@
 				$_ = "";
 			}
 		} elsif (my ($before, $ignored, $dir, $full_filename, $after)
-			 = /^(([^%]|[^\\]%)*)\\(?:sub)?import[{\s]+(.*?)[\s}][{\s]+(.*?)[\s}](.*)$/) {
+			 = /^($NON_COMMENT)\\(?:sub)?import[{\s]+(.*?)[\s}][{\s]+(.*?)[\s}](.*)$/) {
                         if ($explain) {
                               print "% dir " . $dir ."\n";
                               print "% full_filename " . $full_filename ."\n";
@@ -290,7 +313,7 @@
 				$_ = "";
 			}
 		} elsif (my ($before, $ignored, $args, $full_filename, $after)
-			 = /^(([^%]|[^\\]%)*)\\includegraphics[\[\s]+(.*?)[\s\]][{\s]+(.*?)[\s}](.*)$/) {
+			 = /^($NON_COMMENT)\\includegraphics[\[\s]+(.*?)[\s\]][{\s]+(.*?)[\s}](.*)$/) {
                         if ($explain) {
                                 print "% inside_import " . $inside_import ."\n";
                                 print "% before " . $before ."\n";
@@ -305,7 +328,7 @@
                                 $_ = "";
                         }
 		} elsif (my ($before, $ignored, $args, $full_filename, $after)
-			 = /^(([^%]|[^\\]%)*)\\lstinputlisting[\[\s]+(.*?)[\s\]][{\s]+(.*?)[\s}](.*)$/) {
+			 = /^($NON_COMMENT)\\lstinputlisting[\[\s]+(.*?)[\s\]][{\s]+(.*?)[\s}](.*)$/) {
                         if ($explain) {
                                 print "% inside_import " . $inside_import ."\n";
                                 print "% before " . $before ."\n";
@@ -461,6 +484,12 @@
 	                 rare cases it may break your document, but it
 	                 may help fixing bad interactions between
 	                 @-commands and inclusion (see BUGS section).
+	--in-encoding FMT, --out-encoding FMT
+			 File encoding used by input and output files.
+			 This uses the same syntax as PerlIO's layers.
+			 Example:
+			 --in-encoding 'encoding(UTF-8)'
+			 The default is 'bytes' and should always work.
 
 =head1 USES
 
@@ -548,4 +577,4 @@
 
 =head1 VERSION
 
-This is latexpand version v1.4-1-gb32a776.
+This is latexpand version v1.5.



More information about the tex-live-commits mailing list