bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fwd: REVIEW REQUEST - user manual generation


From: Vincent Belaïche
Subject: Re: Fwd: REVIEW REQUEST - user manual generation
Date: Fri, 29 Apr 2016 10:27:43 +0200


Le 29/04/2016 08:55, Vincent Belaïche a écrit :
>
>
> Le 29/04/2016 00:42, Karl Berry a écrit :
>>     <>| are not valid in filenames
>>
>> They are on Unix.  -k
>
>

[...]

>
> However, instead of <>| I could use
>
> \bgroup for group beginning
> \egroup for group end
> nul     for space.
>

[...]

>
>   Vincent.

Attached is an attempt to do that. Unfortunately using \egroup for group
end does not work, because whether it is a \toks or a \def you need the
the end of the definition terminated by a catcode=2 character.

So, I need only one forbidden character in filenames (in addition to
backslash) to make it.

   Vincent.


Index: texi2dvi

===================================================================

--- texi2dvi    (revision 7139)

+++ texi2dvi    (working copy)

@@ -889,8 +889,10 @@

   # resetting their catcodes to other on the command line and changing
   # texinfo.tex to initialize everything to plain catcodes.  Maybe someday.
 
-  # append the \input command.
-  tex_cmd="$tex_cmd '${escape}input'"
+  # append the \input + input filename.
+  if test $# -gt 0; then
+    tex_cmd="$tex_cmd '${escape}input' '$1'"
+  fi
 }
 
 # run_tex - Run TeX as "$tex $in_input", taking care of errors and logs.
@@ -918,14 +920,44 @@

         run rm -f "$_run_tex_file_name"
         run ln -s "$in_input"
       fi
-      tex_cmd="$tex_cmd '$_run_tex_file_name'"
       ;;
 
     *)
-      tex_cmd="$tex_cmd '$in_input'"
+      _run_tex_file_name="$in_input"
       ;;
   esac
 
+
+  # Make input filename relative, in order to alleviate risk of spaces
+  # in name
+  _run_tex_cur_dir=`pwd`
+  case "$_run_tex_file_name" in
+    *"$_run_tex_cur_dir"*)
+      # escape special characters
+      _run_tex_cur_dir=`echo "$_run_tex_cur_dir" | $SED -e 
's/\([.$^\]\)/\\\1/g'`
+      _run_tex_file_name=`echo "$_run_tex_file_name" | $SED -e 
"s<^$_run_tex_cur_dir/<./<1"`
+    ;;
+  esac
+
+  # If there are still spaces remaining the the input file name, we
+  # try double quoting, this is tex implementation and OS dependent,
+  # so that trick may not work always.
+  case "$_run_tex_file_name" in
+    *" "*)
+      _run_tex_dq='"'
+      ;;
+    *)
+      _run_tex_dq=
+      ;;
+  esac
+  #                                          >=}                  nul=space
+  tex_cmd="$tex_cmd '${escape}bgroup${escape}catcode62=2 ${escape}catcode0=10"
+  # make letter {   }   $  #  ~   space(must be last in this list)
+  for w in      123 125 36 35 126 32; do
+    tex_cmd="$tex_cmd ${escape}catcode$w=11";
+  done
+  
tex_cmd="$tex_cmd^^00${escape}toks0${escape}bgroup${escape}input^^00$_run_tex_dq$_run_tex_file_name$_run_tex_dq${escape}relax>${escape}expandafter${escape}egroup${escape}the${escape}toks0^^00'"
+
   verbose "$0: Running $tex_cmd ..."
   if eval "$tex_cmd" >&5; then
     case $out_lang in
@@ -1479,10 +1511,9 @@

     save_batch=$batch
     catcode_special=false
     batch=true
-    make_tex_cmd
+    make_tex_cmd ./openout.tex
     catcode_special=$save_catcode_special
     batch=$save_batch
-    tex_cmd="$tex_cmd ./openout.tex"
     # ./ in case . isn't in path
     verbose "$0: running $tex_cmd ..."
     rm -fr "openout.$2"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]