deri pushed a commit to branch master
in repository groff.

commit 2387949ffc11b753dd91480dcb85be6c22819790
Author: Deri James <d...@chuzzlewit.myzen.co.uk>
AuthorDate: Fri Apr 12 17:10:49 2024 +0100

    Correct linear search introduced in commit cd9fde325f
    
    * tmac/pdf.tmac: Various problems have been rectified, speed
    improvements to the linear search, Keith protection against
    illegal characters being used in string identifiers.
    
    * contrib/mom/om.tmac: Switch to using Branden's linear search
    so that we don't have to maintain two different methods.
    
    Fixes <https://savannah.gnu.org/bugs/?65585>
---
 ChangeLog           | 31 ++++++++++++++++++++++
 contrib/mom/om.tmac |  5 ++--
 tmac/pdf.tmac       | 76 +++++++++++++++++++++++------------------------------
 3 files changed, 67 insertions(+), 45 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3f29eecea..e036b25c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2024-04-12  Deri James  <d...@chuzzlewit.myzen.co.uk>
+
+       Correct and improve linear search introduced in commit
+       cd9fde325f, 4th March.
+
+       * tmac/pdf.tmac: Various problems have been rectified, speed
+       improvements to the linear search, Keith protection against
+       illegal characters being used in string identifiers.
+
+       * contrib/mom/om.tmac: Switch to using Branden's linear search
+       so that we don't have to maintain two different methods.
+
+       Fixes <https://savannah.gnu.org/bugs/?65585>
+
+2024-04-12  Deri James  <d...@chuzzlewit.myzen.co.uk>
+
+       Support UTF-16 Bookmarks.
+
+       * src/devices/grops: Add comment field to the font files
+       which specifies the UTF-16 code for the character.
+
+       * utils/afmtodit/afmtodit.pl: Add comment field holding the
+       UTF-16 code.
+
+       * man/groff_font.5.man: Document use of comment field to hold
+       UTF-16 code.
+
+       * src/devices/gropdf/gropdf.pl: Extract UTF-16 code from font
+       comment field (rather than a new field). And tweak to pdf
+       parser.
+
 2024-03-26  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        * src/utils/grog/grog.pl (do_line): Recognize new requests in
