w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

plain2.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1991,1992,1993 NEC Corporation.
3  * $Id: plain2.h,v 2.21 1994/04/19 10:16:57 uchida Exp $ (NEC)
4  */
5 /*
6  * plain2 -- plain tex to {roff, LaTeX} translator
7  *
8  * Author: uchida@ccs.mt.nec.co.jp (Uchida, Akihiro)
9  *
10  * Organization: C&C Common Software Development Lab.
11  * NEC Corporation
12  *
13  * thanks to: sano@ccs.mt.nec.co.jp (Sano, Susumu)
14  * saji@ccs.mt.nec.co.jp (Saji, Nobuyuki)
15  * 0.0: 18/12/89
16  * 1.0: 17/08/90
17  * 2.0: 12/12/90
18  * 2.2: 31/05/91
19  * 2.4: 28/04/92
20  * 2.5: 06/08/93
21  */
22 /*
23  * modify by k-chinen@is.aist-nara.ac.jp, 1994
24  */
25 
26 /* #define NEC_CCS /* NEC C&C Common Software Lab. dependent */
27 
28 /* #undef NTT_TEX /* NTT jlatex */ /* no longer needed */
29 
30 #define TITLE_SPECIAL
31 
32 #define PLAIN2_ENV "PLAIN2_INIT"
33 #define PLAIN2_LIB "PLAIN2_LIB"
34 
35 #define MACRO_LIB "c:/usr/local/share/plain2"
36 
37 #define DEFAULT_STY "" /* default style in TeX output */
38 /*#define DEFAULT_STY "a4" */
39 
40 #define MIN_INDENT 4 /* minimum indentation to be indented region */
41 #define MIN_SPACING 4 /* minimum number of lines to be space region*/
42 #define MAX_DSCRLEN 40 /* maximum length for description list */
43 
44 #define DEF_PAGE_WIDTH 820 /* default page width in pt. (A4 size) */
45 #define MAX_LINE_LEN 1024 /* length of input buffer */
46 #define ESC 0x1b /* Escape character */
47 /*
48  * Text Line structure
49  */
50 struct text {
51  struct textBlock *block;
52  char *body; /* Pointer to saved text line */
53  /* outlooks of the line */
54  short blank; /* Blank line */
55  short length; /* Text Length (including leading white)*/
56  short indent; /* Text Indentation */
57  short spaces; /* Number of space */
58  short japanese; /* If Japanese character included */
59  short picLines; /* Number of picture line */
60  /* result of line analysis */
61 #define DEFINITELY 2
62 #define AMBIGUOUS 1
63 #define NEVER 0
64  short pListHead; /* looks like list head */
65  short pSecNum; /* looks like section number */
66 #define FT_FIGURE 1
67 #define FT_TABLE 2
68  short fTitle;
69 #define L_NUMBER 1 /* Number list head */
70 #define L_SROMAN 2 /* lower Roman Number list head */
71 #define L_LROMAN 3 /* upper Roman Number list head */
72 #define L_SALPHA 4 /* Alphabetic(small) list head */
73 #define L_LALPHA 5 /* Alphabetic(large) list head */
74 #define L_ENUM_MAX 6 /* type <= L_ENUM_MAX are enum list */
75 #define L_BULLET 7 /* Bullet list head */
76 #define L_DASH 8 /* Dash list head */
77 #define L_DLIST 9 /* Description list */
78  short listType; /* type of list if listHead==T */
79 #define LH_PAREN 1 /* both side parenthesis (1) */
80 #define LH_RPAREN 2 /* right side parenthesis 1) */
81 #define LH_BRACKET 3 /* both side bracket [1] */
82 #define LH_RBRACKET 4 /* right side bracket 1] */
83 #define LH_DOTTED 5 /* both side parenthesis 1. */
84  short listHint; /* more info for list */
85  short headLen; /* length of the Head (list, secnum) */
86  short secDepth; /* depth of section */
87  short listNum; /* value of list (also used for ftitle) */
88 #ifdef DEBUG
89  short printed;
90 #endif
91  struct text *next;
92 };
93 
94 /*
95  * Text Block structure
96  */
97 struct textBlock {
98 #define TB_SECNUM 1 /* section number */
99 #define TB_PLAIN 2 /* plain text */
100 #define TB_QUOTE 3 /* quoted text (>> etc) */
101 #define TB_EXAMPLE 4 /* Example (verbatim) */
102 #define TB_TABLE 5 /* table */
103 #define TB_LIST 6 /* list */
104 #define TB_LISTHD 7 /* list head */
105 #define TB_PAGE 8 /* new page */
106 #define TB_SPACE 9 /* open region */
107 #define TB_PICTURE 10 /* picture */
108 #define TB_RIGHT 11 /* output device specific*/
109 #define TB_CENTER 12 /* output device specific*/
110 #define TB_RAW 13 /* output device specific*/
111 #define TB_FTITLE 14 /* figure/table titles */
112 #define TB_APPENDIX 15 /* appendix */
113 #define TB_CAPSULE 16 /* encapsulation */
114 #define TB_COMMENT 17 /* to be ignored */
115  short type; /* Type of block */
116  short rbegin; /* Region begin */
117  short rend; /* Region end */
118  short hinted; /* hint exists */
119  /* Pointer to ListHead (for LIST,LISTHD)*/
122 };
123 struct strVal {
124  char *pattern;
125  short value;
126 };
127 /*
128  * Character translation table (for textQuote)
129  */
130 struct transTable {
132  char *trans_to;
133 };
134 
135 #define MSG0(format)\
136  if (verbose) (void)fprintf(stderr, format)
137 #define MSG1(format, val)\
138  if (verbose) (void)fprintf(stderr, format, val)
139 #define MSG2(format, val1, val2)\
140  if (verbose) (void)fprintf(stderr, format, val1, val2)
141 #define MSG3(format, val1, val2, val3)\
142  if (verbose) (void)fprintf(stderr, format, val1, val2, val3)
143 #define MSG4(format, val1, val2, val3, val4)\
144  if (verbose) (void)fprintf(stderr, format, val1, val2, val3,val4)
145 #ifdef DEBUG
146 #define DBG0(level, format)\
147  if (debug >= level) (void)fprintf(stderr, format)
148 #define DBG1(level, format, val)\
149  if (debug >= level) (void)fprintf(stderr, format, val)
150 #define DBG2(level, format, val1, val2)\
151  if (debug >= level) (void)fprintf(stderr, format, val1, val2)
152 #define DBG3(level, format, val1, val2, val3)\
153  if (debug >= level) (void)fprintf(stderr, format, val1, val2, val3)
154 #define DBG4(level, format, val1, val2, val3, val4)\
155  if (debug >= level) (void)fprintf(stderr, format, val1, val2, val3,val4)
156 #define PRINTED(lnum) {if (texts[lnum]->printed++)\
157 fprintf(stderr, "ERROR: duplicated output %d:%s\n",lnum, texts[lnum]->body);}
158 #define PRINTED2(l1, l2) {int i; for (i=l1; i<l2; i++)PRINTED(i);}
159 #else
160 #define DBG0(level, format)
161 #define DBG1(level, format, val)
162 #define DBG2(level, format, val1, val2)
163 #define DBG3(level, format, val1, val2, val3)
164 #define DBG4(level, format, val1, val2, val3, val4)
165 #define PRINTED(lnum)
166 #define PRINTED2(l1, l2)
167 #endif
168 
169 #define abs(x) ((x)>0?(x):-(x))
170 #define sign(x) ((x)>0?1:-1)
171 #define max(a,b) (a>b?a:b)
172 #define min(a,b) (a<b?a:b)
173 #define alphaVal(c) ((c) - 'a' + 1)
174 #define isBlank(l) (texts[l]->length == 0 || texts[l]->block != NULL)
175 #define str2match(s1, s2) ((*(s1) == *(s2)) && (*((s1) + 1) == *((s2) + 1)))
176 
177 /*
178  * Parameters for Parsing
179  */
180 extern int tableEnabled; /* Enables Table */
181 extern int jisTableEnabled; /* JIS Wakusen Table enabled */
182 extern int indentedSecnum; /* Section number maybe indented*/
183 extern int picEnabled; /* Enables Picture */
184 extern int tableFactor; /* Table judgement factor */
185 extern int examFactor; /* Example judgement factor
186  * bigger number cause more example
187  */
188 extern int removePaging; /* remove Paging (Header Footer lines)
189  * in the original text
190  */
191 extern int crossRefer; /* Fig/Picture/Section reference*/
192 extern char *texStyleOpt; /* TeX Style option */
193 #define MM_MACRO 1
194 #define MS_MACRO 2
195 extern int roffMacro; /* roff macro (ms or mM) */
196 extern int renumber; /* Only renumbering (section & list)*/
197 /*
198  * Output parameters
199  */
200 extern int pageWidth; /* Page width (in point) */
201 extern int rawOutput; /* text quote enabled(non through)*/
202 extern int halfCooked; /* half cooked mode (not raw) */
203 #define CODE_EUC 0
204 #define CODE_JIS 1
205 #define CODE_SJIS 2
206 extern int outputCode; /* output code (JIS/EUC/SJIS) */
207 extern int inputCode; /* input code (JIS,EUC/SJIS) */
208 extern int preamble; /* preamble block */
209 extern int accurateSecnum; /* Accurate section number output*/
210 extern int listDecor; /* List decoration */
211 extern int reflectSpace; /* reflect space lines */
212 extern int texQuote; /* Use \verb| | for tex output */
213 #ifdef HTML
214 extern int htmlOnce; /* One/Multi-path flag for HTML */
215 extern int htmlHere; /* flag of pic/tbl here or not */
216 #endif
217 extern int indexEnabled; /* Enables Indexing */
218 extern int fontSize; /* font size */
219 extern int fontSpecified; /* font size specified */
220 extern int useJverb; /* use jverbatim (Nide) */
221 /* */
222 extern FILE *inFile; /* intput File */
223 extern struct text **texts; /* texts[lineNum] array of text
224  * lineNum is 1 origin */
225 extern struct text *textTop; /* Top of text structure */
226 extern struct textBlock *pageBp; /* Top of new page block */
227 extern int textLines; /* Text lines */
228 extern int textBegin; /* Where text body begins */
229 extern int rightMargin; /* Right margin of the text */
230 extern int japaneseText; /* Japanese text */
231 extern char *fname; /* Input file name */
232 extern int verbose; /* verbose(generate warnings) */
233 extern int titleStyle; /* TeX style */
234 extern int inlineHint; /* Inline hint */
235 extern char *plain2Lib; /* Plain2 library path */
236 extern int anySection; /* if any section output exists */
237 #ifdef DEBUG
238 extern int debug; /* Debug level */
239 #endif
240 /*
241  * Constants for title block
242  */
243 #define IND_CENTER 1 /* Centering */
244 #define IND_RIGHT 2 /* Right justification */
245 #define IND_RESUME 3 /* Resume from indentation */
246 #define IND_INDENT 4 /* Resume from indentation */
247 
248 #define TITLE_A47 1
249 #define TITLE_A47_1 2
250 #define TITLE_OHP 3
251 
252 /* Definition for begin/end */
253 #define BEGIN 1
254 #define END 0
255 
256 /* Definitions for spacing */
257 #define SP_BLANK 1
258 #define SP_PAGE 2
259 #define SP_NEWLINE 3
260 #define SP_SPACE 4
261 
262 char *codeCvt();
263 char *sftj2eucStr();
264 char *euc2sftjStr();
265 char *euc2jisStr();
266 char *strsave();
267 char *strNum();
268 char *textQuote();
270 struct text *prevLine();
271 struct text *nextLine();
275 char *listSecBody();
276 int dumpText();
283 struct picLineElm *picLineMatch();
284 struct picMiscLines *picMiscMatch();
285 
286 /*
287  * Output driver
288  */
289 struct outDev {
290  /*
291  * Text (in {roff/tex}output.c)
292  */
293  int (*plain)(); /* plain text */
294  int (*example)(); /* example line */
295  int (*listBlock)(); /* List Block (begin/end) */
296  int (*dlistItem)(); /* description list */
297  int (*listItem)(); /* enum/item list */
298  int (*rawText)(); /* Raw text output */
299  int (*space)(); /* Blank lines */
300  int (*capsule)(); /* Capsule block */
301  int (*comment)(); /* Comment out */
302 #ifdef PICTURE
303  /*
304  * Picture
305  */
306  int (*pictureBlock)(); /* Picture Block (begin/end) */
307  int (*picLine)(); /* line */
308  int (*picArc)(); /* arc */
309  int (*picText)(); /* text */
310  int (*picLineWidth)(); /* Set line width */
311 #endif
312  /*
313  * Table
314  */
315  int (*table)(); /* Table */
316  int (*fTitle)(); /* Figure/Table title */
317  int (*title)(); /* Document title */
318  /*
319  * Quoting
320  */
321  char *(*quote1)();
322  char *(*quote2)();
323 };
324 extern struct outDev roffPut;
325 extern struct outDev texPut;
326 #ifdef HTML
327 extern struct outDev htmlPut;
328 #endif
329 extern struct outDev *put;
330 
331 #define INLINE_BEGIN "(("
332 #define INLINE_END "))"
333 #define INLINE_BEGIN_LEN sizeof(INLINE_BEGIN)
334 #define INLINE_END_LEN sizeof(INLINE_END)
335 
336 #define IL_PLAIN 0
337 #define IL_RAW 1
338 #define IL_FOOTNOTE 2
339 #define IL_REFERENCE 3
340 #define IL_BOLD 4
341 #define IL_INDEX 5
342 
343 extern char *malloc();
344 
345 #define INTERNAL_CODE CODE_SJIS
346 
347 #ifdef BSD
348 #include <strings.h>
349 #else
350 #include <string.h>
351 #define index(s,c) strchr(s,c)
352 #define bzero(buff, bytes) memset(buff, 0, bytes)
353 #endif
354 #ifdef WIN32
355 #define iskanji1(c) (((c)>=0x80 && (c)<0xa0) || ((c)>=0xe0 && (c)<0xfd))
356 #endif
357 #ifdef __MSDOS__ /* for Turbo C, Borland C */
358 #define MSDOS 1
359 #endif
#define debug
Definition: pdfparse.c:41
char * textQuote()
int markIfTable()
struct textBlock * pageBp
Definition: plain2.c:114
int dumpText()
int verbose
Definition: pnmhistmap.c:30
char * plain2Lib
Definition: plain2.c:105
int jisTableEnabled
Definition: plain2.c:76
int textLines
Definition: plain2.c:115
int reflectSpace
Definition: plain2.c:96
char * euc2sftjStr()
int rightMargin
Definition: plain2.c:117
int roffMacro
Definition: plain2.c:83
char * listSecBody()
struct textBlock * prevBlock()
struct outDev roffPut
Definition: output.c:68
int markIfExample()
int halfCooked
Definition: plain2.c:90
char * codeCvt()
int pageWidth
Definition: plain2.c:88
struct text ** texts
Definition: plain2.c:112
struct text * textTop
Definition: plain2.c:113
char * roffTextQuote()
struct text * prevLine()
int removePaging
Definition: plain2.c:80
char * euc2jisStr()
int markIfList()
int fontSize
Definition: plain2.c:98
int tableFactor
Definition: plain2.c:78
int useJverb
Definition: plain2.c:109
int renumber
Definition: plain2.c:84
FILE * inFile
Definition: plain2.c:111
int anySection
Definition: plain2.c:120
struct textBlock * newTextBlock()
int fontSpecified
Definition: plain2.c:99
int crossRefer
Definition: plain2.c:81
struct text * nextLine()
int inlineHint
Definition: plain2.c:82
int indexEnabled
int rawOutput
Definition: plain2.c:89
int texQuote
Definition: plain2.c:97
struct picMiscLines * picMiscMatch()
char * sftj2eucStr()
char * texStyleOpt
char * malloc()
int markAsPlain()
struct textBlock * nextBlock()
int listDecor
Definition: plain2.c:95
int markIfPicture()
int indentedSecnum
Definition: plain2.c:77
struct outDev * put
Definition: plain2.c:108
int titleStyle
Definition: plain2.c:119
int preamble
Definition: scanst.c:46
struct outDev texPut
Definition: output.c:81
int picEnabled
char * strNum()
int japaneseText
Definition: plain2.c:118
int markIfQuote()
int tableEnabled
Definition: plain2.c:75
int outputCode
Definition: plain2.c:92
char * fname
Definition: plain2.c:121
int inputCode
Definition: plain2.c:91
int accurateSecnum
Definition: plain2.c:94
int examFactor
Definition: plain2.c:79
int textBegin
Definition: plain2.c:116
char * strsave()
struct picLineElm * picLineMatch()
Definition: plain2.h:289
int(* plain)()
Definition: plain2.h:293
int(* fTitle)()
Definition: plain2.h:316
int(* comment)()
Definition: plain2.h:301
int(* title)()
Definition: plain2.h:317
int(* rawText)()
Definition: plain2.h:298
int(* space)()
Definition: plain2.h:299
int(* example)()
Definition: plain2.h:294
int(* dlistItem)()
Definition: plain2.h:296
int(* listBlock)()
Definition: plain2.h:295
int(* listItem)()
Definition: plain2.h:297
int(* capsule)()
Definition: plain2.h:300
Definition: plain2.h:123
char * pattern
Definition: plain2.h:124
short value
Definition: plain2.h:125
Definition: table.h:30
struct textBlock * superBlock
Definition: plain2.h:121
struct textBlock * nextBlock
Definition: plain2.h:120
short hinted
Definition: plain2.h:118
short rend
Definition: plain2.h:117
short rbegin
Definition: plain2.h:116
short type
Definition: plain2.h:115
short length
Definition: plain2.h:55
short japanese
Definition: plain2.h:58
short secDepth
Definition: plain2.h:86
char * body
Definition: plain2.h:52
short fTitle
Definition: plain2.h:68
short blank
Definition: plain2.h:54
short indent
Definition: plain2.h:56
struct textBlock * block
Definition: plain2.h:51
struct text * next
Definition: plain2.h:91
short spaces
Definition: plain2.h:57
short listHint
Definition: plain2.h:84
short pSecNum
Definition: plain2.h:65
short pListHead
Definition: plain2.h:64
short headLen
Definition: plain2.h:85
short picLines
Definition: plain2.h:59
short listType
Definition: plain2.h:78
short listNum
Definition: plain2.h:87
char * trans_to
Definition: plain2.h:132
char special_char
Definition: plain2.h:131
#define FILE
Definition: t1stdio.h:34
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)