Work around Tex Live 2012 versus doxygen problem.
authorAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Fri, 27 Jul 2012 18:55:35 +0000 (21:55 +0300)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Fri, 27 Jul 2012 19:22:46 +0000 (22:22 +0300)
TeX Live 2012 seems to dislike files produces by doxygen (1.8.x.y).
In particular, makeindex(1) program creates invalid index entries like

\hyperpage{NNN_}

(note the trailing underscore in the page number). This breaks automatic
builds and is very annoying. This patch works around the problem by
post-processing the generated *.ind file. This hack is a bit crude, however
it gets the job done (a proper fix is welcome, though).

doc/CMakeLists.txt
doc/reference/Makefile.am
scripts/fixupind.py [new file with mode: 0755]

index fdfc193..e1416d3 100644 (file)
@@ -35,6 +35,7 @@ macro(pdflatex_process texfile)
        set(_idx ${_dirname}/${_basename}.idx)
        set(_ind ${_dirname}/${_basename}.ind)
        set(_pdf ${_dirname}/${_basename}.pdf)
+       set(_fixupind ${CMAKE_SOURCE_DIR}/scripts/fixupind.py)
        add_custom_command(
                OUTPUT ${_idx}
                COMMAND ${PDFLATEX_COMPILER} ${texfile}
@@ -44,6 +45,7 @@ macro(pdflatex_process texfile)
        add_custom_command(
                OUTPUT ${_ind}
                COMMAND ${MAKEINDEX_COMPILER} ${_idx}
+               COMMAND python ${_fixupind} ${_idx}
                WORKING_DIRECTORY ${_dirname}
                DEPENDS ${texfile} ${_idx}
                COMMENT "MAKEINDEX ${_basename}.idx")
index 67cb8ce..0fddd45 100644 (file)
@@ -53,6 +53,7 @@ pdflatex/reference.pdf: pdflatex/reference.tex
                cd pdflatex; \
          ${PDFLATEX} reference.tex ;\
          ${MAKEINDEX} reference.idx ;\
+         ${PYTHON} $(top_srcdir)/scripts/fixupind.py reference.ind; \
          ${PDFLATEX} reference.tex
 
 reference.dvi: latex latex/reference.dvi
diff --git a/scripts/fixupind.py b/scripts/fixupind.py
new file mode 100755 (executable)
index 0000000..7ebb1e1
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# encoding: utf-8
+# TeX Live 2012 seems to dislike files produces by doxygen (1.8.x.y)
+# In particular, makeindex(1) program creates invalid index entries like
+# \hyperpage{NNN_}
+# (note the trailing underscore in the page number). This breaks automatic
+# builds and is very annoying. Hence this script. It replaces (broken)
+# \hyperpage{NNN_} with \hyperpage{NNN}.
+# Note: this is an ugly work around, a proper fix is welcome.
+import sys, os, re
+
+def fixupind(fname):
+       """ Fix \\hyperpage{NNN_} entries in the ind file @var{fname} """
+       tmpout = fname + '.tmp' 
+       inp = open(fname)
+       out = open(tmpout, 'wt')
+       rx = re.compile('(hyperpage)[{]([0-9]+)[_][}]')
+       for line in inp:
+               out.write(re.sub(rx, '\\1{\\2}', line))
+       out.flush()
+       out.close()
+       inp.close()
+       os.rename(tmpout, fname)
+
+if __name__ == '__main__':
+       if len(sys.argv) <= 1:
+               sys.exit(1)
+       fixupind(sys.argv[1])
+       sys.exit(0)
+