pkgsrc/textproc/rtf-tools/patches/patch-ae
agc bed5d4f4fb Apply patches from PR 12971 from Ben Collver (collver@linuxfreemail.com)
"1) rtf-tools has its own way of switching between symbols and normal
characters when converting to groff.  This patch fixes rtf-tools to
honor the assumption that the \plain command resets to the normal font.
This unscrambles the formatting of some RTF->groff documents.

http://msdn.microsoft.com/library/specs/rtfspec_16.htm#rtfspec_fontcharformat
only mentions resetting font format properties, not the font itself.
It also says that the default properties are application-specific.

2) rtf-tools specifies the column separation for every column.  Since
it is meaningless for the last column of a table, the tbl command
outputs messages to stderr.  This patch removes column separation from
the last column of the table to keep groff quiet."
2001-05-31 11:04:56 +00:00

118 lines
3 KiB
Text

$NetBSD: patch-ae,v 1.2 2001/05/31 11:04:56 agc Exp $
--- lib/reader.c.orig Tue Apr 5 12:14:55 1994
+++ lib/reader.c Wed May 16 22:10:17 2001
@@ -587,38 +587,45 @@
if (autoCharSetFlags == 0)
return;
- if ((autoCharSetFlags & rtfReadCharSet)
- && RTFCheckCM (rtfControl, rtfCharSet))
+ if (autoCharSetFlags & rtfReadCharSet)
{
- ReadCharSetMaps ();
- }
- else if ((autoCharSetFlags & rtfSwitchCharSet)
- && RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum))
- {
- if ((fp = RTFGetFont (rtfParam)) != (RTFFont *) NULL)
+ if (RTFCheckCM (rtfControl, rtfCharSet))
{
- if (strncmp (fp->rtfFName, "Symbol", 6) == 0)
- curCharSet = rtfCSSymbol;
- else
- curCharSet = rtfCSGeneral;
- RTFSetCharSet (curCharSet);
+ ReadCharSetMaps ();
}
- }
- else if ((autoCharSetFlags & rtfSwitchCharSet) && rtfClass == rtfGroup)
- {
- switch (rtfMajor)
+ else if (RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum))
{
- case rtfBeginGroup:
- if (csTop >= maxCSStack)
- RTFPanic ("_RTFGetToken: stack overflow");
- csStack[csTop++] = curCharSet;
- break;
- case rtfEndGroup:
- if (csTop <= 0)
- RTFPanic ("_RTFGetToken: stack underflow");
- curCharSet = csStack[--csTop];
+ if ((fp = RTFGetFont (rtfParam)) != (RTFFont *) NULL)
+ {
+ if (strncmp (fp->rtfFName, "Symbol", 6) == 0)
+ curCharSet = rtfCSSymbol;
+ else
+ curCharSet = rtfCSGeneral;
+ RTFSetCharSet (curCharSet);
+ }
+ }
+ /* so \plain will revert to normal character set -Ben */
+ else if (RTFCheckCMM (rtfControl, rtfCharAttr, rtfPlain))
+ {
+ curCharSet = rtfCSGeneral;
RTFSetCharSet (curCharSet);
- break;
+ }
+ else if (rtfClass == rtfGroup)
+ {
+ switch (rtfMajor)
+ {
+ case rtfBeginGroup:
+ if (csTop >= maxCSStack)
+ RTFPanic ("_RTFGetToken: stack overflow");
+ csStack[csTop++] = curCharSet;
+ break;
+ case rtfEndGroup:
+ if (csTop <= 0)
+ RTFPanic ("_RTFGetToken: stack underflow");
+ curCharSet = csStack[--csTop];
+ RTFSetCharSet (curCharSet);
+ break;
+ }
}
}
}
@@ -1194,6 +1201,7 @@
char buf[rtfBufSiz], *bp;
int old = -1;
char *fn = "ReadFontTbl";
+int i;
for (;;)
{
@@ -1311,11 +1319,30 @@
RTFPanic ("%s: missing \"}\"", fn);
}
}
- if (fp->rtfFNum == -1)
- RTFPanic ("%s: missing font number", fn);
+
/*
* Could check other pieces of structure here, too, I suppose.
*/
+
+/*
+ * I think that would be a good idea because I ran across a program that
+ * generates incorrect RTF that specifies a font family but not a font
+ * name. This was ignored and caused rtf2xxx to coredump when it tried
+ * to strncmp() the NULL name.
+ *
+ * Better to leave no doubt about who's at fault. -Ben
+ */
+ i = 0;
+ fp = fontList;
+ while (fp != (RTFFont *)NULL) {
+ if (fp->rtfFNum == -1)
+ RTFPanic ("%s: missing font number, entry %d in font table", fn, i);
+ if (fp->rtfFName == (char *) NULL)
+ RTFPanic ("%s: missing font name, font number %d", fn, fp->rtfFNum);
+ fp = fp->rtfNextFont;
+ i++;
+ }
+
RTFRouteToken (); /* feed "}" back to router */
}