diff --git a/contrib/mom/om.tmac b/contrib/mom/om.tmac
index 299cbc949..c7d20272e 100644
--- a/contrib/mom/om.tmac
+++ b/contrib/mom/om.tmac
@@ -23631,8 +23631,9 @@ No room to start \\*[MN-pos] margin note #\\n[MN-curr] 
on page \\n[#P].
 .    if '\\*[PDF_AST]'*' \{\
 .        chop PDF_TXT
 .        ie '\\*[.T]'pdf' \{\
-.           ie d pdf:look(\\*[PDF_NM]) \
-.               as PDF_TXT 
\&\\*[PDF_AST_Q]\\*[pdf:look(\\*[PDF_NM])]\\*[PDF_AST_Q]
+.           pdf:lookup \\*[PDF_NM]
+.           ie !'\\*[pdf:lookup-result]'' \
+.               as PDF_TXT \&\\*[PDF_AST_Q]\\*[pdf:lookup-value]\\*[PDF_AST_Q]
 .           el \{\
 .               as PDF_TXT Unknown
 .               if !rPDF_UNKNOWN .tm \
diff --git a/tmac/pdf.tmac b/tmac/pdf.tmac
index 1b2415270..745d4ee37 100644
--- a/tmac/pdf.tmac
+++ b/tmac/pdf.tmac
@@ -68,6 +68,7 @@ am solely responsible for any bugs I may have introduced into 
this file.
 .pdf:SS \[*z]
 .char \[lh] \X'pdf: xrev'\[rh]\X'pdf: xrev'
 .nr pdf:bm.nl 1
+.nr pdf:bm.nk 0
 .de pdfmark
 . nop \!x X ps:exec [\\$* pdfmark
 ..
@@ -156,7 +157,8 @@ am solely responsible for any bugs I may have introduced 
into this file.
 .\"
 .\" Parse any specified (recognisable) PDFNOTE options
 .\"
-.   while dpdf:note\\$1 \{\
+.   while \A'\\$1' \{\
+.      if !dpdf:note\\$1 .break
 .      pdf:note\\$1 \\$@
 .      shift \\n[pdf:note.argc]
 .      \}
@@ -201,9 +203,11 @@ am solely responsible for any bugs I may have introduced 
into this file.
 .de pdf:lookup
 .nr pdf:index 0 1
 .ds pdf:lookup-result \" empty
+.ds pdf:lookup-value  \" empty
 .while d pdf:bm\\n+[pdf:index].tag \{\
 .   if '\\$1'\\*[pdf:bm\\n[pdf:index].tag]' \{\
 .      ds pdf:lookup-result \\*[pdf:bm\\n[pdf:index].tag]\"
+.      ds pdf:lookup-value \\*[pdf:bm\\n[pdf:index].val]\"
 .      break
 .      \}
 .   \}
@@ -230,8 +234,10 @@ am solely responsible for any bugs I may have introduced 
into this file.
 .   \" Make the bookmark name "untagged" by default,
 .   \" then parse any specified options, to set a "tag", if required
 .   \"
+.      nr pdf:bm.nr +1
 .      ds pdf:href-T
-.      while dpdf:href.opt\\$1 \{\
+.      while \A'\\$1' \{\
+.         if !dpdf:href.opt\\$1 .break
 .         pdf:href.opt\\$1 \\$@
 .         shift \\n[pdf:href.argc]
 .         \}
@@ -267,38 +273,26 @@ am solely responsible for any bugs I may have introduced 
into this file.
 .   \" in order to generate a uniquely serialised bookmark name,
 .   \" ( which we return in the string "PDFBOOKMARK.NAME" ),
 .   \"
-.      nr pdf:bm.nr +1
 .      ie '\\*[pdf:href-T]'' .ds PDFBOOKMARK.NAME pdf:bm\\n[pdf:bm.nr]
 .      el .ds PDFBOOKMARK.NAME \\*[pdf:href-T]
 .      pdf:href.sety
 .      ds pdf:cleaned \\$*
-.      ev pdfcln
-.      tr \[em]-
-.      nf
-.      box pdf:clean
-.      nop \\$*
-.      fl
-.      box
-.      chop pdf:clean
-.      asciify pdf:clean
-.      ds pdf:cleaned \\*[pdf:clean]
-.      rm pdf:clean
-.      ev
-.      tr \[em]\[em]
-.      ie d PRINTSTYLE \{\
-.         ds pdf:look(\\*[PDFBOOKMARK.NAME]) \\*[pdf:cleaned]
-.         if dPDF.EXPORT .tm .ds pdf:look(\\*[PDFBOOKMARK.NAME]) 
\\*[pdf:cleaned]
+.      if !'\\*[pdf:href-T]'' \{\
+.         nr pdf:bm.nk +1
+.         if !d pdf:bm\\n[pdf:bm.nk].tag \{\
+.            ds pdf:bm\\n[pdf:bm.nk].tag \\*[PDFBOOKMARK.NAME]
+.            ds pdf:bm\\n[pdf:bm.nk].val \\*[pdf:cleaned]
 .         \}
-.      el \{\
-.         ds pdf:bm\\n[pdf:bm.nr].tag \\*[PDFBOOKMARK.NAME]
-.         if d PDF.EXPORT .tm .ds pdf:bm\\n[pdf:bm.nr].tag 
\\*[PDFBOOKMARK.NAME]
+.         if d PDF.EXPORT \{\
+.            tm .ds pdf:bm\\n[pdf:bm.nk].tag \\*[PDFBOOKMARK.NAME]
+.            tm .ds pdf:bm\\n[pdf:bm.nk].val \\*[pdf:cleaned]
 .         \}
+.      \}
 .      pdfmark /Dest /\\*[PDFBOOKMARK.NAME] /View [\\*[PDFBOOKMARK.VIEW]] /DEST
 .      nop \!x X ps:exec [/Dest /\\*[PDFBOOKMARK.NAME] /Title 
(\\*[pdf:cleaned]) /Level \\n[pdf:bm.lev] /OUT pdfmark
 .      pdf:href.options.clear
 .      rr PDFPAGE.Y
 .      rm pdf:cleaned
-.      rm pdf:clean
 .      \}
 .   \}
 .el \{\
@@ -597,7 +591,8 @@ am solely responsible for any bugs I may have introduced 
into this file.
 .\" options -- anything which is not recognised is assumed to start
 .\" the "descriptive text" component of the argument list).
 .\"
-.while dpdf:href.opt\\$1 \{\
+.while \A'\\$1' \{\
+.   if !dpdf:href.opt\\$1 .break
 .   pdf:href.opt\\$1 \\$@
 .   shift \\n[pdf:href.argc]
 .   \}
@@ -613,16 +608,17 @@ am solely responsible for any bugs I may have introduced 
into this file.
 .\" if any, and set the marker -- if we still can't identify the name
 .\" for the destination, then this marker will not be created.
 .\"
+.nr pdf:bm.nk +1
 .ds PDFBOOKMARK.NAME "\\*[pdf:href-N]\\*[pdf:href-D]
 .pdf*href.set \\*[PDFBOOKMARK.NAME] \\$1
-.ie d PRINTSTYLE \{\
-.   ds pdf:look(\\*[PDFBOOKMARK.NAME]) \\$*
-.   if dPDF.EXPORT .tm .ds pdf:look(\\*[PDFBOOKMARK.NAME]) \\$*
-.   \}
-.el \{\
-.   ds pdf:bm\\n[pdf:bm.nr].tag \\*[PDFBOOKMARK.NAME]
-.   if d PDF.EXPORT .tm .ds pdf:bm\\n[pdf:bm.nr].tag \\*[PDFBOOKMARK.NAME]
-.   \}
+.if !d pdf:bm\\n[pdf:bm.nk].tag \{\
+.   ds pdf:bm\\n[pdf:bm.nk].tag \\*[PDFBOOKMARK.NAME]
+.   ds pdf:bm\\n[pdf:bm.nk].val \\$*
+.\}
+.if d PDF.EXPORT \{\
+.   tm .ds pdf:bm\\n[pdf:bm.nk].tag \\*[PDFBOOKMARK.NAME]
+.   tm .ds pdf:bm\\n[pdf:bm.nk].val \\$*
+.\}
 .\"
 .\"
 .\" Irrespective of whether this marker is created, or not,
@@ -686,7 +682,8 @@ am solely responsible for any bugs I may have introduced 
into this file.
 .\" options -- anything which is not recognised is assumed to start
 .\" the "link text" component of the argument list).
 .\"
-.while dpdf:href.opt\\$1 \{\
+.while \A'\\$1' \{\
+.   if !dpdf:href.opt\\$1 .break
 .   pdf:href.opt\\$1 \\$@
 .   shift \\n[pdf:href.argc]
 .   \}
@@ -746,13 +743,8 @@ with '-A' option
 .      \}
 .   el \{\
 .      ds PDFHREF.DESC Unknown
-.      ie d PRINTSTYLE \{\
-.         if dpdf:look(\\*[pdf:href-D]) .ds PDFHREF.DESC 
\\*[pdf:look(\\*[pdf:href-D])]
-.         \}
-.      el \{\
-.         pdf:lookup \\*[pdf:href-D]
-.         if !'\\*[pdf:lookup-result]'' .ds PDFHREF.DESC \\*[pdf:lookup-result]
-.         \}
+.      pdf:lookup \\*[pdf:href-D]
+.      if !'\\*[pdf:lookup-result]'' .ds PDFHREF.DESC \\*[pdf:lookup-value]
 .      \}
 .   \" Apply border and colour specifications to the PDFMARK string
 .   \" definition, as required.
@@ -862,11 +854,9 @@ with '-A' option
 .
 .de pdfmarksuspend
 .nop \!x X pdf: marksuspend
-.nr pdf*is-mark-suspended 1
 ..
 .de pdfmarkrestart
-.if \\n[pdf*is-mark-suspended] .nop \!x X pdf: markrestart
-.nr pdf*is-mark-suspended 0
+.nop \!x X pdf: markrestart
 ..
 .de pdfpagename
 .nop \!x X pdf: pagename \\$1

_______________________________________________
Groff-commit mailing list
Groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to