Ticket #43617: texinfo-norecode.diff

File texinfo-norecode.diff, 16.3 KB (added by mojca (Mojca Miklavec), 10 years ago)

patch to the latest unreleased version of texi2dvi to avoid problems with sed

  • Portfile

     
    55
    66name                texinfo
    77version             5.2
     8revision            1
    89categories          textproc
    910platforms           darwin
    1011license             GPL-3+
     
    3334checksums           rmd160  564fb99e6876f982cc03c8570f88edc8100d3aab \
    3435                    sha256  5471ef683a64588a7cfef46ef2bdd3fbcbca89d847e10832612293f105e44eda
    3536
     37patchfiles          patch-util-texi2dvi.diff
     38
    3639destroot.target-append  install-tex
    3740destroot.args           TEXMF=${prefix}/share/texmf
    3841
  • files/patch-util-texi2dvi.diff

     
     1http://ftp.gnu.org/gnu/texinfo/texi2dvi
     2http://svn.savannah.gnu.org/viewvc?view=rev&root=texinfo&revision=5704
     3
     4When the next release of texinfo comes out, keep the patch
     5        : ${SED=sed} => : ${SED=gsed}
     6
     7--- util/texi2dvi.orig
     8+++ util/texi2dvi
     9@@ -1,9 +1,9 @@
     10 #! /bin/sh
     11 # texi2dvi --- produce DVI (or PDF) files from Texinfo (or (La)TeX) sources.
     12-# $Id: texi2dvi 5381 2013-09-26 23:03:58Z karl $
     13+# $Id: texi2dvi 5704 2014-07-07 17:45:16Z karl $
     14 #
     15 # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
     16-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
     17+# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
     18 # Free Software Foundation, Inc.
     19 #
     20 # This program is free software; you can redistribute it and/or modify
     21@@ -33,10 +33,13 @@ unset RUNNING_KSH
     22 # No failure shall remain unpunished.
     23 set -e
     24 
     25+# In case the default sed doesn't suffice.
     26+: ${SED=gsed}
     27+
     28 # This string is expanded automatically when this file is checked out.
     29-rcs_revision='$Revision: 5381 $'
     30+rcs_revision='$Revision: 5704 $'
     31 rcs_version=`set - $rcs_revision; echo $2`
     32-program=`echo $0 | sed -e 's!.*/!!'`
     33+program=`echo $0 | $SED -e 's!.*/!!'`
     34 
     35 build_mode=${TEXI2DVI_BUILD_MODE:-local}
     36 build_dir=${TEXI2DVI_BUILD_DIRECTORY:-.}
     37@@ -52,11 +55,10 @@ escape="\\"
     38 expand=false    # true for expansion via makeinfo
     39 includes=
     40 line_error=true # pass --file-line-error to TeX
     41-max_iters=-1    # keep going forever
     42+max_iters=7     # when to quit
     43 oname=          # --output
     44 out_lang=dvi
     45 quiet=false     # let the tools' message be displayed
     46-recode=false
     47 set_language=
     48 src_specials=
     49 shell_escape=
     50@@ -65,7 +67,6 @@ textra=         # Extra TeX commands to insert in the input file.
     51 txiprereq=19990129 # minimum texinfo.tex version with macro expansion
     52 verb=false      # true for verbose mode
     53 translate_file= # name of charset translation file
     54-recode_from=    # if not empty, recode from this encoding to @documentencoding
     55 
     56 orig_pwd=`pwd`
     57 
     58@@ -162,7 +163,7 @@ cd_orig ()
     59 func_dirname ()
     60 {
     61   dirname "$1" 2>/dev/null \
     62-  || { echo "$1" | sed 's!/[^/]*$!!;s!^$!.!'; }
     63+  || { echo "$1" | $SED 's!/[^/]*$!!;s!^$!.!'; }
     64 }
     65 
     66 
     67@@ -171,7 +172,7 @@ func_dirname ()
     68 # Return FILE with one extension remove.  foo.bar.baz -> foo.bar.
     69 noext ()
     70 {
     71-  echo "$1" | sed -e 's/\.[^/.][^/.]*$//'
     72+  echo "$1" | $SED -e 's/\.[^/.][^/.]*$//'
     73 }
     74 
     75 
     76@@ -186,7 +187,7 @@ absolute ()
     77       echo "$1"
     78       ;;
     79    *) local slashes
     80-      slashes=`echo "$1" | sed -n 's,.*[^/]\(/*\)$,\1,p'`
     81+      slashes=`echo "$1" | $SED -n 's,.*[^/]\(/*\)$,\1,p'`
     82       local rel
     83       rel=$orig_pwd/`func_dirname "$1"`
     84       if test -d "$rel"; then
     85@@ -341,8 +342,6 @@ TeX tuning:
     86   -I DIR                     search DIR for Texinfo files
     87   -l, --language=LANG        specify LANG for FILE, either latex or texinfo
     88       --no-line-error        do not pass --file-line-error to TeX
     89-  -r, --recode               call recode before TeX to translate input
     90-      --recode-from=ENC      recode from ENC to the @documentencoding
     91       --shell-escape         pass --shell-escape to TeX
     92       --src-specials         pass --src-specials to TeX
     93   -t, --command=CMD          insert CMD in copy of input file
     94@@ -358,7 +357,7 @@ Build modes:
     95                          defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
     96   --mostly-clean       remove the auxiliary files and directories
     97                          but not the output
     98-  --max-iterations=N   don't process files more than N times
     99+  --max-iterations=N   don't process files more than N times [$max_iters]
     100 
     101 The MODE specifies where the TeX compilation takes place, and, as a
     102 consequence, how auxiliary files are treated.  The build mode
     103@@ -392,7 +391,7 @@ using \\graphicspath): in that case, use -I to specify the additional
     104 directories to consider.
     105 
     106 The values of the BIBER, BIBTEX, DVIPDF, DVIPS, HEVEA, LATEX, MAKEINDEX,
     107-MAKEINFO, PDFLATEX, PDFTEX, T4HT, TEX, TEX4HT, TEXINDEX, and THUMBPDF
     108+MAKEINFO, PDFLATEX, PDFTEX, SED, T4HT, TEX, TEX4HT, TEXINDEX, and THUMBPDF_CMD
     109 environment variables are used to run those commands, if they are set.
     110 
     111 Regarding --dvipdf, if DVIPDF is not set in the environment, the
     112@@ -430,7 +429,7 @@ version ()
     113   cat <<EOF
     114 texi2dvi (GNU Texinfo 5.2) $rcs_version
     115 
     116-Copyright (C) 2013 Free Software Foundation, Inc.
     117+Copyright (C) 2014 Free Software Foundation, Inc.
     118 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
     119 This is free software: you are free to change and redistribute it.
     120 There is NO WARRANTY, to the extent permitted by law.
     121@@ -472,7 +471,7 @@ list_concat_dirs ()
     122                        -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
     123   save_IFS=$IFS
     124   IFS=$path_sep
     125-  set x `echo "$2" | eval sed $replace_EMPTY`; shift
     126+  set x `echo "$2" | eval $SED $replace_EMPTY`; shift
     127   IFS=$save_IFS
     128   local dir
     129   for dir
     130@@ -614,7 +613,7 @@ absolute_filenames ()
     131                        -e 's/$path_sep\$/${path_sep}EMPTY/g' \
     132                        -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
     133   local res
     134-  res=`echo "$1" | eval sed $replace_empty`
     135+  res=`echo "$1" | eval $SED $replace_empty`
     136   save_IFS=$IFS
     137   IFS=$path_sep
     138   set x $res; shift
     139@@ -653,7 +652,7 @@ output_base_name ()
     140      *) local out_noext
     141         out_noext=`noext "$oname"`
     142         local file_ext
     143-        file_ext=`echo "$1" | sed 's/^.*\.//'`
     144+        file_ext=`echo "$1" | $SED 's/^.*\.//'`
     145         echo "$out_noext.$file_ext"
     146       ;;
     147   esac
     148@@ -775,7 +774,7 @@ bibaux_file_p ()
     149 index_file_p ()
     150 {
     151   test -f "$1" || return 1
     152-  case $in_lang:$latex2html:`out_lang_tex`:`sed '1q' "$1"` in
     153+  case $in_lang:$latex2html:`out_lang_tex`:`$SED '1q' "$1"` in
     154     # When working with TeX4HT, *.idx are created by LaTeX.  They must
     155     # be processed to produce *.4ix, *.4dx files.  The *.4dx file is
     156     # passed to makeindex to produce the *.ind file.  This sequence is
     157@@ -803,7 +802,7 @@ xref_file_p ()
     158   # process it.  It's suitable if the first character is a
     159   # backslash or right quote or at, as long as the first line isn't
     160   # \input texinfo.
     161-  case `sed '1q' "$1"` in
     162+  case `$SED '1q' "$1"` in
     163     "\\input texinfo"*) return 1;;
     164     [\\''@]*)           return 0;;
     165            *)           return 1;;
     166@@ -824,7 +823,7 @@ generated_files_get ()
     167   # Gather the files created by TeX.
     168   (
     169     if test -f "$1.log"; then
     170-      sed -n -e "s,^\\\\openout.* = \`\\(.*\\)'\\.,\\1,p" "$1.log"
     171+      $SED -n -e "s,^\\\\openout.* = \`\\(.*\\)'\\.,\\1,p" "$1.log"
     172     fi
     173     echo "$1.log"
     174   ) |
     175@@ -841,10 +840,10 @@ generated_files_get ()
     176       latex)
     177         if aux_file_p $file; then
     178           # bibtex: *.aux -> *.bbl and *.blg.
     179-          echo $file | sed 's/^\(.*\)\.aux$/\1.bbl/'
     180-          echo $file | sed 's/^\(.*\)\.aux$/\1.blg/'
     181+          echo $file | $SED 's/^\(.*\)\.aux$/\1.bbl/'
     182+          echo $file | $SED 's/^\(.*\)\.aux$/\1.blg/'
     183           # -recorder: .fls
     184-          echo $file | sed 's/^\(.*\)\.aux$/\1.fls/'
     185+          echo $file | $SED 's/^\(.*\)\.aux$/\1.fls/'
     186        fi
     187        ;;
     188     esac
     189@@ -915,10 +914,10 @@ xref_files_changed ()
     190 
     191   # Compare each file until we find a difference.
     192   for this_file in $xref_files_new; do
     193-    verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
     194+    verbose "Comparing xref file `echo $this_file | $SED 's|\./||g'` ..."
     195     # cmp -s returns nonzero exit status if files differ.
     196     if cmp -s "$this_file" "$work_bak/$this_file"; then :; else
     197-      verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
     198+      verbose "xref file `echo $this_file | $SED 's|\./||g'` differed ..."
     199       if $debug; then
     200         diff -u "$work_bak/$this_file" "$this_file"
     201       fi
     202@@ -972,7 +971,7 @@ run_tex ()
     203   # subdirectory to exist.
     204   case $in_lang:$tidy in
     205     latex:true)
     206-       sed -n 's|^[ ]*\\include{\(.*\)/.*}.*|\1|p' "$in_input" |
     207+       $SED -n 's|^[ ]*\\include{\(.*\)/.*}.*|\1|p' "$in_input" |
     208        sort -u |
     209        while read d
     210        do
     211@@ -1103,14 +1102,15 @@ run_bibtex ()
     212   # bibtex would never be run.
     213   if test -r "$in_noext.aux" \
     214      && test -r "$in_noext.log" \
     215-     && ((grep 'Warning:.*Citation.*undefined' "$in_noext.log" \
     216+     && ( (grep 'Warning:.*Citation.*undefined' "$in_noext.log" \
     217           || grep '.*Undefined citation' "$in_noext.log" \
     218           || grep 'No file .*\.bbl\.' "$in_noext.log") \
     219           || (grep 'No \.aux file' "$in_noext.log" \
     220-              && grep '^\\bibdata' "$in_noext.aux")) \
     221+              && grep '^\\bibdata' "$in_noext.aux") ) \
     222         >&6 2>&1; \
     223   then
     224-    for f in `generated_files_get "$in_noext" bibaux_file_p`; do
     225+    bibtex_aux=`generated_files_get "$in_noext" bibaux_file_p`
     226+    for f in $bibtex_aux; do
     227       run $bibtex "$f"
     228     done
     229   fi
     230@@ -1199,7 +1199,7 @@ run_thumbpdf ()
     231      && test -r "$in_noext.log" \
     232      && grep 'thumbpdf\.sty'  "$in_noext.log" >&6 2>&1; \
     233   then
     234-    thumbpdf=${THUMBPDF:-thumbpdf}
     235+    thumbpdf=${THUMBPDF_CMD:-thumbpdf}
     236     thumbcmd="$thumbpdf $in_dir/$in_noext"
     237     verbose "Running $thumbcmd ..."
     238     if $thumbcmd >&5; then
     239@@ -1229,7 +1229,7 @@ run_dvipdf ()
     240   # 'input -o output'.  They all seem to accept 'input' only,
     241   # outputting using the expected file name.
     242   run $dvipdf "$1"
     243-  if test ! -f `echo "$1" | sed -e 's/\.dvi$/.pdf/'`; then
     244+  if test ! -f `echo "$1" | $SED -e 's/\.dvi$/.pdf/'`; then
     245     error 1 "cannot find output file"
     246   fi
     247 }
     248@@ -1261,9 +1261,9 @@ run_tex_suite ()
     249 
     250     xref_files_save
     251 
     252-    # We run bibtex first, because I can see reasons for the indexes
     253-    # to change after bibtex is run, but I see no reason for the
     254-    # converse.
     255+    # We run bibtex first, because it's more likely for the indexes
     256+    # to change after bibtex is run than the reverse, though either
     257+    # would be rare.
     258     run_bibtex
     259     run_index
     260     run_core_conversion
     261@@ -1376,7 +1376,7 @@ to tex itself simply not working."
     262       cat "$version_test_dir/txiversion.err" >&2
     263       error 1 "quitting."
     264     fi
     265-    eval `sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' "$version_test_dir/txiversion.out"`
     266+    eval `$SED -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' "$version_test_dir/txiversion.out"`
     267     verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
     268     if test "$txiprereq" -le "$txiversion" >&6 2>&1; then
     269       makeinfo=
     270@@ -1402,10 +1402,10 @@ to tex itself simply not working."
     271     # (running missing) and then we end up with things like '"-I"',
     272     # and "-I" (including the quotes) is not an option name.  This
     273     # happens with gettext 0.14.5, at least.
     274-    sed "$comment_iftex" "$command_line_filename" \
     275+    $SED "$comment_iftex" "$command_line_filename" \
     276       | eval $makeinfo --footnote-style=end -I "$in_dir" $miincludes \
     277         -o /dev/null --macro-expand=- \
     278-      | sed "$uncomment_iftex" >"$in_src"
     279+      | $SED "$uncomment_iftex" >"$in_src"
     280     # Continue only if everything succeeded.
     281     if test $? -ne 0 \
     282        || test ! -r "$in_src"; then
     283@@ -1433,7 +1433,7 @@ insert_commands ()
     284       texinfo) textra_cmd='/^@setfilename/a';;
     285       *)       error 1 "internal error, unknown language: $in_lang";;
     286     esac
     287-    sed "$textra_cmd\\
     288+    $SED "$textra_cmd\\
     289 $textra" "$in_input" >"$in_xtr"
     290     in_input=$in_xtr
     291   fi
     292@@ -1453,45 +1453,6 @@ $textra" "$in_input" >"$in_xtr"
     293   esac
     294 }
     295 
     296-# run_recode ()
     297-# -------------
     298-# If this is a Texinfo file with a specified input encoding, and
     299-# recode is available, then recode to plain 7 bit Texinfo.
     300-run_recode ()
     301-{
     302-  local from
     303-  local to
     304-
     305-  if test $in_lang = texinfo; then
     306-    pgm='s/^ *@documentencoding  *\([^ ][^ ]*\) *$/\1/
     307-        t found
     308-        d
     309-        :found
     310-        q'
     311-    encoding=`sed -e "$pgm" "$in_input"`
     312-    if $recode && test -n "$encoding" && findprog recode; then
     313-      if test -n "$recode_from"; then
     314-        from=$recode_from
     315-        to=$encoding
     316-      else
     317-        from=$encoding
     318-        to=$texinfo
     319-      fi
     320-      verbose "Recoding from $from to $to."
     321-      # _rcd.  The Texinfo file recoded in 7bit.
     322-      work_rcd=$workdir/recode
     323-      in_rcd=$work_rcd/$in_base
     324-      ensure_dir "$work_rcd"
     325-      if recode "$encoding..$to" <"$in_input" >"$in_rcd" \
     326-         && test -s "$in_rcd"; then
     327-        in_input=$in_rcd
     328-      else
     329-        verbose "Recoding failed, using original input."
     330-      fi
     331-    fi
     332-  fi
     333-}
     334-
     335 # compute_language FILENAME
     336 # -------------------------
     337 # Return the short string describing the language in which FILENAME
     338@@ -1503,7 +1464,7 @@ compute_language ()
     339   # Otherwise, guess from the file extension.
     340   if test -n "$set_language"; then
     341     echo $set_language
     342-  elif sed 1q "$1" | grep 'input texinfo' >&6; then
     343+  elif $SED 1q "$1" | grep 'input texinfo' >&6; then
     344     echo texinfo
     345   else
     346     # Get the type of the file (latex or texinfo) from the given language
     347@@ -1618,9 +1579,6 @@ compile ()
     348   # --command, --texinfo
     349   insert_commands
     350 
     351-  # --recode
     352-  run_recode
     353-
     354   # Run until a fix point is reached.
     355   run_tex_suite
     356 }
     357@@ -1689,14 +1647,13 @@ while test x"$1" != x"$arg_sep"; do
     358   # Handle --option=value by splitting apart and putting back on argv.
     359   case "$1" in
     360     --*=*)
     361-      opt=`echo "$1" | sed -e 's/=.*//'`
     362-      val=`echo "$1" | sed -e 's/[^=]*=//'`
     363+      opt=`echo "$1" | $SED -e 's/=.*//'`
     364+      val=`echo "$1" | $SED -e 's/[^=]*=//'`
     365       shift
     366       set dummy "$opt" "$val" ${1+"$@"}; shift
     367       ;;
     368   esac
     369 
     370-  # This recognizes --quark as --quiet.  Oh well.
     371   case "$1" in
     372     -@ ) escape=@;;
     373     -~ ) catcode_special=false;;
     374@@ -1721,17 +1678,15 @@ while test x"$1" != x"$arg_sep"; do
     375     # Output formats.
     376     -O|--output-format) shift; out_lang_set "$1";;
     377        --dvi|--dvipdf|--html|--info|--pdf|--ps|--text)
     378-       out_lang_set `echo "x$1" | sed 's/^x--//'`;;
     379+       out_lang_set `echo "x$1" | $SED 's/^x--//'`;;
     380 
     381     -p) out_lang_set pdf;;
     382     -q | -s | --quiet | --silent) quiet=true; batch=true;;
     383-    -r | --recode) recode=true;;
     384-    --recode-from) shift; recode=true; recode_from="$1";;
     385     --src-specials) src_specials=--src-specials;;
     386     --shell-escape) shell_escape=--shell-escape;; 
     387     --tex4ht) latex2html=tex4ht;;
     388     -t | --texinfo | --command ) shift; textra="$textra\\
     389-"`echo "$1" | sed 's/\\\\/\\\\\\\\/g'`;;
     390+"`echo "$1" | $SED 's/\\\\/\\\\\\\\/g'`;;
     391     --translate-file ) shift; translate_file="$1";;
     392     --tidy) build_mode=tidy;;
     393     -v | --vers*) version;;
     394@@ -1858,7 +1813,7 @@ fi
     395 #   The input file name without extensions (nor directory part).
     396 # - IN_INPUT
     397 #   Defaults to COMMAND_LINE_FILENAME, but might change if the
     398-#   input is preprocessed (recode etc.).  With directory, possibly absolute.
     399+#   input is preprocessed.  With directory, possibly absolute.
     400 input_file_name_decode ()
     401 {
     402   # See if we are run from within AUC-Tex, in which case we are
     403@@ -1943,7 +1898,7 @@ do
     404          # has active characters.  Transform / into ! so that we don't
     405          # need `mkdir -p'.  It might be something to reconsider.
     406          t2ddir=$build_dir/`echo "$out_dir_abs/$out_noext.t2d" |
     407-             sed "s,^$orig_pwd/,,;s,^\./,,;s,/,!,g"`
     408+             $SED "s,^$orig_pwd/,,;s,^\./,,;s,/,!,g"`
     409   esac
     410   # Remove it at exit if clean mode.
     411   trap "cleanup" 0 1 2 15