Debian Codegraph @

texk/web2c/synctexdir/synctex-mem.ch0

raw
1 Copyright (c) 2008, 2009 jerome DOT laurens AT u-bourgogne DOT fr
2
3 This file is part of the SyncTeX package.
4
5 Latest Revision: Wed Jul 1 11:17:37 UTC 2009
6
7 License:
8 --------
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use,
13 copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the
15 Software is furnished to do so, subject to the following
16 conditions:
17
18 The above copyright notice and this permission notice shall be
19 included in all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 OTHER DEALINGS IN THE SOFTWARE
29
30 Except as contained in this notice, the name of the copyright holder
31 shall not be used in advertising or otherwise to promote the sale,
32 use or other dealings in this Software without prior written
33 authorization from the copyright holder.
34
35 Acknowledgments:
36 ----------------
37 The author received useful remarks from the pdfTeX developers, especially Hahn The Thanh,
38 and significant help from XeTeX developer Jonathan Kew
39
40 Nota Bene:
41 ----------
42 If you include or use a significant part of the synctex package into a software,
43 I would appreciate to be listed as contributor and see "SyncTeX" highlighted.
44
45 Notice:
46 -------
47
48 - Fixing the bug pointed out by Hahn The Thanh during the discussion started by Reinhard Kotucha at
49 http://www.ntg.nl/pipermail/ntg-pdftex/2009-May/003786.html.
50
51 The |synctex_field_size| depends on the TeX implementation.
52 pdfTeX uses 2 additional words whereas XeTeX will only use one,
53 because it naturally has bigger words of memory.
54 @x tex.web l.2898
55 @d box_node_size=7 {number of words to allocate for a box node}
56 @y
57 @d box_node_size=7+synctex_field_size {number of words to allocate for a box node}
58 @z
59
60 @x tex.web l.2944
61 @d rule_node_size=4 {number of words to allocate for a rule node}
62 @y
63 @d rule_node_size=4+synctex_field_size {number of words to allocate for a rule node}
64 @z
65
66 @x tex.web l.2985
67 @d small_node_size=2 {number of words to allocate for most node types}
68 @y
69 @d small_node_size=2 {number of words to allocate for most node types}
70 @d medium_node_size=small_node_size+synctex_field_size {number of words to
71 allocate for synchronized node types like math, kern, glue and penalty nodes}
72 @z
73
74 @x tex.web l.3090
75 @p function new_math(@!w:scaled;@!s:small_number):pointer;
76 @y
77 @p function new_math(@!w:scaled;@!s:small_number):pointer;
78 @z
79
80 @x
81 begin p:=get_node(small_node_size); type(p):=math_node;
82 @y
83 begin p:=get_node(medium_node_size); type(p):=math_node;
84 @z
85
86 @x tex.web l.3185
87 @p function new_param_glue(@!n:small_number):pointer;
88 @y
89 @p function new_param_glue(@!n:small_number):pointer;
90 @z
91
92 @x
93 begin p:=get_node(small_node_size); type(p):=glue_node; subtype(p):=n+1;
94 @y
95 begin p:=get_node(medium_node_size); type(p):=glue_node; subtype(p):=n+1;
96 @z
97
98 @x tex.web l.3198
99 @p function new_glue(@!q:pointer):pointer;
100 @y
101 @p function new_glue(@!q:pointer):pointer;
102 @z
103
104 @x
105 begin p:=get_node(small_node_size); type(p):=glue_node; subtype(p):=normal;
106 @y
107 begin p:=get_node(medium_node_size); type(p):=glue_node; subtype(p):=normal;
108 @z
109
110
111 @x tex.web l.3236
112 @p function new_kern(@!w:scaled):pointer;
113 @y
114 @p function new_kern(@!w:scaled):pointer;
115 @z
116
117 @x
118 begin p:=get_node(small_node_size); type(p):=kern_node;
119 @y
120 begin p:=get_node(medium_node_size); type(p):=kern_node;
121 @z
122
123 @x tex.web l.3259
124 @p function new_penalty(@!m:integer):pointer;
125 @y
126 @p function new_penalty(@!m:integer):pointer;
127 @z
128
129 @x
130 begin p:=get_node(small_node_size); type(p):=penalty_node;
131 @y
132 begin p:=get_node(medium_node_size); type(p):=penalty_node;
133 @z
134
135 @x
136 @p procedure flush_node_list(@!p:pointer); {erase list of nodes starting at |p|}
137 @y
138 @p procedure flush_node_list(@!p:pointer); {erase list of nodes starting at |p|}
139 @z
140
141 @x tex.web l.3934: free nodes with proper size
142 glue_node: begin fast_delete_glue_ref(glue_ptr(p));
143 if leader_ptr(p)<>null then flush_node_list(leader_ptr(p));
144 end;
145 @y
146 glue_node: begin fast_delete_glue_ref(glue_ptr(p));
147 if leader_ptr(p)<>null then flush_node_list(leader_ptr(p));
148 free_node(p, medium_node_size);
149 goto done;
150 end;
151 @z
152
153 @x tex.web l.3937: free nodes with proper size
154 kern_node,math_node,penalty_node: do_nothing;
155 @y
156 kern_node,math_node,penalty_node:begin
157 free_node(p, medium_node_size);
158 goto done;
159 end;
160 @z
161
162 @x tex.web l.4002:
163 @ @<Case statement to copy...@>=
164 @y
165 @ @<Case statement to copy...@>=
166 @z
167
168 @x tex.web l.4018:
169 glue_node: begin r:=get_node(small_node_size); add_glue_ref(glue_ptr(p));
170 @y
171 glue_node: begin r:=get_node(medium_node_size); add_glue_ref(glue_ptr(p));
172 @z
173
174 @x tex.web l.4021:
175 kern_node,math_node,penalty_node: begin r:=get_node(small_node_size);
176 words:=small_node_size;
177 end;
178 @y
179 kern_node,math_node,penalty_node: begin r:=get_node(medium_node_size);
180 words:=medium_node_size;
181 end;
182 @z
183
184 @x tex.web l.4912
185 @d pretolerance_code=0 {badness tolerance before hyphenation}
186 @y
187 @d REMOVE ME IF synctex_code is properly defined
188
189 @d pretolerance_code=0 {badness tolerance before hyphenation}
190 @z
191
192 @x tex.web l.5031
193 @d error_context_lines==int_par(error_context_lines_code)
194 @y
195 @d error_context_lines==int_par(error_context_lines_code)
196 @#
197 @d synctex == int_par(synctex_code)
198 @z
199
200 @x In the second "@<Types...@>="
201 @!in_state_record = record
202 @!state_field, @!index_field: quarterword;
203 @!start_field,@!loc_field, @!limit_field, @!name_field: halfword;
204 end;
205 @y
206 @!in_state_record = record
207 @!state_field, @!index_field: quarterword;
208 @!start_field,@!loc_field, @!limit_field, @!name_field: halfword;
209 @!synctex_tag_field: integer; {stack the tag of the current file}
210 end;
211 @z
212
213 @x tex.web l.6461
214 @d name==cur_input.name_field {name of the current file}
215 @y
216 @d name==cur_input.name_field {name of the current file}
217 @d synctex_tag==cur_input.synctex_tag_field {{\sl Sync\TeX} tag of the current file}
218 @z
219
220 @x tex.web l. 14185
221 @<Simplify a trivial box@>=
222 @y
223 @<Simplify a trivial box@>=
224 @z
225
226 @x tex.web l. 14191
227 begin free_node(r,small_node_size); link(q):=null;
228 @y
229 begin free_node(r,medium_node_size); link(q):=null;
230 @z
231
232 @x tex.web l. 24274
233 history:=spotless; {ready to go!}
234 @y
235 history:=spotless; {ready to go!}
236 @<Initialize synctex primitive@>
237 @z
238
239 @x tex.web l. 24956
240 @* \[54] System-dependent changes.
241 @y
242 @* \[54/SyncTeX] The {\sl Synchronize \TeX nology}.
243 This section is devoted to the {\sl Synchronize \TeX nology}
244 - or simply {\sl Sync\TeX} - used to synchronize between input and output.
245 This section explains how synchronization basics are implemented.
246 Before we enter into more technical details,
247 let us recall in a few words what is synchronization.
248
249 \TeX\ typesetting system clearly separates the input and the output material,
250 and synchronization will provide a new link between both that can help
251 text editors and viewers to work together.
252 More precisely, forwards synchronization is the ability,
253 given a location in the input source file,
254 to find what is the corresponding place in the output.
255 Backwards synchronization just performs the opposite:
256 given a location in the output,
257 retrieve the corresponding material in the input source file.
258
259 For better code management and maintainance, we adopt a naming convention.
260 Throughout this program, code related to the {\sl Synchronize \TeX nology} is tagged
261 with the ``{\sl synctex}'' key word. Any code extract where {\sl Sync\TeX} plays
262 its part, either explicitly or implicitly, (should) contain the string ``{\sl synctex}''.
263 This naming convention also holds for external files.
264 Moreover, all the code related to {\sl Sync\TeX} is gathered in this section,
265 except the definitions.
266
267 @ Enabling synchronization should be performed from the command line,
268 |synctexoption| is used for that purpose.
269 This global integer variable is declared here but it is not used here.
270 This is just a placeholder where the command line controller will put
271 the {\sl Sync\TeX} related options, and the {\sl Sync\TeX} controller will read them.
272
273 @ @<Glob...@>=
274 @!synctexoption:integer;
275
276 @ A convenient primitive is provided:
277 \.{\\synctex=1} in the input source file enables synchronization whereas
278 \.{\\synctex=0} disables it.
279 Its memory address is |synctex_code|.
280 It is initialized by the {\sl Sync\TeX} controller to the command-line option if given.
281 The controller may filter some reserved bits.
282
283 @ @<Put each...@>=
284 primitive("synctex",assign_int,int_base+synctex_code);@/
285 @!@:synctex_}{\.{\\synctex} primitive@>
286
287 @ In order to give the {\sl Sync\TeX} controller read and write access to
288 the contents of the \.{\\synctex} primitive, we declare |synctexoffset|,
289 such that |mem[synctexoffset]| and \.{\\synctex} correspond to
290 the same memory storage. |synctexoffset| is initialized to
291 the correct value when quite everything is initialized.
292
293 @ @<Glob...@>=
294 @!synctexoffset:integer; {holds the true value of |synctex_code|}
295
296 @ @<Initialize whatever...@>=
297 synctexoffset:=int_base+synctex_code;
298
299 @ @<Initialize synctex primitive@>=
300 synctex_init_command;
301
302 @ Synchronization is achieved with the help of an auxiliary file...
303 @^synctex@>
304 @^synchronization@>
305
306 @* \[54] System-dependent changes.
307 @z