Index: Portfile
===================================================================
--- Portfile	(revision 121933)
+++ Portfile	(working copy)
@@ -5,6 +5,7 @@
 
 name                texinfo
 version             5.2
+revision            1
 categories          textproc
 platforms           darwin
 license             GPL-3+
@@ -33,6 +34,8 @@
 checksums           rmd160  564fb99e6876f982cc03c8570f88edc8100d3aab \
                     sha256  5471ef683a64588a7cfef46ef2bdd3fbcbca89d847e10832612293f105e44eda
 
+patchfiles          patch-util-texi2dvi.diff
+
 destroot.target-append  install-tex
 destroot.args           TEXMF=${prefix}/share/texmf
 
Index: files/patch-util-texi2dvi.diff
===================================================================
--- files/patch-util-texi2dvi.diff	(revision 0)
+++ files/patch-util-texi2dvi.diff	(working copy)
@@ -0,0 +1,411 @@
+http://ftp.gnu.org/gnu/texinfo/texi2dvi
+http://svn.savannah.gnu.org/viewvc?view=rev&root=texinfo&revision=5704
+
+When the next release of texinfo comes out, keep the patch
+	: ${SED=sed} => : ${SED=gsed}
+
+--- util/texi2dvi.orig
++++ util/texi2dvi
+@@ -1,9 +1,9 @@
+ #! /bin/sh
+ # texi2dvi --- produce DVI (or PDF) files from Texinfo (or (La)TeX) sources.
+-# $Id: texi2dvi 5381 2013-09-26 23:03:58Z karl $
++# $Id: texi2dvi 5704 2014-07-07 17:45:16Z karl $
+ #
+ # Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
+-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
++# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
+ # Free Software Foundation, Inc.
+ #
+ # This program is free software; you can redistribute it and/or modify
+@@ -33,10 +33,13 @@ unset RUNNING_KSH
+ # No failure shall remain unpunished.
+ set -e
+ 
++# In case the default sed doesn't suffice.
++: ${SED=gsed}
++
+ # This string is expanded automatically when this file is checked out.
+-rcs_revision='$Revision: 5381 $'
++rcs_revision='$Revision: 5704 $'
+ rcs_version=`set - $rcs_revision; echo $2`
+-program=`echo $0 | sed -e 's!.*/!!'`
++program=`echo $0 | $SED -e 's!.*/!!'`
+ 
+ build_mode=${TEXI2DVI_BUILD_MODE:-local}
+ build_dir=${TEXI2DVI_BUILD_DIRECTORY:-.}
+@@ -52,11 +55,10 @@ escape="\\"
+ expand=false    # true for expansion via makeinfo
+ includes=
+ line_error=true # pass --file-line-error to TeX
+-max_iters=-1    # keep going forever
++max_iters=7     # when to quit
+ oname=          # --output
+ out_lang=dvi
+ quiet=false     # let the tools' message be displayed
+-recode=false
+ set_language=
+ src_specials=
+ shell_escape=
+@@ -65,7 +67,6 @@ textra=         # Extra TeX commands to insert in the input file.
+ txiprereq=19990129 # minimum texinfo.tex version with macro expansion
+ verb=false      # true for verbose mode
+ translate_file= # name of charset translation file
+-recode_from=    # if not empty, recode from this encoding to @documentencoding
+ 
+ orig_pwd=`pwd`
+ 
+@@ -162,7 +163,7 @@ cd_orig ()
+ func_dirname ()
+ {
+   dirname "$1" 2>/dev/null \
+-  || { echo "$1" | sed 's!/[^/]*$!!;s!^$!.!'; }
++  || { echo "$1" | $SED 's!/[^/]*$!!;s!^$!.!'; }
+ }
+ 
+ 
+@@ -171,7 +172,7 @@ func_dirname ()
+ # Return FILE with one extension remove.  foo.bar.baz -> foo.bar.
+ noext ()
+ {
+-  echo "$1" | sed -e 's/\.[^/.][^/.]*$//'
++  echo "$1" | $SED -e 's/\.[^/.][^/.]*$//'
+ }
+ 
+ 
+@@ -186,7 +187,7 @@ absolute ()
+       echo "$1"
+       ;;
+    *) local slashes
+-      slashes=`echo "$1" | sed -n 's,.*[^/]\(/*\)$,\1,p'`
++      slashes=`echo "$1" | $SED -n 's,.*[^/]\(/*\)$,\1,p'`
+       local rel
+       rel=$orig_pwd/`func_dirname "$1"`
+       if test -d "$rel"; then
+@@ -341,8 +342,6 @@ TeX tuning:
+   -I DIR                     search DIR for Texinfo files
+   -l, --language=LANG        specify LANG for FILE, either latex or texinfo
+       --no-line-error        do not pass --file-line-error to TeX
+-  -r, --recode               call recode before TeX to translate input
+-      --recode-from=ENC      recode from ENC to the @documentencoding
+       --shell-escape         pass --shell-escape to TeX
+       --src-specials         pass --src-specials to TeX
+   -t, --command=CMD          insert CMD in copy of input file
+@@ -358,7 +357,7 @@ Build modes:
+                          defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
+   --mostly-clean       remove the auxiliary files and directories
+                          but not the output
+-  --max-iterations=N   don't process files more than N times
++  --max-iterations=N   don't process files more than N times [$max_iters]
+ 
+ The MODE specifies where the TeX compilation takes place, and, as a
+ consequence, how auxiliary files are treated.  The build mode
+@@ -392,7 +391,7 @@ using \\graphicspath): in that case, use -I to specify the additional
+ directories to consider.
+ 
+ The values of the BIBER, BIBTEX, DVIPDF, DVIPS, HEVEA, LATEX, MAKEINDEX,
+-MAKEINFO, PDFLATEX, PDFTEX, T4HT, TEX, TEX4HT, TEXINDEX, and THUMBPDF
++MAKEINFO, PDFLATEX, PDFTEX, SED, T4HT, TEX, TEX4HT, TEXINDEX, and THUMBPDF_CMD
+ environment variables are used to run those commands, if they are set.
+ 
+ Regarding --dvipdf, if DVIPDF is not set in the environment, the
+@@ -430,7 +429,7 @@ version ()
+   cat <<EOF
+ texi2dvi (GNU Texinfo 5.2) $rcs_version
+ 
+-Copyright (C) 2013 Free Software Foundation, Inc.
++Copyright (C) 2014 Free Software Foundation, Inc.
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+ This is free software: you are free to change and redistribute it.
+ There is NO WARRANTY, to the extent permitted by law.
+@@ -472,7 +471,7 @@ list_concat_dirs ()
+                        -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+   save_IFS=$IFS
+   IFS=$path_sep
+-  set x `echo "$2" | eval sed $replace_EMPTY`; shift
++  set x `echo "$2" | eval $SED $replace_EMPTY`; shift
+   IFS=$save_IFS
+   local dir
+   for dir
+@@ -614,7 +613,7 @@ absolute_filenames ()
+                        -e 's/$path_sep\$/${path_sep}EMPTY/g' \
+                        -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+   local res
+-  res=`echo "$1" | eval sed $replace_empty`
++  res=`echo "$1" | eval $SED $replace_empty`
+   save_IFS=$IFS
+   IFS=$path_sep
+   set x $res; shift
+@@ -653,7 +652,7 @@ output_base_name ()
+      *) local out_noext
+         out_noext=`noext "$oname"`
+         local file_ext
+-        file_ext=`echo "$1" | sed 's/^.*\.//'`
++        file_ext=`echo "$1" | $SED 's/^.*\.//'`
+         echo "$out_noext.$file_ext"
+       ;;
+   esac
+@@ -775,7 +774,7 @@ bibaux_file_p ()
+ index_file_p ()
+ {
+   test -f "$1" || return 1
+-  case $in_lang:$latex2html:`out_lang_tex`:`sed '1q' "$1"` in
++  case $in_lang:$latex2html:`out_lang_tex`:`$SED '1q' "$1"` in
+     # When working with TeX4HT, *.idx are created by LaTeX.  They must
+     # be processed to produce *.4ix, *.4dx files.  The *.4dx file is
+     # passed to makeindex to produce the *.ind file.  This sequence is
+@@ -803,7 +802,7 @@ xref_file_p ()
+   # process it.  It's suitable if the first character is a
+   # backslash or right quote or at, as long as the first line isn't
+   # \input texinfo.
+-  case `sed '1q' "$1"` in
++  case `$SED '1q' "$1"` in
+     "\\input texinfo"*) return 1;;
+     [\\''@]*)           return 0;;
+            *)           return 1;;
+@@ -824,7 +823,7 @@ generated_files_get ()
+   # Gather the files created by TeX.
+   (
+     if test -f "$1.log"; then
+-      sed -n -e "s,^\\\\openout.* = \`\\(.*\\)'\\.,\\1,p" "$1.log"
++      $SED -n -e "s,^\\\\openout.* = \`\\(.*\\)'\\.,\\1,p" "$1.log"
+     fi
+     echo "$1.log"
+   ) |
+@@ -841,10 +840,10 @@ generated_files_get ()
+       latex)
+         if aux_file_p $file; then
+           # bibtex: *.aux -> *.bbl and *.blg.
+-          echo $file | sed 's/^\(.*\)\.aux$/\1.bbl/'
+-          echo $file | sed 's/^\(.*\)\.aux$/\1.blg/'
++          echo $file | $SED 's/^\(.*\)\.aux$/\1.bbl/'
++          echo $file | $SED 's/^\(.*\)\.aux$/\1.blg/'
+           # -recorder: .fls
+-          echo $file | sed 's/^\(.*\)\.aux$/\1.fls/'
++          echo $file | $SED 's/^\(.*\)\.aux$/\1.fls/'
+        fi
+        ;;
+     esac
+@@ -915,10 +914,10 @@ xref_files_changed ()
+ 
+   # Compare each file until we find a difference.
+   for this_file in $xref_files_new; do
+-    verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
++    verbose "Comparing xref file `echo $this_file | $SED 's|\./||g'` ..."
+     # cmp -s returns nonzero exit status if files differ.
+     if cmp -s "$this_file" "$work_bak/$this_file"; then :; else
+-      verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
++      verbose "xref file `echo $this_file | $SED 's|\./||g'` differed ..."
+       if $debug; then
+         diff -u "$work_bak/$this_file" "$this_file"
+       fi
+@@ -972,7 +971,7 @@ run_tex ()
+   # subdirectory to exist.
+   case $in_lang:$tidy in
+     latex:true)
+-       sed -n 's|^[ ]*\\include{\(.*\)/.*}.*|\1|p' "$in_input" |
++       $SED -n 's|^[ ]*\\include{\(.*\)/.*}.*|\1|p' "$in_input" |
+        sort -u |
+        while read d
+        do
+@@ -1103,14 +1102,15 @@ run_bibtex ()
+   # bibtex would never be run.
+   if test -r "$in_noext.aux" \
+      && test -r "$in_noext.log" \
+-     && ((grep 'Warning:.*Citation.*undefined' "$in_noext.log" \
++     && ( (grep 'Warning:.*Citation.*undefined' "$in_noext.log" \
+           || grep '.*Undefined citation' "$in_noext.log" \
+           || grep 'No file .*\.bbl\.' "$in_noext.log") \
+           || (grep 'No \.aux file' "$in_noext.log" \
+-              && grep '^\\bibdata' "$in_noext.aux")) \
++              && grep '^\\bibdata' "$in_noext.aux") ) \
+         >&6 2>&1; \
+   then
+-    for f in `generated_files_get "$in_noext" bibaux_file_p`; do
++    bibtex_aux=`generated_files_get "$in_noext" bibaux_file_p`
++    for f in $bibtex_aux; do
+       run $bibtex "$f"
+     done
+   fi
+@@ -1199,7 +1199,7 @@ run_thumbpdf ()
+      && test -r "$in_noext.log" \
+      && grep 'thumbpdf\.sty'  "$in_noext.log" >&6 2>&1; \
+   then
+-    thumbpdf=${THUMBPDF:-thumbpdf}
++    thumbpdf=${THUMBPDF_CMD:-thumbpdf}
+     thumbcmd="$thumbpdf $in_dir/$in_noext"
+     verbose "Running $thumbcmd ..."
+     if $thumbcmd >&5; then
+@@ -1229,7 +1229,7 @@ run_dvipdf ()
+   # 'input -o output'.  They all seem to accept 'input' only,
+   # outputting using the expected file name.
+   run $dvipdf "$1"
+-  if test ! -f `echo "$1" | sed -e 's/\.dvi$/.pdf/'`; then
++  if test ! -f `echo "$1" | $SED -e 's/\.dvi$/.pdf/'`; then
+     error 1 "cannot find output file"
+   fi
+ }
+@@ -1261,9 +1261,9 @@ run_tex_suite ()
+ 
+     xref_files_save
+ 
+-    # We run bibtex first, because I can see reasons for the indexes
+-    # to change after bibtex is run, but I see no reason for the
+-    # converse.
++    # We run bibtex first, because it's more likely for the indexes
++    # to change after bibtex is run than the reverse, though either
++    # would be rare.
+     run_bibtex
+     run_index
+     run_core_conversion
+@@ -1376,7 +1376,7 @@ to tex itself simply not working."
+       cat "$version_test_dir/txiversion.err" >&2
+       error 1 "quitting."
+     fi
+-    eval `sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' "$version_test_dir/txiversion.out"`
++    eval `$SED -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' "$version_test_dir/txiversion.out"`
+     verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
+     if test "$txiprereq" -le "$txiversion" >&6 2>&1; then
+       makeinfo=
+@@ -1402,10 +1402,10 @@ to tex itself simply not working."
+     # (running missing) and then we end up with things like '"-I"',
+     # and "-I" (including the quotes) is not an option name.  This
+     # happens with gettext 0.14.5, at least.
+-    sed "$comment_iftex" "$command_line_filename" \
++    $SED "$comment_iftex" "$command_line_filename" \
+       | eval $makeinfo --footnote-style=end -I "$in_dir" $miincludes \
+         -o /dev/null --macro-expand=- \
+-      | sed "$uncomment_iftex" >"$in_src"
++      | $SED "$uncomment_iftex" >"$in_src"
+     # Continue only if everything succeeded.
+     if test $? -ne 0 \
+        || test ! -r "$in_src"; then
+@@ -1433,7 +1433,7 @@ insert_commands ()
+       texinfo) textra_cmd='/^@setfilename/a';;
+       *)       error 1 "internal error, unknown language: $in_lang";;
+     esac
+-    sed "$textra_cmd\\
++    $SED "$textra_cmd\\
+ $textra" "$in_input" >"$in_xtr"
+     in_input=$in_xtr
+   fi
+@@ -1453,45 +1453,6 @@ $textra" "$in_input" >"$in_xtr"
+   esac
+ }
+ 
+-# run_recode ()
+-# -------------
+-# If this is a Texinfo file with a specified input encoding, and
+-# recode is available, then recode to plain 7 bit Texinfo.
+-run_recode ()
+-{
+-  local from
+-  local to
+-
+-  if test $in_lang = texinfo; then
+-    pgm='s/^ *@documentencoding  *\([^ ][^ ]*\) *$/\1/
+-        t found
+-        d
+-        :found
+-        q'
+-    encoding=`sed -e "$pgm" "$in_input"`
+-    if $recode && test -n "$encoding" && findprog recode; then
+-      if test -n "$recode_from"; then
+-        from=$recode_from
+-        to=$encoding
+-      else
+-        from=$encoding
+-        to=$texinfo
+-      fi
+-      verbose "Recoding from $from to $to."
+-      # _rcd.  The Texinfo file recoded in 7bit.
+-      work_rcd=$workdir/recode
+-      in_rcd=$work_rcd/$in_base
+-      ensure_dir "$work_rcd"
+-      if recode "$encoding..$to" <"$in_input" >"$in_rcd" \
+-         && test -s "$in_rcd"; then
+-        in_input=$in_rcd
+-      else
+-        verbose "Recoding failed, using original input."
+-      fi
+-    fi
+-  fi
+-}
+-
+ # compute_language FILENAME
+ # -------------------------
+ # Return the short string describing the language in which FILENAME
+@@ -1503,7 +1464,7 @@ compute_language ()
+   # Otherwise, guess from the file extension.
+   if test -n "$set_language"; then
+     echo $set_language
+-  elif sed 1q "$1" | grep 'input texinfo' >&6; then
++  elif $SED 1q "$1" | grep 'input texinfo' >&6; then
+     echo texinfo
+   else
+     # Get the type of the file (latex or texinfo) from the given language
+@@ -1618,9 +1579,6 @@ compile ()
+   # --command, --texinfo
+   insert_commands
+ 
+-  # --recode
+-  run_recode
+-
+   # Run until a fix point is reached.
+   run_tex_suite
+ }
+@@ -1689,14 +1647,13 @@ while test x"$1" != x"$arg_sep"; do
+   # Handle --option=value by splitting apart and putting back on argv.
+   case "$1" in
+     --*=*)
+-      opt=`echo "$1" | sed -e 's/=.*//'`
+-      val=`echo "$1" | sed -e 's/[^=]*=//'`
++      opt=`echo "$1" | $SED -e 's/=.*//'`
++      val=`echo "$1" | $SED -e 's/[^=]*=//'`
+       shift
+       set dummy "$opt" "$val" ${1+"$@"}; shift
+       ;;
+   esac
+ 
+-  # This recognizes --quark as --quiet.  Oh well.
+   case "$1" in
+     -@ ) escape=@;;
+     -~ ) catcode_special=false;;
+@@ -1721,17 +1678,15 @@ while test x"$1" != x"$arg_sep"; do
+     # Output formats.
+     -O|--output-format) shift; out_lang_set "$1";;
+        --dvi|--dvipdf|--html|--info|--pdf|--ps|--text)
+-       out_lang_set `echo "x$1" | sed 's/^x--//'`;;
++       out_lang_set `echo "x$1" | $SED 's/^x--//'`;;
+ 
+     -p) out_lang_set pdf;;
+     -q | -s | --quiet | --silent) quiet=true; batch=true;;
+-    -r | --recode) recode=true;;
+-    --recode-from) shift; recode=true; recode_from="$1";;
+     --src-specials) src_specials=--src-specials;;
+     --shell-escape) shell_escape=--shell-escape;;  
+     --tex4ht) latex2html=tex4ht;;
+     -t | --texinfo | --command ) shift; textra="$textra\\
+-"`echo "$1" | sed 's/\\\\/\\\\\\\\/g'`;;
++"`echo "$1" | $SED 's/\\\\/\\\\\\\\/g'`;;
+     --translate-file ) shift; translate_file="$1";;
+     --tidy) build_mode=tidy;;
+     -v | --vers*) version;;
+@@ -1858,7 +1813,7 @@ fi
+ #   The input file name without extensions (nor directory part).
+ # - IN_INPUT
+ #   Defaults to COMMAND_LINE_FILENAME, but might change if the
+-#   input is preprocessed (recode etc.).  With directory, possibly absolute.
++#   input is preprocessed.  With directory, possibly absolute.
+ input_file_name_decode ()
+ {
+   # See if we are run from within AUC-Tex, in which case we are
+@@ -1943,7 +1898,7 @@ do
+          # has active characters.  Transform / into ! so that we don't
+          # need `mkdir -p'.  It might be something to reconsider.
+          t2ddir=$build_dir/`echo "$out_dir_abs/$out_noext.t2d" |
+-             sed "s,^$orig_pwd/,,;s,^\./,,;s,/,!,g"`
++             $SED "s,^$orig_pwd/,,;s,^\./,,;s,/,!,g"`
+   esac
+   # Remove it at exit if clean mode.
+   trap "cleanup" 0 1 2 15
