TeX in C
Explore TeX with modern c compiler.
hyphen.h
浏览该文件的文档.
1 #pragma once
2 #ifndef INC_HYPHEN_H
4 #define INC_HYPHEN_H
5 #include "global.h" // [macro] qi
6 #include "mem.h" // [macro] link; [func] get_avail, free_node
7 #include "box.h" // [macro] font, character, subtype, ligptr, smallnodesize;
8  // [func] new_ligature
9 #include "fonts.h" // [type] InternalFontNumber, [macro] NON_CHAR
10 #include "eqtb.h" // [macro] language
11 #include "charset.h" // [type] ASCIICode
12 #include "tex_constant.h" // [const] TRIE_SIZE, TRIE_OP_SIZE, HYPH_SIZE, MIN_QUARTER_WORD, MAX_QUARTER_WORD
13  // end group S891x899_P330x333
19 
24 #define appendcharnodetot(x) \
25  { \
26  link(t) = get_avail(); \
27  t = link(t); \
28  font(t) = hf; \
29  character(t) = x; \
30  }
31 
33 #define setcurr() \
34  { \
35  if (j < n) { \
36  curr = qi(hu[j + 1]); \
37  } else { \
38  curr = bchar; \
39  } \
40  if (hyf[j] & 1) { \
41  currh = hchar; \
42  } else { \
43  currh = NON_CHAR; \
44  } \
45  }
46 
48 #define wraplig(x) \
49  if (ligaturepresent) { \
50  p = new_ligature(hf, curl, link(curq)); \
51  if (lfthit) { \
52  subtype(p) = 2; \
53  lfthit = false; \
54  } \
55  if (x) \
56  if (ligstack == 0) { \
57  (subtype(p))++; \
58  rthit = false; \
59  } \
60  link(curq) = p; \
61  t = p; \
62  ligaturepresent = false; \
63  }
64 
66 #define popligstack() \
67  { \
68  if (ligptr(ligstack) > null) { \
69  /* this is a charnode for |hu[j+1]| */ \
70  link(t) = ligptr(ligstack); \
71  t = link(t); \
72  j++; \
73  } \
74  p = ligstack; \
75  ligstack = link(p); \
76  free_node(p, smallnodesize); \
77  if (ligstack == null) { \
78  setcurr(); \
79  } else { \
80  curr = character(ligstack); \
81  } \
82  }
83 
85 #define advancemajortail() \
86  { \
87  majortail = link(majortail); \
88  rcount++; \
89  }
90  // end group S900x918_P334x343
92 
98 #define trielink(x) trie[x].rh
100 #define triechar(x) trie[x].UU.U2.b1
102 #define trieop(x) trie[x].UU.U2.b0
103 
105 #define setcurlang() \
106  ((language <= 0) \
107  ? (curlang = 0) \
108  : ((language > 255) ? (curlang = 0) : (curlang = language)))
109  // end group S919x941_P344x349
111 
117 #define trieroot (triel[0]) // root of the linked trie
118 
120 #define trieback(x) trie[x].UU.lh
121  // end group S942x966_P350x359
123 
124 
125 // pre-hyphen
126 extern short hc[66];
127 extern int hn;
128 extern InternalFontNumber hf;
129 extern short hu[64];
130 extern Integer hyfchar;
133 extern HalfWord hyfbchar;
134 
135 // post-hyphen
136 extern char hyf[65];
141 
142 extern void hyphenate(void);
143 extern SmallNumber reconstitute(int j, SmallNumber n,
144  HalfWord bchar, HalfWord hchar);
145 
146 // hyphen
147 extern TwoHalves trie[TRIE_SIZE + 1];
151 extern short opstart[256];
152 
153 extern StrNumber hyphword[HYPH_SIZE + 1];
154 extern Pointer hyphlist[HYPH_SIZE + 1];
155 extern HyphPointer hyphcount;
156 
157 extern void hyphen_init();
158 extern void newhyphexceptions(void);
159 
160 
161 // hyphen-init
162 extern void hyphen_init_once();
163 extern void newpatterns(void);
164 extern void inittrie(void);
165 
166 extern void hypen_dump();
167 extern Boolean hyphen_undump();
168 
169 #endif /* INC_HYPHEN_H */
uint16_t QuarterWord
[p43#113]: QuarterWord(8=>16) .
Definition: tex_types.h:126
uint32_t HalfWord
[p43#113]: HalfWord(16=>32) .
Definition: tex_types.h:127
UChar ASCIICode
[#18]: ASCIICode::UChar(8) = [0, 255]
Definition: charset.h:11
#define HYPH_SIZE
[#12] another prime; the number of \hyphenation exceptions.
Definition: tex_constant.h:148
#define TRIE_SIZE
[#11] space for hyphenation patterns.
Definition: tex_constant.h:103
#define TRIE_OP_SIZE
[#11] space for "opcodes" in the hyphenation patterns.
Definition: tex_constant.h:108
uint_fast32_t StrNumber
Definition: str.h:73
UChar InternalFontNumber
[#548]: [FONT_BASE, FONT_MAX] = [0, 75]
Definition: fonts.h:92
InternalFontNumber hf
Definition: hyphen_pre.c:17
Integer lhyf
Definition: hyphen_pre.c:21
int hn
Definition: hyphen_pre.c:16
short hu[64]
Definition: hyphen_pre.c:18
ASCIICode curlang
Definition: hyphen_pre.c:20
void hyphenate(void)
Definition: hyphen_pre.c:26
short hc[66]
Definition: hyphen_pre.c:15
Integer hyfchar
Definition: hyphen_pre.c:19
HalfWord hyfbchar
Definition: hyphen_pre.c:22
Boolean initlig
Definition: hyphen_post.c:11
char hyf[65]
Definition: hyphen_post.c:10
HalfWord curl
Definition: hyphen_post.c:17
Boolean ligaturepresent
Definition: hyphen_post.c:18
SmallNumber reconstitute(int j, SmallNumber n, HalfWord bchar, HalfWord hchar)
Definition: hyphen_post.c:24
SmallNumber hyphenpassed
Definition: hyphen_post.c:14
SmallNumber hyfnum[TRIE_OP_SIZE]
Definition: hyphen.c:17
StrNumber hyphword[HYPH_SIZE+1]
Definition: hyphen.c:22
TwoHalves trie[TRIE_SIZE+1]
Definition: hyphen.c:15
QuarterWord hyfnext[TRIE_OP_SIZE]
Definition: hyphen.c:18
Pointer hyphlist[HYPH_SIZE+1]
Definition: hyphen.c:23
short opstart[256]
Definition: hyphen.c:19
HyphPointer hyphcount
Definition: hyphen.c:24
void newhyphexceptions(void)
[#934] enters new exceptions.
Definition: hyphen.c:38
void hyphen_init()
[p346#928]
Definition: hyphen.c:29
SmallNumber hyfdistance[TRIE_OP_SIZE]
Definition: hyphen.c:16
void newpatterns(void)
#960
Definition: hyphen_init.c:264
void hypen_dump()
[#1324] Dump the hyphenation tables.
Definition: hyphen_init.c:461
void inittrie(void)
#966
Definition: hyphen_init.c:390
void hyphen_init_once()
[#946, #951]
Definition: hyphen_init.c:68
Boolean hyphen_undump()
[#1325] Undump the hyphenation tables.
Definition: hyphen_init.c:510
Boolean rthit
Definition: hyphen.h:140
HalfWord curr
Definition: hyphen.h:139
Boolean lfthit
Definition: hyphen.h:140
Integer rhyf
Definition: hyphen.h:132
Integer initlhyf
Definition: hyphen.h:132
ASCIICode initcurlang
Definition: hyphen.h:131
Integer initrhyf
Definition: hyphen.h:132
Boolean initlft
Definition: hyphen.h:137
[p43#113]: TwoHalves(64) .
Definition: tex_types.h:144
int64_t Integer
Integer(64) =
Definition: tex_types.h:42
size_t Pointer
Pointer::size_t(64), a flag or a location in mem or eqtb.
Definition: tex_types.h:45
bool Boolean
布尔类型定义
Definition: tex_types.h:11
Pointer HyphPointer
an index into the ordered hash table; [0, HYPH_SIZE=307].
Definition: tex_types.h:191
UChar SmallNumber
[p38#101]: SmallNumber::UChar(8) = [0, 255] only need: (6bit)[0, 63] .
Definition: tex_types.h:112