(original) (raw)

--- doc2rtf.c.ORG Wed Feb 19 01:38:08 2003 +++ doc2rtf.c Wed Sep 17 17:33:38 2003 @@ -108,7 +108,11 @@ fprintf(b, "{\\rtf1\\ansi "); /* vers 1 rtf, ansi char set */ fprintf(b, "\\deff0"); /* default font font 0 */ /* font table: font 0 proportional, font 1 fixed */ +#ifdef JAPANESE + fprintf(b,"{\\fonttbl{\\f0\\fnil\\fcharset128 \\\'82\\\'6c\\\'82\\\'72\\\'82\\\'6f\\\'83\\\'53\\\'83\\\'56\\\'83\\\'62\\\'83\\\'4e;}{\\f1\\fnil\\fcharset128 \\\'82\\\'6c\\\'82\\\'72\\\'82\\\'6f\\\'83\\\'53\\\'83\\\'56\\\'83\\\'62\\\'83\\\'4e;}{\\f2\\fnil\\fprq2\\fcharset128 System;}{\\f3\\fnil\\fcharset128 \\\'82\\\'6c\\\'82\\\'72\\\'82\\\'6f\\\'83\\\'53\\\'83\\\'56\\\'83\\\'62\\\'83\\\'4e;}}\n"); +#else fprintf(b, "{\\fonttbl{\\f0\\fswiss Arial;}{\\f1\\fmodern Courier New;}}\n"); +#endif /* process each line of the file */ while (get_line(line, sizeof(line), a)) { @@ -117,10 +121,22 @@ /* close final page and generate trailer */ fprintf(b, "}{\\plain \\page}\n"); - /* fprintf(b,"}\n"); */ /* HBB: HACK ALERT: only without this, hc31 works */ +#ifndef JAPANESE + fprintf(b,"}\n"); /* HBB: HACK ALERT: only without this, hc31 works */ +#endif list_free(); } +#ifdef JAPANESE +char filtrated_char(char *str, int nbyte) +{ + char c; + c=*(str+nbyte); + if(c&0x80) return (char)0xff; + else return c; +} +#endif + void process_line(char *line, FILE *b) { @@ -145,7 +161,11 @@ i = 0; j = 0; while (line[i] != NUL) { +#ifdef JAPANESE + switch (filtrated_char(line,i)) { +#else switch (line[i]) { +#endif case '\\': case '{': case '}': @@ -157,12 +177,20 @@ case '\n': break; case '`': /* backquotes mean boldface or link */ +#ifdef JAPANESE + if (filtrated_char(line,i) == ' ') /* tabular line */ +#else if (line[1] == ' ') /* tabular line */ +#endif line2[j] = line[i]; else if ((!inref) && (!inquote)) { k = i + 1; /* index into current string */ l = 0; /* index into topic string */ +#ifdef JAPANESE + while ((filtrated_char(line,k) != '`') && (line[k] != NUL)) +#else while ((line[k] != '`') && (line[k] != NUL)) +#endif topic[l++] = line[k++]; topic[l] = NUL; klist = lookup(topic); @@ -220,9 +248,17 @@ i = 1; +#ifdef JAPANESE + switch (filtrated_char(line, 0)) { /* control character */ +#else switch (line[0]) { /* control character */ +#endif case '?':{ /* interactive help entry */ +#ifdef JAPANESE + if ((line2[1] != NUL) && (filtrated_char(line2, 1) != ' ')) +#else if ((line2[1] != NUL) && (line2[1] != ' ')) +#endif footnote('K', &(line2[1]), b); break; } @@ -245,13 +281,21 @@ tabl = 0; break; case ' ':{ /* normal text line */ +#ifdef JAPANESE + if ((line2[1] == NUL) || (filtrated_char(line2, 1) == '\n')) { +#else if ((line2[1] == NUL) || (line2[1] == '\n')) { +#endif fprintf(b, "\\par\n"); llpara = para; para = 0; tabl = 0; } +#ifdef JAPANESE + if (filtrated_char(line2, 1) == ' ') { +#else if (line2[1] == ' ') { +#endif if (!tabl) { fprintf(b, "\\par\n"); } @@ -275,7 +319,11 @@ break; } default:{ +#ifdef JAPANESE + if (isdigit((int)filtrated_char(line, 0))) { /* start of section */ +#else if (isdigit((int)line[0])) { /* start of section */ +#endif if (startpage) { /* use new level 0 item */ refs(0, b, "\\par", NULL, "\\par{\\uldb %s}{\\v loc%d}\n"); fprintf(b, "}{\\plain \\page}\n");