head 1.7; access; symbols pkgsrc-2013Q2:1.7.0.6 pkgsrc-2013Q2-base:1.7 pkgsrc-2012Q4:1.7.0.4 pkgsrc-2012Q4-base:1.7 pkgsrc-2011Q4:1.7.0.2 pkgsrc-2011Q4-base:1.7 pkgsrc-2011Q3:1.6.0.2 pkgsrc-2011Q3-base:1.6 pkgsrc-2011Q2:1.5.0.48 pkgsrc-2011Q2-base:1.5 pkgsrc-2011Q1:1.5.0.46 pkgsrc-2011Q1-base:1.5 pkgsrc-2010Q4:1.5.0.44 pkgsrc-2010Q4-base:1.5 pkgsrc-2010Q3:1.5.0.42 pkgsrc-2010Q3-base:1.5 pkgsrc-2010Q2:1.5.0.40 pkgsrc-2010Q2-base:1.5 pkgsrc-2010Q1:1.5.0.38 pkgsrc-2010Q1-base:1.5 pkgsrc-2009Q4:1.5.0.36 pkgsrc-2009Q4-base:1.5 pkgsrc-2009Q3:1.5.0.34 pkgsrc-2009Q3-base:1.5 pkgsrc-2009Q2:1.5.0.32 pkgsrc-2009Q2-base:1.5 pkgsrc-2009Q1:1.5.0.30 pkgsrc-2009Q1-base:1.5 pkgsrc-2008Q4:1.5.0.28 pkgsrc-2008Q4-base:1.5 pkgsrc-2008Q3:1.5.0.26 pkgsrc-2008Q3-base:1.5 cube-native-xorg:1.5.0.24 cube-native-xorg-base:1.5 pkgsrc-2008Q2:1.5.0.22 pkgsrc-2008Q2-base:1.5 cwrapper:1.5.0.20 pkgsrc-2008Q1:1.5.0.18 pkgsrc-2008Q1-base:1.5 pkgsrc-2007Q4:1.5.0.16 pkgsrc-2007Q4-base:1.5 pkgsrc-2007Q3:1.5.0.14 pkgsrc-2007Q3-base:1.5 pkgsrc-2007Q2:1.5.0.12 pkgsrc-2007Q2-base:1.5 pkgsrc-2007Q1:1.5.0.10 pkgsrc-2007Q1-base:1.5 pkgsrc-2006Q4:1.5.0.8 pkgsrc-2006Q4-base:1.5 pkgsrc-2006Q3:1.5.0.6 pkgsrc-2006Q3-base:1.5 pkgsrc-2006Q2:1.5.0.4 pkgsrc-2006Q2-base:1.5 pkgsrc-2006Q1:1.5.0.2 pkgsrc-2006Q1-base:1.5 pkgsrc-2005Q4:1.4.0.6 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.4 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.2 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.2.0.20 pkgsrc-2005Q1-base:1.2 pkgsrc-2004Q4:1.2.0.18 pkgsrc-2004Q4-base:1.2 pkgsrc-2004Q3:1.2.0.16 pkgsrc-2004Q3-base:1.2 pkgsrc-2004Q2:1.2.0.14 pkgsrc-2004Q2-base:1.2 pkgsrc-2004Q1:1.2.0.12 pkgsrc-2004Q1-base:1.2 pkgsrc-2003Q4:1.2.0.10 pkgsrc-2003Q4-base:1.2 netbsd-1-6-1:1.2.0.6 netbsd-1-6-1-base:1.2 netbsd-1-6:1.2.0.8 netbsd-1-6-RELEASE-base:1.2 pkgviews:1.2.0.4 pkgviews-base:1.2 buildlink2:1.2.0.2 buildlink2-base:1.2 netbsd-1-5-PATCH003:1.2 netbsd-1-5-PATCH001:1.1.1.1 pkgsrc-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.7 date 2011.10.06.21.56.16; author dholland; state dead; branches; next 1.6; 1.6 date 2011.10.03.07.21.15; author dholland; state Exp; branches; next 1.5; 1.5 date 2006.01.08.20.52.57; author joerg; state Exp; branches; next 1.4; 1.4 date 2005.03.28.14.48.23; author ben; state Exp; branches; next 1.3; 1.3 date 2005.03.27.18.22.35; author ben; state Exp; branches; next 1.2; 1.2 date 2001.05.31.11.04.56; author agc; state Exp; branches; next 1.1; 1.1 date 2001.04.27.12.18.33; author agc; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2001.04.27.12.18.33; author agc; state Exp; branches; next ; desc @@ 1.7 log @Collect the pkgsrc patches, plus a lot of other more or less needed cleanup, into a jumbo distfile patch. I've almost got a clean WARNS build; the remaining warnings are almost certainly bugs and need investigation by someone with deeper knowledge of rtf and/or troff than I have. PKGREVISION -> 3 @ text @$NetBSD: patch-ae,v 1.6 2011/10/03 07:21:15 dholland Exp $ - use stdlib.h instead of customized wrong malloc declaration - disable varargs code - use snprintf where obvious - ...? --- lib/reader.c.orig 1994-04-05 19:14:55.000000000 +0000 +++ lib/reader.c @@@@ -43,10 +43,11 @@@@ # define STRING_H # endif +#include # include # include # include STRING_H -# ifdef STDARG +# if 1 # include # else # ifdef VARARGS @@@@ -78,12 +79,6 @@@@ # define maxCSStack 10 -#ifndef THINK_C -extern char *malloc (); -#else -extern void *malloc(size_t); -#endif - static void _RTFGetToken (); static void _RTFGetToken2 (); static int GetChar (); @@@@ -137,7 +132,7 @@@@ static RTFColor *colorList = (RTFColor * static RTFStyle *styleList = (RTFStyle *) NULL; -static FILE *rtffp = stdin; +static FILE *rtffp; static char *inputName = (char *) NULL; static char *outputName = (char *) NULL; @@@@ -207,6 +202,9 @@@@ RTFFont *fp; RTFStyle *sp; RTFStyleElt *eltList, *ep; + if (rtffp == NULL) + rtffp = stdin; + if (rtfTextBuf == (char *) NULL) /* initialize the text buffers */ { rtfTextBuf = RTFAlloc (rtfBufSiz); @@@@ -587,38 +585,45 @@@@ RTFFont *fp; if (autoCharSetFlags == 0) return; - if ((autoCharSetFlags & rtfReadCharSet) - && RTFCheckCM (rtfControl, rtfCharSet)) - { - ReadCharSetMaps (); - } - else if ((autoCharSetFlags & rtfSwitchCharSet) - && RTFCheckCMM (rtfControl, rtfCharAttr, rtfFontNum)) + if (autoCharSetFlags & rtfReadCharSet) { - 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 +1199,7 @@@@ RTFFont *fp; char buf[rtfBufSiz], *bp; int old = -1; char *fn = "ReadFontTbl"; +int i; for (;;) { @@@@ -1311,11 +1317,30 @@@@ char *fn = "ReadFontTbl"; 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 */ } @@@@ -1375,6 +1400,7 @@@@ ReadStyleSheet () RTFStyle *sp; RTFStyleElt *sep, *sepLast; char buf[rtfBufSiz], *bp; +char *bs; char *fn = "ReadStyleSheet"; for (;;) @@@@ -1507,8 +1533,10 @@@@ char *fn = "ReadStyleSheet"; RTFPanic ("%s: missing style name", fn); if (sp->rtfSNum < 0) { - if (strncmp (buf, "Normal", 6) != 0 - && strncmp (buf, "Standard", 8) != 0) + /* skip leading spaces */ + for (bs = buf; *bs == ' '; bs++); + if (strncmp (bs, "Normal", 6) != 0 + && strncmp (bs, "Standard", 8) != 0) RTFPanic ("%s: missing style number", fn); sp->rtfSNum = rtfNormalStyleNum; } @@@@ -2260,6 +2288,7 @@@@ static RTFKey rtfKey[] = rtfCharSet, rtfMacCharSet, "mac", 0, rtfCharSet, rtfAnsiCharSet, "ansi", 0, + rtfCharSet, rtfAnsiCpCharSet, "ansicpg", 0, rtfCharSet, rtfPcCharSet, "pc", 0, rtfCharSet, rtfPcaCharSet, "pca", 0, @@@@ -2896,20 +2925,20 @@@@ RTFFuncPtr proc; } -# ifdef STDARG +# if 1 /* * This version is for systems with stdarg */ void -RTFMsg (char *fmt, ...) +RTFMsg (const char *fmt, ...) { char buf[rtfBufSiz]; va_list args; va_start (args,fmt); - vsprintf (buf, fmt, args); + vsnprintf (buf, sizeof(buf), fmt, args); va_end (args); (*msgProc) (buf); } @@@@ -2989,25 +3018,25 @@@@ RTFFuncPtr proc; } -# ifdef STDARG +# if 1 /* * This version is for systems with stdarg */ void -RTFPanic (char *fmt, ...) +RTFPanic (const char *fmt, ...) { char buf[rtfBufSiz]; va_list args; va_start (args,fmt); - vsprintf (buf, fmt, args); + vsnprintf (buf, sizeof(buf), fmt, args); va_end (args); - (void) strcat (buf, "\n"); + (void) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n"); if (prevChar != EOF && rtfTextBuf != (char *) NULL) { - sprintf (buf + strlen (buf), + snprintf(buf + strlen (buf), sizeof(buf) - strlen(buf), "Last token read was \"%s\" near line %ld, position %d.\n", rtfTextBuf, rtfLineNum, rtfLinePos); } @ 1.6 log @Remove varargs code. May fix build. XXX: this needs a lot more work @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.5 2006/01/08 20:52:57 joerg Exp $ @ 1.5 log @Move initialisation of FILE structures to run time, stdin and stdout are not valid rvalues on global scope. @ text @d1 6 a6 1 $NetBSD$ d10 27 a36 1 @@@@ -137,7 +137,7 @@@@ static RTFColor *colorList = (RTFColor * d45 1 a45 1 @@@@ -207,6 +207,9 @@@@ RTFFont *fp; d55 1 a55 1 @@@@ -587,38 +590,45 @@@@ RTFFont *fp; d128 1 a128 1 @@@@ -1194,6 +1204,7 @@@@ RTFFont *fp; d136 1 a136 1 @@@@ -1311,11 +1322,30 @@@@ char *fn = "ReadFontTbl"; d169 1 a169 1 @@@@ -1375,6 +1405,7 @@@@ ReadStyleSheet () d177 1 a177 1 @@@@ -1507,8 +1538,10 @@@@ char *fn = "ReadStyleSheet"; d190 1 a190 1 @@@@ -2260,6 +2293,7 @@@@ static RTFKey rtfKey[] = d198 55 @ 1.4 log @Make rtf-tools skip leading whitespace in stylesheet name when checking for a Normal or Standard stylesheet. @ text @d3 1 a3 1 --- lib/reader.c.orig 1994-04-05 12:14:55.000000000 -0700 d5 20 a24 1 @@@@ -587,38 +587,45 @@@@ RTFFont *fp; d30 1 a30 2 + if (autoCharSetFlags & rtfReadCharSet) { d35 2 a36 1 - { d97 1 a97 1 @@@@ -1194,6 +1201,7 @@@@ RTFFont *fp; d105 1 a105 1 @@@@ -1311,11 +1319,30 @@@@ char *fn = "ReadFontTbl"; d138 1 a138 1 @@@@ -1375,6 +1402,7 @@@@ ReadStyleSheet () d146 1 a146 1 @@@@ -1507,8 +1535,10 @@@@ char *fn = "ReadStyleSheet"; d159 1 a159 1 @@@@ -2260,6 +2290,7 @@@@ static RTFKey rtfKey[] = @ 1.3 log @Add support for codepage 1252 characters, sort PLIST, bump PKGREVISION. @ text @d78 1 a78 1 @@@@ -1194,6 +1213,7 @@@@ RTFFont *fp; d86 1 a86 1 @@@@ -1311,11 +1331,30 @@@@ char *fn = "ReadFontTbl"; d119 22 a140 1 @@@@ -2260,6 +2299,7 @@@@ static RTFKey rtfKey[] = @ 1.2 log @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." @ text @d3 3 a5 3 --- 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 @@@@ d78 1 a78 1 @@@@ -1194,6 +1201,7 @@@@ d86 1 a86 1 @@@@ -1311,11 +1319,30 @@@@ d119 8 @ 1.1 log @Initial revision @ text @d3 76 a78 3 --- lib/reader.c.orig Sun Apr 8 14:53:30 2001 +++ lib/reader.c Sun Apr 8 14:54:58 2001 @@@@ -1194,6 +1194,7 @@@@ d86 1 a86 1 @@@@ -1311,11 +1312,30 @@@@ @ 1.1.1.1 log @Initial import of rtf-tools-1.10 into the packages collection. Provided in PR 12583 by Ben Collver (collver@@linuxfreemail.com). This distribution contains source and documentation for an RTF (Rich Text Format) translation tool. Translators exist to produce plaintext and troff output. @ text @@