forked from pool/netpbm
Petr Gajdos
20145d3c7b
* asciitopgm: fix bug: memory corruption on too-long lines. * asciitopgm: fix bug: improper handling of blank lines. * pngtopnm: fix bug: -verbose reports history chunk present when it's really a palette. * bmptopnm: Don't crash on invalid zero value of image height in the BMP header of a compressed file. * bmptopnm: don't crash on large invalid value of 'colorsused' in the BMP header. * ilbmtoppm: Don't crash on image that has a transparent color index, but no color map. OBS-URL: https://build.opensuse.org/package/show/graphics/netpbm?expand=0&rev=29
81 lines
3.8 KiB
Diff
81 lines
3.8 KiB
Diff
--- buildtools/makeman
|
|
+++ buildtools/makeman
|
|
@@ -1,4 +1,4 @@
|
|
-#!/bin/env python
|
|
+#!/usr/bin/python
|
|
#
|
|
# makeman -- compile netpbm's stereotyped HTML to troff markup
|
|
#
|
|
@@ -95,6 +95,8 @@
|
|
indoc = re.sub("(?i)\n *</PRE>", "\n.fi", indoc)
|
|
indoc = re.sub("(?i)\n *<BLOCKQUOTE>", "\n.nf", indoc)
|
|
indoc = re.sub("(?i)\n *</BLOCKQUOTE>", "\n.fi", indoc)
|
|
+ indoc = re.sub("(?i)\n *<code>", "\n.nf", indoc)
|
|
+ indoc = re.sub("(?i)\n *</code>", "\n.fi", indoc)
|
|
# Highlight processing
|
|
indoc = re.sub("(?i)<B>", r"\\fB", indoc)
|
|
indoc = re.sub("(?i)</B>", r"\\fP", indoc)
|
|
@@ -114,7 +116,10 @@
|
|
indoc = re.sub("(?i)</SUP>", r"\\d", indoc)
|
|
# Paragraph handling
|
|
indoc = re.sub("(?i)\n*<P>\n*", r"\n.PP\n", indoc)
|
|
+ indoc = re.sub("(?i)<br */>", r"\n.PP\n", indoc)
|
|
indoc = re.sub("(?i)</P>", "", indoc)
|
|
+ indoc = re.sub("(?i)<!--[^>]*-->", "", indoc)
|
|
+ indoc = re.sub("(?i)<meta[^>]*>", "", indoc)
|
|
lines = indoc.split("\n")
|
|
listdepth = 0
|
|
for i in range(len(lines)):
|
|
@@ -131,13 +136,14 @@
|
|
indoc = re.sub('(?i)<A[ \n]+HREF="mailto:[^>]+">([^<]+)</A>', r'\\fI\1\\fP', indoc)
|
|
# Format manual crossreferences
|
|
def xrefmatch(match):
|
|
- xrefto = match.group(1)
|
|
- xrefsection = sectmap.get(xrefto, 1)
|
|
+ xrefto = match.group(2)
|
|
+ xrefurl = match.group(1)
|
|
+ xrefsection = sectmap.get(xrefurl, 1)
|
|
if xrefsection == 0:
|
|
return "\n.I " + xrefto
|
|
else:
|
|
- return "\n.BR %s (%d)" % (xrefto, xrefsection)
|
|
- indoc = re.sub(r'(?i)\n* *(?:\\fB)?<A[ \n]+HREF="[^>]+.html">([^<]+)</A>(?:\\fP)?',
|
|
+ return "\n.BR %s (%d)\n" % (xrefto, xrefsection)
|
|
+ indoc = re.sub(r'(?i)\n* *(?:\\fB)?<A[ \n]+HREF="?([^>]+.html)"?>([^<]+)</A>(?:\\fP)?',
|
|
xrefmatch, indoc)
|
|
# Format URLs
|
|
def urlmatch(match):
|
|
@@ -151,7 +157,7 @@
|
|
indoc = indoc.replace("×", r"\(mu")
|
|
indoc = indoc.replace("®", r"\*R")
|
|
# Turn anchors into .UN tags
|
|
- indoc = re.sub('(?i)<A NAME *= *"#?([a-zA-Z][a-zA-Z0-9.-]+)">(?: )*</A>\s*', ".UN \\1\n", indoc)
|
|
+ indoc = re.sub('(?i)<A NAME *= *"#?([a-zA-Z_][a-zA-Z_0-9.-]+)">(?: )*</A>\s*', ".UN \\1\n", indoc)
|
|
# Strip off the index trailer
|
|
trailer = re.compile('<HR */*>.*', re.DOTALL | re.IGNORECASE)
|
|
indoc = re.sub(trailer, "", indoc)
|
|
@@ -159,17 +165,17 @@
|
|
indoc = indoc.replace("</BODY>", "").replace("</HTML>", "")
|
|
indoc = indoc.replace("</body>", "").replace("</html>", "")
|
|
# Recognize sections with IDs
|
|
- indoc = re.sub('(?i)<H2><A (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</A></H2>',
|
|
+ indoc = re.sub('(?i)<H2><A (?:ID|NAME)="([a-zA-Z_0-9]+)">([^><]*)</A></H2>',
|
|
".UN \\1\n.SH \\2", indoc)
|
|
- indoc = re.sub('(?i)<H3><A (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</A></H3>',
|
|
+ indoc = re.sub('(?i)<H3><A (?:ID|NAME)="([a-zA-Z_0-9]+)">([^><]*)</A></H3>',
|
|
".UN \\1\n.SS \\2", indoc)
|
|
- indoc = re.sub('(?i)<H4><A (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</A></H4>',
|
|
+ indoc = re.sub('(?i)<H4><A (?:ID|NAME)="([a-zA-Z_0-9]+)">([^><]*)</A></H4>',
|
|
".UN \\1\n.B \\2", indoc)
|
|
- indoc = re.sub('(?i)<H2 (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</H2>',
|
|
+ indoc = re.sub('(?i)<H2 (?:ID|NAME)="([a-zA-Z_0-9]+)">([^><]*)</H2>',
|
|
".UN \\1\n.SH \\2", indoc)
|
|
- indoc = re.sub('(?i)<H3 (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</H3>',
|
|
+ indoc = re.sub('(?i)<H3 (?:ID|NAME)="([a-zA-Z_0-9]+)">([^><]*)</H3>',
|
|
".UN \\1\n.SS \\2", indoc)
|
|
- indoc = re.sub('(?i)<H4 (?:ID|NAME)="([a-zA-Z]+)">([^><]*)</H4>',
|
|
+ indoc = re.sub('(?i)<H4 (?:ID|NAME)="([a-zA-Z_0-9]+)">([^><]*)</H4>',
|
|
".UN \\1\n.B \\2", indoc)
|
|
# Sections without IDs
|
|
indoc = re.sub('(?i)<H2>([^><]*)</H2>', ".SH \\1", indoc)
|