New upstream version 0.21.10-clean
Willi Mann
5 years ago
283 | 283 | - Support EndNote reference citations in convert.c |
284 | 284 | - Improved handling of some tables |
285 | 285 | - Fixed --text processing broken in 0.21.8 - outputs/text.conf |
286 | 0.21.10: | |
287 | - added gentoo automake-fix and iconv-detection patches |
0 | 0 | Installation Instructions |
1 | 1 | ************************* |
2 | 2 | |
3 | Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, | |
4 | Inc. | |
3 | Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software | |
4 | Foundation, Inc. | |
5 | 5 | |
6 | 6 | Copying and distribution of this file, with or without modification, |
7 | 7 | are permitted in any medium without royalty provided the copyright |
11 | 11 | Basic Installation |
12 | 12 | ================== |
13 | 13 | |
14 | Briefly, the shell commands `./configure; make; make install' should | |
15 | configure, build, and install this package. The following | |
16 | more-detailed instructions are generic; see the `README' file for | |
14 | Briefly, the shell command './configure && make && make install' | |
15 | should configure, build, and install this package. The following | |
16 | more-detailed instructions are generic; see the 'README' file for | |
17 | 17 | instructions specific to this package. Some packages provide this |
18 | `INSTALL' file but do not implement all of the features documented | |
18 | 'INSTALL' file but do not implement all of the features documented | |
19 | 19 | below. The lack of an optional feature in a given package is not |
20 | 20 | necessarily a bug. More recommendations for GNU packages can be found |
21 | 21 | in *note Makefile Conventions: (standards)Makefile Conventions. |
22 | 22 | |
23 | The `configure' shell script attempts to guess correct values for | |
23 | The 'configure' shell script attempts to guess correct values for | |
24 | 24 | various system-dependent variables used during compilation. It uses |
25 | those values to create a `Makefile' in each directory of the package. | |
26 | It may also create one or more `.h' files containing system-dependent | |
27 | definitions. Finally, it creates a shell script `config.status' that | |
25 | those values to create a 'Makefile' in each directory of the package. | |
26 | It may also create one or more '.h' files containing system-dependent | |
27 | definitions. Finally, it creates a shell script 'config.status' that | |
28 | 28 | you can run in the future to recreate the current configuration, and a |
29 | file `config.log' containing compiler output (useful mainly for | |
30 | debugging `configure'). | |
31 | ||
32 | It can also use an optional file (typically called `config.cache' | |
33 | and enabled with `--cache-file=config.cache' or simply `-C') that saves | |
34 | the results of its tests to speed up reconfiguring. Caching is | |
35 | disabled by default to prevent problems with accidental use of stale | |
36 | cache files. | |
29 | file 'config.log' containing compiler output (useful mainly for | |
30 | debugging 'configure'). | |
31 | ||
32 | It can also use an optional file (typically called 'config.cache' and | |
33 | enabled with '--cache-file=config.cache' or simply '-C') that saves the | |
34 | results of its tests to speed up reconfiguring. Caching is disabled by | |
35 | default to prevent problems with accidental use of stale cache files. | |
37 | 36 | |
38 | 37 | If you need to do unusual things to compile the package, please try |
39 | to figure out how `configure' could check whether to do them, and mail | |
40 | diffs or instructions to the address given in the `README' so they can | |
38 | to figure out how 'configure' could check whether to do them, and mail | |
39 | diffs or instructions to the address given in the 'README' so they can | |
41 | 40 | be considered for the next release. If you are using the cache, and at |
42 | some point `config.cache' contains results you don't want to keep, you | |
41 | some point 'config.cache' contains results you don't want to keep, you | |
43 | 42 | may remove or edit it. |
44 | 43 | |
45 | The file `configure.ac' (or `configure.in') is used to create | |
46 | `configure' by a program called `autoconf'. You need `configure.ac' if | |
47 | you want to change it or regenerate `configure' using a newer version | |
48 | of `autoconf'. | |
44 | The file 'configure.ac' (or 'configure.in') is used to create | |
45 | 'configure' by a program called 'autoconf'. You need 'configure.ac' if | |
46 | you want to change it or regenerate 'configure' using a newer version of | |
47 | 'autoconf'. | |
49 | 48 | |
50 | 49 | The simplest way to compile this package is: |
51 | 50 | |
52 | 1. `cd' to the directory containing the package's source code and type | |
53 | `./configure' to configure the package for your system. | |
54 | ||
55 | Running `configure' might take a while. While running, it prints | |
51 | 1. 'cd' to the directory containing the package's source code and type | |
52 | './configure' to configure the package for your system. | |
53 | ||
54 | Running 'configure' might take a while. While running, it prints | |
56 | 55 | some messages telling which features it is checking for. |
57 | 56 | |
58 | 2. Type `make' to compile the package. | |
59 | ||
60 | 3. Optionally, type `make check' to run any self-tests that come with | |
57 | 2. Type 'make' to compile the package. | |
58 | ||
59 | 3. Optionally, type 'make check' to run any self-tests that come with | |
61 | 60 | the package, generally using the just-built uninstalled binaries. |
62 | 61 | |
63 | 4. Type `make install' to install the programs and any data files and | |
62 | 4. Type 'make install' to install the programs and any data files and | |
64 | 63 | documentation. When installing into a prefix owned by root, it is |
65 | 64 | recommended that the package be configured and built as a regular |
66 | user, and only the `make install' phase executed with root | |
65 | user, and only the 'make install' phase executed with root | |
67 | 66 | privileges. |
68 | 67 | |
69 | 5. Optionally, type `make installcheck' to repeat any self-tests, but | |
68 | 5. Optionally, type 'make installcheck' to repeat any self-tests, but | |
70 | 69 | this time using the binaries in their final installed location. |
71 | 70 | This target does not install anything. Running this target as a |
72 | regular user, particularly if the prior `make install' required | |
71 | regular user, particularly if the prior 'make install' required | |
73 | 72 | root privileges, verifies that the installation completed |
74 | 73 | correctly. |
75 | 74 | |
76 | 75 | 6. You can remove the program binaries and object files from the |
77 | source code directory by typing `make clean'. To also remove the | |
78 | files that `configure' created (so you can compile the package for | |
79 | a different kind of computer), type `make distclean'. There is | |
80 | also a `make maintainer-clean' target, but that is intended mainly | |
76 | source code directory by typing 'make clean'. To also remove the | |
77 | files that 'configure' created (so you can compile the package for | |
78 | a different kind of computer), type 'make distclean'. There is | |
79 | also a 'make maintainer-clean' target, but that is intended mainly | |
81 | 80 | for the package's developers. If you use it, you may have to get |
82 | 81 | all sorts of other programs in order to regenerate files that came |
83 | 82 | with the distribution. |
84 | 83 | |
85 | 7. Often, you can also type `make uninstall' to remove the installed | |
84 | 7. Often, you can also type 'make uninstall' to remove the installed | |
86 | 85 | files again. In practice, not all packages have tested that |
87 | 86 | uninstallation works correctly, even though it is required by the |
88 | 87 | GNU Coding Standards. |
89 | 88 | |
90 | 8. Some packages, particularly those that use Automake, provide `make | |
89 | 8. Some packages, particularly those that use Automake, provide 'make | |
91 | 90 | distcheck', which can by used by developers to test that all other |
92 | targets like `make install' and `make uninstall' work correctly. | |
91 | targets like 'make install' and 'make uninstall' work correctly. | |
93 | 92 | This target is generally not run by end users. |
94 | 93 | |
95 | 94 | Compilers and Options |
96 | 95 | ===================== |
97 | 96 | |
98 | 97 | Some systems require unusual options for compilation or linking that |
99 | the `configure' script does not know about. Run `./configure --help' | |
98 | the 'configure' script does not know about. Run './configure --help' | |
100 | 99 | for details on some of the pertinent environment variables. |
101 | 100 | |
102 | You can give `configure' initial values for configuration parameters | |
103 | by setting variables in the command line or in the environment. Here | |
104 | is an example: | |
101 | You can give 'configure' initial values for configuration parameters | |
102 | by setting variables in the command line or in the environment. Here is | |
103 | an example: | |
105 | 104 | |
106 | 105 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix |
107 | 106 | |
112 | 111 | |
113 | 112 | You can compile the package for more than one kind of computer at the |
114 | 113 | same time, by placing the object files for each architecture in their |
115 | own directory. To do this, you can use GNU `make'. `cd' to the | |
114 | own directory. To do this, you can use GNU 'make'. 'cd' to the | |
116 | 115 | directory where you want the object files and executables to go and run |
117 | the `configure' script. `configure' automatically checks for the | |
118 | source code in the directory that `configure' is in and in `..'. This | |
119 | is known as a "VPATH" build. | |
120 | ||
121 | With a non-GNU `make', it is safer to compile the package for one | |
116 | the 'configure' script. 'configure' automatically checks for the source | |
117 | code in the directory that 'configure' is in and in '..'. This is known | |
118 | as a "VPATH" build. | |
119 | ||
120 | With a non-GNU 'make', it is safer to compile the package for one | |
122 | 121 | architecture at a time in the source code directory. After you have |
123 | installed the package for one architecture, use `make distclean' before | |
122 | installed the package for one architecture, use 'make distclean' before | |
124 | 123 | reconfiguring for another architecture. |
125 | 124 | |
126 | 125 | On MacOS X 10.5 and later systems, you can create libraries and |
127 | 126 | executables that work on multiple system types--known as "fat" or |
128 | "universal" binaries--by specifying multiple `-arch' options to the | |
129 | compiler but only a single `-arch' option to the preprocessor. Like | |
127 | "universal" binaries--by specifying multiple '-arch' options to the | |
128 | compiler but only a single '-arch' option to the preprocessor. Like | |
130 | 129 | this: |
131 | 130 | |
132 | 131 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ |
135 | 134 | |
136 | 135 | This is not guaranteed to produce working output in all cases, you |
137 | 136 | may have to build one architecture at a time and combine the results |
138 | using the `lipo' tool if you have problems. | |
137 | using the 'lipo' tool if you have problems. | |
139 | 138 | |
140 | 139 | Installation Names |
141 | 140 | ================== |
142 | 141 | |
143 | By default, `make install' installs the package's commands under | |
144 | `/usr/local/bin', include files under `/usr/local/include', etc. You | |
145 | can specify an installation prefix other than `/usr/local' by giving | |
146 | `configure' the option `--prefix=PREFIX', where PREFIX must be an | |
142 | By default, 'make install' installs the package's commands under | |
143 | '/usr/local/bin', include files under '/usr/local/include', etc. You | |
144 | can specify an installation prefix other than '/usr/local' by giving | |
145 | 'configure' the option '--prefix=PREFIX', where PREFIX must be an | |
147 | 146 | absolute file name. |
148 | 147 | |
149 | 148 | You can specify separate installation prefixes for |
150 | 149 | architecture-specific files and architecture-independent files. If you |
151 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses | |
150 | pass the option '--exec-prefix=PREFIX' to 'configure', the package uses | |
152 | 151 | PREFIX as the prefix for installing programs and libraries. |
153 | 152 | Documentation and other data files still use the regular prefix. |
154 | 153 | |
155 | 154 | In addition, if you use an unusual directory layout you can give |
156 | options like `--bindir=DIR' to specify different values for particular | |
157 | kinds of files. Run `configure --help' for a list of the directories | |
158 | you can set and what kinds of files go in them. In general, the | |
159 | default for these options is expressed in terms of `${prefix}', so that | |
160 | specifying just `--prefix' will affect all of the other directory | |
155 | options like '--bindir=DIR' to specify different values for particular | |
156 | kinds of files. Run 'configure --help' for a list of the directories | |
157 | you can set and what kinds of files go in them. In general, the default | |
158 | for these options is expressed in terms of '${prefix}', so that | |
159 | specifying just '--prefix' will affect all of the other directory | |
161 | 160 | specifications that were not explicitly provided. |
162 | 161 | |
163 | 162 | The most portable way to affect installation locations is to pass the |
164 | correct locations to `configure'; however, many packages provide one or | |
163 | correct locations to 'configure'; however, many packages provide one or | |
165 | 164 | both of the following shortcuts of passing variable assignments to the |
166 | `make install' command line to change installation locations without | |
165 | 'make install' command line to change installation locations without | |
167 | 166 | having to reconfigure or recompile. |
168 | 167 | |
169 | 168 | The first method involves providing an override variable for each |
170 | affected directory. For example, `make install | |
169 | affected directory. For example, 'make install | |
171 | 170 | prefix=/alternate/directory' will choose an alternate location for all |
172 | 171 | directory configuration variables that were expressed in terms of |
173 | `${prefix}'. Any directories that were specified during `configure', | |
174 | but not in terms of `${prefix}', must each be overridden at install | |
175 | time for the entire installation to be relocated. The approach of | |
176 | makefile variable overrides for each directory variable is required by | |
177 | the GNU Coding Standards, and ideally causes no recompilation. | |
178 | However, some platforms have known limitations with the semantics of | |
179 | shared libraries that end up requiring recompilation when using this | |
180 | method, particularly noticeable in packages that use GNU Libtool. | |
181 | ||
182 | The second method involves providing the `DESTDIR' variable. For | |
183 | example, `make install DESTDIR=/alternate/directory' will prepend | |
184 | `/alternate/directory' before all installation names. The approach of | |
185 | `DESTDIR' overrides is not required by the GNU Coding Standards, and | |
172 | '${prefix}'. Any directories that were specified during 'configure', | |
173 | but not in terms of '${prefix}', must each be overridden at install time | |
174 | for the entire installation to be relocated. The approach of makefile | |
175 | variable overrides for each directory variable is required by the GNU | |
176 | Coding Standards, and ideally causes no recompilation. However, some | |
177 | platforms have known limitations with the semantics of shared libraries | |
178 | that end up requiring recompilation when using this method, particularly | |
179 | noticeable in packages that use GNU Libtool. | |
180 | ||
181 | The second method involves providing the 'DESTDIR' variable. For | |
182 | example, 'make install DESTDIR=/alternate/directory' will prepend | |
183 | '/alternate/directory' before all installation names. The approach of | |
184 | 'DESTDIR' overrides is not required by the GNU Coding Standards, and | |
186 | 185 | does not work on platforms that have drive letters. On the other hand, |
187 | 186 | it does better at avoiding recompilation issues, and works well even |
188 | when some directory options were not specified in terms of `${prefix}' | |
189 | at `configure' time. | |
187 | when some directory options were not specified in terms of '${prefix}' | |
188 | at 'configure' time. | |
190 | 189 | |
191 | 190 | Optional Features |
192 | 191 | ================= |
193 | 192 | |
194 | 193 | If the package supports it, you can cause programs to be installed |
195 | with an extra prefix or suffix on their names by giving `configure' the | |
196 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. | |
197 | ||
198 | Some packages pay attention to `--enable-FEATURE' options to | |
199 | `configure', where FEATURE indicates an optional part of the package. | |
200 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE | |
201 | is something like `gnu-as' or `x' (for the X Window System). The | |
202 | `README' should mention any `--enable-' and `--with-' options that the | |
194 | with an extra prefix or suffix on their names by giving 'configure' the | |
195 | option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. | |
196 | ||
197 | Some packages pay attention to '--enable-FEATURE' options to | |
198 | 'configure', where FEATURE indicates an optional part of the package. | |
199 | They may also pay attention to '--with-PACKAGE' options, where PACKAGE | |
200 | is something like 'gnu-as' or 'x' (for the X Window System). The | |
201 | 'README' should mention any '--enable-' and '--with-' options that the | |
203 | 202 | package recognizes. |
204 | 203 | |
205 | For packages that use the X Window System, `configure' can usually | |
204 | For packages that use the X Window System, 'configure' can usually | |
206 | 205 | find the X include and library files automatically, but if it doesn't, |
207 | you can use the `configure' options `--x-includes=DIR' and | |
208 | `--x-libraries=DIR' to specify their locations. | |
206 | you can use the 'configure' options '--x-includes=DIR' and | |
207 | '--x-libraries=DIR' to specify their locations. | |
209 | 208 | |
210 | 209 | Some packages offer the ability to configure how verbose the |
211 | execution of `make' will be. For these packages, running `./configure | |
210 | execution of 'make' will be. For these packages, running './configure | |
212 | 211 | --enable-silent-rules' sets the default to minimal output, which can be |
213 | overridden with `make V=1'; while running `./configure | |
212 | overridden with 'make V=1'; while running './configure | |
214 | 213 | --disable-silent-rules' sets the default to verbose, which can be |
215 | overridden with `make V=0'. | |
214 | overridden with 'make V=0'. | |
216 | 215 | |
217 | 216 | Particular systems |
218 | 217 | ================== |
219 | 218 | |
220 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU | |
221 | CC is not installed, it is recommended to use the following options in | |
219 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC | |
220 | is not installed, it is recommended to use the following options in | |
222 | 221 | order to use an ANSI C compiler: |
223 | 222 | |
224 | 223 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" |
225 | 224 | |
226 | 225 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. |
227 | 226 | |
228 | HP-UX `make' updates targets which have the same time stamps as | |
229 | their prerequisites, which makes it generally unusable when shipped | |
230 | generated files such as `configure' are involved. Use GNU `make' | |
231 | instead. | |
227 | HP-UX 'make' updates targets which have the same time stamps as their | |
228 | prerequisites, which makes it generally unusable when shipped generated | |
229 | files such as 'configure' are involved. Use GNU 'make' instead. | |
232 | 230 | |
233 | 231 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot |
234 | parse its `<wchar.h>' header file. The option `-nodtk' can be used as | |
235 | a workaround. If GNU CC is not installed, it is therefore recommended | |
236 | to try | |
232 | parse its '<wchar.h>' header file. The option '-nodtk' can be used as a | |
233 | workaround. If GNU CC is not installed, it is therefore recommended to | |
234 | try | |
237 | 235 | |
238 | 236 | ./configure CC="cc" |
239 | 237 | |
241 | 239 | |
242 | 240 | ./configure CC="cc -nodtk" |
243 | 241 | |
244 | On Solaris, don't put `/usr/ucb' early in your `PATH'. This | |
242 | On Solaris, don't put '/usr/ucb' early in your 'PATH'. This | |
245 | 243 | directory contains several dysfunctional programs; working variants of |
246 | these programs are available in `/usr/bin'. So, if you need `/usr/ucb' | |
247 | in your `PATH', put it _after_ `/usr/bin'. | |
248 | ||
249 | On Haiku, software installed for all users goes in `/boot/common', | |
250 | not `/usr/local'. It is recommended to use the following options: | |
244 | these programs are available in '/usr/bin'. So, if you need '/usr/ucb' | |
245 | in your 'PATH', put it _after_ '/usr/bin'. | |
246 | ||
247 | On Haiku, software installed for all users goes in '/boot/common', | |
248 | not '/usr/local'. It is recommended to use the following options: | |
251 | 249 | |
252 | 250 | ./configure --prefix=/boot/common |
253 | 251 | |
254 | 252 | Specifying the System Type |
255 | 253 | ========================== |
256 | 254 | |
257 | There may be some features `configure' cannot figure out | |
255 | There may be some features 'configure' cannot figure out | |
258 | 256 | automatically, but needs to determine by the type of machine the package |
259 | 257 | will run on. Usually, assuming the package is built to be run on the |
260 | _same_ architectures, `configure' can figure that out, but if it prints | |
258 | _same_ architectures, 'configure' can figure that out, but if it prints | |
261 | 259 | a message saying it cannot guess the machine type, give it the |
262 | `--build=TYPE' option. TYPE can either be a short name for the system | |
263 | type, such as `sun4', or a canonical name which has the form: | |
260 | '--build=TYPE' option. TYPE can either be a short name for the system | |
261 | type, such as 'sun4', or a canonical name which has the form: | |
264 | 262 | |
265 | 263 | CPU-COMPANY-SYSTEM |
266 | 264 | |
269 | 267 | OS |
270 | 268 | KERNEL-OS |
271 | 269 | |
272 | See the file `config.sub' for the possible values of each field. If | |
273 | `config.sub' isn't included in this package, then this package doesn't | |
270 | See the file 'config.sub' for the possible values of each field. If | |
271 | 'config.sub' isn't included in this package, then this package doesn't | |
274 | 272 | need to know the machine type. |
275 | 273 | |
276 | 274 | If you are _building_ compiler tools for cross-compiling, you should |
277 | use the option `--target=TYPE' to select the type of system they will | |
275 | use the option '--target=TYPE' to select the type of system they will | |
278 | 276 | produce code for. |
279 | 277 | |
280 | 278 | If you want to _use_ a cross compiler, that generates code for a |
281 | 279 | platform different from the build platform, you should specify the |
282 | 280 | "host" platform (i.e., that on which the generated programs will |
283 | eventually be run) with `--host=TYPE'. | |
281 | eventually be run) with '--host=TYPE'. | |
284 | 282 | |
285 | 283 | Sharing Defaults |
286 | 284 | ================ |
287 | 285 | |
288 | If you want to set default values for `configure' scripts to share, | |
289 | you can create a site shell script called `config.site' that gives | |
290 | default values for variables like `CC', `cache_file', and `prefix'. | |
291 | `configure' looks for `PREFIX/share/config.site' if it exists, then | |
292 | `PREFIX/etc/config.site' if it exists. Or, you can set the | |
293 | `CONFIG_SITE' environment variable to the location of the site script. | |
294 | A warning: not all `configure' scripts look for a site script. | |
286 | If you want to set default values for 'configure' scripts to share, | |
287 | you can create a site shell script called 'config.site' that gives | |
288 | default values for variables like 'CC', 'cache_file', and 'prefix'. | |
289 | 'configure' looks for 'PREFIX/share/config.site' if it exists, then | |
290 | 'PREFIX/etc/config.site' if it exists. Or, you can set the | |
291 | 'CONFIG_SITE' environment variable to the location of the site script. | |
292 | A warning: not all 'configure' scripts look for a site script. | |
295 | 293 | |
296 | 294 | Defining Variables |
297 | 295 | ================== |
298 | 296 | |
299 | 297 | Variables not defined in a site shell script can be set in the |
300 | environment passed to `configure'. However, some packages may run | |
298 | environment passed to 'configure'. However, some packages may run | |
301 | 299 | configure again during the build, and the customized values of these |
302 | 300 | variables may be lost. In order to avoid this problem, you should set |
303 | them in the `configure' command line, using `VAR=value'. For example: | |
301 | them in the 'configure' command line, using 'VAR=value'. For example: | |
304 | 302 | |
305 | 303 | ./configure CC=/usr/local2/bin/gcc |
306 | 304 | |
307 | causes the specified `gcc' to be used as the C compiler (unless it is | |
305 | causes the specified 'gcc' to be used as the C compiler (unless it is | |
308 | 306 | overridden in the site shell script). |
309 | 307 | |
310 | Unfortunately, this technique does not work for `CONFIG_SHELL' due to | |
311 | an Autoconf limitation. Until the limitation is lifted, you can use | |
312 | this workaround: | |
308 | Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an | |
309 | Autoconf limitation. Until the limitation is lifted, you can use this | |
310 | workaround: | |
313 | 311 | |
314 | 312 | CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash |
315 | 313 | |
316 | `configure' Invocation | |
314 | 'configure' Invocation | |
317 | 315 | ====================== |
318 | 316 | |
319 | `configure' recognizes the following options to control how it | |
317 | 'configure' recognizes the following options to control how it | |
320 | 318 | operates. |
321 | 319 | |
322 | `--help' | |
323 | `-h' | |
324 | Print a summary of all of the options to `configure', and exit. | |
325 | ||
326 | `--help=short' | |
327 | `--help=recursive' | |
320 | '--help' | |
321 | '-h' | |
322 | Print a summary of all of the options to 'configure', and exit. | |
323 | ||
324 | '--help=short' | |
325 | '--help=recursive' | |
328 | 326 | Print a summary of the options unique to this package's |
329 | `configure', and exit. The `short' variant lists options used | |
330 | only in the top level, while the `recursive' variant lists options | |
331 | also present in any nested packages. | |
332 | ||
333 | `--version' | |
334 | `-V' | |
335 | Print the version of Autoconf used to generate the `configure' | |
327 | 'configure', and exit. The 'short' variant lists options used only | |
328 | in the top level, while the 'recursive' variant lists options also | |
329 | present in any nested packages. | |
330 | ||
331 | '--version' | |
332 | '-V' | |
333 | Print the version of Autoconf used to generate the 'configure' | |
336 | 334 | script, and exit. |
337 | 335 | |
338 | `--cache-file=FILE' | |
336 | '--cache-file=FILE' | |
339 | 337 | Enable the cache: use and save the results of the tests in FILE, |
340 | traditionally `config.cache'. FILE defaults to `/dev/null' to | |
338 | traditionally 'config.cache'. FILE defaults to '/dev/null' to | |
341 | 339 | disable caching. |
342 | 340 | |
343 | `--config-cache' | |
344 | `-C' | |
345 | Alias for `--cache-file=config.cache'. | |
346 | ||
347 | `--quiet' | |
348 | `--silent' | |
349 | `-q' | |
341 | '--config-cache' | |
342 | '-C' | |
343 | Alias for '--cache-file=config.cache'. | |
344 | ||
345 | '--quiet' | |
346 | '--silent' | |
347 | '-q' | |
350 | 348 | Do not print messages saying which checks are being made. To |
351 | suppress all normal output, redirect it to `/dev/null' (any error | |
349 | suppress all normal output, redirect it to '/dev/null' (any error | |
352 | 350 | messages will still be shown). |
353 | 351 | |
354 | `--srcdir=DIR' | |
352 | '--srcdir=DIR' | |
355 | 353 | Look for the package's source code in directory DIR. Usually |
356 | `configure' can determine that directory automatically. | |
357 | ||
358 | `--prefix=DIR' | |
359 | Use DIR as the installation prefix. *note Installation Names:: | |
360 | for more details, including other options available for fine-tuning | |
361 | the installation locations. | |
362 | ||
363 | `--no-create' | |
364 | `-n' | |
354 | 'configure' can determine that directory automatically. | |
355 | ||
356 | '--prefix=DIR' | |
357 | Use DIR as the installation prefix. *note Installation Names:: for | |
358 | more details, including other options available for fine-tuning the | |
359 | installation locations. | |
360 | ||
361 | '--no-create' | |
362 | '-n' | |
365 | 363 | Run the configure checks, but stop before creating any output |
366 | 364 | files. |
367 | 365 | |
368 | `configure' also accepts some other, not widely useful, options. Run | |
369 | `configure --help' for more details. | |
366 | 'configure' also accepts some other, not widely useful, options. Run | |
367 | 'configure --help' for more details. |
0 | # Makefile.in generated by automake 1.13.4 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.15.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. | |
3 | # Copyright (C) 1994-2017 Free Software Foundation, Inc. | |
4 | 4 | |
5 | 5 | # This Makefile.in is free software; the Free Software Foundation |
6 | 6 | # gives unlimited permission to copy and/or distribute it, |
15 | 15 | |
16 | 16 | # this is the main Makefile.am |
17 | 17 | VPATH = @srcdir@ |
18 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' | |
18 | am__is_gnu_make = { \ | |
19 | if test -z '$(MAKELEVEL)'; then \ | |
20 | false; \ | |
21 | elif test -n '$(MAKE_HOST)'; then \ | |
22 | true; \ | |
23 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ | |
24 | true; \ | |
25 | else \ | |
26 | false; \ | |
27 | fi; \ | |
28 | } | |
19 | 29 | am__make_running_with_option = \ |
20 | 30 | case $${target_option-} in \ |
21 | 31 | ?) ;; \ |
79 | 89 | build_triplet = @build@ |
80 | 90 | host_triplet = @host@ |
81 | 91 | subdir = . |
82 | DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \ | |
83 | $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ | |
84 | $(top_srcdir)/configure $(am__configure_deps) \ | |
85 | $(srcdir)/config.h.in COPYING config/config.guess \ | |
86 | config/config.sub config/depcomp config/install-sh \ | |
87 | config/missing $(top_srcdir)/config/config.guess \ | |
88 | $(top_srcdir)/config/config.sub \ | |
89 | $(top_srcdir)/config/install-sh $(top_srcdir)/config/missing | |
90 | 92 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
91 | 93 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac |
92 | 94 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
93 | 95 | $(ACLOCAL_M4) |
96 | DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ | |
97 | $(am__configure_deps) $(am__DIST_COMMON) | |
94 | 98 | am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ |
95 | 99 | configure.lineno config.status.lineno |
96 | 100 | mkinstalldirs = $(install_sh) -d |
154 | 158 | CTAGS = ctags |
155 | 159 | CSCOPE = cscope |
156 | 160 | DIST_SUBDIRS = $(SUBDIRS) |
161 | am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ | |
162 | $(top_srcdir)/config/compile $(top_srcdir)/config/config.guess \ | |
163 | $(top_srcdir)/config/config.sub \ | |
164 | $(top_srcdir)/config/install-sh $(top_srcdir)/config/missing \ | |
165 | AUTHORS COPYING ChangeLog INSTALL NEWS README config/compile \ | |
166 | config/config.guess config/config.sub config/install-sh \ | |
167 | config/missing | |
157 | 168 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
158 | 169 | distdir = $(PACKAGE)-$(VERSION) |
159 | 170 | top_distdir = $(distdir) |
318 | 329 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ |
319 | 330 | $(am__cd) $(top_srcdir) && \ |
320 | 331 | $(AUTOMAKE) --gnu Makefile |
321 | .PRECIOUS: Makefile | |
322 | 332 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
323 | 333 | @case '$?' in \ |
324 | 334 | *config.status*) \ |
339 | 349 | $(am__aclocal_m4_deps): |
340 | 350 | |
341 | 351 | config.h: stamp-h1 |
342 | @if test ! -f $@; then rm -f stamp-h1; else :; fi | |
343 | @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi | |
352 | @test -f $@ || rm -f stamp-h1 | |
353 | @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 | |
344 | 354 | |
345 | 355 | stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status |
346 | 356 | @rm -f stamp-h1 |
524 | 534 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ |
525 | 535 | || chmod -R a+r "$(distdir)" |
526 | 536 | dist-gzip: distdir |
527 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz | |
537 | tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz | |
528 | 538 | $(am__post_remove_distdir) |
529 | 539 | |
530 | 540 | dist-bzip2: distdir |
540 | 550 | $(am__post_remove_distdir) |
541 | 551 | |
542 | 552 | dist-tarZ: distdir |
553 | @echo WARNING: "Support for distribution archives compressed with" \ | |
554 | "legacy program 'compress' is deprecated." >&2 | |
555 | @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 | |
543 | 556 | tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z |
544 | 557 | $(am__post_remove_distdir) |
545 | 558 | |
546 | 559 | dist-shar: distdir |
547 | shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz | |
560 | @echo WARNING: "Support for shar distribution archives is" \ | |
561 | "deprecated." >&2 | |
562 | @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 | |
563 | shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz | |
548 | 564 | $(am__post_remove_distdir) |
549 | 565 | |
550 | 566 | dist-zip: distdir |
562 | 578 | distcheck: dist |
563 | 579 | case '$(DIST_ARCHIVES)' in \ |
564 | 580 | *.tar.gz*) \ |
565 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ | |
581 | eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ | |
566 | 582 | *.tar.bz2*) \ |
567 | 583 | bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ |
568 | 584 | *.tar.lz*) \ |
572 | 588 | *.tar.Z*) \ |
573 | 589 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ |
574 | 590 | *.shar.gz*) \ |
575 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ | |
591 | eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ | |
576 | 592 | *.zip*) \ |
577 | 593 | unzip $(distdir).zip ;;\ |
578 | 594 | esac |
579 | 595 | chmod -R a-w $(distdir) |
580 | 596 | chmod u+w $(distdir) |
581 | mkdir $(distdir)/_build $(distdir)/_inst | |
597 | mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst | |
582 | 598 | chmod a-w $(distdir) |
583 | 599 | test -d $(distdir)/_build || exit 0; \ |
584 | 600 | dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ |
585 | 601 | && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ |
586 | 602 | && am__cwd=`pwd` \ |
587 | && $(am__cd) $(distdir)/_build \ | |
588 | && ../configure --srcdir=.. --prefix="$$dc_install_base" \ | |
603 | && $(am__cd) $(distdir)/_build/sub \ | |
604 | && ../../configure \ | |
589 | 605 | $(AM_DISTCHECK_CONFIGURE_FLAGS) \ |
590 | 606 | $(DISTCHECK_CONFIGURE_FLAGS) \ |
607 | --srcdir=../.. --prefix="$$dc_install_base" \ | |
591 | 608 | && $(MAKE) $(AM_MAKEFLAGS) \ |
592 | 609 | && $(MAKE) $(AM_MAKEFLAGS) dvi \ |
593 | 610 | && $(MAKE) $(AM_MAKEFLAGS) check \ |
762 | 779 | mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ |
763 | 780 | uninstall-am |
764 | 781 | |
782 | .PRECIOUS: Makefile | |
783 | ||
765 | 784 | |
766 | 785 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
767 | 786 | # Otherwise a system limit (for SysV at least) may be exceeded. |
0 | 0.21.10 (23 Nov 2018): | |
1 | Applied gentoo automake-fix and iconv.detection patches | |
0 | 2 | 0.21.9 (2 Jan 2015): |
1 | 3 | Correct text conversion failure introduced in 0.21.8 |
2 | 4 | Improved processing of tables |
0 | # | |
1 | # Makefile for unrtf (MinGW version) | |
2 | # | |
3 | ||
4 | CC = gcc | |
5 | LD = gcc | |
6 | ||
7 | INSTALL = cp -f | |
8 | INSTALL_PROGRAM = $(INSTALL) | |
9 | INSTALL_DATA = $(INSTALL) | |
10 | ||
11 | # must be equal to DEBUG or NDEBUG | |
12 | DB = NDEBUG | |
13 | OPT = -O2 | |
14 | ||
15 | LDLIBS = -liconv -lShlwapi | |
16 | ||
17 | CFLAGS = -Wall $(OPT) -D$(DB) -I. -DHAVE_CONFIG_H | |
18 | LDFLAGS = | |
19 | ||
20 | SRCS = attr.c convert.c error.c hash.c my_iconv.c main.c \ | |
21 | malloc.c output.c parse.c path.c unicode.c user.c \ | |
22 | util.c word.c unrtf_w.c | |
23 | OBJS = attr.o convert.o error.o hash.o my_iconv.o main.o \ | |
24 | malloc.o output.o parse.o path.o unicode.o user.o \ | |
25 | util.o word.o unrtf_w.o | |
26 | ||
27 | PROGS = unrtf | |
28 | ||
29 | VPATH = ./:../src | |
30 | ||
31 | all: $(PROGS) | |
32 | ||
33 | clean: | |
34 | rm -f $(OBJS) | |
35 | rm -f $(PROGS) | |
36 | ||
37 | unrtf : $(OBJS) | |
38 | @rm -f $@ | |
39 | $(LD) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@ | |
40 | ||
41 | .c.o: | |
42 | $(CC) $(CFLAGS) -c $< |
0 | <?xml version="1.0" encoding="utf-8"?> | |
1 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
2 | <ImportGroup Label="PropertySheets" /> | |
3 | <PropertyGroup Label="UserMacros"> | |
4 | <libiconv>c:\recolldeps\iconv64</libiconv> | |
5 | </PropertyGroup> | |
6 | <PropertyGroup /> | |
7 | <ItemDefinitionGroup /> | |
8 | <ItemGroup> | |
9 | <BuildMacro Include="libiconv"> | |
10 | <Value>$(libiconv)</Value> | |
11 | <EnvironmentVariable>true</EnvironmentVariable> | |
12 | </BuildMacro> | |
13 | </ItemGroup> | |
14 | </Project>⏎ |
0 | /* safeunistd.h: <unistd.h>, but with compat. and large file support for MSVC. | |
1 | * | |
2 | * Copyright (C) 2007 Olly Betts | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License as | |
6 | * published by the Free Software Foundation; either version 2 of the | |
7 | * License, or (at your option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | |
17 | * USA | |
18 | */ | |
19 | ||
20 | #ifndef XAPIAN_INCLUDED_SAFEUNISTD_H | |
21 | #define XAPIAN_INCLUDED_SAFEUNISTD_H | |
22 | ||
23 | #ifndef _MSC_VER | |
24 | # include <unistd.h> | |
25 | #else | |
26 | ||
27 | // sys/types.h has a typedef for off_t so make sure we've seen that before | |
28 | // we hide it behind a #define. | |
29 | # include <sys/types.h> | |
30 | ||
31 | // MSVC doesn't even HAVE unistd.h - io.h seems the nearest equivalent. | |
32 | // We also need to do some renaming of functions to get versions which | |
33 | // work on large files. | |
34 | # include <io.h> | |
35 | ||
36 | # ifdef lseek | |
37 | # undef lseek | |
38 | # endif | |
39 | ||
40 | # ifdef off_t | |
41 | # undef off_t | |
42 | # endif | |
43 | ||
44 | # define lseek(FD, OFF, WHENCE) _lseeki64(FD, OFF, WHENCE) | |
45 | # define off_t __int64 | |
46 | ||
47 | // process.h is needed for getpid(). | |
48 | # include <process.h> | |
49 | ||
50 | #endif | |
51 | ||
52 | #ifdef _MSC_VER | |
53 | ||
54 | inline unsigned int | |
55 | sleep(unsigned int seconds) | |
56 | { | |
57 | // Use our own little helper function to avoid pulling in <windows.h>. | |
58 | extern void xapian_sleep_milliseconds(unsigned int millisecs); | |
59 | ||
60 | // Sleep takes a time interval in milliseconds, whereas POSIX sleep takes | |
61 | // a time interval in seconds, so we need to multiply 'seconds' by 1000. | |
62 | // | |
63 | // But make sure the multiplication won't overflow! 4294967 seconds is | |
64 | // nearly 50 days, so just sleep for that long and return the number of | |
65 | // seconds left to sleep for. The common case of sleep(CONSTANT) should | |
66 | // optimise to just xapian_sleep_milliseconds(CONSTANT). | |
67 | if (seconds > 4294967u) { | |
68 | xapian_sleep_milliseconds(4294967000u); | |
69 | return seconds - 4294967u; | |
70 | } | |
71 | xapian_sleep_milliseconds(seconds * 1000u); | |
72 | return 0; | |
73 | } | |
74 | ||
75 | #endif | |
76 | ||
77 | #endif /* XAPIAN_INCLUDED_SAFEUNISTD_H */ |
0 | | |
1 | Microsoft Visual Studio Solution File, Format Version 12.00 | |
2 | # Visual Studio 14 | |
3 | VisualStudioVersion = 14.0.23107.0 | |
4 | MinimumVisualStudioVersion = 10.0.40219.1 | |
5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unrtf", "unrtf.vcxproj", "{4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}" | |
6 | EndProject | |
7 | Global | |
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution | |
9 | Debug|x64 = Debug|x64 | |
10 | Debug|x86 = Debug|x86 | |
11 | Release|x64 = Release|x64 | |
12 | Release|x86 = Release|x86 | |
13 | EndGlobalSection | |
14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution | |
15 | {4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}.Debug|x64.ActiveCfg = Release|Win32 | |
16 | {4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}.Debug|x64.Build.0 = Release|Win32 | |
17 | {4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}.Debug|x86.ActiveCfg = Debug|Win32 | |
18 | {4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}.Debug|x86.Build.0 = Debug|Win32 | |
19 | {4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}.Release|x64.ActiveCfg = Release|x64 | |
20 | {4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}.Release|x64.Build.0 = Release|x64 | |
21 | {4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}.Release|x86.ActiveCfg = Release|Win32 | |
22 | {4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}.Release|x86.Build.0 = Release|Win32 | |
23 | EndGlobalSection | |
24 | GlobalSection(SolutionProperties) = preSolution | |
25 | HideSolutionNode = FALSE | |
26 | EndGlobalSection | |
27 | EndGlobal |
0 | <?xml version="1.0" encoding="utf-8"?> | |
1 | <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
2 | <ItemGroup Label="ProjectConfigurations"> | |
3 | <ProjectConfiguration Include="Debug|Win32"> | |
4 | <Configuration>Debug</Configuration> | |
5 | <Platform>Win32</Platform> | |
6 | </ProjectConfiguration> | |
7 | <ProjectConfiguration Include="Release|Win32"> | |
8 | <Configuration>Release</Configuration> | |
9 | <Platform>Win32</Platform> | |
10 | </ProjectConfiguration> | |
11 | <ProjectConfiguration Include="Debug|x64"> | |
12 | <Configuration>Debug</Configuration> | |
13 | <Platform>x64</Platform> | |
14 | </ProjectConfiguration> | |
15 | <ProjectConfiguration Include="Release|x64"> | |
16 | <Configuration>Release</Configuration> | |
17 | <Platform>x64</Platform> | |
18 | </ProjectConfiguration> | |
19 | </ItemGroup> | |
20 | <PropertyGroup Label="Globals"> | |
21 | <ProjectGuid>{4122B6B8-B7D8-46A4-9119-C7CE1CA9AB24}</ProjectGuid> | |
22 | <Keyword>Win32Proj</Keyword> | |
23 | <RootNamespace>unrtf</RootNamespace> | |
24 | <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> | |
25 | </PropertyGroup> | |
26 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | |
27 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | |
28 | <ConfigurationType>Application</ConfigurationType> | |
29 | <UseDebugLibraries>true</UseDebugLibraries> | |
30 | <PlatformToolset>v140</PlatformToolset> | |
31 | <CharacterSet>MultiByte</CharacterSet> | |
32 | </PropertyGroup> | |
33 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | |
34 | <ConfigurationType>Application</ConfigurationType> | |
35 | <UseDebugLibraries>false</UseDebugLibraries> | |
36 | <PlatformToolset>v140</PlatformToolset> | |
37 | <WholeProgramOptimization>true</WholeProgramOptimization> | |
38 | <CharacterSet>MultiByte</CharacterSet> | |
39 | </PropertyGroup> | |
40 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | |
41 | <ConfigurationType>Application</ConfigurationType> | |
42 | <UseDebugLibraries>true</UseDebugLibraries> | |
43 | <PlatformToolset>v140</PlatformToolset> | |
44 | <CharacterSet>MultiByte</CharacterSet> | |
45 | </PropertyGroup> | |
46 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | |
47 | <ConfigurationType>Application</ConfigurationType> | |
48 | <UseDebugLibraries>false</UseDebugLibraries> | |
49 | <PlatformToolset>v140</PlatformToolset> | |
50 | <WholeProgramOptimization>true</WholeProgramOptimization> | |
51 | <CharacterSet>MultiByte</CharacterSet> | |
52 | </PropertyGroup> | |
53 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | |
54 | <ImportGroup Label="ExtensionSettings"> | |
55 | </ImportGroup> | |
56 | <ImportGroup Label="Shared"> | |
57 | </ImportGroup> | |
58 | <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |
59 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |
60 | <Import Project="SolutionSettings.props" /> | |
61 | </ImportGroup> | |
62 | <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |
63 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |
64 | <Import Project="SolutionSettings.props" /> | |
65 | </ImportGroup> | |
66 | <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |
67 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |
68 | <Import Project="SolutionSettings.props" /> | |
69 | </ImportGroup> | |
70 | <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |
71 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |
72 | <Import Project="SolutionSettings.props" /> | |
73 | </ImportGroup> | |
74 | <PropertyGroup Label="UserMacros" /> | |
75 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |
76 | <LinkIncremental>true</LinkIncremental> | |
77 | </PropertyGroup> | |
78 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |
79 | <LinkIncremental>true</LinkIncremental> | |
80 | </PropertyGroup> | |
81 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |
82 | <LinkIncremental>false</LinkIncremental> | |
83 | <OutDir>$(SolutionDir)\$(Platform)\$(Configuration)\</OutDir> | |
84 | </PropertyGroup> | |
85 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |
86 | <LinkIncremental>false</LinkIncremental> | |
87 | </PropertyGroup> | |
88 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | |
89 | <ClCompile> | |
90 | <PrecompiledHeader> | |
91 | </PrecompiledHeader> | |
92 | <WarningLevel>Level3</WarningLevel> | |
93 | <Optimization>Disabled</Optimization> | |
94 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
95 | <AdditionalIncludeDirectories>$(SolutionDir);$(libiconv)\include</AdditionalIncludeDirectories> | |
96 | </ClCompile> | |
97 | <Link> | |
98 | <SubSystem>Console</SubSystem> | |
99 | <GenerateDebugInformation>true</GenerateDebugInformation> | |
100 | <AdditionalLibraryDirectories>$(libiconv)\libiconv\$(Platform)\$(Configuration)</AdditionalLibraryDirectories> | |
101 | <AdditionalDependencies>libiconv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> | |
102 | </Link> | |
103 | </ItemDefinitionGroup> | |
104 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | |
105 | <ClCompile> | |
106 | <PrecompiledHeader> | |
107 | </PrecompiledHeader> | |
108 | <WarningLevel>Level3</WarningLevel> | |
109 | <Optimization>Disabled</Optimization> | |
110 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
111 | <AdditionalIncludeDirectories>$(SolutionDir);$(libiconv)\include</AdditionalIncludeDirectories> | |
112 | </ClCompile> | |
113 | <Link> | |
114 | <SubSystem>Console</SubSystem> | |
115 | <GenerateDebugInformation>true</GenerateDebugInformation> | |
116 | <AdditionalLibraryDirectories>$(libiconv)\libiconv\$(Platform)\$(Configuration)</AdditionalLibraryDirectories> | |
117 | <AdditionalDependencies>libiconv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> | |
118 | </Link> | |
119 | </ItemDefinitionGroup> | |
120 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | |
121 | <ClCompile> | |
122 | <WarningLevel>Level3</WarningLevel> | |
123 | <PrecompiledHeader> | |
124 | </PrecompiledHeader> | |
125 | <Optimization>MaxSpeed</Optimization> | |
126 | <FunctionLevelLinking>true</FunctionLevelLinking> | |
127 | <IntrinsicFunctions>true</IntrinsicFunctions> | |
128 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
129 | <AdditionalIncludeDirectories>$(SolutionDir);$(libiconv)\include</AdditionalIncludeDirectories> | |
130 | </ClCompile> | |
131 | <Link> | |
132 | <SubSystem>Console</SubSystem> | |
133 | <GenerateDebugInformation>true</GenerateDebugInformation> | |
134 | <EnableCOMDATFolding>true</EnableCOMDATFolding> | |
135 | <OptimizeReferences>true</OptimizeReferences> | |
136 | <AdditionalLibraryDirectories>$(libiconv)\libiconv\$(Platform)\$(Configuration)</AdditionalLibraryDirectories> | |
137 | <AdditionalDependencies>libiconv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> | |
138 | </Link> | |
139 | </ItemDefinitionGroup> | |
140 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | |
141 | <ClCompile> | |
142 | <WarningLevel>Level3</WarningLevel> | |
143 | <PrecompiledHeader> | |
144 | </PrecompiledHeader> | |
145 | <Optimization>MaxSpeed</Optimization> | |
146 | <FunctionLevelLinking>true</FunctionLevelLinking> | |
147 | <IntrinsicFunctions>true</IntrinsicFunctions> | |
148 | <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;HAVE_CONFIG_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | |
149 | <AdditionalIncludeDirectories>$(SolutionDir);$(libiconv)\include</AdditionalIncludeDirectories> | |
150 | </ClCompile> | |
151 | <Link> | |
152 | <SubSystem>Console</SubSystem> | |
153 | <GenerateDebugInformation>true</GenerateDebugInformation> | |
154 | <EnableCOMDATFolding>true</EnableCOMDATFolding> | |
155 | <OptimizeReferences>true</OptimizeReferences> | |
156 | <AdditionalLibraryDirectories>$(libiconv)\libiconv\$(Platform)\$(Configuration)</AdditionalLibraryDirectories> | |
157 | <AdditionalDependencies>libiconv.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> | |
158 | </Link> | |
159 | </ItemDefinitionGroup> | |
160 | <ItemGroup> | |
161 | <ClCompile Include="..\src\attr.c" /> | |
162 | <ClCompile Include="..\src\convert.c" /> | |
163 | <ClCompile Include="..\src\error.c" /> | |
164 | <ClCompile Include="..\src\hash.c" /> | |
165 | <ClCompile Include="..\src\main.c" /> | |
166 | <ClCompile Include="..\src\malloc.c" /> | |
167 | <ClCompile Include="..\src\my_iconv.c" /> | |
168 | <ClCompile Include="..\src\output.c" /> | |
169 | <ClCompile Include="..\src\parse.c" /> | |
170 | <ClCompile Include="..\src\path.c" /> | |
171 | <ClCompile Include="..\src\unicode.c" /> | |
172 | <ClCompile Include="..\src\user.c" /> | |
173 | <ClCompile Include="..\src\util.c" /> | |
174 | <ClCompile Include="..\src\word.c" /> | |
175 | <ClCompile Include="unrtf_w.c" /> | |
176 | </ItemGroup> | |
177 | <ItemGroup> | |
178 | <ClInclude Include="..\src\attr.h" /> | |
179 | <ClInclude Include="..\src\convert.h" /> | |
180 | <ClInclude Include="..\src\defs.h" /> | |
181 | <ClInclude Include="..\src\error.h" /> | |
182 | <ClInclude Include="..\src\hash.h" /> | |
183 | <ClInclude Include="..\src\main.h" /> | |
184 | <ClInclude Include="..\src\malloc.h" /> | |
185 | <ClInclude Include="..\src\my_iconv.h" /> | |
186 | <ClInclude Include="..\src\output.h" /> | |
187 | <ClInclude Include="..\src\parse.h" /> | |
188 | <ClInclude Include="..\src\path.h" /> | |
189 | <ClInclude Include="..\src\unicode.h" /> | |
190 | <ClInclude Include="..\src\user.h" /> | |
191 | <ClInclude Include="..\src\util.h" /> | |
192 | <ClInclude Include="..\src\word.h" /> | |
193 | <ClInclude Include="config.h" /> | |
194 | </ItemGroup> | |
195 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |
196 | <ImportGroup Label="ExtensionTargets"> | |
197 | </ImportGroup> | |
198 | </Project>⏎ |
0 | <?xml version="1.0" encoding="utf-8"?> | |
1 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
2 | <ItemGroup> | |
3 | <Filter Include="Source Files"> | |
4 | <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | |
5 | <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | |
6 | </Filter> | |
7 | <Filter Include="Header Files"> | |
8 | <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | |
9 | <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | |
10 | </Filter> | |
11 | <Filter Include="Resource Files"> | |
12 | <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | |
13 | <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | |
14 | </Filter> | |
15 | </ItemGroup> | |
16 | <ItemGroup> | |
17 | <ClCompile Include="..\src\attr.c"> | |
18 | <Filter>Source Files</Filter> | |
19 | </ClCompile> | |
20 | <ClCompile Include="..\src\convert.c"> | |
21 | <Filter>Source Files</Filter> | |
22 | </ClCompile> | |
23 | <ClCompile Include="..\src\error.c"> | |
24 | <Filter>Source Files</Filter> | |
25 | </ClCompile> | |
26 | <ClCompile Include="..\src\hash.c"> | |
27 | <Filter>Source Files</Filter> | |
28 | </ClCompile> | |
29 | <ClCompile Include="..\src\main.c"> | |
30 | <Filter>Source Files</Filter> | |
31 | </ClCompile> | |
32 | <ClCompile Include="..\src\malloc.c"> | |
33 | <Filter>Source Files</Filter> | |
34 | </ClCompile> | |
35 | <ClCompile Include="..\src\my_iconv.c"> | |
36 | <Filter>Source Files</Filter> | |
37 | </ClCompile> | |
38 | <ClCompile Include="..\src\output.c"> | |
39 | <Filter>Source Files</Filter> | |
40 | </ClCompile> | |
41 | <ClCompile Include="..\src\parse.c"> | |
42 | <Filter>Source Files</Filter> | |
43 | </ClCompile> | |
44 | <ClCompile Include="..\src\path.c"> | |
45 | <Filter>Source Files</Filter> | |
46 | </ClCompile> | |
47 | <ClCompile Include="..\src\unicode.c"> | |
48 | <Filter>Source Files</Filter> | |
49 | </ClCompile> | |
50 | <ClCompile Include="..\src\user.c"> | |
51 | <Filter>Source Files</Filter> | |
52 | </ClCompile> | |
53 | <ClCompile Include="..\src\util.c"> | |
54 | <Filter>Source Files</Filter> | |
55 | </ClCompile> | |
56 | <ClCompile Include="..\src\word.c"> | |
57 | <Filter>Source Files</Filter> | |
58 | </ClCompile> | |
59 | <ClCompile Include="unrtf_w.c"> | |
60 | <Filter>Source Files</Filter> | |
61 | </ClCompile> | |
62 | </ItemGroup> | |
63 | <ItemGroup> | |
64 | <ClInclude Include="..\src\attr.h"> | |
65 | <Filter>Header Files</Filter> | |
66 | </ClInclude> | |
67 | <ClInclude Include="..\src\convert.h"> | |
68 | <Filter>Header Files</Filter> | |
69 | </ClInclude> | |
70 | <ClInclude Include="..\src\error.h"> | |
71 | <Filter>Header Files</Filter> | |
72 | </ClInclude> | |
73 | <ClInclude Include="..\src\hash.h"> | |
74 | <Filter>Header Files</Filter> | |
75 | </ClInclude> | |
76 | <ClInclude Include="..\src\main.h"> | |
77 | <Filter>Header Files</Filter> | |
78 | </ClInclude> | |
79 | <ClInclude Include="..\src\malloc.h"> | |
80 | <Filter>Header Files</Filter> | |
81 | </ClInclude> | |
82 | <ClInclude Include="..\src\my_iconv.h"> | |
83 | <Filter>Header Files</Filter> | |
84 | </ClInclude> | |
85 | <ClInclude Include="..\src\output.h"> | |
86 | <Filter>Header Files</Filter> | |
87 | </ClInclude> | |
88 | <ClInclude Include="..\src\parse.h"> | |
89 | <Filter>Header Files</Filter> | |
90 | </ClInclude> | |
91 | <ClInclude Include="..\src\path.h"> | |
92 | <Filter>Header Files</Filter> | |
93 | </ClInclude> | |
94 | <ClInclude Include="..\src\unicode.h"> | |
95 | <Filter>Header Files</Filter> | |
96 | </ClInclude> | |
97 | <ClInclude Include="..\src\user.h"> | |
98 | <Filter>Header Files</Filter> | |
99 | </ClInclude> | |
100 | <ClInclude Include="..\src\util.h"> | |
101 | <Filter>Header Files</Filter> | |
102 | </ClInclude> | |
103 | <ClInclude Include="..\src\word.h"> | |
104 | <Filter>Header Files</Filter> | |
105 | </ClInclude> | |
106 | <ClInclude Include="config.h"> | |
107 | <Filter>Header Files</Filter> | |
108 | </ClInclude> | |
109 | <ClInclude Include="..\src\defs.h"> | |
110 | <Filter>Header Files</Filter> | |
111 | </ClInclude> | |
112 | </ItemGroup> | |
113 | </Project>⏎ |
0 | #include "config.h" | |
1 | ||
2 | #ifdef _WIN32 | |
3 | /*- | |
4 | * Copyright (c) 1990, 1993 | |
5 | * The Regents of the University of California. All rights reserved. | |
6 | * | |
7 | * The quadratic code is derived from software contributed to Berkeley by | |
8 | * Chris Torek. | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | |
18 | * 4. Neither the name of the University nor the names of its contributors | |
19 | * may be used to endorse or promote products derived from this software | |
20 | * without specific prior written permission. | |
21 | * | |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | * SUCH DAMAGE. | |
33 | */ | |
34 | ||
35 | #include <ctype.h> | |
36 | #include <string.h> | |
37 | #include <stdio.h> | |
38 | ||
39 | /* | |
40 | * Find the first occurrence of find in s, ignore case. | |
41 | */ | |
42 | char *strcasestr(const char *s, const char *find) | |
43 | { | |
44 | /* Less code size, but quadratic performance in the worst case. */ | |
45 | char c, sc; | |
46 | size_t len; | |
47 | ||
48 | if ((c = *find++) != 0) { | |
49 | c = tolower((unsigned char)c); | |
50 | len = strlen(find); | |
51 | do { | |
52 | do { | |
53 | if ((sc = *s++) == 0) | |
54 | return (NULL); | |
55 | } while ((char)tolower((unsigned char)sc) != c); | |
56 | } while (strncasecmp(s, find, len) != 0); | |
57 | s--; | |
58 | } | |
59 | return ((char *)s); | |
60 | } | |
61 | ||
62 | ||
63 | ||
64 | unsigned int unrtf_ntohl(unsigned int in) | |
65 | { | |
66 | const unsigned char *f = (const unsigned char*)∈ | |
67 | return( | |
68 | ((unsigned int)(f[3])) + | |
69 | ((unsigned int)(f[2]) << 8) + | |
70 | ((unsigned int)(f[1]) << 16) + | |
71 | ((unsigned int)(f[0]) << 24)); | |
72 | } | |
73 | ||
74 | #endif | |
75 | ||
76 | #include <Shlwapi.h> | |
77 | #pragma comment(lib, "shlwapi.lib") | |
78 | ||
79 | const char *path_thisexecpath() | |
80 | { | |
81 | #ifdef UNICODE | |
82 | Error: Need to add UNICODE code here | |
83 | #else | |
84 | static TCHAR text[MAX_PATH]; | |
85 | if (text[0] == 0) { | |
86 | DWORD length = GetModuleFileName(NULL, text, MAX_PATH); | |
87 | #ifdef NTDDI_WIN8_future | |
88 | PathCchRemoveFileSpec(text, MAX_PATH); | |
89 | #else | |
90 | PathRemoveFileSpec(text); | |
91 | #endif | |
92 | } | |
93 | return (const char *)text; | |
94 | #endif | |
95 | } | |
96 | ||
97 | /* Location for program data: charmaps etc */ | |
98 | const char *unrtfDataDir() | |
99 | { | |
100 | static char buffer[MAX_PATH]; | |
101 | if (buffer[0] == 0) { | |
102 | const char *execdir = path_thisexecpath(); | |
103 | if (strlen(execdir) + strlen("Share") + 4 < MAX_PATH) { | |
104 | snprintf(buffer, MAX_PATH, "%s\\Share\\", execdir); | |
105 | } | |
106 | } | |
107 | return buffer; | |
108 | } |
0 | # generated automatically by aclocal 1.13.4 -*- Autoconf -*- | |
1 | ||
2 | # Copyright (C) 1996-2013 Free Software Foundation, Inc. | |
0 | # generated automatically by aclocal 1.15.1 -*- Autoconf -*- | |
1 | ||
2 | # Copyright (C) 1996-2017 Free Software Foundation, Inc. | |
3 | 3 | |
4 | 4 | # This file is free software; the Free Software Foundation |
5 | 5 | # gives unlimited permission to copy and/or distribute it, |
19 | 19 | If you have problems, you may need to regenerate the build system entirely. |
20 | 20 | To do so, use the procedure documented by the package, typically 'autoreconf'.])]) |
21 | 21 | |
22 | # Copyright (C) 2002-2013 Free Software Foundation, Inc. | |
22 | # Copyright (C) 2002-2017 Free Software Foundation, Inc. | |
23 | 23 | # |
24 | 24 | # This file is free software; the Free Software Foundation |
25 | 25 | # gives unlimited permission to copy and/or distribute it, |
31 | 31 | # generated from the m4 files accompanying Automake X.Y. |
32 | 32 | # (This private macro should not be called outside this file.) |
33 | 33 | AC_DEFUN([AM_AUTOMAKE_VERSION], |
34 | [am__api_version='1.13' | |
34 | [am__api_version='1.15' | |
35 | 35 | dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to |
36 | 36 | dnl require some minimum version. Point them to the right macro. |
37 | m4_if([$1], [1.13.4], [], | |
37 | m4_if([$1], [1.15.1], [], | |
38 | 38 | [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl |
39 | 39 | ]) |
40 | 40 | |
50 | 50 | # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. |
51 | 51 | # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. |
52 | 52 | AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], |
53 | [AM_AUTOMAKE_VERSION([1.13.4])dnl | |
53 | [AM_AUTOMAKE_VERSION([1.15.1])dnl | |
54 | 54 | m4_ifndef([AC_AUTOCONF_VERSION], |
55 | 55 | [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl |
56 | 56 | _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) |
57 | 57 | |
58 | 58 | # AM_AUX_DIR_EXPAND -*- Autoconf -*- |
59 | 59 | |
60 | # Copyright (C) 2001-2013 Free Software Foundation, Inc. | |
60 | # Copyright (C) 2001-2017 Free Software Foundation, Inc. | |
61 | 61 | # |
62 | 62 | # This file is free software; the Free Software Foundation |
63 | 63 | # gives unlimited permission to copy and/or distribute it, |
102 | 102 | # configured tree to be moved without reconfiguration. |
103 | 103 | |
104 | 104 | AC_DEFUN([AM_AUX_DIR_EXPAND], |
105 | [dnl Rely on autoconf to set up CDPATH properly. | |
106 | AC_PREREQ([2.50])dnl | |
107 | # expand $ac_aux_dir to an absolute path | |
108 | am_aux_dir=`cd $ac_aux_dir && pwd` | |
105 | [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl | |
106 | # Expand $ac_aux_dir to an absolute path. | |
107 | am_aux_dir=`cd "$ac_aux_dir" && pwd` | |
109 | 108 | ]) |
110 | 109 | |
111 | 110 | # AM_CONDITIONAL -*- Autoconf -*- |
112 | 111 | |
113 | # Copyright (C) 1997-2013 Free Software Foundation, Inc. | |
112 | # Copyright (C) 1997-2017 Free Software Foundation, Inc. | |
114 | 113 | # |
115 | 114 | # This file is free software; the Free Software Foundation |
116 | 115 | # gives unlimited permission to copy and/or distribute it, |
141 | 140 | Usually this means the macro was only invoked conditionally.]]) |
142 | 141 | fi])]) |
143 | 142 | |
144 | # Copyright (C) 1999-2013 Free Software Foundation, Inc. | |
143 | # Copyright (C) 1999-2017 Free Software Foundation, Inc. | |
145 | 144 | # |
146 | 145 | # This file is free software; the Free Software Foundation |
147 | 146 | # gives unlimited permission to copy and/or distribute it, |
332 | 331 | |
333 | 332 | # Generate code to set up dependency tracking. -*- Autoconf -*- |
334 | 333 | |
335 | # Copyright (C) 1999-2013 Free Software Foundation, Inc. | |
334 | # Copyright (C) 1999-2017 Free Software Foundation, Inc. | |
336 | 335 | # |
337 | 336 | # This file is free software; the Free Software Foundation |
338 | 337 | # gives unlimited permission to copy and/or distribute it, |
408 | 407 | |
409 | 408 | # Do all the work for Automake. -*- Autoconf -*- |
410 | 409 | |
411 | # Copyright (C) 1996-2013 Free Software Foundation, Inc. | |
410 | # Copyright (C) 1996-2017 Free Software Foundation, Inc. | |
412 | 411 | # |
413 | 412 | # This file is free software; the Free Software Foundation |
414 | 413 | # gives unlimited permission to copy and/or distribute it, |
416 | 415 | |
417 | 416 | # This macro actually does too much. Some checks are only needed if |
418 | 417 | # your package does certain things. But this isn't really a big deal. |
418 | ||
419 | dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. | |
420 | m4_define([AC_PROG_CC], | |
421 | m4_defn([AC_PROG_CC]) | |
422 | [_AM_PROG_CC_C_O | |
423 | ]) | |
419 | 424 | |
420 | 425 | # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) |
421 | 426 | # AM_INIT_AUTOMAKE([OPTIONS]) |
492 | 497 | # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html> |
493 | 498 | # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> |
494 | 499 | AC_SUBST([mkdir_p], ['$(MKDIR_P)']) |
495 | # We need awk for the "check" target. The system "awk" is bad on | |
496 | # some platforms. | |
500 | # We need awk for the "check" target (and possibly the TAP driver). The | |
501 | # system "awk" is bad on some platforms. | |
497 | 502 | AC_REQUIRE([AC_PROG_AWK])dnl |
498 | 503 | AC_REQUIRE([AC_PROG_MAKE_SET])dnl |
499 | 504 | AC_REQUIRE([AM_SET_LEADING_DOT])dnl |
525 | 530 | AC_CONFIG_COMMANDS_PRE(dnl |
526 | 531 | [m4_provide_if([_AM_COMPILER_EXEEXT], |
527 | 532 | [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl |
533 | ||
534 | # POSIX will say in a future version that running "rm -f" with no argument | |
535 | # is OK; and we want to be able to make that assumption in our Makefile | |
536 | # recipes. So use an aggressive probe to check that the usage we want is | |
537 | # actually supported "in the wild" to an acceptable degree. | |
538 | # See automake bug#10828. | |
539 | # To make any issue more visible, cause the running configure to be aborted | |
540 | # by default if the 'rm' program in use doesn't match our expectations; the | |
541 | # user can still override this though. | |
542 | if rm -f && rm -fr && rm -rf; then : OK; else | |
543 | cat >&2 <<'END' | |
544 | Oops! | |
545 | ||
546 | Your 'rm' program seems unable to run without file operands specified | |
547 | on the command line, even when the '-f' option is present. This is contrary | |
548 | to the behaviour of most rm programs out there, and not conforming with | |
549 | the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542> | |
550 | ||
551 | Please tell bug-automake@gnu.org about your system, including the value | |
552 | of your $PATH and any error possibly output before this message. This | |
553 | can help us improve future automake versions. | |
554 | ||
555 | END | |
556 | if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then | |
557 | echo 'Configuration will proceed anyway, since you have set the' >&2 | |
558 | echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 | |
559 | echo >&2 | |
560 | else | |
561 | cat >&2 <<'END' | |
562 | Aborting the configuration process, to ensure you take notice of the issue. | |
563 | ||
564 | You can download and install GNU coreutils to get an 'rm' implementation | |
565 | that behaves properly: <http://www.gnu.org/software/coreutils/>. | |
566 | ||
567 | If you want to complete the configuration process using your problematic | |
568 | 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM | |
569 | to "yes", and re-run configure. | |
570 | ||
571 | END | |
572 | AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) | |
573 | fi | |
574 | fi | |
575 | dnl The trailing newline in this macro's definition is deliberate, for | |
576 | dnl backward compatibility and to allow trailing 'dnl'-style comments | |
577 | dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. | |
528 | 578 | ]) |
529 | 579 | |
530 | 580 | dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not |
532 | 582 | dnl mangled by Autoconf and run in a shell conditional statement. |
533 | 583 | m4_define([_AC_COMPILER_EXEEXT], |
534 | 584 | m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) |
535 | ||
536 | 585 | |
537 | 586 | # When config.status generates a header, we must update the stamp-h file. |
538 | 587 | # This file resides in the same directory as the config header |
555 | 604 | done |
556 | 605 | echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) |
557 | 606 | |
558 | # Copyright (C) 2001-2013 Free Software Foundation, Inc. | |
607 | # Copyright (C) 2001-2017 Free Software Foundation, Inc. | |
559 | 608 | # |
560 | 609 | # This file is free software; the Free Software Foundation |
561 | 610 | # gives unlimited permission to copy and/or distribute it, |
566 | 615 | # Define $install_sh. |
567 | 616 | AC_DEFUN([AM_PROG_INSTALL_SH], |
568 | 617 | [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl |
569 | if test x"${install_sh}" != xset; then | |
618 | if test x"${install_sh+set}" != xset; then | |
570 | 619 | case $am_aux_dir in |
571 | 620 | *\ * | *\ *) |
572 | 621 | install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; |
576 | 625 | fi |
577 | 626 | AC_SUBST([install_sh])]) |
578 | 627 | |
579 | # Copyright (C) 2003-2013 Free Software Foundation, Inc. | |
628 | # Copyright (C) 2003-2017 Free Software Foundation, Inc. | |
580 | 629 | # |
581 | 630 | # This file is free software; the Free Software Foundation |
582 | 631 | # gives unlimited permission to copy and/or distribute it, |
598 | 647 | # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- |
599 | 648 | # From Jim Meyering |
600 | 649 | |
601 | # Copyright (C) 1996-2013 Free Software Foundation, Inc. | |
650 | # Copyright (C) 1996-2017 Free Software Foundation, Inc. | |
602 | 651 | # |
603 | 652 | # This file is free software; the Free Software Foundation |
604 | 653 | # gives unlimited permission to copy and/or distribute it, |
633 | 682 | |
634 | 683 | # Check to see how 'make' treats includes. -*- Autoconf -*- |
635 | 684 | |
636 | # Copyright (C) 2001-2013 Free Software Foundation, Inc. | |
685 | # Copyright (C) 2001-2017 Free Software Foundation, Inc. | |
637 | 686 | # |
638 | 687 | # This file is free software; the Free Software Foundation |
639 | 688 | # gives unlimited permission to copy and/or distribute it, |
683 | 732 | |
684 | 733 | # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- |
685 | 734 | |
686 | # Copyright (C) 1997-2013 Free Software Foundation, Inc. | |
735 | # Copyright (C) 1997-2017 Free Software Foundation, Inc. | |
687 | 736 | # |
688 | 737 | # This file is free software; the Free Software Foundation |
689 | 738 | # gives unlimited permission to copy and/or distribute it, |
722 | 771 | |
723 | 772 | # Helper functions for option handling. -*- Autoconf -*- |
724 | 773 | |
725 | # Copyright (C) 2001-2013 Free Software Foundation, Inc. | |
774 | # Copyright (C) 2001-2017 Free Software Foundation, Inc. | |
726 | 775 | # |
727 | 776 | # This file is free software; the Free Software Foundation |
728 | 777 | # gives unlimited permission to copy and/or distribute it, |
751 | 800 | AC_DEFUN([_AM_IF_OPTION], |
752 | 801 | [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) |
753 | 802 | |
803 | # Copyright (C) 1999-2017 Free Software Foundation, Inc. | |
804 | # | |
805 | # This file is free software; the Free Software Foundation | |
806 | # gives unlimited permission to copy and/or distribute it, | |
807 | # with or without modifications, as long as this notice is preserved. | |
808 | ||
809 | # _AM_PROG_CC_C_O | |
810 | # --------------- | |
811 | # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC | |
812 | # to automatically call this. | |
813 | AC_DEFUN([_AM_PROG_CC_C_O], | |
814 | [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl | |
815 | AC_REQUIRE_AUX_FILE([compile])dnl | |
816 | AC_LANG_PUSH([C])dnl | |
817 | AC_CACHE_CHECK( | |
818 | [whether $CC understands -c and -o together], | |
819 | [am_cv_prog_cc_c_o], | |
820 | [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) | |
821 | # Make sure it works both with $CC and with simple cc. | |
822 | # Following AC_PROG_CC_C_O, we do the test twice because some | |
823 | # compilers refuse to overwrite an existing .o file with -o, | |
824 | # though they will create one. | |
825 | am_cv_prog_cc_c_o=yes | |
826 | for am_i in 1 2; do | |
827 | if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ | |
828 | && test -f conftest2.$ac_objext; then | |
829 | : OK | |
830 | else | |
831 | am_cv_prog_cc_c_o=no | |
832 | break | |
833 | fi | |
834 | done | |
835 | rm -f core conftest* | |
836 | unset am_i]) | |
837 | if test "$am_cv_prog_cc_c_o" != yes; then | |
838 | # Losing compiler, so override with the script. | |
839 | # FIXME: It is wrong to rewrite CC. | |
840 | # But if we don't then we get into trouble of one sort or another. | |
841 | # A longer-term fix would be to have automake use am__CC in this case, | |
842 | # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" | |
843 | CC="$am_aux_dir/compile $CC" | |
844 | fi | |
845 | AC_LANG_POP([C])]) | |
846 | ||
847 | # For backward compatibility. | |
848 | AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) | |
849 | ||
850 | # Copyright (C) 2001-2017 Free Software Foundation, Inc. | |
851 | # | |
852 | # This file is free software; the Free Software Foundation | |
853 | # gives unlimited permission to copy and/or distribute it, | |
854 | # with or without modifications, as long as this notice is preserved. | |
855 | ||
856 | # AM_RUN_LOG(COMMAND) | |
857 | # ------------------- | |
858 | # Run COMMAND, save the exit status in ac_status, and log it. | |
859 | # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) | |
860 | AC_DEFUN([AM_RUN_LOG], | |
861 | [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD | |
862 | ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD | |
863 | ac_status=$? | |
864 | echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD | |
865 | (exit $ac_status); }]) | |
866 | ||
754 | 867 | # Check to make sure that the build environment is sane. -*- Autoconf -*- |
755 | 868 | |
756 | # Copyright (C) 1996-2013 Free Software Foundation, Inc. | |
869 | # Copyright (C) 1996-2017 Free Software Foundation, Inc. | |
757 | 870 | # |
758 | 871 | # This file is free software; the Free Software Foundation |
759 | 872 | # gives unlimited permission to copy and/or distribute it, |
834 | 947 | rm -f conftest.file |
835 | 948 | ]) |
836 | 949 | |
837 | # Copyright (C) 2009-2013 Free Software Foundation, Inc. | |
950 | # Copyright (C) 2009-2017 Free Software Foundation, Inc. | |
838 | 951 | # |
839 | 952 | # This file is free software; the Free Software Foundation |
840 | 953 | # gives unlimited permission to copy and/or distribute it, |
894 | 1007 | _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl |
895 | 1008 | ]) |
896 | 1009 | |
897 | # Copyright (C) 2001-2013 Free Software Foundation, Inc. | |
1010 | # Copyright (C) 2001-2017 Free Software Foundation, Inc. | |
898 | 1011 | # |
899 | 1012 | # This file is free software; the Free Software Foundation |
900 | 1013 | # gives unlimited permission to copy and/or distribute it, |
922 | 1035 | INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" |
923 | 1036 | AC_SUBST([INSTALL_STRIP_PROGRAM])]) |
924 | 1037 | |
925 | # Copyright (C) 2006-2013 Free Software Foundation, Inc. | |
1038 | # Copyright (C) 2006-2017 Free Software Foundation, Inc. | |
926 | 1039 | # |
927 | 1040 | # This file is free software; the Free Software Foundation |
928 | 1041 | # gives unlimited permission to copy and/or distribute it, |
941 | 1054 | |
942 | 1055 | # Check how to create a tarball. -*- Autoconf -*- |
943 | 1056 | |
944 | # Copyright (C) 2004-2013 Free Software Foundation, Inc. | |
1057 | # Copyright (C) 2004-2017 Free Software Foundation, Inc. | |
945 | 1058 | # |
946 | 1059 | # This file is free software; the Free Software Foundation |
947 | 1060 | # gives unlimited permission to copy and/or distribute it, |
0 | outputsdir = ${libdir}/${PACKAGE} | |
0 | outputsdir = ${pkgdatadir} | |
1 | 1 | dist_outputs_DATA = SYMBOL.charmap |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.69 for unrtf 0.21.9. | |
2 | # Generated by GNU Autoconf 2.69 for unrtf 0.21.10. | |
3 | 3 | # |
4 | 4 | # Report bugs to <bug-unrtf@gnu.org>. |
5 | 5 | # |
579 | 579 | # Identity of this package. |
580 | 580 | PACKAGE_NAME='unrtf' |
581 | 581 | PACKAGE_TARNAME='unrtf' |
582 | PACKAGE_VERSION='0.21.9' | |
583 | PACKAGE_STRING='unrtf 0.21.9' | |
582 | PACKAGE_VERSION='0.21.10' | |
583 | PACKAGE_STRING='unrtf 0.21.10' | |
584 | 584 | PACKAGE_BUGREPORT='bug-unrtf@gnu.org' |
585 | 585 | PACKAGE_URL='' |
586 | 586 | |
1277 | 1277 | # Omit some internal or obsolete options to make the list less imposing. |
1278 | 1278 | # This message is too long to be a string in the A/UX 3.1 sh. |
1279 | 1279 | cat <<_ACEOF |
1280 | \`configure' configures unrtf 0.21.9 to adapt to many kinds of systems. | |
1280 | \`configure' configures unrtf 0.21.10 to adapt to many kinds of systems. | |
1281 | 1281 | |
1282 | 1282 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1283 | 1283 | |
1347 | 1347 | |
1348 | 1348 | if test -n "$ac_init_help"; then |
1349 | 1349 | case $ac_init_help in |
1350 | short | recursive ) echo "Configuration of unrtf 0.21.9:";; | |
1350 | short | recursive ) echo "Configuration of unrtf 0.21.10:";; | |
1351 | 1351 | esac |
1352 | 1352 | cat <<\_ACEOF |
1353 | 1353 | |
1441 | 1441 | test -n "$ac_init_help" && exit $ac_status |
1442 | 1442 | if $ac_init_version; then |
1443 | 1443 | cat <<\_ACEOF |
1444 | unrtf configure 0.21.9 | |
1444 | unrtf configure 0.21.10 | |
1445 | 1445 | generated by GNU Autoconf 2.69 |
1446 | 1446 | |
1447 | 1447 | Copyright (C) 2012 Free Software Foundation, Inc. |
1810 | 1810 | This file contains any messages produced by compilers while |
1811 | 1811 | running configure, to aid debugging if configure makes a mistake. |
1812 | 1812 | |
1813 | It was created by unrtf $as_me 0.21.9, which was | |
1813 | It was created by unrtf $as_me 0.21.10, which was | |
1814 | 1814 | generated by GNU Autoconf 2.69. Invocation command line was |
1815 | 1815 | |
1816 | 1816 | $ $0 $@ |
2193 | 2193 | |
2194 | 2194 | # Initialize automake |
2195 | 2195 | |
2196 | am__api_version='1.13' | |
2196 | am__api_version='1.15' | |
2197 | 2197 | |
2198 | 2198 | # Find a good install program. We prefer a C program (faster), |
2199 | 2199 | # so one script is as good as another. But avoid the broken or |
2365 | 2365 | ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' |
2366 | 2366 | program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` |
2367 | 2367 | |
2368 | # expand $ac_aux_dir to an absolute path | |
2369 | am_aux_dir=`cd $ac_aux_dir && pwd` | |
2368 | # Expand $ac_aux_dir to an absolute path. | |
2369 | am_aux_dir=`cd "$ac_aux_dir" && pwd` | |
2370 | 2370 | |
2371 | 2371 | if test x"${MISSING+set}" != xset; then |
2372 | 2372 | case $am_aux_dir in |
2385 | 2385 | $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} |
2386 | 2386 | fi |
2387 | 2387 | |
2388 | if test x"${install_sh}" != xset; then | |
2388 | if test x"${install_sh+set}" != xset; then | |
2389 | 2389 | case $am_aux_dir in |
2390 | 2390 | *\ * | *\ *) |
2391 | 2391 | install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; |
2679 | 2679 | |
2680 | 2680 | # Define the identity of the package. |
2681 | 2681 | PACKAGE='unrtf' |
2682 | VERSION='0.21.9' | |
2682 | VERSION='0.21.10' | |
2683 | 2683 | |
2684 | 2684 | |
2685 | 2685 | cat >>confdefs.h <<_ACEOF |
2713 | 2713 | # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html> |
2714 | 2714 | mkdir_p='$(MKDIR_P)' |
2715 | 2715 | |
2716 | # We need awk for the "check" target. The system "awk" is bad on | |
2717 | # some platforms. | |
2716 | # We need awk for the "check" target (and possibly the TAP driver). The | |
2717 | # system "awk" is bad on some platforms. | |
2718 | 2718 | # Always define AMTAR for backward compatibility. Yes, it's still used |
2719 | 2719 | # in the wild :-( We should find a proper way to deprecate it ... |
2720 | 2720 | AMTAR='$${TAR-tar}' |
2729 | 2729 | |
2730 | 2730 | |
2731 | 2731 | |
2732 | ||
2733 | # POSIX will say in a future version that running "rm -f" with no argument | |
2734 | # is OK; and we want to be able to make that assumption in our Makefile | |
2735 | # recipes. So use an aggressive probe to check that the usage we want is | |
2736 | # actually supported "in the wild" to an acceptable degree. | |
2737 | # See automake bug#10828. | |
2738 | # To make any issue more visible, cause the running configure to be aborted | |
2739 | # by default if the 'rm' program in use doesn't match our expectations; the | |
2740 | # user can still override this though. | |
2741 | if rm -f && rm -fr && rm -rf; then : OK; else | |
2742 | cat >&2 <<'END' | |
2743 | Oops! | |
2744 | ||
2745 | Your 'rm' program seems unable to run without file operands specified | |
2746 | on the command line, even when the '-f' option is present. This is contrary | |
2747 | to the behaviour of most rm programs out there, and not conforming with | |
2748 | the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542> | |
2749 | ||
2750 | Please tell bug-automake@gnu.org about your system, including the value | |
2751 | of your $PATH and any error possibly output before this message. This | |
2752 | can help us improve future automake versions. | |
2753 | ||
2754 | END | |
2755 | if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then | |
2756 | echo 'Configuration will proceed anyway, since you have set the' >&2 | |
2757 | echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 | |
2758 | echo >&2 | |
2759 | else | |
2760 | cat >&2 <<'END' | |
2761 | Aborting the configuration process, to ensure you take notice of the issue. | |
2762 | ||
2763 | You can download and install GNU coreutils to get an 'rm' implementation | |
2764 | that behaves properly: <http://www.gnu.org/software/coreutils/>. | |
2765 | ||
2766 | If you want to complete the configuration process using your problematic | |
2767 | 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM | |
2768 | to "yes", and re-run configure. | |
2769 | ||
2770 | END | |
2771 | as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 | |
2772 | fi | |
2773 | fi | |
2732 | 2774 | |
2733 | 2775 | |
2734 | 2776 | # AM_MAINTAINER_MODE is a controversial macro. |
3555 | 3597 | ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' |
3556 | 3598 | ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' |
3557 | 3599 | ac_compiler_gnu=$ac_cv_c_compiler_gnu |
3600 | ||
3601 | ac_ext=c | |
3602 | ac_cpp='$CPP $CPPFLAGS' | |
3603 | ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' | |
3604 | ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' | |
3605 | ac_compiler_gnu=$ac_cv_c_compiler_gnu | |
3606 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 | |
3607 | $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } | |
3608 | if ${am_cv_prog_cc_c_o+:} false; then : | |
3609 | $as_echo_n "(cached) " >&6 | |
3610 | else | |
3611 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |
3612 | /* end confdefs.h. */ | |
3613 | ||
3614 | int | |
3615 | main () | |
3616 | { | |
3617 | ||
3618 | ; | |
3619 | return 0; | |
3620 | } | |
3621 | _ACEOF | |
3622 | # Make sure it works both with $CC and with simple cc. | |
3623 | # Following AC_PROG_CC_C_O, we do the test twice because some | |
3624 | # compilers refuse to overwrite an existing .o file with -o, | |
3625 | # though they will create one. | |
3626 | am_cv_prog_cc_c_o=yes | |
3627 | for am_i in 1 2; do | |
3628 | if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 | |
3629 | ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 | |
3630 | ac_status=$? | |
3631 | echo "$as_me:$LINENO: \$? = $ac_status" >&5 | |
3632 | (exit $ac_status); } \ | |
3633 | && test -f conftest2.$ac_objext; then | |
3634 | : OK | |
3635 | else | |
3636 | am_cv_prog_cc_c_o=no | |
3637 | break | |
3638 | fi | |
3639 | done | |
3640 | rm -f core conftest* | |
3641 | unset am_i | |
3642 | fi | |
3643 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 | |
3644 | $as_echo "$am_cv_prog_cc_c_o" >&6; } | |
3645 | if test "$am_cv_prog_cc_c_o" != yes; then | |
3646 | # Losing compiler, so override with the script. | |
3647 | # FIXME: It is wrong to rewrite CC. | |
3648 | # But if we don't then we get into trouble of one sort or another. | |
3649 | # A longer-term fix would be to have automake use am__CC in this case, | |
3650 | # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" | |
3651 | CC="$am_aux_dir/compile $CC" | |
3652 | fi | |
3653 | ac_ext=c | |
3654 | ac_cpp='$CPP $CPPFLAGS' | |
3655 | ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' | |
3656 | ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' | |
3657 | ac_compiler_gnu=$ac_cv_c_compiler_gnu | |
3658 | ||
3558 | 3659 | DEPDIR="${am__leading_dot}deps" |
3559 | 3660 | |
3560 | 3661 | ac_config_commands="$ac_config_commands depfiles" |
4326 | 4427 | ;; |
4327 | 4428 | *-*-darwin*) LIBS="-liconv" |
4328 | 4429 | ;; |
4430 | *-*-solaris*) LIBS="-liconv" | |
4431 | ;; | |
4329 | 4432 | esac |
4330 | 4433 | |
4331 | 4434 | ac_config_files="$ac_config_files Makefile doc/Makefile outputs/Makefile patches/Makefile src/Makefile tests/Makefile" |
4864 | 4967 | # report actual input values of CONFIG_FILES etc. instead of their |
4865 | 4968 | # values after options handling. |
4866 | 4969 | ac_log=" |
4867 | This file was extended by unrtf $as_me 0.21.9, which was | |
4970 | This file was extended by unrtf $as_me 0.21.10, which was | |
4868 | 4971 | generated by GNU Autoconf 2.69. Invocation command line was |
4869 | 4972 | |
4870 | 4973 | CONFIG_FILES = $CONFIG_FILES |
4930 | 5033 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
4931 | 5034 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
4932 | 5035 | ac_cs_version="\\ |
4933 | unrtf config.status 0.21.9 | |
5036 | unrtf config.status 0.21.10 | |
4934 | 5037 | configured by $0, generated by GNU Autoconf 2.69, |
4935 | 5038 | with options \\"\$ac_cs_config\\" |
4936 | 5039 |
1 | 1 | # Process this file with autoconf to produce a configure script. |
2 | 2 | |
3 | 3 | AC_PREREQ(2.59) |
4 | AC_INIT([unrtf], [0.21.9], [bug-unrtf@gnu.org]) | |
4 | AC_INIT([unrtf], [0.21.10], [bug-unrtf@gnu.org]) | |
5 | 5 | AC_CONFIG_SRCDIR([src/attr.c]) |
6 | 6 | AC_CONFIG_AUX_DIR([config]) |
7 | 7 | AC_CONFIG_HEADER([config.h]) |
45 | 45 | *-*-cygwin*) AC_SUBST(LIBS, ["-liconv"]);; |
46 | 46 | *aix*) AC_SUBST(LIBS, ["-liconv"]);; |
47 | 47 | *-*-darwin*) AC_SUBST(LIBS, ["-liconv"]);; |
48 | *-*-solaris*) AC_SUBST(LIBS, ["-liconv"]);; | |
48 | 49 | esac |
49 | 50 | |
50 | 51 | AC_CONFIG_FILES([Makefile |
0 | # Makefile.in generated by automake 1.13.4 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.15.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. | |
3 | # Copyright (C) 1994-2017 Free Software Foundation, Inc. | |
4 | 4 | |
5 | 5 | # This Makefile.in is free software; the Free Software Foundation |
6 | 6 | # gives unlimited permission to copy and/or distribute it, |
13 | 13 | |
14 | 14 | @SET_MAKE@ |
15 | 15 | VPATH = @srcdir@ |
16 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' | |
16 | am__is_gnu_make = { \ | |
17 | if test -z '$(MAKELEVEL)'; then \ | |
18 | false; \ | |
19 | elif test -n '$(MAKE_HOST)'; then \ | |
20 | true; \ | |
21 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ | |
22 | true; \ | |
23 | else \ | |
24 | false; \ | |
25 | fi; \ | |
26 | } | |
17 | 27 | am__make_running_with_option = \ |
18 | 28 | case $${target_option-} in \ |
19 | 29 | ?) ;; \ |
77 | 87 | build_triplet = @build@ |
78 | 88 | host_triplet = @host@ |
79 | 89 | subdir = doc |
80 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ | |
81 | $(dist_man1_MANS) | |
82 | 90 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
83 | 91 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac |
84 | 92 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
85 | 93 | $(ACLOCAL_M4) |
94 | DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) | |
86 | 95 | mkinstalldirs = $(install_sh) -d |
87 | 96 | CONFIG_HEADER = $(top_builddir)/config.h |
88 | 97 | CONFIG_CLEAN_FILES = |
138 | 147 | NROFF = nroff |
139 | 148 | MANS = $(dist_man1_MANS) |
140 | 149 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) |
150 | am__DIST_COMMON = $(dist_man1_MANS) $(srcdir)/Makefile.in | |
141 | 151 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
142 | 152 | ACLOCAL = @ACLOCAL@ |
143 | 153 | AMTAR = @AMTAR@ |
252 | 262 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ |
253 | 263 | $(am__cd) $(top_srcdir) && \ |
254 | 264 | $(AUTOMAKE) --gnu doc/Makefile |
255 | .PRECIOUS: Makefile | |
256 | 265 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
257 | 266 | @case '$?' in \ |
258 | 267 | *config.status*) \ |
467 | 476 | mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \ |
468 | 477 | uninstall-am uninstall-man uninstall-man1 |
469 | 478 | |
479 | .PRECIOUS: Makefile | |
480 | ||
470 | 481 | |
471 | 482 | unrtf.1: unrtf.1.in Makefile |
472 | 483 | sed -e 's!@DATADIR@!${datarootdir}/unrtf!g' < ${srcdir}/unrtf.1.in > unrtf.1 |
0 | # Makefile.in generated by automake 1.13.4 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.15.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. | |
3 | # Copyright (C) 1994-2017 Free Software Foundation, Inc. | |
4 | 4 | |
5 | 5 | # This Makefile.in is free software; the Free Software Foundation |
6 | 6 | # gives unlimited permission to copy and/or distribute it, |
14 | 14 | @SET_MAKE@ |
15 | 15 | |
16 | 16 | VPATH = @srcdir@ |
17 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' | |
17 | am__is_gnu_make = { \ | |
18 | if test -z '$(MAKELEVEL)'; then \ | |
19 | false; \ | |
20 | elif test -n '$(MAKE_HOST)'; then \ | |
21 | true; \ | |
22 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ | |
23 | true; \ | |
24 | else \ | |
25 | false; \ | |
26 | fi; \ | |
27 | } | |
18 | 28 | am__make_running_with_option = \ |
19 | 29 | case $${target_option-} in \ |
20 | 30 | ?) ;; \ |
78 | 88 | build_triplet = @build@ |
79 | 89 | host_triplet = @host@ |
80 | 90 | subdir = outputs |
81 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ | |
82 | $(dist_outputs_DATA) | |
83 | 91 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
84 | 92 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac |
85 | 93 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
86 | 94 | $(ACLOCAL_M4) |
95 | DIST_COMMON = $(srcdir)/Makefile.am $(dist_outputs_DATA) \ | |
96 | $(am__DIST_COMMON) | |
87 | 97 | mkinstalldirs = $(install_sh) -d |
88 | 98 | CONFIG_HEADER = $(top_builddir)/config.h |
89 | 99 | CONFIG_CLEAN_FILES = |
137 | 147 | am__installdirs = "$(DESTDIR)$(outputsdir)" |
138 | 148 | DATA = $(dist_outputs_DATA) |
139 | 149 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) |
150 | am__DIST_COMMON = $(srcdir)/Makefile.in | |
140 | 151 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
141 | 152 | ACLOCAL = @ACLOCAL@ |
142 | 153 | AMTAR = @AMTAR@ |
259 | 270 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu outputs/Makefile'; \ |
260 | 271 | $(am__cd) $(top_srcdir) && \ |
261 | 272 | $(AUTOMAKE) --gnu outputs/Makefile |
262 | .PRECIOUS: Makefile | |
263 | 273 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
264 | 274 | @case '$?' in \ |
265 | 275 | *config.status*) \ |
452 | 462 | mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \ |
453 | 463 | uninstall-am uninstall-dist_outputsDATA |
454 | 464 | |
465 | .PRECIOUS: Makefile | |
466 | ||
455 | 467 | |
456 | 468 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
457 | 469 | # Otherwise a system limit (for SysV at least) may be exceeded. |
177 | 177 | <s> |
178 | 178 | dbl_strikethru_end |
179 | 179 | </s> |
180 | all_caps_begin | |
181 | <span style="text-transform: uppercase"> | |
182 | all_caps_end | |
183 | </span> | |
184 | small_caps_begin | |
185 | <span style="font-variant: small-caps"> | |
186 | small_caps_end | |
187 | </span> | |
180 | 188 | emboss_begin |
181 | 189 | <span style="background:gray"><font color="black"> |
182 | 190 | emboss_end |
758 | 766 | ♥ |
759 | 767 | 9839 |
760 | 768 | ♦ |
769 | # non unicode characters in the symbol font | |
770 | # see http://www.fileformat.info/info/unicode/font/symbol/nonunicode.htm | |
771 | # 61472 space? | |
772 | 61473 | |
773 | ! | |
774 | 61474 | |
775 | ∀ | |
776 | 61475 | |
777 | \# | |
778 | 61476 | |
779 | ∃ | |
780 | 61475 | |
781 | % | |
782 | 61478 | |
783 | & | |
784 | 61479 | |
785 | ∋ | |
786 | 61480 | |
787 | ( | |
788 | 61481 | |
789 | ) | |
790 | 61482 | |
791 | * | |
792 | 61483 | |
793 | + | |
794 | 61484 | |
795 | , | |
796 | 61485 | |
797 | — | |
798 | 61486 | |
799 | . | |
800 | 61487 | |
801 | / | |
802 | 61488 | |
803 | 0 | |
804 | 61489 | |
805 | 1 | |
806 | 61490 | |
807 | 2 | |
808 | 61491 | |
809 | 3 | |
810 | 61492 | |
811 | 4 | |
812 | 61493 | |
813 | 5 | |
814 | 61494 | |
815 | 6 | |
816 | 61495 | |
817 | 7 | |
818 | 61496 | |
819 | 8 | |
820 | 61497 | |
821 | 9 | |
822 | 61498 | |
823 | : | |
824 | 61499 | |
825 | ; | |
826 | 61500 | |
827 | < | |
828 | 61501 | |
829 | = | |
830 | 61502 | |
831 | > | |
832 | 61503 | |
833 | ? | |
834 | 61504 | |
835 | ≅ | |
836 | 61505 | |
837 | Α | |
838 | 61506 | |
839 | Β | |
840 | 61507 | |
841 | Χ | |
842 | 61508 | |
843 | Δ | |
844 | 61509 | |
845 | Ε | |
846 | 61510 | |
847 | Φ | |
848 | 61511 | |
849 | Γ | |
850 | 61512 | |
851 | Η | |
852 | 61513 | |
853 | Ι | |
854 | 61514 | |
855 | ϕ | |
856 | 61515 | |
857 | Κ | |
858 | 61516 | |
859 | Λ | |
860 | 61517 | |
861 | Μ | |
862 | 61518 | |
863 | Ν | |
864 | 61519 | |
865 | Ο | |
866 | 61520 | |
867 | Π | |
868 | 61521 | |
869 | Θ | |
870 | 61522 | |
871 | Ρ | |
872 | 61523 | |
873 | Σ | |
874 | 61524 | |
875 | Τ | |
876 | 61525 | |
877 | Υ | |
878 | 61526 | |
879 | ς | |
880 | 61527 | |
881 | Ω | |
882 | 61528 | |
883 | Ξ | |
884 | 61529 | |
885 | Ψ | |
886 | 61530 | |
887 | Ζ | |
888 | 61531 | |
889 | [ | |
890 | 61532 | |
891 | ∴ | |
892 | 61533 | |
893 | ] | |
894 | 61534 | |
895 | ⊥ | |
896 | 61535 | |
897 | _ | |
898 | 61536 | |
899 | ‾ | |
900 | 61537 | |
901 | α | |
902 | 61538 | |
903 | β | |
904 | 61539 | |
905 | χ | |
906 | 61540 | |
907 | δ | |
908 | 61541 | |
909 | ε | |
910 | 61542 | |
911 | φ | |
912 | 61543 | |
913 | γ | |
914 | 61544 | |
915 | η | |
916 | 61545 | |
917 | τ | |
918 | 61546 | |
919 | ϕ | |
920 | 61547 | |
921 | κ | |
922 | 61548 | |
923 | λ | |
924 | 61549 | |
925 | μ | |
926 | 61550 | |
927 | ν | |
928 | 61551 | |
929 | ο | |
930 | 61552 | |
931 | π | |
932 | 61553 | |
933 | θ | |
934 | 61554 | |
935 | ρ | |
936 | 61555 | |
937 | σ | |
938 | 61556 | |
939 | τ | |
940 | 61557 | |
941 | υ | |
942 | 61558 | |
943 | ϖ | |
944 | 61559 | |
945 | ω | |
946 | 61560 | |
947 | ξ | |
948 | 61561 | |
949 | ψ | |
950 | 61562 | |
951 | ζ | |
952 | 61563 | |
953 | { | |
954 | 61564 | |
955 | | | |
956 | 61565 | |
957 | } | |
958 | 61566 | |
959 | ∼ | |
960 | 61600 | |
961 | € | |
962 | 61601 | |
963 | ϒ | |
964 | 61602 | |
965 | ′ | |
966 | 61603 | |
967 | ≤ | |
968 | 61604 | |
969 | ⁄ | |
970 | 61605 | |
971 | ∞ | |
972 | 61606 | |
973 | ƒ | |
974 | 61607 | |
975 | ♣ | |
976 | 61608 | |
977 | ♦ | |
978 | 61609 | |
979 | ♥ | |
980 | 61610 | |
981 | ♠ | |
982 | 61611 | |
983 | ↔ | |
984 | 61612 | |
985 | ← | |
986 | 61613 | |
987 | ↑ | |
988 | 61614 | |
989 | → | |
990 | 61615 | |
991 | ↓ | |
992 | 61616 | |
993 | ° | |
994 | 61617 | |
995 | ± | |
996 | 61618 | |
997 | ″ | |
998 | 61619 | |
999 | ≥ | |
1000 | 61620 | |
1001 | × | |
1002 | 61621 | |
1003 | ∝ | |
1004 | 61622 | |
1005 | ∂ | |
1006 | 61623 | |
1007 | • | |
1008 | 61624 | |
1009 | ÷ | |
1010 | 61625 | |
1011 | ≠ | |
1012 | 61626 | |
1013 | ≡ | |
1014 | 61627 | |
1015 | ≈ | |
1016 | 61628 | |
1017 | … | |
1018 | # vertical bar | |
1019 | 61629 | |
1020 | | | |
1021 | 61630 | |
1022 | — | |
1023 | 61631 | |
1024 | ↵ | |
1025 | 61632 | |
1026 | ℵ | |
1027 | 61633 | |
1028 | ℑ | |
1029 | 61634 | |
1030 | ℜ | |
1031 | 61635 | |
1032 | ℘ | |
1033 | 61636 | |
1034 | ⊗ | |
1035 | 61637 | |
1036 | ⊕ | |
1037 | 61638 | |
1038 | ∅ | |
1039 | 61639 | |
1040 | ∩ | |
1041 | 61640 | |
1042 | ∪ | |
1043 | 61641 | |
1044 | ⊃ | |
1045 | 61642 | |
1046 | ⊇ | |
1047 | 61643 | |
1048 | ⊄ | |
1049 | 61644 | |
1050 | ⊂ | |
1051 | 61645 | |
1052 | ⊆ | |
1053 | 61646 | |
1054 | ∈ | |
1055 | 61647 | |
1056 | ∉ | |
1057 | 61648 | |
1058 | ∠ | |
1059 | 61649 | |
1060 | ∇ | |
1061 | 61650 | |
1062 | ® | |
1063 | 61651 | |
1064 | © | |
1065 | 61652 | |
1066 | ™ | |
1067 | 61653 | |
1068 | ∏ | |
1069 | 61654 | |
1070 | √ | |
1071 | 61655 | |
1072 | · | |
1073 | 61656 | |
1074 | ¬ | |
1075 | 61657 | |
1076 | ∧ | |
1077 | 61658 | |
1078 | ∨ | |
1079 | 61659 | |
1080 | ⇔ | |
1081 | 61660 | |
1082 | ⇐ | |
1083 | 61661 | |
1084 | ⇑ | |
1085 | 61662 | |
1086 | ⇒ | |
1087 | 61663 | |
1088 | ⇓ | |
1089 | 61664 | |
1090 | ◊ | |
1091 | 61665 | |
1092 | ⟨ | |
1093 | 61666 | |
1094 | ® | |
1095 | 61667 | |
1096 | © | |
1097 | 61668 | |
1098 | ™ | |
1099 | 61669 | |
1100 | ∑ | |
1101 | #61670 | |
1102 | # large right parenthesis ceiling | |
1103 | #61671 | |
1104 | # large parenthesis middle | |
1105 | #61672 | |
1106 | # large left parenthesis floor | |
1107 | 61673 | |
1108 | # large left square bracket ceiling | |
1109 | ⌈ | |
1110 | #61674 | |
1111 | # large left square bracket middle | |
1112 | 61675 | |
1113 | # large left square bracket floor | |
1114 | ⌊ | |
1115 | #61676 | |
1116 | # large left bracket ceiling | |
1117 | # 61677 | |
1118 | # large left bracket middle | |
1119 | #61678 | |
1120 | # large left bracket floor | |
1121 | #61679 | |
1122 | # large vertical bar | |
1123 | #61680 | |
1124 | # appears blank | |
1125 | 61681 | |
1126 | ⟩ | |
1127 | 61682 | |
1128 | # integral | |
1129 | ∫ | |
1130 | #61683 | |
1131 | # large integral ceiling | |
1132 | #61684 | |
1133 | # large integral middle | |
1134 | #61685 | |
1135 | # large integral floor | |
1136 | #61686 | |
1137 | # large right parenthesis ceiling | |
1138 | #61687 | |
1139 | # large right parenthesis middle | |
1140 | #61688 | |
1141 | # large right parenthesis floor | |
1142 | 61689 | |
1143 | # large right square bracket ceiling | |
1144 | ⌉ | |
1145 | #61690 | |
1146 | # large right square bracket middle | |
1147 | 61691 | |
1148 | # large right square bracket floor | |
1149 | ⌋ | |
1150 | #61692 | |
1151 | # large right bracket middle | |
1152 | #61694 | |
1153 | # large right bracket floot |
0 | # Makefile.in generated by automake 1.13.4 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.15.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. | |
3 | # Copyright (C) 1994-2017 Free Software Foundation, Inc. | |
4 | 4 | |
5 | 5 | # This Makefile.in is free software; the Free Software Foundation |
6 | 6 | # gives unlimited permission to copy and/or distribute it, |
16 | 16 | # this simple Makefile.am just adds the patches to the distributed |
17 | 17 | # tarball in the release. |
18 | 18 | VPATH = @srcdir@ |
19 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' | |
19 | am__is_gnu_make = { \ | |
20 | if test -z '$(MAKELEVEL)'; then \ | |
21 | false; \ | |
22 | elif test -n '$(MAKE_HOST)'; then \ | |
23 | true; \ | |
24 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ | |
25 | true; \ | |
26 | else \ | |
27 | false; \ | |
28 | fi; \ | |
29 | } | |
20 | 30 | am__make_running_with_option = \ |
21 | 31 | case $${target_option-} in \ |
22 | 32 | ?) ;; \ |
80 | 90 | build_triplet = @build@ |
81 | 91 | host_triplet = @host@ |
82 | 92 | subdir = patches |
83 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am | |
84 | 93 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
85 | 94 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac |
86 | 95 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
87 | 96 | $(ACLOCAL_M4) |
97 | DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) | |
88 | 98 | mkinstalldirs = $(install_sh) -d |
89 | 99 | CONFIG_HEADER = $(top_builddir)/config.h |
90 | 100 | CONFIG_CLEAN_FILES = |
109 | 119 | *) (install-info --version) >/dev/null 2>&1;; \ |
110 | 120 | esac |
111 | 121 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) |
122 | am__DIST_COMMON = $(srcdir)/Makefile.in | |
112 | 123 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
113 | 124 | ACLOCAL = @ACLOCAL@ |
114 | 125 | AMTAR = @AMTAR@ |
222 | 233 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu patches/Makefile'; \ |
223 | 234 | $(am__cd) $(top_srcdir) && \ |
224 | 235 | $(AUTOMAKE) --gnu patches/Makefile |
225 | .PRECIOUS: Makefile | |
226 | 236 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
227 | 237 | @case '$?' in \ |
228 | 238 | *config.status*) \ |
390 | 400 | maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ |
391 | 401 | pdf-am ps ps-am tags-am uninstall uninstall-am |
392 | 402 | |
403 | .PRECIOUS: Makefile | |
404 | ||
393 | 405 | |
394 | 406 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
395 | 407 | # Otherwise a system limit (for SysV at least) may be exceeded. |
0 | # Makefile.in generated by automake 1.13.4 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.15.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. | |
3 | # Copyright (C) 1994-2017 Free Software Foundation, Inc. | |
4 | 4 | |
5 | 5 | # This Makefile.in is free software; the Free Software Foundation |
6 | 6 | # gives unlimited permission to copy and/or distribute it, |
17 | 17 | # It all works automagically. |
18 | 18 | |
19 | 19 | VPATH = @srcdir@ |
20 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' | |
20 | am__is_gnu_make = { \ | |
21 | if test -z '$(MAKELEVEL)'; then \ | |
22 | false; \ | |
23 | elif test -n '$(MAKE_HOST)'; then \ | |
24 | true; \ | |
25 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ | |
26 | true; \ | |
27 | else \ | |
28 | false; \ | |
29 | fi; \ | |
30 | } | |
21 | 31 | am__make_running_with_option = \ |
22 | 32 | case $${target_option-} in \ |
23 | 33 | ?) ;; \ |
82 | 92 | host_triplet = @host@ |
83 | 93 | bin_PROGRAMS = unrtf$(EXEEXT) |
84 | 94 | subdir = src |
85 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ | |
86 | $(top_srcdir)/config/depcomp | |
87 | 95 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
88 | 96 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac |
89 | 97 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
90 | 98 | $(ACLOCAL_M4) |
99 | DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) | |
91 | 100 | mkinstalldirs = $(install_sh) -d |
92 | 101 | CONFIG_HEADER = $(top_builddir)/config.h |
93 | 102 | CONFIG_CLEAN_FILES = |
155 | 164 | done | $(am__uniquify_input)` |
156 | 165 | ETAGS = etags |
157 | 166 | CTAGS = ctags |
167 | am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp | |
158 | 168 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
159 | 169 | ACLOCAL = @ACLOCAL@ |
160 | 170 | AMTAR = @AMTAR@ |
285 | 295 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ |
286 | 296 | $(am__cd) $(top_srcdir) && \ |
287 | 297 | $(AUTOMAKE) --gnu src/Makefile |
288 | .PRECIOUS: Makefile | |
289 | 298 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
290 | 299 | @case '$?' in \ |
291 | 300 | *config.status*) \ |
376 | 385 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |
377 | 386 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
378 | 387 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
379 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< | |
388 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< | |
380 | 389 | |
381 | 390 | .c.obj: |
382 | 391 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` |
383 | 392 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |
384 | 393 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
385 | 394 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
386 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` | |
395 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` | |
387 | 396 | |
388 | 397 | ID: $(am__tagged_files) |
389 | 398 | $(am__define_uniq_tagged_files); mkid -fID $$unique |
589 | 598 | ps ps-am tags tags-am uninstall uninstall-am \ |
590 | 599 | uninstall-binPROGRAMS |
591 | 600 | |
601 | .PRECIOUS: Makefile | |
602 | ||
592 | 603 | |
593 | 604 | # Tell versions [3.59,3.63) of GNU make to not export all variables. |
594 | 605 | # Otherwise a system limit (for SysV at least) may be exceeded. |
74 | 74 | extern int simulate_smallcaps; |
75 | 75 | |
76 | 76 | |
77 | #define MAX_ATTRS (10000) | |
77 | #define MAX_ATTRS 100 | |
78 | 78 | |
79 | 79 | |
80 | 80 | /* For each RTF text block (the text within braces) we must keep |
84 | 84 | * from parent blocks, all new AttrStacks do the same from |
85 | 85 | * their parent AttrStack. |
86 | 86 | */ |
87 | typedef struct _stack { | |
87 | typedef struct _stack | |
88 | { | |
88 | 89 | unsigned char attr_stack[MAX_ATTRS]; |
89 | char *attr_stack_params[MAX_ATTRS]; | |
90 | char *attr_stack_params[MAX_ATTRS]; | |
90 | 91 | int tos; |
91 | struct _stack *next; | |
92 | struct _stack *prev; | |
92 | 93 | } AttrStack; |
93 | 94 | |
94 | 95 | /*@null@*/ static AttrStack *stack_of_stacks = NULL; |
95 | 96 | /*@null@*/ static AttrStack *stack_of_stacks_top = NULL; |
96 | 97 | |
97 | ||
98 | static void attr_express_begin(int attr, char *param); | |
99 | static void attr_express_end(int attr, char *param); | |
100 | ||
101 | ||
102 | /* Iterate from top of given stack looking for findattr */ | |
103 | static int attr_find(AttrStack *stack, int findattr) | |
104 | { | |
105 | int i; | |
106 | for (i = stack->tos; i >= 0; i--) | |
107 | if (stack->attr_stack[i] == findattr) | |
108 | { | |
109 | return i; | |
110 | } | |
111 | return -1; | |
112 | } | |
113 | ||
114 | /* Iterate all stacks looking for most recent value for attr */ | |
115 | static int attrstack_find_attr(int findattr, char **paramp) | |
116 | { | |
117 | AttrStack *stack = stack_of_stacks_top; | |
118 | ||
119 | while (stack) | |
120 | { | |
121 | int index = attr_find(stack, findattr); | |
122 | if (index >= 0) | |
123 | { | |
124 | *paramp = stack->attr_stack_params[index]; | |
125 | return TRUE; | |
126 | } | |
127 | stack = stack->prev; | |
128 | } | |
129 | return FALSE; | |
130 | } | |
131 | ||
132 | /* Remove attribute at the given index, unexpressing and reexpressing | |
133 | the ones above in appropriate order. */ | |
134 | static void attr_pull_out(AttrStack *stack, int index) | |
135 | { | |
136 | int j; | |
137 | /* Unexpress all newer attributes, and the one we'll remove */ | |
138 | for (j = stack->tos; j >= index; j--) | |
139 | { | |
140 | attr_express_end(stack->attr_stack[j], stack->attr_stack_params[j]); | |
141 | } | |
142 | ||
143 | /* Delete target attribute and shift the stack down */ | |
144 | if (stack->attr_stack_params[index]) | |
145 | my_free(stack->attr_stack_params[index]); | |
146 | for (j = index; j < stack->tos; j++) | |
147 | { | |
148 | stack->attr_stack[j] = stack->attr_stack[j + 1]; | |
149 | stack->attr_stack_params[j] = stack->attr_stack_params[j + 1]; | |
150 | } | |
151 | stack->tos--; | |
152 | ||
153 | /* Re-express unexpressed attributes */ | |
154 | for (j = index; j <= stack->tos; j++) | |
155 | { | |
156 | attr_express_begin(stack->attr_stack[j], stack->attr_stack_params[j]); | |
157 | } | |
158 | return; | |
159 | } | |
160 | ||
161 | /* Unexpress and remove top attr. Internal version, no checking of args */ | |
162 | static void attr_pop_internal(AttrStack *stack, int attr) | |
163 | { | |
164 | if (stack->tos >= 0) | |
165 | { | |
166 | char *param = stack->attr_stack_params[stack->tos]; | |
167 | ||
168 | attr_express_end(attr, param); | |
169 | ||
170 | if (param) | |
171 | { | |
172 | my_free(param); | |
173 | } | |
174 | ||
175 | stack->tos--; | |
176 | } | |
177 | } | |
98 | 178 | |
99 | 179 | |
100 | 180 | /*======================================================================== |
104 | 184 | * Returns: None. |
105 | 185 | *=======================================================================*/ |
106 | 186 | |
107 | void | |
108 | attr_express_begin (int attr, char* param) { | |
109 | switch(attr) | |
110 | { | |
111 | case ATTR_BOLD: | |
112 | if (safe_printf(0, op->bold_begin)) fprintf(stderr, TOO_MANY_ARGS, "bold_begin");; | |
113 | break; | |
114 | case ATTR_ITALIC: | |
115 | if (safe_printf(0, op->italic_begin)) fprintf(stderr, TOO_MANY_ARGS, "italic_begin");; | |
187 | static void attr_express_begin(int attr, char *param) | |
188 | { | |
189 | switch (attr) | |
190 | { | |
191 | case ATTR_BOLD: | |
192 | if (safe_printf(0, op->bold_begin)) | |
193 | { | |
194 | fprintf(stderr, TOO_MANY_ARGS, "bold_begin"); | |
195 | }; | |
196 | break; | |
197 | case ATTR_ITALIC: | |
198 | if (safe_printf(0, op->italic_begin)) | |
199 | { | |
200 | fprintf(stderr, TOO_MANY_ARGS, "italic_begin"); | |
201 | }; | |
116 | 202 | break; |
117 | 203 | |
118 | 204 | /* Various underlines, they all resolve to HTML's <u> */ |
119 | 205 | case ATTR_THICK_UL: |
120 | 206 | case ATTR_WAVE_UL: |
121 | 207 | case ATTR_DASH_UL: |
122 | case ATTR_DOT_UL: | |
208 | case ATTR_DOT_UL: | |
123 | 209 | case ATTR_DOT_DASH_UL: |
124 | 210 | case ATTR_2DOT_DASH_UL: |
125 | case ATTR_WORD_UL: | |
126 | case ATTR_UNDERLINE: | |
127 | if (safe_printf(0, op->underline_begin)) fprintf(stderr, TOO_MANY_ARGS, "underline_begin");; | |
128 | break; | |
129 | ||
130 | case ATTR_DOUBLE_UL: | |
131 | if (safe_printf(0, op->dbl_underline_begin)) fprintf(stderr, TOO_MANY_ARGS, "dbl_underline_begin");; | |
132 | break; | |
133 | ||
134 | case ATTR_FONTSIZE: | |
135 | op_begin_std_fontsize (op, atoi (param)); | |
136 | break; | |
137 | ||
138 | case ATTR_FONTFACE: | |
139 | if (safe_printf(1, op->font_begin,param)) fprintf(stderr, TOO_MANY_ARGS, "font_begin");; | |
140 | break; | |
141 | ||
142 | case ATTR_FOREGROUND: | |
143 | if (safe_printf(1, op->foreground_begin, param)) fprintf(stderr, TOO_MANY_ARGS, "foreground_begin");; | |
144 | break; | |
145 | ||
146 | case ATTR_BACKGROUND: | |
211 | case ATTR_WORD_UL: | |
212 | case ATTR_UNDERLINE: | |
213 | if (safe_printf(0, op->underline_begin)) | |
214 | { | |
215 | fprintf(stderr, TOO_MANY_ARGS, "underline_begin"); | |
216 | }; | |
217 | break; | |
218 | ||
219 | case ATTR_DOUBLE_UL: | |
220 | if (safe_printf(0, op->dbl_underline_begin)) | |
221 | { | |
222 | fprintf(stderr, TOO_MANY_ARGS, "dbl_underline_begin"); | |
223 | }; | |
224 | break; | |
225 | ||
226 | case ATTR_FONTSIZE: | |
227 | op_begin_std_fontsize(op, atoi(param)); | |
228 | break; | |
229 | ||
230 | case ATTR_FONTFACE: | |
231 | if (safe_printf(1, op->font_begin, param)) | |
232 | { | |
233 | fprintf(stderr, TOO_MANY_ARGS, "font_begin"); | |
234 | }; | |
235 | break; | |
236 | ||
237 | case ATTR_FOREGROUND: | |
238 | if (safe_printf(1, op->foreground_begin, param)) | |
239 | { | |
240 | fprintf(stderr, TOO_MANY_ARGS, "foreground_begin"); | |
241 | }; | |
242 | break; | |
243 | ||
244 | case ATTR_BACKGROUND: | |
147 | 245 | if (!simple_mode) |
148 | if (safe_printf(1, op->background_begin,param)) fprintf(stderr, TOO_MANY_ARGS, "background_begin");; | |
149 | break; | |
150 | ||
151 | case ATTR_SUPER: | |
152 | if (safe_printf(0, op->superscript_begin)) fprintf(stderr, TOO_MANY_ARGS, "superscript_begin");; | |
153 | break; | |
154 | case ATTR_SUB: | |
155 | if (safe_printf(0, op->subscript_begin)) fprintf(stderr, TOO_MANY_ARGS, "subscript_begin");; | |
156 | break; | |
157 | ||
158 | case ATTR_STRIKE: | |
159 | if (safe_printf(0, op->strikethru_begin)) fprintf(stderr, TOO_MANY_ARGS, "strikethru_begin");; | |
160 | break; | |
161 | ||
162 | case ATTR_DBL_STRIKE: | |
163 | if (safe_printf(0, op->dbl_strikethru_begin)) fprintf(stderr, TOO_MANY_ARGS, "dbl_strikethru_begin");; | |
164 | break; | |
165 | ||
166 | case ATTR_EXPAND: | |
167 | if (safe_printf(1, op->expand_begin, param)) fprintf(stderr, TOO_MANY_ARGS, "expand_begin");; | |
168 | break; | |
169 | ||
170 | case ATTR_OUTLINE: | |
171 | if (safe_printf(0, op->outline_begin)) fprintf(stderr, TOO_MANY_ARGS, "outline_begin");; | |
172 | break; | |
173 | case ATTR_SHADOW: | |
174 | if (safe_printf(0, op->shadow_begin)) fprintf(stderr, TOO_MANY_ARGS, "shadow_begin");; | |
175 | break; | |
176 | case ATTR_EMBOSS: | |
177 | if (safe_printf(0, op->emboss_begin)) fprintf(stderr, TOO_MANY_ARGS, "emboss_begin");; | |
178 | break; | |
179 | case ATTR_ENGRAVE: | |
180 | if (safe_printf(0, op->engrave_begin)) fprintf(stderr, TOO_MANY_ARGS, "engrave_begin");; | |
246 | if (safe_printf(1, op->background_begin, param)) | |
247 | { | |
248 | fprintf(stderr, TOO_MANY_ARGS, "background_begin"); | |
249 | }; | |
250 | break; | |
251 | ||
252 | case ATTR_SUPER: | |
253 | if (safe_printf(0, op->superscript_begin)) | |
254 | { | |
255 | fprintf(stderr, TOO_MANY_ARGS, "superscript_begin"); | |
256 | }; | |
257 | break; | |
258 | case ATTR_SUB: | |
259 | if (safe_printf(0, op->subscript_begin)) | |
260 | { | |
261 | fprintf(stderr, TOO_MANY_ARGS, "subscript_begin"); | |
262 | }; | |
263 | break; | |
264 | ||
265 | case ATTR_STRIKE: | |
266 | if (safe_printf(0, op->strikethru_begin)) | |
267 | { | |
268 | fprintf(stderr, TOO_MANY_ARGS, "strikethru_begin"); | |
269 | }; | |
270 | break; | |
271 | ||
272 | case ATTR_DBL_STRIKE: | |
273 | if (safe_printf(0, op->dbl_strikethru_begin)) | |
274 | { | |
275 | fprintf(stderr, TOO_MANY_ARGS, "dbl_strikethru_begin"); | |
276 | }; | |
277 | break; | |
278 | ||
279 | case ATTR_EXPAND: | |
280 | if (safe_printf(1, op->expand_begin, param)) | |
281 | { | |
282 | fprintf(stderr, TOO_MANY_ARGS, "expand_begin"); | |
283 | }; | |
284 | break; | |
285 | ||
286 | case ATTR_OUTLINE: | |
287 | if (safe_printf(0, op->outline_begin)) | |
288 | { | |
289 | fprintf(stderr, TOO_MANY_ARGS, "outline_begin"); | |
290 | }; | |
291 | break; | |
292 | case ATTR_SHADOW: | |
293 | if (safe_printf(0, op->shadow_begin)) | |
294 | { | |
295 | fprintf(stderr, TOO_MANY_ARGS, "shadow_begin"); | |
296 | }; | |
297 | break; | |
298 | case ATTR_EMBOSS: | |
299 | if (safe_printf(0, op->emboss_begin)) | |
300 | { | |
301 | fprintf(stderr, TOO_MANY_ARGS, "emboss_begin"); | |
302 | }; | |
303 | break; | |
304 | case ATTR_ENGRAVE: | |
305 | if (safe_printf(0, op->engrave_begin)) | |
306 | { | |
307 | fprintf(stderr, TOO_MANY_ARGS, "engrave_begin"); | |
308 | }; | |
181 | 309 | break; |
182 | 310 | |
183 | 311 | case ATTR_CAPS: |
184 | 312 | if (op->simulate_all_caps) |
313 | { | |
185 | 314 | simulate_allcaps = TRUE; |
186 | break; | |
187 | ||
188 | case ATTR_SMALLCAPS: | |
315 | } | |
316 | else | |
317 | { | |
318 | if (op->all_caps_begin) | |
319 | if (safe_printf(0, op->all_caps_begin)) | |
320 | { | |
321 | fprintf(stderr, TOO_MANY_ARGS, "all_caps_begin"); | |
322 | } | |
323 | } | |
324 | break; | |
325 | ||
326 | case ATTR_SMALLCAPS: | |
189 | 327 | if (op->simulate_small_caps) |
328 | { | |
190 | 329 | simulate_smallcaps = TRUE; |
191 | else { | |
330 | } | |
331 | else | |
332 | { | |
192 | 333 | if (op->small_caps_begin) |
193 | if (safe_printf(0, op->small_caps_begin)) fprintf(stderr, TOO_MANY_ARGS, "small_caps_begin");; | |
334 | if (safe_printf(0, op->small_caps_begin)) | |
335 | { | |
336 | fprintf(stderr, TOO_MANY_ARGS, "small_caps_begin"); | |
337 | }; | |
194 | 338 | } |
195 | 339 | break; |
196 | 340 | } |
204 | 348 | * Returns: None. |
205 | 349 | *=======================================================================*/ |
206 | 350 | |
207 | void | |
208 | attr_express_end (int attr, char *param) | |
209 | { | |
210 | switch(attr) | |
211 | { | |
212 | case ATTR_BOLD: | |
213 | if (safe_printf(0, op->bold_end)) fprintf(stderr, TOO_MANY_ARGS, "bold_end");; | |
214 | break; | |
215 | case ATTR_ITALIC: | |
216 | if (safe_printf(0, op->italic_end)) fprintf(stderr, TOO_MANY_ARGS, "italic_end");; | |
351 | static void attr_express_end(int attr, char *param) | |
352 | { | |
353 | switch (attr) | |
354 | { | |
355 | case ATTR_BOLD: | |
356 | if (safe_printf(0, op->bold_end)) | |
357 | { | |
358 | fprintf(stderr, TOO_MANY_ARGS, "bold_end"); | |
359 | }; | |
360 | break; | |
361 | case ATTR_ITALIC: | |
362 | if (safe_printf(0, op->italic_end)) | |
363 | { | |
364 | fprintf(stderr, TOO_MANY_ARGS, "italic_end"); | |
365 | }; | |
217 | 366 | break; |
218 | 367 | |
219 | 368 | /* Various underlines, they all resolve to HTML's </u> */ |
220 | 369 | case ATTR_THICK_UL: |
221 | 370 | case ATTR_WAVE_UL: |
222 | 371 | case ATTR_DASH_UL: |
223 | case ATTR_DOT_UL: | |
372 | case ATTR_DOT_UL: | |
224 | 373 | case ATTR_DOT_DASH_UL: |
225 | case ATTR_2DOT_DASH_UL: | |
226 | case ATTR_WORD_UL: | |
227 | case ATTR_UNDERLINE: | |
228 | if (safe_printf(0, op->underline_end)) fprintf(stderr, TOO_MANY_ARGS, "underline_end");; | |
229 | break; | |
230 | ||
231 | case ATTR_DOUBLE_UL: | |
232 | if (safe_printf(0, op->dbl_underline_end)) fprintf(stderr, TOO_MANY_ARGS, "dbl_underline_end");; | |
233 | break; | |
234 | ||
235 | case ATTR_FONTSIZE: | |
236 | op_end_std_fontsize (op, atoi (param)); | |
237 | break; | |
238 | ||
239 | case ATTR_FONTFACE: | |
240 | if (safe_printf(0, op->font_end)) fprintf(stderr, TOO_MANY_ARGS, "font_end");; | |
241 | break; | |
242 | ||
243 | case ATTR_FOREGROUND: | |
244 | if (safe_printf(0, op->foreground_end)) fprintf(stderr, TOO_MANY_ARGS, "foreground_end");; | |
245 | break; | |
246 | case ATTR_BACKGROUND: | |
374 | case ATTR_2DOT_DASH_UL: | |
375 | case ATTR_WORD_UL: | |
376 | case ATTR_UNDERLINE: | |
377 | if (safe_printf(0, op->underline_end)) | |
378 | { | |
379 | fprintf(stderr, TOO_MANY_ARGS, "underline_end"); | |
380 | }; | |
381 | break; | |
382 | ||
383 | case ATTR_DOUBLE_UL: | |
384 | if (safe_printf(0, op->dbl_underline_end)) | |
385 | { | |
386 | fprintf(stderr, TOO_MANY_ARGS, "dbl_underline_end"); | |
387 | }; | |
388 | break; | |
389 | ||
390 | case ATTR_FONTSIZE: | |
391 | op_end_std_fontsize(op, atoi(param)); | |
392 | break; | |
393 | ||
394 | case ATTR_FONTFACE: | |
395 | if (safe_printf(0, op->font_end)) | |
396 | { | |
397 | fprintf(stderr, TOO_MANY_ARGS, "font_end"); | |
398 | }; | |
399 | break; | |
400 | ||
401 | case ATTR_FOREGROUND: | |
402 | if (safe_printf(0, op->foreground_end)) | |
403 | { | |
404 | fprintf(stderr, TOO_MANY_ARGS, "foreground_end"); | |
405 | }; | |
406 | break; | |
407 | case ATTR_BACKGROUND: | |
247 | 408 | if (!simple_mode) |
248 | if (safe_printf(0, op->background_end)) fprintf(stderr, TOO_MANY_ARGS, "background_end");; | |
249 | break; | |
250 | ||
251 | case ATTR_SUPER: | |
252 | if (safe_printf(0, op->superscript_end)) fprintf(stderr, TOO_MANY_ARGS, "superscript_end");; | |
253 | break; | |
254 | case ATTR_SUB: | |
255 | if (safe_printf(0, op->subscript_end)) fprintf(stderr, TOO_MANY_ARGS, "subscript_end");; | |
256 | break; | |
257 | ||
258 | case ATTR_STRIKE: | |
259 | if (safe_printf(0, op->strikethru_end)) fprintf(stderr, TOO_MANY_ARGS, "strikethru_end");; | |
260 | break; | |
261 | ||
262 | case ATTR_DBL_STRIKE: | |
263 | if (safe_printf(0, op->dbl_strikethru_end)) fprintf(stderr, TOO_MANY_ARGS, "dbl_strikethru_end");; | |
264 | break; | |
265 | ||
266 | case ATTR_OUTLINE: | |
267 | if (safe_printf(0, op->outline_end)) fprintf(stderr, TOO_MANY_ARGS, "outline_end");; | |
268 | break; | |
269 | case ATTR_SHADOW: | |
270 | if (safe_printf(0, op->shadow_end)) fprintf(stderr, TOO_MANY_ARGS, "shadow_end");; | |
271 | break; | |
272 | case ATTR_EMBOSS: | |
273 | if (safe_printf(0, op->emboss_end)) fprintf(stderr, TOO_MANY_ARGS, "emboss_end");; | |
274 | break; | |
275 | case ATTR_ENGRAVE: | |
276 | if (safe_printf(0, op->engrave_end)) fprintf(stderr, TOO_MANY_ARGS, "engrave_end");; | |
277 | break; | |
278 | ||
279 | case ATTR_EXPAND: | |
280 | if (safe_printf(0, op->expand_end)) fprintf(stderr, TOO_MANY_ARGS, "expand_end");; | |
409 | if (safe_printf(0, op->background_end)) | |
410 | { | |
411 | fprintf(stderr, TOO_MANY_ARGS, "background_end"); | |
412 | }; | |
413 | break; | |
414 | ||
415 | case ATTR_SUPER: | |
416 | if (safe_printf(0, op->superscript_end)) | |
417 | { | |
418 | fprintf(stderr, TOO_MANY_ARGS, "superscript_end"); | |
419 | }; | |
420 | break; | |
421 | case ATTR_SUB: | |
422 | if (safe_printf(0, op->subscript_end)) | |
423 | { | |
424 | fprintf(stderr, TOO_MANY_ARGS, "subscript_end"); | |
425 | }; | |
426 | break; | |
427 | ||
428 | case ATTR_STRIKE: | |
429 | if (safe_printf(0, op->strikethru_end)) | |
430 | { | |
431 | fprintf(stderr, TOO_MANY_ARGS, "strikethru_end"); | |
432 | }; | |
433 | break; | |
434 | ||
435 | case ATTR_DBL_STRIKE: | |
436 | if (safe_printf(0, op->dbl_strikethru_end)) | |
437 | { | |
438 | fprintf(stderr, TOO_MANY_ARGS, "dbl_strikethru_end"); | |
439 | }; | |
440 | break; | |
441 | ||
442 | case ATTR_OUTLINE: | |
443 | if (safe_printf(0, op->outline_end)) | |
444 | { | |
445 | fprintf(stderr, TOO_MANY_ARGS, "outline_end"); | |
446 | }; | |
447 | break; | |
448 | case ATTR_SHADOW: | |
449 | if (safe_printf(0, op->shadow_end)) | |
450 | { | |
451 | fprintf(stderr, TOO_MANY_ARGS, "shadow_end"); | |
452 | }; | |
453 | break; | |
454 | case ATTR_EMBOSS: | |
455 | if (safe_printf(0, op->emboss_end)) | |
456 | { | |
457 | fprintf(stderr, TOO_MANY_ARGS, "emboss_end"); | |
458 | }; | |
459 | break; | |
460 | case ATTR_ENGRAVE: | |
461 | if (safe_printf(0, op->engrave_end)) | |
462 | { | |
463 | fprintf(stderr, TOO_MANY_ARGS, "engrave_end"); | |
464 | }; | |
465 | break; | |
466 | ||
467 | case ATTR_EXPAND: | |
468 | if (safe_printf(0, op->expand_end)) | |
469 | { | |
470 | fprintf(stderr, TOO_MANY_ARGS, "expand_end"); | |
471 | }; | |
281 | 472 | break; |
282 | 473 | |
283 | 474 | case ATTR_CAPS: |
284 | 475 | if (op->simulate_all_caps) |
476 | { | |
285 | 477 | simulate_allcaps = FALSE; |
286 | break; | |
287 | ||
288 | case ATTR_SMALLCAPS: | |
478 | } | |
479 | else | |
480 | { | |
481 | if (op->all_caps_end) | |
482 | if (safe_printf(0, op->all_caps_end)) | |
483 | { | |
484 | fprintf(stderr, TOO_MANY_ARGS, "all_caps_end"); | |
485 | }; | |
486 | } | |
487 | break; | |
488 | ||
489 | case ATTR_SMALLCAPS: | |
289 | 490 | if (op->simulate_small_caps) |
491 | { | |
290 | 492 | simulate_smallcaps = FALSE; |
291 | else { | |
493 | } | |
494 | else | |
495 | { | |
292 | 496 | if (op->small_caps_end) |
293 | if (safe_printf(0, op->small_caps_end)) fprintf(stderr, TOO_MANY_ARGS, "small_caps_end");; | |
497 | if (safe_printf(0, op->small_caps_end)) | |
498 | { | |
499 | fprintf(stderr, TOO_MANY_ARGS, "small_caps_end"); | |
500 | }; | |
294 | 501 | } |
295 | 502 | break; |
296 | 503 | } |
305 | 512 | * Returns: None. |
306 | 513 | *=======================================================================*/ |
307 | 514 | |
308 | void | |
309 | attr_push(int attr, char* param) | |
515 | void attr_push(int attr, char *param) | |
310 | 516 | { |
311 | 517 | AttrStack *stack = stack_of_stacks_top; |
312 | if (!stack) { | |
518 | int i; | |
519 | char *oldparam; | |
520 | ||
521 | /*fprintf(stderr, "attr_push: [%d] [%s]\n", attr, param);*/ | |
522 | ||
523 | if (!stack) | |
524 | { | |
313 | 525 | warning_handler("No stack to push attribute onto"); |
314 | 526 | return; |
315 | 527 | } |
316 | 528 | |
317 | if (stack->tos >= MAX_ATTRS -1) { | |
529 | /* Remove any current value of the same attr in the top stack */ | |
530 | if ((i = attr_find(stack, attr)) != -1) | |
531 | { | |
532 | attr_pull_out(stack, i); | |
533 | } | |
534 | ||
535 | if (stack->tos >= MAX_ATTRS - 1) | |
536 | { | |
318 | 537 | fprintf(stderr, "Too many attributes!\n"); |
319 | 538 | return; |
320 | 539 | } |
326 | 545 | |
327 | 546 | ++stack->tos; |
328 | 547 | stack->attr_stack[stack->tos] = attr; |
329 | if (param) | |
548 | if (param) | |
549 | { | |
330 | 550 | stack->attr_stack_params[stack->tos] = my_strdup(param); |
551 | } | |
331 | 552 | else |
553 | { | |
332 | 554 | stack->attr_stack_params[stack->tos] = NULL; |
555 | } | |
333 | 556 | |
334 | 557 | attr_express_begin(attr, param); |
335 | 558 | } |
336 | 559 | |
560 | /* Unexpress and remove an attribute which is not the top one */ | |
561 | int attr_find_pop(int findattr) | |
562 | { | |
563 | int i; | |
564 | AttrStack *stack = stack_of_stacks_top; | |
565 | ||
566 | if (!stack) | |
567 | { | |
568 | warning_handler("no stack to pop attributes from"); | |
569 | return FALSE; | |
570 | } | |
571 | ||
572 | /* Check whether findattr is on stack at all; if not, just give up */ | |
573 | if ((i = attr_find(stack, findattr)) < 0) | |
574 | { | |
575 | return FALSE; | |
576 | } | |
577 | attr_pull_out(stack, i); | |
578 | return TRUE; | |
579 | } | |
337 | 580 | |
338 | 581 | /*======================================================================== |
339 | 582 | * Name: attr_get_param |
342 | 585 | * Returns: string. |
343 | 586 | *=======================================================================*/ |
344 | 587 | |
345 | char * | |
346 | attr_get_param(int attr) | |
588 | char * | |
589 | attr_get_param(int attr) | |
347 | 590 | { |
348 | 591 | int i; |
349 | 592 | AttrStack *stack = stack_of_stacks_top; |
350 | if (!stack) { | |
351 | if (attr != ATTR_ENCODING) { | |
593 | if (!stack) | |
594 | { | |
595 | if (attr != ATTR_ENCODING) | |
596 | { | |
352 | 597 | /* |
353 | 598 | * attr_get_param(ATTR_ENCODING) is always called |
354 | 599 | * called once without a stack being available. |
358 | 603 | return NULL; |
359 | 604 | } |
360 | 605 | |
361 | i=stack->tos; | |
362 | while (i>=0) | |
363 | { | |
364 | if(stack->attr_stack [i] == attr) | |
365 | { | |
366 | if(stack->attr_stack_params [i] != NULL) | |
367 | return stack->attr_stack_params [i]; | |
368 | else | |
369 | return NULL; | |
370 | } | |
371 | i--; | |
606 | if ((i = attr_find(stack, attr)) >= 0) { | |
607 | return stack->attr_stack_params[i]; | |
372 | 608 | } |
373 | 609 | return NULL; |
374 | 610 | } |
381 | 617 | * Returns: None. |
382 | 618 | *=======================================================================*/ |
383 | 619 | |
384 | void | |
385 | attrstack_copy_all (AttrStack *src, AttrStack *dest) | |
620 | void | |
621 | attrstack_copy_all(AttrStack *src, AttrStack *dest) | |
386 | 622 | { |
387 | 623 | int i; |
388 | int total; | |
389 | 624 | |
390 | 625 | CHECK_PARAM_NOT_NULL(src); |
391 | 626 | CHECK_PARAM_NOT_NULL(dest); |
392 | 627 | |
393 | total = src->tos + 1; | |
394 | ||
395 | for (i=0; i<total; i++) | |
396 | { | |
397 | int attr=src->attr_stack [i]; | |
398 | char *param=src->attr_stack_params [i]; | |
399 | ||
400 | dest->attr_stack[i] = attr; | |
628 | for (i = 0; i <= src->tos; i++) | |
629 | { | |
630 | dest->attr_stack[i] = src->attr_stack[i]; | |
631 | ||
632 | char *param = src->attr_stack_params[i]; | |
401 | 633 | if (param) |
402 | dest->attr_stack_params[i] = my_strdup (param); | |
634 | { | |
635 | dest->attr_stack_params[i] = my_strdup(param); | |
636 | } | |
403 | 637 | else |
638 | { | |
404 | 639 | dest->attr_stack_params[i] = NULL; |
640 | } | |
405 | 641 | } |
406 | 642 | |
407 | 643 | dest->tos = src->tos; |
414 | 650 | * Args: Stack whose contents should be unexpressed. |
415 | 651 | * Returns: None. |
416 | 652 | * Notes: This is needed by attrstack_push, but also for \cell, which |
417 | * often occurs within a brace group, yet HTML uses <td></td> | |
653 | * often occurs within a brace group, yet HTML uses <td></td> | |
418 | 654 | * which clear attribute info within that block. |
419 | 655 | *=======================================================================*/ |
420 | 656 | |
421 | void | |
422 | attrstack_unexpress_all (AttrStack *stack) | |
657 | void | |
658 | attrstack_unexpress_all(AttrStack *stack) | |
423 | 659 | { |
424 | 660 | int i; |
425 | 661 | |
426 | 662 | CHECK_PARAM_NOT_NULL(stack); |
427 | 663 | |
428 | i=stack->tos; | |
429 | while (i>=0) | |
430 | { | |
431 | int attr=stack->attr_stack [i]; | |
432 | char *param=stack->attr_stack_params [i]; | |
433 | ||
434 | attr_express_end (attr, param); | |
435 | i--; | |
664 | for (i = stack->tos; i >= 0; i--) | |
665 | { | |
666 | attr_express_end(stack->attr_stack[i], stack->attr_stack_params[i]); | |
436 | 667 | } |
437 | 668 | } |
438 | 669 | |
444 | 675 | * Args: None. |
445 | 676 | * Returns: None. |
446 | 677 | *=======================================================================*/ |
447 | void | |
448 | attrstack_push () | |
678 | void | |
679 | attrstack_push() | |
449 | 680 | { |
450 | 681 | AttrStack *new_stack; |
451 | 682 | |
452 | new_stack = (AttrStack*) my_malloc (sizeof (AttrStack)); | |
453 | memset ((void*) new_stack, 0, sizeof (AttrStack)); | |
454 | ||
455 | if (!stack_of_stacks) { | |
683 | new_stack = (AttrStack *) my_malloc(sizeof(AttrStack)); | |
684 | ||
685 | if (new_stack == NULL) | |
686 | { | |
687 | warning_handler("out of memory"); | |
688 | return; | |
689 | } | |
690 | ||
691 | memset((void *) new_stack, 0, sizeof(AttrStack)); | |
692 | ||
693 | if (!stack_of_stacks) | |
694 | { | |
456 | 695 | stack_of_stacks = new_stack; |
457 | } else { | |
458 | stack_of_stacks_top->next = new_stack; | |
459 | } | |
696 | new_stack->tos = -1; | |
697 | } | |
698 | else | |
699 | { | |
700 | /* Parent stack exists. Copy all attributes. This means that they | |
701 | will be unexpressed when we exit this group, which is why there | |
702 | is a call to re-express the parent context in attrstack_drop */ | |
703 | attrstack_copy_all(stack_of_stacks_top, new_stack); | |
704 | } | |
705 | ||
706 | /* stack_of_stacks_top is NULL if this is the first stack */ | |
707 | new_stack->prev = stack_of_stacks_top; | |
460 | 708 | stack_of_stacks_top = new_stack; |
461 | new_stack->tos = -1; | |
462 | } | |
463 | ||
464 | ||
465 | ||
466 | /*======================================================================== | |
467 | * Name: attr_pop | |
709 | } | |
710 | ||
711 | /*======================================================================== | |
712 | * Name: attr_pop | |
468 | 713 | * Purpose: Removes and undoes the effect of the top attribute of |
469 | 714 | * the current AttrStack. |
470 | 715 | * Args: The top attribute's number, for verification. |
471 | 716 | * Returns: Success/fail flag. |
472 | 717 | *=======================================================================*/ |
473 | 718 | |
474 | int | |
475 | attr_pop (int attr) | |
719 | int | |
720 | attr_pop(int attr) | |
476 | 721 | { |
477 | 722 | AttrStack *stack = stack_of_stacks_top; |
478 | 723 | |
479 | if (!stack) { | |
480 | warning_handler ("no stack to pop attribute from"); | |
724 | if (!stack) | |
725 | { | |
726 | warning_handler("no stack to pop attribute from"); | |
481 | 727 | return FALSE; |
482 | 728 | } |
483 | 729 | |
484 | if(stack->tos>=0 && stack->attr_stack[stack->tos]==attr) | |
485 | { | |
486 | char *param = stack->attr_stack_params [stack->tos]; | |
487 | ||
488 | attr_express_end (attr, param); | |
489 | ||
490 | if (param) my_free(param); | |
491 | ||
492 | stack->tos--; | |
493 | ||
730 | if (stack->tos >= 0 && stack->attr_stack[stack->tos] == attr) | |
731 | { | |
732 | attr_pop_internal(stack, attr); | |
494 | 733 | return TRUE; |
495 | 734 | } |
496 | 735 | else |
736 | { | |
497 | 737 | return FALSE; |
738 | } | |
498 | 739 | } |
499 | 740 | |
500 | 741 | |
507 | 748 | * Returns: Attribute number. |
508 | 749 | *=======================================================================*/ |
509 | 750 | |
510 | int | |
511 | attr_read() { | |
751 | int | |
752 | attr_read() | |
753 | { | |
512 | 754 | AttrStack *stack = stack_of_stacks_top; |
513 | if (!stack) { | |
514 | warning_handler ("no stack to read attribute from"); | |
755 | if (!stack) | |
756 | { | |
757 | warning_handler("no stack to read attribute from"); | |
515 | 758 | return FALSE; |
516 | 759 | } |
517 | 760 | |
518 | if(stack->tos>=0) | |
761 | if (stack->tos >= 0) | |
519 | 762 | { |
520 | 763 | int attr = stack->attr_stack [stack->tos]; |
521 | 764 | return attr; |
522 | 765 | } |
523 | 766 | else |
767 | { | |
524 | 768 | return ATTR_NONE; |
525 | } | |
526 | ||
527 | ||
528 | /*======================================================================== | |
529 | * Name: attr_drop_all | |
530 | * Purpose: Undoes all attributes that an AttrStack contains. | |
769 | } | |
770 | } | |
771 | ||
772 | ||
773 | /*======================================================================== | |
774 | * Name: attr_drop_all | |
775 | * Purpose: Empty top attr stack without unexpressing attributes. | |
531 | 776 | * Args: None. |
532 | 777 | * Returns: None. |
533 | 778 | *=======================================================================*/ |
534 | 779 | |
535 | void | |
536 | attr_drop_all () | |
780 | void | |
781 | attr_drop_all() | |
537 | 782 | { |
538 | 783 | AttrStack *stack = stack_of_stacks_top; |
539 | if (!stack) { | |
540 | warning_handler ("no stack to drop all attributes from"); | |
784 | if (!stack) | |
785 | { | |
786 | warning_handler("no stack to drop all attributes from"); | |
541 | 787 | return; |
542 | 788 | } |
543 | 789 | |
544 | while (stack->tos>=0) | |
545 | { | |
546 | char *param=stack->attr_stack_params [stack->tos]; | |
547 | if (param) my_free(param); | |
790 | while (stack->tos >= 0) | |
791 | { | |
792 | char *param = stack->attr_stack_params [stack->tos]; | |
793 | if (param) | |
794 | { | |
795 | my_free(param); | |
796 | } | |
548 | 797 | stack->tos--; |
549 | 798 | } |
550 | 799 | } |
558 | 807 | * Returns: None. |
559 | 808 | *=======================================================================*/ |
560 | 809 | |
561 | void | |
562 | attrstack_drop () | |
810 | void | |
811 | attrstack_drop() | |
563 | 812 | { |
564 | 813 | AttrStack *stack = stack_of_stacks_top; |
565 | AttrStack *prev_stack; | |
566 | if (!stack) { | |
567 | warning_handler ("no attr-stack to drop"); | |
814 | if (!stack) | |
815 | { | |
816 | warning_handler("no attr-stack to drop"); | |
568 | 817 | return; |
569 | 818 | } |
570 | 819 | |
571 | attr_pop_all (); | |
572 | prev_stack = stack_of_stacks; | |
573 | ||
574 | while(prev_stack && prev_stack->next && prev_stack->next != stack) | |
575 | prev_stack = prev_stack->next; | |
576 | ||
577 | /* prev_stack == stack_of_stacks_top if there was only one | |
578 | element. We'll be empty. Note that prev_stack can't be | |
579 | actually NULL here, this would happen with an empty stack, | |
580 | which would have been detected by the !stack test above. | |
581 | */ | |
582 | if (prev_stack && (prev_stack != stack_of_stacks_top)) { | |
583 | stack_of_stacks_top = prev_stack; | |
584 | prev_stack->next = NULL; | |
585 | } else { | |
586 | stack_of_stacks_top = NULL; | |
820 | attr_pop_all(); | |
821 | ||
822 | if (stack->prev == NULL) | |
823 | { | |
587 | 824 | stack_of_stacks = NULL; |
588 | 825 | } |
589 | ||
590 | my_free ((void*) stack); | |
826 | stack_of_stacks_top = stack->prev; | |
827 | ||
828 | my_free((void *) stack); | |
829 | ||
830 | /* Re-set attributes for parent state */ | |
831 | if (stack_of_stacks_top) | |
832 | { | |
833 | attrstack_express_all(/*stack_of_stacks_top*/); | |
834 | } | |
591 | 835 | } |
592 | 836 | |
593 | 837 | /*======================================================================== |
594 | 838 | * Name: attr_pop_all |
595 | * Purpose: Routine to undo all attributes heretofore applied, | |
839 | * Purpose: Routine to undo all attributes heretofore applied, | |
596 | 840 | * also reversing the order in which they were applied. |
597 | 841 | * Args: None. |
598 | 842 | * Returns: None. |
599 | 843 | *=======================================================================*/ |
600 | 844 | |
601 | void | |
602 | attr_pop_all() | |
845 | void | |
846 | attr_pop_all() | |
603 | 847 | { |
604 | 848 | AttrStack *stack = stack_of_stacks_top; |
605 | if (!stack) { | |
606 | warning_handler ("no stack to pop from"); | |
849 | if (!stack) | |
850 | { | |
851 | warning_handler("no stack to pop from"); | |
607 | 852 | return; |
608 | 853 | } |
609 | 854 | |
610 | while (stack->tos>=0) { | |
611 | int attr=stack->attr_stack [stack->tos]; | |
612 | char *param=stack->attr_stack_params [stack->tos]; | |
613 | attr_express_end (attr,param); | |
614 | if (param) my_free(param); | |
615 | stack->tos--; | |
616 | } | |
617 | } | |
618 | ||
855 | while (stack->tos >= 0) | |
856 | { | |
857 | attr_pop_internal(stack, stack->attr_stack[stack->tos]); | |
858 | } | |
859 | } | |
619 | 860 | |
620 | 861 | /*======================================================================== |
621 | 862 | * Name: attrstack_express_all |
623 | 864 | * Args: None. |
624 | 865 | * Returns: None. |
625 | 866 | * Notes: This is needed by attrstack_push, but also for \cell, which |
626 | * often occurs within a brace group, yet HTML uses <td></td> | |
867 | * often occurs within a brace group, yet HTML uses <td></td> | |
627 | 868 | * which clear attribute info within that block. |
628 | 869 | *=======================================================================*/ |
629 | 870 | |
630 | void | |
631 | attrstack_express_all() { | |
871 | void | |
872 | attrstack_express_all() | |
873 | { | |
632 | 874 | AttrStack *stack = stack_of_stacks_top; |
633 | 875 | int i; |
634 | 876 | |
635 | if (!stack) { | |
636 | warning_handler ("no stack to pop from"); | |
877 | if (!stack) | |
878 | { | |
879 | warning_handler("no stack to pop from"); | |
637 | 880 | return; |
638 | 881 | } |
639 | 882 | |
640 | i=0; | |
641 | while (i<=stack->tos) | |
642 | { | |
643 | int attr=stack->attr_stack [i]; | |
644 | char *param=stack->attr_stack_params [i]; | |
645 | attr_express_begin (attr, param); | |
646 | i++; | |
647 | } | |
648 | } | |
649 | ||
650 | ||
651 | /*======================================================================== | |
652 | * Name: attr_pop_dump | |
653 | * Purpose: Routine to un-express all attributes heretofore applied. | |
654 | * Args: None. | |
655 | * Returns: None. | |
656 | * Notes: This is needed for \cell, which often occurs within a | |
657 | * brace group, yet HTML uses <td></td> which clear attribute | |
658 | * info within that block. | |
659 | *=======================================================================*/ | |
660 | ||
661 | void | |
662 | attr_pop_dump() { | |
663 | AttrStack *stack = stack_of_stacks_top; | |
664 | int i; | |
665 | ||
666 | if (!stack) return; | |
667 | ||
668 | i=stack->tos; | |
669 | while (i>=0) | |
670 | { | |
671 | int attr=stack->attr_stack [i]; | |
672 | attr_pop (attr); | |
673 | i--; | |
883 | for (i = 0; i <= stack->tos; i++) | |
884 | { | |
885 | attr_express_begin(stack->attr_stack[i], stack->attr_stack_params[i]); | |
674 | 886 | } |
675 | 887 | } |
676 | 888 | |
701 | 913 | |
702 | 914 | for (; nr > 0; nr--) |
703 | 915 | { |
704 | while (string[i] != '\0' && (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i-1] == '\\')))) | |
916 | while (string[i] != '\0' && (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i - 1] == '\\')))) | |
705 | 917 | { |
706 | if (string[i] != '\\' || string[i+1] != '%') | |
918 | if (string[i] != '\\' || string[i + 1] != '%') | |
919 | { | |
707 | 920 | printf("%c", string[i]); |
921 | } | |
708 | 922 | i++; |
709 | 923 | } |
710 | 924 | |
719 | 933 | |
720 | 934 | while (string[i] != '\0') |
721 | 935 | { |
722 | if (string[i] != '\\' || (string[i] == '\\' && string[i+1] != '%')) | |
936 | if (string[i] != '\\' || (string[i] == '\\' && string[i + 1] != '%')) | |
723 | 937 | { |
724 | if (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i-1] == '\\'))) | |
938 | if (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i - 1] == '\\'))) | |
939 | { | |
725 | 940 | printf("%c", string[i]); |
941 | } | |
726 | 942 | else |
943 | { | |
727 | 944 | ret_code = -1; |
945 | } | |
728 | 946 | } |
729 | 947 | i++; |
730 | 948 | } |
745 | 963 | assemble_string(char *string, int nr) |
746 | 964 | { |
747 | 965 | |
748 | char *s, tmp[12];/* Number of characters that can be in int type (including '\0') - AF */ | |
966 | char *s, tmp[20]; | |
749 | 967 | int i = 0, j = 0; |
750 | 968 | |
751 | 969 | if (string == NULL) |
970 | { | |
752 | 971 | return NULL; |
753 | else { | |
972 | } | |
973 | else | |
974 | { | |
754 | 975 | s = my_malloc(strlen(string) + 1 + 12/* Number of characters that can be in int type (including '\0') - AF */); |
755 | while(string[i] != '\0' && (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i-1] == '\\')))) { | |
756 | if (string[i] != '\\' || string[i+1] != '%') { | |
757 | s[j] = string[i]; | |
976 | while (string[i] != '\0' && (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i - 1] == '\\')))) | |
977 | { | |
978 | if (string[i] != '\\' || string[i + 1] != '%') | |
979 | { | |
980 | s[j] = string[i]; | |
758 | 981 | j++; |
759 | 982 | } |
760 | 983 | i++; |
761 | 984 | } |
762 | 985 | |
763 | if (string[i] != '\0') { | |
764 | sprintf(tmp, "%d", nr); | |
986 | if (string[i] != '\0') | |
987 | { | |
988 | snprintf(tmp, 20, "%d", nr); | |
765 | 989 | strcpy(&s[j], tmp); |
766 | 990 | j = j + strlen(tmp); |
767 | 991 | } |
768 | 992 | |
769 | while (string[i] != '\0') { | |
770 | if (string[i] != '\\' || (string[i] == '\\' && string[i+1] != '%')) { | |
771 | if (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i-1] == '\\'))) { | |
772 | s[j] = string[i]; | |
993 | while (string[i] != '\0') | |
994 | { | |
995 | if (string[i] != '\\' || (string[i] == '\\' && string[i + 1] != '%')) | |
996 | { | |
997 | if (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i - 1] == '\\'))) | |
998 | { | |
999 | s[j] = string[i]; | |
773 | 1000 | j++; |
774 | 1001 | } |
775 | else { | |
776 | /* More than one char % occured */ | |
1002 | else | |
1003 | { | |
1004 | /* More than one char % occured */ | |
777 | 1005 | } |
778 | 1006 | } |
779 | 1007 | i++; |
807 | 1035 | } |
808 | 1036 | else |
809 | 1037 | { |
810 | do { | |
1038 | do | |
1039 | { | |
811 | 1040 | if (c->nr == nr) |
812 | 1041 | { |
813 | /* Here is a memory leak but not heavy. Do we need to care about this? | |
814 | my_free(a->alias.text); | |
815 | */ | |
1042 | /* Here is a memory leak but not heavy. Do we need to care about this? | |
1043 | my_free(a->alias.text); | |
1044 | */ | |
816 | 1045 | c->text = text; |
817 | 1046 | |
818 | 1047 | return col; |
819 | 1048 | } |
820 | 1049 | |
821 | if (c->next == NULL) | |
822 | break; | |
1050 | if (c->next == NULL) | |
1051 | { | |
1052 | break; | |
1053 | } | |
823 | 1054 | c = c->next; |
824 | } while (1); | |
1055 | } | |
1056 | while (1); | |
825 | 1057 | |
826 | 1058 | c->next = (Collection *)my_malloc(sizeof(Collection)); |
827 | 1059 | c->next->nr = nr; |
845 | 1077 | while (c != NULL) |
846 | 1078 | { |
847 | 1079 | if (c->nr == nr) |
1080 | { | |
848 | 1081 | return c->text; |
1082 | } | |
849 | 1083 | |
850 | 1084 | c = c->next; |
851 | 1085 | } |
857 | 1091 | * Name: free_collection |
858 | 1092 | * Purpose: Release memory used by collection. |
859 | 1093 | * Args: Needless collection. |
860 | * Returns: | |
1094 | * Returns: | |
861 | 1095 | *=======================================================================*/ |
862 | 1096 | |
863 | 1097 | void |
872 | 1106 | c = c2; |
873 | 1107 | } |
874 | 1108 | } |
875 | ||
876 | #define SUPPORT_UNNESTED | |
877 | #ifdef SUPPORT_UNNESTED | |
878 | ||
879 | // Push onto AttrStack generally, without extra bells and whistles | |
880 | void attr_push_gen(AttrStack *stack, int attr, char *param) { | |
881 | stack->tos++; | |
882 | stack->attr_stack[stack->tos] = attr; | |
883 | if (param) | |
884 | stack->attr_stack_params[stack->tos] = param; | |
885 | else | |
886 | stack->attr_stack_params[stack->tos] = NULL; | |
887 | } | |
888 | ||
889 | // Pop from AttrStack generally, without extra bells and whistles | |
890 | void attr_pop_gen(AttrStack *stack, int *attr, char **param) { | |
891 | *attr = stack->attr_stack[stack->tos]; | |
892 | *param = stack->attr_stack_params[stack->tos]; | |
893 | stack->tos--; | |
894 | } | |
895 | ||
896 | // Iterate through stack looking for findattr | |
897 | int attr_find(AttrStack *stack, int findattr) { | |
898 | int i; | |
899 | for (i = 0; i <= stack->tos; ++i) | |
900 | if (stack->attr_stack[i] == findattr) return i; | |
901 | return -1; | |
902 | } | |
903 | ||
904 | // Pop attrs until we find the match, then push the non-matches back | |
905 | static AttrStack temp_stack; | |
906 | int attr_find_pop(int findattr) { | |
907 | temp_stack.tos = -1; // initialize temp_stack if necessary | |
908 | ||
909 | AttrStack *stack = stack_of_stacks_top; | |
910 | if (!stack) { | |
911 | warning_handler ("no stack to pop attributes from"); | |
912 | return FALSE; | |
913 | } | |
914 | ||
915 | // Check whether findattr is on stack at all; if not, just give up | |
916 | if (attr_find(stack, findattr) < 0) return FALSE; | |
917 | ||
918 | // Get findattr from stack, expressing endings. | |
919 | // Store any non-matches to temp_stack. | |
920 | int attr = ATTR_NONE; | |
921 | char *param = NULL; | |
922 | while (stack->tos >= 0) { | |
923 | attr_pop_gen(stack, &attr, ¶m); | |
924 | attr_express_end(attr, param); | |
925 | if (attr == findattr) break; | |
926 | attr_push_gen(&temp_stack, attr, param); | |
927 | } | |
928 | ||
929 | // Put the non-matches back, reexpressing beginnings | |
930 | while (temp_stack.tos >= 0) { | |
931 | attr_pop_gen(&temp_stack, &attr, ¶m); | |
932 | attr_push(attr, param); | |
933 | } | |
934 | ||
935 | return TRUE; | |
936 | } | |
937 | #endif /* SUPPORT_UNNESTED */ |
38 | 38 | * 07 Oct 11, jf@dockes.org: removed unused protocols, added _ATTR_H_INCLUDED_ |
39 | 39 | *--------------------------------------------------------------------*/ |
40 | 40 | |
41 | enum { | |
42 | ATTR_NONE=0, | |
41 | enum | |
42 | { | |
43 | ATTR_NONE = 0, | |
43 | 44 | ATTR_BOLD, ATTR_ITALIC, |
44 | 45 | |
45 | ATTR_UNDERLINE, ATTR_DOUBLE_UL, ATTR_WORD_UL, | |
46 | ATTR_UNDERLINE, ATTR_DOUBLE_UL, ATTR_WORD_UL, | |
46 | 47 | |
47 | ATTR_THICK_UL, ATTR_WAVE_UL, | |
48 | ATTR_THICK_UL, ATTR_WAVE_UL, | |
48 | 49 | |
49 | 50 | ATTR_DOT_UL, ATTR_DASH_UL, ATTR_DOT_DASH_UL, ATTR_2DOT_DASH_UL, |
50 | 51 | |
55 | 56 | ATTR_SMALLCAPS, |
56 | 57 | |
57 | 58 | ATTR_SHADOW, |
58 | ATTR_OUTLINE, | |
59 | ATTR_EMBOSS, | |
60 | ATTR_ENGRAVE, | |
59 | ATTR_OUTLINE, | |
60 | ATTR_EMBOSS, | |
61 | ATTR_ENGRAVE, | |
61 | 62 | |
62 | ATTR_SUPER, ATTR_SUB, | |
63 | ATTR_STRIKE, | |
64 | ATTR_DBL_STRIKE, | |
63 | ATTR_SUPER, ATTR_SUB, | |
64 | ATTR_STRIKE, | |
65 | ATTR_DBL_STRIKE, | |
65 | 66 | |
66 | 67 | ATTR_EXPAND, |
67 | ATTR_ENCODING, | |
68 | ATTR_ENCODING, | |
68 | 69 | /* ATTR_CONDENSE */ |
69 | 70 | }; |
70 | 71 | |
79 | 80 | const char *get_from_collection(Collection *c, int nr); |
80 | 81 | void free_collection(Collection *c); |
81 | 82 | |
82 | extern void attr_push(int attr, char* param); | |
83 | extern void attr_push(int attr, char *param); | |
83 | 84 | |
84 | 85 | extern void attrstack_push(); |
85 | 86 | extern void attrstack_drop(); |
90 | 91 | |
91 | 92 | extern int attr_read(); |
92 | 93 | |
93 | extern void attr_drop_all (); | |
94 | extern void attr_drop_all(); | |
94 | 95 | |
95 | 96 | extern void attr_pop_all(); |
96 | 97 | |
97 | 98 | extern void attr_pop_dump(); |
98 | 99 | |
99 | char * attr_get_param(int attr); | |
100 | char *attr_get_param(int attr); | |
100 | 101 | |
101 | 102 | int safe_printf(int nr, char *string, ...); |
102 | 103 | char *assemble_string(char *string, int nr); |
47 | 47 | * 08 Sep 01, tuorfa@yahoo.com: added use of UnRTF |
48 | 48 | * 11 Sep 01, tuorfa@yahoo.com: added support for JPEG and PNG pictures |
49 | 49 | * 19 Sep 01, tuorfa@yahoo.com: added output personality support |
50 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
50 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
51 | 51 | * 23 Sep 01, tuorfa@yahoo.com: fixed translation of \'XX expressions |
52 | 52 | * 08 Oct 03, daved@physiol.usyd.edu.au: more special character code |
53 | 53 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
102 | 102 | |
103 | 103 | #ifdef HAVE_STRING_H |
104 | 104 | /* For strcasestr() */ |
105 | #define __USE_GNU | |
105 | #define __USE_GNU | |
106 | 106 | #include <string.h> |
107 | 107 | #endif |
108 | 108 | |
119 | 119 | #include "convert.h" |
120 | 120 | #include "attr.h" |
121 | 121 | |
122 | typedef struct { | |
122 | typedef struct | |
123 | { | |
123 | 124 | char *name; |
124 | int (*func)(Word*, int, char, int); | |
125 | int (*func)(Word *, int, char, int); | |
125 | 126 | char *debug_print; |
126 | 127 | } HashItem; |
127 | 128 | static HashItem *find_command(const char *cmdpp, int *hasparamp, int *paramp); |
128 | 129 | |
129 | 130 | extern int nopict_mode; |
131 | extern int quiet; | |
130 | 132 | |
131 | 133 | /* |
132 | 134 | #define BINARY_ATTRS |
138 | 140 | */ |
139 | 141 | static int coming_pars_that_are_tabular = 0; |
140 | 142 | static int within_table = FALSE; |
141 | static int have_printed_row_begin=FALSE; | |
142 | static int have_printed_cell_begin=FALSE; | |
143 | static int have_printed_row_end=FALSE; | |
144 | static int have_printed_cell_end=FALSE; | |
143 | static int have_printed_row_begin = FALSE; | |
144 | static int have_printed_cell_begin = FALSE; | |
145 | static int have_printed_row_end = FALSE; | |
146 | static int have_printed_cell_end = FALSE; | |
145 | 147 | static void check_for_table(); |
146 | 148 | |
147 | 149 | |
148 | /* Previously in word_print_core function | |
150 | /* Previously in word_print_core function | |
149 | 151 | */ |
150 | static int total_chars_this_line=0; /* for simulating \tab */ | |
152 | static int total_chars_this_line = 0; /* for simulating \tab */ | |
151 | 153 | |
152 | 154 | |
153 | 155 | /* Paragraph alignment (kludge) |
154 | 156 | */ |
155 | enum { | |
156 | ALIGN_LEFT=0, | |
157 | enum | |
158 | { | |
159 | ALIGN_LEFT = 0, | |
157 | 160 | ALIGN_RIGHT, |
158 | 161 | ALIGN_CENTER, |
159 | 162 | ALIGN_JUSTIFY |
161 | 164 | |
162 | 165 | |
163 | 166 | |
164 | /* This value is set by attr_push and attr_pop | |
167 | /* This value is set by attr_push and attr_pop | |
165 | 168 | */ |
166 | 169 | int simulate_smallcaps; |
167 | 170 | int simulate_allcaps; |
168 | 171 | |
169 | 172 | |
170 | 173 | /* Most pictures must be written to files. */ |
171 | enum { | |
172 | PICT_UNKNOWN=0, | |
174 | enum | |
175 | { | |
176 | PICT_UNKNOWN = 0, | |
173 | 177 | PICT_WM, |
174 | 178 | PICT_MAC, |
175 | 179 | PICT_PM, |
179 | 183 | PICT_PNG, |
180 | 184 | PICT_EMF, |
181 | 185 | }; |
182 | static int within_picture=FALSE; | |
186 | static int within_picture = FALSE; | |
183 | 187 | static int within_picture_depth; |
184 | static int picture_file_number=1; | |
188 | static int picture_file_number = 1; | |
185 | 189 | static char picture_path[255]; |
186 | 190 | static int picture_width; |
187 | 191 | static int picture_height; |
188 | static int picture_bits_per_pixel=1; | |
189 | static int picture_type=PICT_UNKNOWN; | |
192 | static int picture_bits_per_pixel = 1; | |
193 | static int picture_type = PICT_UNKNOWN; | |
190 | 194 | static int picture_wmetafile_type; |
191 | 195 | static char *picture_wmetafile_type_str; |
192 | 196 | |
193 | static int EndNoteCitations=FALSE; | |
194 | ||
195 | static int have_printed_body=FALSE; | |
196 | static int within_header=TRUE; | |
197 | static int EndNoteCitations = FALSE; | |
198 | ||
199 | static int have_printed_body = FALSE; | |
200 | static int within_header = TRUE; | |
197 | 201 | |
198 | 202 | |
199 | 203 | static const char *hyperlink_base = NULL; |
201 | 205 | |
202 | 206 | void starting_body(); |
203 | 207 | void starting_text(); |
204 | void print_with_special_exprs (const char *s); | |
205 | ||
206 | static int banner_printed=FALSE; | |
208 | void print_with_special_exprs(const char *s); | |
209 | ||
210 | static int banner_printed = FALSE; | |
207 | 211 | |
208 | 212 | |
209 | 213 | /*======================================================================== |
214 | 218 | *=======================================================================*/ |
215 | 219 | |
216 | 220 | void |
217 | print_banner () { | |
218 | if (!banner_printed) { | |
219 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
220 | printf(" Translation from RTF performed by "); | |
221 | print_banner() | |
222 | { | |
223 | if (!banner_printed) | |
224 | { | |
225 | if (safe_printf(0, op->comment_begin)) | |
226 | { | |
227 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
228 | } | |
229 | printf(" Translation from RTF performed by "); | |
221 | 230 | printf("UnRTF, version "); |
222 | 231 | printf("%s ", PACKAGE_VERSION); |
223 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
224 | } | |
225 | banner_printed=TRUE; | |
232 | if (safe_printf(0, op->comment_end)) | |
233 | { | |
234 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
235 | } | |
236 | } | |
237 | banner_printed = TRUE; | |
226 | 238 | } |
227 | 239 | |
228 | 240 | |
234 | 246 | *=======================================================================*/ |
235 | 247 | |
236 | 248 | void |
237 | starting_body () | |
238 | { | |
239 | if (!have_printed_body) { | |
240 | if (!inline_mode) { | |
241 | if (safe_printf(0, op->header_end)) fprintf(stderr, TOO_MANY_ARGS, "header_end"); | |
242 | if (safe_printf(0, op->body_begin)) fprintf(stderr, TOO_MANY_ARGS, "body_begin"); | |
249 | starting_body() | |
250 | { | |
251 | if (!have_printed_body) | |
252 | { | |
253 | if (!inline_mode) | |
254 | { | |
255 | if (safe_printf(0, op->header_end)) | |
256 | { | |
257 | fprintf(stderr, TOO_MANY_ARGS, "header_end"); | |
258 | } | |
259 | if (safe_printf(0, op->body_begin)) | |
260 | { | |
261 | fprintf(stderr, TOO_MANY_ARGS, "body_begin"); | |
262 | } | |
243 | 263 | } |
244 | 264 | within_header = FALSE; |
245 | 265 | have_printed_body = TRUE; |
252 | 272 | /*-------------------------------------------------------------------*/ |
253 | 273 | |
254 | 274 | |
255 | static char *month_strings[12]= { | |
275 | static char *month_strings[12] = | |
276 | { | |
256 | 277 | #ifdef ENGLISH |
257 | "January","February","March","April","May","June","July","August", | |
258 | "September","October","November","December" | |
278 | "January", "February", "March", "April", "May", "June", "July", "August", | |
279 | "September", "October", "November", "December" | |
259 | 280 | #endif |
260 | 281 | #ifdef FRANCAIS |
261 | "Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre", | |
262 | "Octobre","Novembre","Decembre" | |
282 | "Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", | |
283 | "Octobre", "Novembre", "Decembre" | |
263 | 284 | #endif |
264 | 285 | #ifdef ITALIANO |
265 | "Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno", | |
266 | "Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre" | |
286 | "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", | |
287 | "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" | |
267 | 288 | #endif |
268 | 289 | #ifdef ESPANOL /* amaral - 0.19.2 */ |
269 | "Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto", | |
270 | "Septiembre","Octubre","Noviembre","Diciembre" | |
290 | "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", | |
291 | "Septiembre", "Octubre", "Noviembre", "Diciembre" | |
271 | 292 | #endif |
272 | 293 | #ifdef DEUTSCH /* daved - 0.21.6 */ |
273 | "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", | |
274 | "September", "Oktober", "November", "Dezember" | |
294 | "Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", | |
295 | "September", "Oktober", "November", "Dezember" | |
275 | 296 | #endif |
276 | 297 | #ifdef PORTUGUES /* amaral - 0.19.2 */ |
277 | "Janeiro","Fevereiro","Marco","Abril","Maio","Junho","Julho","Agosto", | |
278 | "Setembro","Outubro","Novembro","Dezembro" | |
298 | "Janeiro", "Fevereiro", "Marco", "Abril", "Maio", "Junho", "Julho", "Agosto", | |
299 | "Setembro", "Outubro", "Novembro", "Dezembro" | |
279 | 300 | #endif |
280 | 301 | }; |
281 | 302 | |
288 | 309 | * Returns: None. |
289 | 310 | *=======================================================================*/ |
290 | 311 | |
291 | void | |
292 | word_dump_date (Word *w) | |
293 | { | |
294 | int year=0, month=0, day=0, hour=0, minute=0; | |
312 | void | |
313 | word_dump_date(Word *w) | |
314 | { | |
315 | int year = 0, month = 0, day = 0, hour = 0, minute = 0; | |
295 | 316 | CHECK_PARAM_NOT_NULL(w); |
296 | 317 | |
297 | 318 | while (w) |
298 | 319 | { |
299 | const char *s = word_string (w); | |
320 | const char *s = word_string(w); | |
300 | 321 | if (!s) |
322 | { | |
301 | 323 | return; |
302 | if (*s == '\\') { | |
324 | } | |
325 | if (*s == '\\') | |
326 | { | |
303 | 327 | ++s; |
304 | if (!strncmp (s, "yr", 2) && isdigit(s[2])) { | |
305 | year = atoi (&s[2]); | |
328 | if (!strncmp(s, "yr", 2) && isdigit(s[2])) | |
329 | { | |
330 | year = atoi(&s[2]); | |
306 | 331 | } |
307 | else if (!strncmp (s, "mo", 2) && isdigit(s[2])) | |
332 | else if (!strncmp(s, "mo", 2) && isdigit(s[2])) | |
308 | 333 | { |
309 | month= atoi (&s[2]); | |
310 | if(month > 12) | |
334 | month = atoi(&s[2]); | |
335 | if (month > 12) | |
311 | 336 | { |
312 | 337 | warning_handler("bogus month"); |
313 | 338 | return; |
314 | 339 | } |
315 | 340 | } |
316 | else if (!strncmp (s, "dy", 2) && isdigit(s[2])) { | |
317 | day= atoi (&s[2]); | |
341 | else if (!strncmp(s, "dy", 2) && isdigit(s[2])) | |
342 | { | |
343 | day = atoi(&s[2]); | |
318 | 344 | } |
319 | else if (!strncmp (s, "min", 3) && isdigit(s[3])) { | |
320 | minute= atoi (&s[3]); | |
345 | else if (!strncmp(s, "min", 3) && isdigit(s[3])) | |
346 | { | |
347 | minute = atoi(&s[3]); | |
321 | 348 | } |
322 | else if (!strncmp (s, "hr", 2) && isdigit(s[2])) { | |
323 | hour= atoi (&s[2]); | |
349 | else if (!strncmp(s, "hr", 2) && isdigit(s[2])) | |
350 | { | |
351 | hour = atoi(&s[2]); | |
324 | 352 | } |
325 | 353 | } |
326 | w=w->next; | |
327 | } | |
328 | if (year && month > 0 && month <= 12 && day) { | |
329 | printf("%d %s %d ", day, month_strings[month-1], year); | |
330 | } | |
331 | if (hour && minute) { | |
354 | w = w->next; | |
355 | } | |
356 | if (year && month > 0 && month <= 12 && day) | |
357 | { | |
358 | printf("%d %s %d ", day, month_strings[month - 1], year); | |
359 | } | |
360 | if (hour && minute) | |
361 | { | |
332 | 362 | printf("%02d:%02d ", hour, minute); |
333 | 363 | } |
334 | 364 | } |
337 | 367 | |
338 | 368 | /*-------------------------------------------------------------------*/ |
339 | 369 | |
340 | typedef struct { | |
370 | typedef struct | |
371 | { | |
341 | 372 | int num; |
342 | 373 | char *name; |
343 | char *encoding; | |
374 | char *encoding; | |
344 | 375 | } FontEntry; |
345 | 376 | |
346 | 377 | static char *default_encoding = "CP1252"; |
347 | 378 | /* current_encoding not NULL to be safe. "" is detected to avoid |
348 | 379 | free() on 1st call */ |
349 | static char *current_encoding = ""; | |
380 | static char *current_encoding = ""; | |
350 | 381 | /* Encoding expected by op_translate_buffer. Until we find a way to specify |
351 | 382 | transparent UTF-8 passthrough */ |
352 | 383 | static char *output_encoding = "UTF-32BE"; |
354 | 385 | static int had_ansicpg; |
355 | 386 | #define MAX_FONTS (8192) |
356 | 387 | static FontEntry font_table[MAX_FONTS]; |
357 | static int total_fonts=0; | |
388 | static int total_fonts = 0; | |
358 | 389 | |
359 | 390 | static void flush_iconv_input(); |
360 | 391 | static void accumulate_iconv_input(int ch); |
361 | 392 | |
362 | static void | |
393 | static void | |
363 | 394 | set_current_encoding(char *encoding) |
364 | 395 | { |
365 | if (current_encoding && *current_encoding) | |
366 | my_free(current_encoding); | |
367 | current_encoding = my_strdup(encoding); | |
368 | } | |
369 | ||
370 | static void | |
396 | if (current_encoding && *current_encoding) | |
397 | { | |
398 | my_free(current_encoding); | |
399 | } | |
400 | current_encoding = my_strdup(encoding); | |
401 | } | |
402 | ||
403 | static void | |
371 | 404 | maybeopeniconv() |
372 | 405 | { |
373 | if (!my_iconv_is_valid(desc)) { | |
374 | /* This may happen if output begins without a font command */ | |
375 | char *encoding = attr_get_param(ATTR_ENCODING); | |
376 | if (!encoding || !*encoding) | |
377 | encoding = default_encoding; | |
378 | desc = my_iconv_open(output_encoding, encoding); | |
379 | set_current_encoding(encoding); | |
380 | } | |
406 | if (!my_iconv_is_valid(desc)) | |
407 | { | |
408 | /* This may happen if output begins without a font command */ | |
409 | char *encoding = attr_get_param(ATTR_ENCODING); | |
410 | if (!encoding || !*encoding) | |
411 | { | |
412 | encoding = default_encoding; | |
413 | } | |
414 | desc = my_iconv_open(output_encoding, encoding); | |
415 | set_current_encoding(encoding); | |
416 | } | |
381 | 417 | } |
382 | 418 | |
383 | 419 | |
388 | 424 | * Returns: Font name. |
389 | 425 | *=======================================================================*/ |
390 | 426 | FontEntry * |
391 | lookup_font (int num) | |
392 | { | |
393 | int i; | |
394 | if (total_fonts) | |
395 | for(i=0;i<total_fonts;i++) { | |
396 | if (font_table[i].num==num) | |
397 | return &font_table[i]; | |
398 | } | |
399 | return NULL; | |
400 | } | |
401 | char* | |
402 | lookup_fontname (int num) { | |
403 | FontEntry *e = lookup_font(num); | |
404 | if (e == NULL) | |
405 | return NULL; | |
406 | return e->name; | |
427 | lookup_font(int num) | |
428 | { | |
429 | int i; | |
430 | if (total_fonts) | |
431 | for (i = 0; i < total_fonts; i++) | |
432 | { | |
433 | if (font_table[i].num == num) | |
434 | { | |
435 | return &font_table[i]; | |
436 | } | |
437 | } | |
438 | return NULL; | |
439 | } | |
440 | char * | |
441 | lookup_fontname(int num) | |
442 | { | |
443 | FontEntry *e = lookup_font(num); | |
444 | if (e == NULL) | |
445 | { | |
446 | return NULL; | |
447 | } | |
448 | return e->name; | |
407 | 449 | } |
408 | 450 | |
409 | 451 | // Extract name and parameter from command. RTF spec says name is max |
412 | 454 | // Returns 0 for error, 1 if ok no parm, 0 else |
413 | 455 | static int controlToNameParm(const char *s, char *name, int maxlen, int *parm) |
414 | 456 | { |
415 | const char *cp = s; | |
416 | int len = 0; | |
417 | ||
418 | if (s == 0) | |
419 | return 0; | |
420 | while (isalpha(*cp) && len < maxlen) { | |
421 | *name++ = *cp++; | |
422 | len++; | |
423 | } | |
424 | if (len == maxlen) | |
425 | return 0; | |
426 | *name = 0; | |
427 | if (!*cp) | |
428 | return 1; | |
429 | if (!(*cp == '-') && !isdigit(*cp)) | |
430 | return 0; | |
431 | *parm=atoi(cp); | |
432 | return 2; | |
457 | const char *cp = s; | |
458 | int len = 0; | |
459 | ||
460 | if (s == 0) | |
461 | { | |
462 | return 0; | |
463 | } | |
464 | while (isalpha(*cp) && len < maxlen) | |
465 | { | |
466 | *name++ = *cp++; | |
467 | len++; | |
468 | } | |
469 | if (len == maxlen) | |
470 | { | |
471 | return 0; | |
472 | } | |
473 | *name = 0; | |
474 | if (!*cp) | |
475 | { | |
476 | return 1; | |
477 | } | |
478 | if (!(*cp == '-') && !isdigit(*cp)) | |
479 | { | |
480 | return 0; | |
481 | } | |
482 | *parm = atoi(cp); | |
483 | return 2; | |
433 | 484 | } |
434 | 485 | |
435 | 486 | // translate \fcharset parameter value to code page. See MS RTF doc |
436 | 487 | static const int fcharsetparmtocp(int parm) |
437 | 488 | { |
438 | switch (parm) { | |
439 | case 0: return 1252; | |
440 | case 1: return 0; | |
441 | case 2: return 42; | |
442 | case 77: return 10000; | |
443 | case 78: return 10001; | |
444 | case 79: return 10003; | |
445 | case 80: return 10008; | |
446 | case 81: return 10002; | |
447 | case 83: return 10005; | |
448 | case 84: return 10004; | |
449 | case 85: return 10006; | |
450 | case 86: return 10081; | |
451 | case 87: return 10021; | |
452 | case 88: return 10029; | |
453 | case 89: return 10007; | |
454 | case 128: return 932; | |
455 | case 129: return 949; | |
456 | case 130: return 1361; | |
457 | case 134: return 936; | |
458 | case 136: return 950; | |
459 | case 161: return 1253; | |
460 | case 162: return 1254; | |
461 | case 163: return 1258; | |
462 | case 177: return 1255; | |
463 | case 178: return 1256; | |
464 | case 186: return 1257; | |
465 | case 204: return 1251; | |
466 | case 222: return 874; | |
467 | case 238: return 1250; | |
468 | case 254: return 437; | |
469 | default: return 1252; | |
470 | } | |
489 | switch (parm) | |
490 | { | |
491 | case 0: | |
492 | return 1252; | |
493 | case 1: | |
494 | return 0; | |
495 | case 2: | |
496 | return 42; | |
497 | case 77: | |
498 | return 10000; | |
499 | case 78: | |
500 | return 10001; | |
501 | case 79: | |
502 | return 10003; | |
503 | case 80: | |
504 | return 10008; | |
505 | case 81: | |
506 | return 10002; | |
507 | case 83: | |
508 | return 10005; | |
509 | case 84: | |
510 | return 10004; | |
511 | case 85: | |
512 | return 10006; | |
513 | case 86: | |
514 | return 10081; | |
515 | case 87: | |
516 | return 10021; | |
517 | case 88: | |
518 | return 10029; | |
519 | case 89: | |
520 | return 10007; | |
521 | case 128: | |
522 | return 932; | |
523 | case 129: | |
524 | return 949; | |
525 | case 130: | |
526 | return 1361; | |
527 | case 134: | |
528 | return 936; | |
529 | case 136: | |
530 | return 950; | |
531 | case 161: | |
532 | return 1253; | |
533 | case 162: | |
534 | return 1254; | |
535 | case 163: | |
536 | return 1258; | |
537 | case 177: | |
538 | return 1255; | |
539 | case 178: | |
540 | return 1256; | |
541 | case 186: | |
542 | return 1257; | |
543 | case 204: | |
544 | return 1251; | |
545 | case 222: | |
546 | return 874; | |
547 | case 238: | |
548 | return 1250; | |
549 | case 254: | |
550 | return 437; | |
551 | default: | |
552 | return 1252; | |
553 | } | |
471 | 554 | } |
472 | 555 | |
473 | 556 | // Translate code page to encoding name hopefully suitable as iconv input |
474 | static char *cptoencoding(parm) | |
475 | { | |
476 | // Note that CP0 is supposed to mean current system default, which does | |
477 | // not make any sense as a stored value, we don't handle it. | |
478 | ||
479 | // It's quite possible that some of the CPxx values had better be | |
480 | // replaced in some case by an equivalent better understood by | |
481 | // iconv. Need testing | |
482 | switch (parm) { | |
483 | case 42: return "SYMBOL"; | |
484 | case 437: return "CP437"; /* United States IBM */ | |
485 | case 708: return "CP708"; /* Arabic (ASMO 708) */ | |
486 | case 709: return "CP709"; /* Arabic (ASMO 449+, BCON V4) */ | |
487 | case 710: return "CP710"; /* Arabic (transparent Arabic) */ | |
488 | case 711: return "CP711"; /* Arabic (Nafitha Enhanced) */ | |
489 | case 720: return "CP720"; /* Arabic (transparent ASMO) */ | |
490 | case 819: return "CP819"; /* Windows 3.1 (United States and Western Europe) */ | |
491 | case 850: return "CP850"; /* IBM multilingual */ | |
492 | case 852: return "CP852"; /* Eastern European */ | |
493 | case 860: return "CP860"; /* Portuguese */ | |
494 | case 862: return "CP862"; /* Hebrew */ | |
495 | case 863: return "CP863"; /* French Canadian */ | |
496 | case 864: return "CP864"; /* Arabic */ | |
497 | case 865: return "CP865"; /* Norwegian */ | |
498 | case 866: return "CP866"; /* Soviet Union */ | |
499 | case 874: return "CP874"; /* Thai */ | |
500 | case 932: return "CP932"; /* Japanese */ | |
501 | case 936: return "CP936"; /* Simplified Chinese */ | |
502 | case 949: return "CP949"; /* Korean */ | |
503 | case 950: return "CP950"; /* Traditional Chinese */ | |
504 | case 1250: return "CP1250"; /* Eastern European */ | |
505 | case 1251: return "CP1251"; /* Cyrillic */ | |
506 | case 1252: return "CP1252"; /* Western European */ | |
507 | case 1253: return "CP1253"; /* Greek */ | |
508 | case 1254: return "CP1254"; /* Turkish */ | |
509 | case 1255: return "CP1255"; /* Hebrew */ | |
510 | case 1256: return "CP1256"; /* Arabic */ | |
511 | case 1257: return "CP1257"; /* Baltic */ | |
512 | case 1258: return "CP1258"; /* Vietnamese */ | |
513 | case 1361: return "CP1361"; /* Johab */ | |
514 | case 10000: return "MAC"; /* MAC Roman */ | |
515 | case 10001: return "CP10001"; /* MAC Japan ?? Iconv does not know this*/ | |
516 | case 10004: return "MACARABIC"; /* MAC Arabic */ | |
517 | case 10005: return "MACHEBREW"; /* MAC Hebrew */ | |
518 | case 10006: return "MACGREEK"; /* MAC Greek */ | |
519 | case 10007: return "MACCYRILLIC"; /* MAC Cyrillic */ | |
520 | case 10029: return "MACCENTRALEUROPE"; /* MAC Latin2 */ | |
521 | case 10081: return "MACTURKISH"; /* MAC Turkish */ | |
522 | case 57002: return "CP57002"; /* Devanagari */ | |
523 | case 57003: return "CP57003"; /* Bengali */ | |
524 | case 57004: return "CP57004"; /* Tamil */ | |
525 | case 57005: return "CP57005"; /* Telugu */ | |
526 | case 57006: return "CP57006"; /* Assamese */ | |
527 | case 57007: return "CP57007"; /* Oriya */ | |
528 | default: return "CP1252"; | |
529 | } | |
557 | static char *cptoencoding(int parm) | |
558 | { | |
559 | // Note that CP0 is supposed to mean current system default, which does | |
560 | // not make any sense as a stored value, we don't handle it. | |
561 | ||
562 | // It's quite possible that some of the CPxx values had better be | |
563 | // replaced in some case by an equivalent better understood by | |
564 | // iconv. Need testing | |
565 | switch (parm) | |
566 | { | |
567 | case 42: | |
568 | return "SYMBOL"; | |
569 | case 437: | |
570 | return "CP437"; /* United States IBM */ | |
571 | case 708: | |
572 | return "CP708"; /* Arabic (ASMO 708) */ | |
573 | case 709: | |
574 | return "CP709"; /* Arabic (ASMO 449+, BCON V4) */ | |
575 | case 710: | |
576 | return "CP710"; /* Arabic (transparent Arabic) */ | |
577 | case 711: | |
578 | return "CP711"; /* Arabic (Nafitha Enhanced) */ | |
579 | case 720: | |
580 | return "CP720"; /* Arabic (transparent ASMO) */ | |
581 | case 819: | |
582 | return "CP819"; /* Windows 3.1 (United States and Western Europe) */ | |
583 | case 850: | |
584 | return "CP850"; /* IBM multilingual */ | |
585 | case 852: | |
586 | return "CP852"; /* Eastern European */ | |
587 | case 860: | |
588 | return "CP860"; /* Portuguese */ | |
589 | case 862: | |
590 | return "CP862"; /* Hebrew */ | |
591 | case 863: | |
592 | return "CP863"; /* French Canadian */ | |
593 | case 864: | |
594 | return "CP864"; /* Arabic */ | |
595 | case 865: | |
596 | return "CP865"; /* Norwegian */ | |
597 | case 866: | |
598 | return "CP866"; /* Soviet Union */ | |
599 | case 874: | |
600 | return "CP874"; /* Thai */ | |
601 | case 932: | |
602 | return "CP932"; /* Japanese */ | |
603 | case 936: | |
604 | return "CP936"; /* Simplified Chinese */ | |
605 | case 949: | |
606 | return "CP949"; /* Korean */ | |
607 | case 950: | |
608 | return "CP950"; /* Traditional Chinese */ | |
609 | case 1250: | |
610 | return "CP1250"; /* Eastern European */ | |
611 | case 1251: | |
612 | return "CP1251"; /* Cyrillic */ | |
613 | case 1252: | |
614 | return "CP1252"; /* Western European */ | |
615 | case 1253: | |
616 | return "CP1253"; /* Greek */ | |
617 | case 1254: | |
618 | return "CP1254"; /* Turkish */ | |
619 | case 1255: | |
620 | return "CP1255"; /* Hebrew */ | |
621 | case 1256: | |
622 | return "CP1256"; /* Arabic */ | |
623 | case 1257: | |
624 | return "CP1257"; /* Baltic */ | |
625 | case 1258: | |
626 | return "CP1258"; /* Vietnamese */ | |
627 | case 1361: | |
628 | return "CP1361"; /* Johab */ | |
629 | case 10000: | |
630 | return "MAC"; /* MAC Roman */ | |
631 | case 10001: | |
632 | return "CP10001"; /* MAC Japan ?? Iconv does not know this*/ | |
633 | case 10004: | |
634 | return "MACARABIC"; /* MAC Arabic */ | |
635 | case 10005: | |
636 | return "MACHEBREW"; /* MAC Hebrew */ | |
637 | case 10006: | |
638 | return "MACGREEK"; /* MAC Greek */ | |
639 | case 10007: | |
640 | return "MACCYRILLIC"; /* MAC Cyrillic */ | |
641 | case 10029: | |
642 | return "MACCENTRALEUROPE"; /* MAC Latin2 */ | |
643 | case 10081: | |
644 | return "MACTURKISH"; /* MAC Turkish */ | |
645 | case 57002: | |
646 | return "CP57002"; /* Devanagari */ | |
647 | case 57003: | |
648 | return "CP57003"; /* Bengali */ | |
649 | case 57004: | |
650 | return "CP57004"; /* Tamil */ | |
651 | case 57005: | |
652 | return "CP57005"; /* Telugu */ | |
653 | case 57006: | |
654 | return "CP57006"; /* Assamese */ | |
655 | case 57007: | |
656 | return "CP57007"; /* Oriya */ | |
657 | default: | |
658 | return "CP1252"; | |
659 | } | |
660 | } | |
661 | ||
662 | /*======================================================================== | |
663 | * Name: read_font_decl | |
664 | * Purpose: Reads exactly one font declaration from the font table: e.g. | |
665 | * \f<num>\froman\fcharset204\fprq2 Times New Roman Cyr; | |
666 | * We are only interested in the font number, encoding and name, and skip the | |
667 | * other commands. The font decl can be alone in a group, or part of | |
668 | * a semicolon-separated list, in which case we take care to stop input just | |
669 | * after the semi-colon | |
670 | * Args: Group containing one or several font decls | |
671 | * Returns: None. | |
672 | *=======================================================================*/ | |
673 | ||
674 | Word *read_font_decl(Word *w) | |
675 | { | |
676 | int num; | |
677 | char name[BUFSIZ]; | |
678 | const char *tmp; | |
679 | int cpgcp = -1; | |
680 | int fcharsetcp = -1; | |
681 | int l; | |
682 | int i; | |
683 | ||
684 | name[0] = 0; | |
685 | ||
686 | /* Read font number ('\fxx'). There can be an optional <themefont> | |
687 | entry (e.g. '\flomajor') before the font number */ | |
688 | for (i = 0; i < 2; i++) | |
689 | { | |
690 | tmp = word_string(w); | |
691 | if (!tmp || strlen(tmp) < 3 || strncmp("\\f", tmp, 2)) | |
692 | { | |
693 | return 0; | |
694 | } | |
695 | if (isdigit(tmp[2])) | |
696 | { | |
697 | num = atoi(&tmp[2]); | |
698 | break; | |
699 | } else if (i == 1) { | |
700 | return 0; | |
701 | } | |
702 | w = w->next; | |
703 | } | |
704 | ||
705 | /* Read other font entry elements, e.g. encoding, and name. The | |
706 | loop is weird because it would allow interleaving commands and | |
707 | name words. We should read command words until non command, the | |
708 | rest until the semi-colon being the font name. Kept this way | |
709 | for minimal perturbation of existing code. We stop at the | |
710 | semi-colon in all cases, which is not necessary if we are | |
711 | reading from a single-entry group which seems to be now the | |
712 | standard way, but we also support groups with multiple | |
713 | semicolon-separated entries */ | |
714 | while (w) | |
715 | { | |
716 | int needbreak = 0; | |
717 | tmp = word_string(w); | |
718 | ||
719 | if (tmp && tmp[0] != '\\') | |
720 | { | |
721 | /* Read font name word. Note: the parser breaks the input | |
722 | at every space char. */ | |
723 | if (strchr(tmp, ';')) | |
724 | needbreak = 1; | |
725 | if (strlen(tmp) + strlen(name) > BUFSIZ - 1) | |
726 | { | |
727 | fprintf(stderr, "Invalid font table entry\n"); | |
728 | name[0] = 0; | |
729 | } | |
730 | else | |
731 | { | |
732 | strncat(name, tmp, sizeof(name) - strlen(name) - 1); | |
733 | } | |
734 | } | |
735 | else if (tmp) | |
736 | { | |
737 | char nm[MAX_CONTROL_LEN + 1]; | |
738 | int parm; | |
739 | int ret = controlToNameParm(tmp + 1, nm, MAX_CONTROL_LEN, &parm); | |
740 | if (ret == 2) | |
741 | { | |
742 | if (!strcmp(nm, "fcharset")) | |
743 | { | |
744 | fcharsetcp = fcharsetparmtocp(parm); | |
745 | } | |
746 | else if (!strcmp(nm, "cpg")) | |
747 | { | |
748 | cpgcp = parm; | |
749 | } | |
750 | /* not interested by stuff like \froman */ | |
751 | } | |
752 | } | |
753 | w = w->next; | |
754 | if (needbreak) | |
755 | break; | |
756 | } | |
757 | ||
758 | /* We probably read the semi-colon, remove it from the font name */ | |
759 | { | |
760 | char *t = strchr(name, ';'); | |
761 | if (t) | |
762 | *t = 0; | |
763 | } | |
764 | ||
765 | font_table[total_fonts].num = num; | |
766 | font_table[total_fonts].name = my_strdup(name); | |
767 | ||
768 | /* Explicit cpg parameter has priority on fcharset one */ | |
769 | if (cpgcp == -1) | |
770 | { | |
771 | cpgcp = fcharsetcp; | |
772 | } | |
773 | ||
774 | if (cpgcp != -1) | |
775 | { | |
776 | font_table[total_fonts].encoding = cptoencoding(cpgcp); | |
777 | } | |
778 | else | |
779 | { | |
780 | /* If there is "symbol" in the font name, use | |
781 | * symbol encoding, else no local encoding */ | |
782 | if (strcasestr(name, "symbol")) | |
783 | { | |
784 | font_table[total_fonts].encoding = "SYMBOL"; | |
785 | } | |
786 | else | |
787 | { | |
788 | font_table[total_fonts].encoding = 0; | |
789 | } | |
790 | } | |
791 | ||
792 | /* Need to have this outside last block as it must be detected | |
793 | even if cpgcp is set */ | |
794 | if (strcasecmp(name, "symbol") == 0) | |
795 | { | |
796 | font_table[total_fonts].encoding = "SYMBOL"; | |
797 | } | |
798 | if (safe_printf(0, assemble_string(op->fonttable_fontnr, num))) | |
799 | { | |
800 | fprintf(stderr, TOO_MANY_ARGS, "fonttable_fontnr"); | |
801 | } | |
802 | if (safe_printf(1, op->fonttable_fontname, name)) | |
803 | { | |
804 | fprintf(stderr, TOO_MANY_ARGS, "fonttable_fontname"); | |
805 | } | |
806 | total_fonts++; | |
807 | return w; | |
530 | 808 | } |
531 | 809 | |
532 | 810 | /*======================================================================== |
537 | 815 | *=======================================================================*/ |
538 | 816 | |
539 | 817 | void |
540 | process_font_table (Word *w) | |
541 | { | |
542 | Word *w2; | |
543 | CHECK_PARAM_NOT_NULL(w); | |
544 | ||
545 | if (safe_printf(0, op->fonttable_begin)) fprintf(stderr, TOO_MANY_ARGS, "fonttable_begin"); | |
546 | ||
547 | while (w) { | |
548 | int num; | |
549 | char name[BUFSIZ]; | |
550 | const char *tmp; | |
551 | ||
552 | if ((w2 = w->child)) | |
553 | { | |
554 | tmp = word_string(w2); | |
555 | if(!tmp) | |
556 | return; | |
557 | if (!strncmp("\\f", tmp, 2)) { | |
558 | num = atoi(&tmp[2]); | |
559 | name[0] = 0; | |
560 | int cpgcp = -1; | |
561 | int fcharsetcp = -1; | |
562 | w2 = w2->next; | |
563 | while (w2) { | |
564 | tmp = word_string (w2); | |
565 | if (tmp && tmp[0] != '\\') { | |
566 | if (strlen(tmp) + strlen(name) > BUFSIZ - 1) { | |
567 | fprintf(stderr, "Invalid font table entry\n"); | |
568 | name[0] = 0; | |
569 | } | |
570 | else | |
571 | strncat(name,tmp,sizeof(name) - strlen(name) - 1); | |
572 | } else if (tmp) { | |
573 | char nm[MAX_CONTROL_LEN+1]; | |
574 | int parm; | |
575 | int ret = | |
576 | controlToNameParm(tmp+1,nm, MAX_CONTROL_LEN, &parm); | |
577 | if (ret == 2) { | |
578 | if (!strcmp(nm, "fcharset")) { | |
579 | fcharsetcp = fcharsetparmtocp(parm); | |
580 | } else if (!strcmp(nm, "cpg")) { | |
581 | cpgcp = parm; | |
582 | } | |
583 | } | |
584 | } | |
585 | w2 = w2->next; | |
586 | } | |
587 | ||
588 | /* Chop the gall-derned semicolon. */ | |
589 | { char *t; | |
590 | if ((t = strchr(name, ';'))) | |
591 | *t = 0; | |
592 | } | |
593 | ||
594 | font_table[total_fonts].num=num; | |
595 | font_table[total_fonts].name=my_strdup(name); | |
596 | // Explicit cpg parameter has priority on fcharset one | |
597 | if (cpgcp == -1) | |
598 | cpgcp = fcharsetcp; | |
599 | if (cpgcp != -1) | |
600 | font_table[total_fonts].encoding = cptoencoding(cpgcp); | |
601 | else { | |
602 | /* If there is "symbol" in the font name, use | |
603 | * symbol encoding, else no local encoding */ | |
604 | if (strcasestr(name, "symbol")) | |
605 | font_table[total_fonts].encoding = "SYMBOL"; | |
606 | else | |
607 | font_table[total_fonts].encoding = 0; | |
608 | } | |
609 | // need to have this outside last block as it must be detected | |
610 | // even if cpgcp is set | |
611 | if (strcasecmp(name, "symbol") == 0) | |
612 | font_table[total_fonts].encoding = "SYMBOL"; | |
613 | if (safe_printf(0, assemble_string(op->fonttable_fontnr, num))) fprintf(stderr, TOO_MANY_ARGS, "fonttable_fontnr"); | |
614 | if (safe_printf(1, op->fonttable_fontname, name)) fprintf(stderr, TOO_MANY_ARGS, "fonttable_fontname"); | |
615 | total_fonts++; | |
616 | } | |
617 | } | |
618 | w=w->next; | |
619 | } | |
620 | ||
621 | if (safe_printf(0, op->fonttable_end)) fprintf(stderr, TOO_MANY_ARGS, "fonttable_end"); | |
622 | ||
623 | /* | |
624 | * If the default font has an encoding, set it as default | |
625 | * encoding. The default font number was set by the \deff command | |
626 | * in the header (or not in which case it is o). Don't do it if | |
627 | * we had an explicit ansicpg command (no logic in this, just works). | |
628 | */ | |
629 | if (total_fonts > 0 && !had_ansicpg) { | |
630 | FontEntry *e = lookup_font(default_font_number); | |
631 | if (e && e->encoding && *e->encoding) | |
632 | default_encoding = e->encoding; | |
633 | } | |
634 | ||
635 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
636 | printf("font table contains %d fonts total",total_fonts); | |
637 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
638 | ||
639 | if (debug_mode) { | |
640 | int i; | |
641 | ||
642 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
643 | printf("font table dump: \n"); | |
644 | for (i=0; i<total_fonts; i++) { | |
645 | printf(" font %d = %s encoding = %s\n", font_table[i].num, | |
646 | font_table[i].name, font_table[i].encoding); | |
647 | } | |
648 | ||
649 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
650 | } | |
818 | process_font_table(Word *w) | |
819 | { | |
820 | CHECK_PARAM_NOT_NULL(w); | |
821 | ||
822 | if (safe_printf(0, op->fonttable_begin)) | |
823 | { | |
824 | fprintf(stderr, TOO_MANY_ARGS, "fonttable_begin"); | |
825 | } | |
826 | ||
827 | /* We may be reading from a group with multiple entries separated | |
828 | by semi-colons, or multiple subgroups, each with one | |
829 | entry. Handle both */ | |
830 | while (w) | |
831 | { | |
832 | if (w->child) | |
833 | { | |
834 | read_font_decl(w->child); | |
835 | w = w->next; | |
836 | } | |
837 | else if (word_string(w)) | |
838 | { | |
839 | w = read_font_decl(w); | |
840 | } | |
841 | else | |
842 | { | |
843 | /* Not sure that we should not bail out here. Every | |
844 | element should have string or child */ | |
845 | w = w->next; | |
846 | } | |
847 | } | |
848 | ||
849 | if (safe_printf(0, op->fonttable_end)) | |
850 | { | |
851 | fprintf(stderr, TOO_MANY_ARGS, "fonttable_end"); | |
852 | } | |
853 | ||
854 | /* | |
855 | * If the default font has an encoding, set it as default | |
856 | * encoding. The default font number was set by the \deff command | |
857 | * in the header (or not in which case it is o). Don't do it if | |
858 | * we had an explicit ansicpg command (no logic in this, just works). | |
859 | */ | |
860 | if (total_fonts > 0 && !had_ansicpg) | |
861 | { | |
862 | FontEntry *e = lookup_font(default_font_number); | |
863 | if (e && e->encoding && *e->encoding) | |
864 | { | |
865 | default_encoding = e->encoding; | |
866 | } | |
867 | } | |
868 | ||
869 | if (!quiet) | |
870 | { | |
871 | if (safe_printf(0, op->comment_begin)) | |
872 | { | |
873 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
874 | } | |
875 | printf("font table contains %d fonts total", total_fonts); | |
876 | if (safe_printf(0, op->comment_end)) | |
877 | { | |
878 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
879 | } | |
880 | } | |
881 | ||
882 | if (debug_mode) | |
883 | { | |
884 | int i; | |
885 | ||
886 | if (safe_printf(0, op->comment_begin)) | |
887 | { | |
888 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
889 | } | |
890 | printf("font table dump: \n"); | |
891 | for (i = 0; i < total_fonts; i++) | |
892 | { | |
893 | printf(" font %d = %s encoding = %s\n", font_table[i].num, | |
894 | font_table[i].name, font_table[i].encoding); | |
895 | } | |
896 | ||
897 | if (safe_printf(0, op->comment_end)) | |
898 | { | |
899 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
900 | } | |
901 | } | |
651 | 902 | } |
652 | 903 | |
653 | 904 | |
659 | 910 | *=======================================================================*/ |
660 | 911 | |
661 | 912 | void |
662 | process_index_entry (Word *w) | |
913 | process_index_entry(Word *w) | |
663 | 914 | { |
664 | 915 | Word *w2; |
665 | 916 | |
666 | 917 | CHECK_PARAM_NOT_NULL(w); |
667 | 918 | |
668 | while(w) { | |
669 | if ((w2=w->child)) { | |
670 | const char *str = word_string (w2); | |
671 | ||
672 | if (debug_mode && str) { | |
673 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
674 | printf("index entry word: %s ", str); | |
675 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
919 | while (w) | |
920 | { | |
921 | if ((w2 = w->child)) | |
922 | { | |
923 | const char *str = word_string(w2); | |
924 | ||
925 | if (debug_mode && str) | |
926 | { | |
927 | if (safe_printf(0, op->comment_begin)) | |
928 | { | |
929 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
930 | } | |
931 | printf("index entry word: %s ", str); | |
932 | if (safe_printf(0, op->comment_end)) | |
933 | { | |
934 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
935 | } | |
676 | 936 | } |
677 | 937 | } |
678 | w=w->next; | |
938 | w = w->next; | |
679 | 939 | } |
680 | 940 | } |
681 | 941 | |
688 | 948 | *=======================================================================*/ |
689 | 949 | |
690 | 950 | void |
691 | process_toc_entry (Word *w, int include_page_num) | |
951 | process_toc_entry(Word *w, int include_page_num) | |
692 | 952 | { |
693 | 953 | Word *w2; |
694 | 954 | |
695 | 955 | CHECK_PARAM_NOT_NULL(w); |
696 | 956 | |
697 | while(w) { | |
698 | if ((w2=w->child)) { | |
699 | const char *str = word_string (w2); | |
700 | ||
701 | if (debug_mode && str) { | |
702 | ||
703 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
704 | printf("toc %s entry word: %s ", | |
705 | include_page_num ? "page#":"no page#", | |
706 | str); | |
707 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
957 | while (w) | |
958 | { | |
959 | if ((w2 = w->child)) | |
960 | { | |
961 | const char *str = word_string(w2); | |
962 | ||
963 | if (debug_mode && str) | |
964 | { | |
965 | ||
966 | if (safe_printf(0, op->comment_begin)) | |
967 | { | |
968 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
969 | } | |
970 | printf("toc %s entry word: %s ", | |
971 | include_page_num ? "page#" : "no page#", | |
972 | str); | |
973 | if (safe_printf(0, op->comment_end)) | |
974 | { | |
975 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
976 | } | |
708 | 977 | } |
709 | 978 | } |
710 | w=w->next; | |
979 | w = w->next; | |
711 | 980 | } |
712 | 981 | } |
713 | 982 | |
720 | 989 | *=======================================================================*/ |
721 | 990 | |
722 | 991 | void |
723 | process_info_group (Word *w) | |
992 | process_info_group(Word *w) | |
724 | 993 | { |
725 | 994 | Word *child; |
726 | 995 | |
727 | maybeopeniconv(); | |
728 | /* amaral - 0.19.2 */ | |
729 | /* CHECK_PARAM_NOT_NULL(w); */ | |
730 | if (!w) printf("AUTHOR'S COMMENT: \\info command is null!\n"); | |
731 | ||
732 | while(w) | |
996 | if (!w) | |
997 | { | |
998 | /* Happens. Means empty info group, like {\info} */ | |
999 | return; | |
1000 | } | |
1001 | ||
1002 | maybeopeniconv(); | |
1003 | ||
1004 | while (w) | |
733 | 1005 | { |
734 | 1006 | child = w->child; |
735 | if (child) { | |
1007 | if (child) | |
1008 | { | |
736 | 1009 | Word *w2; |
737 | 1010 | const char *s; |
738 | 1011 | |
739 | 1012 | s = word_string(child); |
740 | if(!s) | |
1013 | if (!s) | |
1014 | { | |
741 | 1015 | return; |
742 | ||
743 | if (!inline_mode) { | |
744 | if (!strcmp("\\title", s)) { | |
745 | ||
746 | if (safe_printf(0, op->document_title_begin)) fprintf(stderr, TOO_MANY_ARGS, "document_title_begin"); | |
747 | w2=child->next; | |
748 | while (w2) { | |
1016 | } | |
1017 | ||
1018 | if (!inline_mode) | |
1019 | { | |
1020 | if (!strcmp("\\title", s)) | |
1021 | { | |
1022 | ||
1023 | if (safe_printf(0, op->document_title_begin)) | |
1024 | { | |
1025 | fprintf(stderr, TOO_MANY_ARGS, "document_title_begin"); | |
1026 | } | |
1027 | w2 = child->next; | |
1028 | while (w2) | |
1029 | { | |
749 | 1030 | const char *s2 = word_string(w2); |
750 | if (s2 && s2[0] != '\\') | |
1031 | if (s2 && s2[0] != '\\') | |
751 | 1032 | { |
752 | print_with_special_exprs (s2); | |
1033 | print_with_special_exprs(s2); | |
753 | 1034 | } |
754 | 1035 | else if (s2 && s2[1] == '\'' && s2[2] && s2[3]) |
755 | 1036 | { |
756 | int ch = h2toi (&s2[2]); | |
1037 | int ch = h2toi(&s2[2]); | |
757 | 1038 | accumulate_iconv_input(ch); |
758 | 1039 | } |
759 | 1040 | |
760 | 1041 | w2 = w2->next; |
761 | 1042 | } |
762 | flush_iconv_input(); | |
763 | if (safe_printf(0, op->document_title_end)) fprintf(stderr, TOO_MANY_ARGS, "document_title_end"); | |
1043 | flush_iconv_input(); | |
1044 | if (safe_printf(0, op->document_title_end)) | |
1045 | { | |
1046 | fprintf(stderr, TOO_MANY_ARGS, "document_title_end"); | |
1047 | } | |
764 | 1048 | } |
765 | else if (!strcmp("\\keywords", s)) { | |
766 | if (safe_printf(0, op->document_keywords_begin)) fprintf(stderr, TOO_MANY_ARGS, "document_keywords_begin"); | |
767 | w2=child->next; | |
768 | while (w2) { | |
1049 | else if (!strcmp("\\keywords", s)) | |
1050 | { | |
1051 | if (safe_printf(0, op->document_keywords_begin)) | |
1052 | { | |
1053 | fprintf(stderr, TOO_MANY_ARGS, "document_keywords_begin"); | |
1054 | } | |
1055 | w2 = child->next; | |
1056 | while (w2) | |
1057 | { | |
769 | 1058 | const char *s2 = word_string(w2); |
770 | if (s2 && s2[0] != '\\') | |
1059 | if (s2 && s2[0] != '\\') | |
1060 | { | |
771 | 1061 | printf("%s,", s2); |
1062 | } | |
772 | 1063 | w2 = w2->next; |
773 | 1064 | } |
774 | if (safe_printf(0, op->document_keywords_end)) fprintf(stderr, TOO_MANY_ARGS, "document_keywords_end"); | |
1065 | if (safe_printf(0, op->document_keywords_end)) | |
1066 | { | |
1067 | fprintf(stderr, TOO_MANY_ARGS, "document_keywords_end"); | |
1068 | } | |
775 | 1069 | } |
776 | else if (!strcmp("\\author", s)) { | |
777 | if (safe_printf(0, op->document_author_begin)) fprintf(stderr, TOO_MANY_ARGS, "document_author_begin"); | |
778 | w2=child->next; | |
779 | while (w2) { | |
1070 | else if (!strcmp("\\author", s)) | |
1071 | { | |
1072 | if (safe_printf(0, op->document_author_begin)) | |
1073 | { | |
1074 | fprintf(stderr, TOO_MANY_ARGS, "document_author_begin"); | |
1075 | } | |
1076 | w2 = child->next; | |
1077 | while (w2) | |
1078 | { | |
780 | 1079 | const char *s2 = word_string(w2); |
781 | if (s2 && s2[0] != '\\') | |
1080 | if (s2 && s2[0] != '\\') | |
1081 | { | |
782 | 1082 | printf("%s", s2); |
1083 | } | |
783 | 1084 | w2 = w2->next; |
784 | 1085 | } |
785 | if (safe_printf(0, op->document_author_end)) fprintf(stderr, TOO_MANY_ARGS, "document_author_end"); | |
1086 | if (safe_printf(0, op->document_author_end)) | |
1087 | { | |
1088 | fprintf(stderr, TOO_MANY_ARGS, "document_author_end"); | |
1089 | } | |
786 | 1090 | } |
787 | else if (!strcmp("\\comment", s)) { | |
788 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1091 | else if (!strcmp("\\comment", s)) | |
1092 | { | |
1093 | if (safe_printf(0, op->comment_begin)) | |
1094 | { | |
1095 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1096 | } | |
789 | 1097 | printf("comments: "); |
790 | w2=child->next; | |
791 | while (w2) { | |
1098 | w2 = child->next; | |
1099 | while (w2) | |
1100 | { | |
792 | 1101 | const char *s2 = word_string(w2); |
793 | if (s2 && s2[0] != '\\') | |
1102 | if (s2 && s2[0] != '\\') | |
1103 | { | |
794 | 1104 | printf("%s", s2); |
1105 | } | |
795 | 1106 | w2 = w2->next; |
796 | 1107 | } |
797 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1108 | if (safe_printf(0, op->comment_end)) | |
1109 | { | |
1110 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1111 | } | |
798 | 1112 | } |
799 | else if (!strncmp("\\nofpages", s, 9)) { | |
800 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
801 | printf("total pages: %s",&s[9]); | |
802 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1113 | else if (!strncmp("\\nofpages", s, 9)) | |
1114 | { | |
1115 | if (safe_printf(0, op->comment_begin)) | |
1116 | { | |
1117 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1118 | } | |
1119 | printf("total pages: %s", &s[9]); | |
1120 | if (safe_printf(0, op->comment_end)) | |
1121 | { | |
1122 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1123 | } | |
803 | 1124 | } |
804 | else if (!strncmp("\\nofwords", s, 9)) { | |
805 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
806 | printf("total words: %s",&s[9]); | |
807 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1125 | else if (!strncmp("\\nofwords", s, 9)) | |
1126 | { | |
1127 | if (safe_printf(0, op->comment_begin)) | |
1128 | { | |
1129 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1130 | } | |
1131 | printf("total words: %s", &s[9]); | |
1132 | if (safe_printf(0, op->comment_end)) | |
1133 | { | |
1134 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1135 | } | |
808 | 1136 | } |
809 | else if (!strncmp("\\nofchars", s, 9) && isdigit(s[9])) { | |
810 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
811 | printf("total chars: %s",&s[9]); | |
812 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1137 | else if (!strncmp("\\nofchars", s, 9) && isdigit(s[9])) | |
1138 | { | |
1139 | if (safe_printf(0, op->comment_begin)) | |
1140 | { | |
1141 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1142 | } | |
1143 | printf("total chars: %s", &s[9]); | |
1144 | if (safe_printf(0, op->comment_end)) | |
1145 | { | |
1146 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1147 | } | |
813 | 1148 | } |
814 | else if (!strcmp("\\creatim", s)) { | |
815 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1149 | else if (!strcmp("\\creatim", s)) | |
1150 | { | |
1151 | if (safe_printf(0, op->comment_begin)) | |
1152 | { | |
1153 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1154 | } | |
816 | 1155 | printf("creation date: "); |
817 | if (child->next) word_dump_date (child->next); | |
818 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1156 | if (child->next) | |
1157 | { | |
1158 | word_dump_date(child->next); | |
1159 | } | |
1160 | if (safe_printf(0, op->comment_end)) | |
1161 | { | |
1162 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1163 | } | |
819 | 1164 | } |
820 | else if (!strcmp("\\printim", s)) { | |
821 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1165 | else if (!strcmp("\\printim", s)) | |
1166 | { | |
1167 | if (safe_printf(0, op->comment_begin)) | |
1168 | { | |
1169 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1170 | } | |
822 | 1171 | printf("last printed: "); |
823 | if (child->next) word_dump_date (child->next); | |
824 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1172 | if (child->next) | |
1173 | { | |
1174 | word_dump_date(child->next); | |
1175 | } | |
1176 | if (safe_printf(0, op->comment_end)) | |
1177 | { | |
1178 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1179 | } | |
825 | 1180 | } |
826 | else if (!strcmp("\\buptim", s)) { | |
827 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1181 | else if (!strcmp("\\buptim", s)) | |
1182 | { | |
1183 | if (safe_printf(0, op->comment_begin)) | |
1184 | { | |
1185 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1186 | } | |
828 | 1187 | printf("last backup: "); |
829 | if (child->next) word_dump_date (child->next); | |
830 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1188 | if (child->next) | |
1189 | { | |
1190 | word_dump_date(child->next); | |
1191 | } | |
1192 | if (safe_printf(0, op->comment_end)) | |
1193 | { | |
1194 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1195 | } | |
831 | 1196 | } |
832 | else if (!strcmp("\\revtim", s)) { | |
833 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1197 | else if (!strcmp("\\revtim", s)) | |
1198 | { | |
1199 | if (safe_printf(0, op->comment_begin)) | |
1200 | { | |
1201 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1202 | } | |
834 | 1203 | printf("revision date: "); |
835 | if (child->next) word_dump_date (child->next); | |
836 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1204 | if (child->next) | |
1205 | { | |
1206 | word_dump_date(child->next); | |
1207 | } | |
1208 | if (safe_printf(0, op->comment_end)) | |
1209 | { | |
1210 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1211 | } | |
837 | 1212 | } |
838 | 1213 | } |
839 | 1214 | |
840 | 1215 | /* Irregardless of whether we're in inline mode, |
841 | 1216 | * we want to process the following. |
842 | 1217 | */ |
843 | if (!strcmp("\\hlinkbase", s)) { | |
1218 | if (!strcmp("\\hlinkbase", s)) | |
1219 | { | |
844 | 1220 | const char *linkstr = NULL; |
845 | 1221 | |
846 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1222 | if (safe_printf(0, op->comment_begin)) | |
1223 | { | |
1224 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1225 | } | |
847 | 1226 | printf("hyperlink base: "); |
848 | if (child->next) { | |
1227 | if (child->next) | |
1228 | { | |
849 | 1229 | Word *nextword = child->next; |
850 | 1230 | |
851 | if (nextword) | |
852 | linkstr=word_string (nextword); | |
1231 | if (nextword) | |
1232 | { | |
1233 | linkstr = word_string(nextword); | |
1234 | } | |
853 | 1235 | } |
854 | 1236 | |
855 | 1237 | if (linkstr) |
1238 | { | |
856 | 1239 | printf("%s", linkstr); |
1240 | } | |
857 | 1241 | else |
1242 | { | |
858 | 1243 | printf("(none)"); |
859 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1244 | } | |
1245 | if (safe_printf(0, op->comment_end)) | |
1246 | { | |
1247 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1248 | } | |
860 | 1249 | |
861 | 1250 | /* Store the pointer, it will remain good. */ |
862 | hyperlink_base = linkstr; | |
1251 | hyperlink_base = linkstr; | |
863 | 1252 | } |
864 | } | |
1253 | } | |
865 | 1254 | w = w->next; |
866 | 1255 | } |
867 | 1256 | } |
870 | 1259 | |
871 | 1260 | /* RTF color table colors are RGB */ |
872 | 1261 | |
873 | typedef struct { | |
874 | unsigned char r,g,b; | |
1262 | typedef struct | |
1263 | { | |
1264 | unsigned char r, g, b; | |
875 | 1265 | } Color; |
876 | 1266 | |
877 | 1267 | #define MAX_COLORS (1024) |
878 | 1268 | static Color color_table[MAX_COLORS]; |
879 | static int total_colors=0; | |
1269 | static int total_colors = 0; | |
880 | 1270 | |
881 | 1271 | |
882 | 1272 | /*======================================================================== |
887 | 1277 | *=======================================================================*/ |
888 | 1278 | |
889 | 1279 | void |
890 | process_color_table (Word *w) | |
891 | { | |
892 | int r,g,b; | |
1280 | process_color_table(Word *w) | |
1281 | { | |
1282 | int r, g, b; | |
893 | 1283 | |
894 | 1284 | CHECK_PARAM_NOT_NULL(w); |
895 | 1285 | |
896 | 1286 | /* Sometimes, RTF color tables begin with a semicolon, |
897 | * i.e. an empty color entry. This seems to indicate that color 0 | |
1287 | * i.e. an empty color entry. This seems to indicate that color 0 | |
898 | 1288 | * will not be used, so here I set it to black. |
899 | 1289 | */ |
900 | r=g=b=0; | |
901 | ||
902 | while(w) | |
903 | { | |
904 | const char *s = word_string (w); | |
905 | if(s == 0 || total_colors >= MAX_COLORS) | |
1290 | r = g = b = 0; | |
1291 | ||
1292 | while (w) | |
1293 | { | |
1294 | const char *s = word_string(w); | |
1295 | if (s == 0 || total_colors >= MAX_COLORS) | |
1296 | { | |
906 | 1297 | break; |
907 | ||
908 | if (!strncmp("\\red",s,4)) { | |
1298 | } | |
1299 | ||
1300 | if (!strncmp("\\red", s, 4)) | |
1301 | { | |
909 | 1302 | r = atoi(&s[4]); |
910 | while(r>255) r>>=8; | |
911 | } | |
912 | else if (!strncmp("\\green",s,6)) { | |
1303 | while (r > 255) | |
1304 | { | |
1305 | r >>= 8; | |
1306 | } | |
1307 | } | |
1308 | else if (!strncmp("\\green", s, 6)) | |
1309 | { | |
913 | 1310 | g = atoi(&s[6]); |
914 | while(g>255) g>>=8; | |
915 | } | |
916 | else if (!strncmp("\\blue",s,5)) { | |
1311 | while (g > 255) | |
1312 | { | |
1313 | g >>= 8; | |
1314 | } | |
1315 | } | |
1316 | else if (!strncmp("\\blue", s, 5)) | |
1317 | { | |
917 | 1318 | b = atoi(&s[5]); |
918 | while(b>255) b>>=8; | |
1319 | while (b > 255) | |
1320 | { | |
1321 | b >>= 8; | |
1322 | } | |
919 | 1323 | } |
920 | 1324 | else |
921 | /* If we find the semicolon which denotes the end of | |
922 | * a color entry then store the color, even if we don't | |
923 | * have all of it. | |
924 | */ | |
925 | if (!strcmp (";", s)) { | |
926 | color_table[total_colors].r = r; | |
927 | color_table[total_colors].g = g; | |
928 | color_table[total_colors++].b = b; | |
929 | if (debug_mode) { | |
930 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
931 | printf("storing color entry %d: %02x%02x%02x", | |
932 | total_colors-1, r,g,b); | |
933 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1325 | /* If we find the semicolon which denotes the end of | |
1326 | * a color entry then store the color, even if we don't | |
1327 | * have all of it. | |
1328 | */ | |
1329 | if (!strcmp(";", s)) | |
1330 | { | |
1331 | color_table[total_colors].r = r; | |
1332 | color_table[total_colors].g = g; | |
1333 | color_table[total_colors++].b = b; | |
1334 | if (debug_mode) | |
1335 | { | |
1336 | if (safe_printf(0, op->comment_begin)) | |
1337 | { | |
1338 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1339 | } | |
1340 | printf("storing color entry %d: %02x%02x%02x", | |
1341 | total_colors - 1, r, g, b); | |
1342 | if (safe_printf(0, op->comment_end)) | |
1343 | { | |
1344 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1345 | } | |
1346 | } | |
1347 | r = g = b = 0; | |
934 | 1348 | } |
935 | r=g=b=0; | |
936 | } | |
937 | ||
938 | w=w->next; | |
939 | } | |
940 | ||
941 | if (debug_mode) { | |
942 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
943 | printf("color table had %d entries", total_colors); | |
944 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1349 | ||
1350 | w = w->next; | |
1351 | } | |
1352 | ||
1353 | if (debug_mode) | |
1354 | { | |
1355 | if (safe_printf(0, op->comment_begin)) | |
1356 | { | |
1357 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1358 | } | |
1359 | printf("color table had %d entries", total_colors); | |
1360 | if (safe_printf(0, op->comment_end)) | |
1361 | { | |
1362 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1363 | } | |
945 | 1364 | } |
946 | 1365 | } |
947 | 1366 | |
952 | 1371 | * Returns: Flag, true only if rest of Words on line should be ignored. |
953 | 1372 | *=======================================================================*/ |
954 | 1373 | |
955 | static int | |
956 | cmd_cf (Word *w, int align, char has_param, int num) | |
1374 | static int | |
1375 | cmd_cf(Word *w, int align, char has_param, int num) | |
957 | 1376 | { |
958 | 1377 | char str[40]; |
959 | 1378 | |
960 | if (!has_param || num<0 || num>=total_colors) | |
961 | { | |
962 | warning_handler ("font color change attempted is invalid"); | |
1379 | if (!has_param || num < 0 || num >= total_colors) | |
1380 | { | |
1381 | warning_handler("font color change attempted is invalid"); | |
963 | 1382 | } |
964 | 1383 | else |
965 | 1384 | { |
966 | sprintf(str,"#%02x%02x%02x", | |
967 | color_table[num].r, | |
968 | color_table[num].g, | |
969 | color_table[num].b); | |
970 | attr_push(ATTR_FOREGROUND,str); | |
1385 | snprintf(str, 40, "#%02x%02x%02x", | |
1386 | color_table[num].r, | |
1387 | color_table[num].g, | |
1388 | color_table[num].b); | |
1389 | attr_push(ATTR_FOREGROUND, str); | |
971 | 1390 | } |
972 | 1391 | return FALSE; |
973 | 1392 | } |
981 | 1400 | * Returns: Flag, true only if rest of Words on line should be ignored. |
982 | 1401 | *=======================================================================*/ |
983 | 1402 | |
984 | static int | |
985 | cmd_cb (Word *w, int align, char has_param, int num) | |
1403 | static int | |
1404 | cmd_cb(Word *w, int align, char has_param, int num) | |
986 | 1405 | { |
987 | 1406 | char str[40]; |
988 | 1407 | |
989 | if (!has_param || num<0 || num>=total_colors) | |
990 | { | |
991 | warning_handler ("font color change attempted is invalid"); | |
1408 | if (!has_param || num < 0 || num >= total_colors) | |
1409 | { | |
1410 | warning_handler("font color change attempted is invalid"); | |
992 | 1411 | } |
993 | 1412 | else |
994 | 1413 | { |
995 | sprintf(str,"#%02x%02x%02x", | |
996 | color_table[num].r, | |
997 | color_table[num].g, | |
998 | color_table[num].b); | |
999 | attr_push(ATTR_BACKGROUND,str); | |
1414 | snprintf(str, 40, "#%02x%02x%02x", | |
1415 | color_table[num].r, | |
1416 | color_table[num].g, | |
1417 | color_table[num].b); | |
1418 | attr_push(ATTR_BACKGROUND, str); | |
1000 | 1419 | } |
1001 | 1420 | return FALSE; |
1002 | 1421 | } |
1008 | 1427 | * Args: Word, paragraph align info, and numeric param if any. |
1009 | 1428 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1010 | 1429 | *=======================================================================*/ |
1011 | static int | |
1012 | cmd_fs (Word *w, int align, char has_param, int points) { | |
1430 | static int | |
1431 | cmd_fs(Word *w, int align, char has_param, int points) | |
1432 | { | |
1013 | 1433 | char str[20]; |
1014 | 1434 | |
1015 | if (!has_param) return FALSE; | |
1435 | if (!has_param) | |
1436 | { | |
1437 | return FALSE; | |
1438 | } | |
1016 | 1439 | |
1017 | 1440 | /* Note, fs20 means 10pt */ |
1018 | 1441 | points /= 2; |
1019 | 1442 | |
1020 | sprintf(str,"%d",points); | |
1021 | attr_push(ATTR_FONTSIZE,str); | |
1443 | snprintf(str, 20, "%d", points); | |
1444 | attr_push(ATTR_FONTSIZE, str); | |
1022 | 1445 | |
1023 | 1446 | return FALSE; |
1024 | 1447 | } |
1033 | 1456 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1034 | 1457 | *=======================================================================*/ |
1035 | 1458 | |
1036 | static int | |
1037 | cmd_field (Word *w, int align, char has_param, int num) { | |
1459 | static int | |
1460 | cmd_field(Word *w, int align, char has_param, int num) | |
1461 | { | |
1038 | 1462 | Word *child; |
1039 | 1463 | |
1040 | 1464 | CHECK_PARAM_NOT_NULL(w); |
1041 | maybeopeniconv(); | |
1042 | while(w) { | |
1465 | maybeopeniconv(); | |
1466 | while (w) | |
1467 | { | |
1043 | 1468 | child = w->child; |
1044 | if (child) { | |
1469 | if (child) | |
1470 | { | |
1045 | 1471 | Word *w2; |
1046 | 1472 | const char *s; |
1047 | 1473 | |
1048 | 1474 | s = word_string(child); |
1049 | 1475 | if (!s) |
1476 | { | |
1050 | 1477 | return TRUE; |
1478 | } | |
1051 | 1479 | |
1052 | 1480 | #if 1 /* daved experimenting with fldrslt */ |
1053 | if(!strcmp("\\fldrslt", s)) | |
1481 | if (!strcmp("\\fldrslt", s)) | |
1482 | { | |
1054 | 1483 | return FALSE; |
1484 | } | |
1055 | 1485 | #endif |
1056 | 1486 | |
1057 | 1487 | |
1058 | 1488 | if (!strcmp("\\*", s)) |
1059 | 1489 | { |
1060 | w2=child->next; | |
1061 | while (w2) | |
1062 | { | |
1063 | const char *s2 = word_string(w2); | |
1064 | if (s2 && !strcmp("\\fldinst", s2)) | |
1490 | w2 = child->next; | |
1491 | while (w2) | |
1065 | 1492 | { |
1066 | Word *w3; | |
1067 | const char *s; | |
1068 | const char *s4; | |
1069 | Word *w4; | |
1070 | w3=w2->next; | |
1071 | s = word_string(w3); | |
1072 | if (s && !strcmp(s, "SYMBOL") ) | |
1073 | { | |
1074 | w4=w3->next; | |
1075 | while(w4 && word_string(w4) && !strcmp(word_string(w4), " ")) | |
1076 | w4 = w4->next; | |
1077 | s4 = word_string(w4); | |
1078 | if (s4) | |
1079 | { | |
1080 | int char_num; | |
1081 | const char *string; | |
1082 | char_num = atoi(s4); | |
1083 | ||
1084 | string = op_translate_char(op, | |
1085 | FONT_SYMBOL, char_num); | |
1086 | if (string != NULL) | |
1087 | printf("%s", string); | |
1088 | else | |
1089 | fprintf(stderr, "unrtf: Error in translation SYMBOL character %d\n", char_num); | |
1090 | } | |
1091 | } | |
1092 | while (w3 && !w3->child) { | |
1093 | w3=w3->next; | |
1094 | } | |
1095 | if (w3) w3=w3->child; | |
1096 | while (w3) | |
1097 | { | |
1098 | const char *s3=word_string(w3); | |
1099 | if (s3 && !strcmp("EN.CITE", s3)) | |
1100 | { | |
1101 | EndNoteCitations = TRUE; | |
1102 | } | |
1103 | /* | |
1104 | ** If we have a file with EndNote | |
1105 | ** citations, we don't want to | |
1106 | ** insert "hyperlink", we want the | |
1107 | ** citation text, so we return | |
1108 | ** FALSE. (We could extract "<url>" | |
1109 | ** for a link, but probably not | |
1110 | ** wanted.) | |
1111 | */ | |
1112 | ||
1113 | if (s3 && !strcmp("HYPERLINK",s3) && !EndNoteCitations) { | |
1114 | Word *w4; | |
1115 | const char *s4; | |
1116 | w4=w3->next; | |
1117 | while (w4 && word_string(w4) && !strcmp(" ", word_string(w4))) | |
1118 | w4=w4->next; | |
1119 | if (w4) { | |
1120 | s4=word_string(w4); | |
1121 | if (safe_printf(0, op->hyperlink_begin)) fprintf(stderr, TOO_MANY_ARGS, "hyperlink_begin"); | |
1122 | printf("%s", s4); | |
1123 | if (safe_printf(0, op->hyperlink_end)) fprintf(stderr, TOO_MANY_ARGS, "hyperlink_end"); | |
1124 | return TRUE; | |
1125 | } | |
1126 | ||
1127 | } | |
1128 | else | |
1129 | return FALSE; | |
1130 | w3=w3->next; | |
1131 | } | |
1493 | const char *s2 = word_string(w2); | |
1494 | if (s2 && !strcmp("\\fldinst", s2)) | |
1495 | { | |
1496 | Word *w3; | |
1497 | const char *s; | |
1498 | const char *s4; | |
1499 | Word *w4; | |
1500 | w3 = w2->next; | |
1501 | s = word_string(w3); | |
1502 | if (s && !strcmp(s, "SYMBOL")) | |
1503 | { | |
1504 | w4 = w3->next; | |
1505 | while (w4 && word_string(w4) && !strcmp(word_string(w4), " ")) | |
1506 | { | |
1507 | w4 = w4->next; | |
1508 | } | |
1509 | s4 = word_string(w4); | |
1510 | if (s4) | |
1511 | { | |
1512 | int char_num; | |
1513 | const char *string; | |
1514 | char_num = atoi(s4); | |
1515 | ||
1516 | string = op_translate_char(op, | |
1517 | FONT_SYMBOL, char_num); | |
1518 | if (string != NULL) | |
1519 | { | |
1520 | printf("%s", string); | |
1521 | my_free(string); | |
1522 | } | |
1523 | else | |
1524 | { | |
1525 | fprintf(stderr, "unrtf: Error in translation SYMBOL character %d\n", char_num); | |
1526 | } | |
1527 | } | |
1528 | } | |
1529 | while (w3 && !w3->child) | |
1530 | { | |
1531 | w3 = w3->next; | |
1532 | } | |
1533 | if (w3) | |
1534 | { | |
1535 | w3 = w3->child; | |
1536 | } | |
1537 | while (w3) | |
1538 | { | |
1539 | const char *s3 = word_string(w3); | |
1540 | if (s3 && !strcmp("EN.CITE", s3)) | |
1541 | { | |
1542 | EndNoteCitations = TRUE; | |
1543 | } | |
1544 | /* | |
1545 | ** If we have a file with EndNote | |
1546 | ** citations, we don't want to | |
1547 | ** insert "hyperlink", we want the | |
1548 | ** citation text, so we return | |
1549 | ** FALSE. (We could extract "<url>" | |
1550 | ** for a link, but probably not | |
1551 | ** wanted.) | |
1552 | */ | |
1553 | ||
1554 | if (s3 && !strcmp("HYPERLINK", s3) && !EndNoteCitations) | |
1555 | { | |
1556 | Word *w4; | |
1557 | const char *s4; | |
1558 | w4 = w3->next; | |
1559 | while (w4 && word_string(w4) && !strcmp(" ", word_string(w4))) | |
1560 | { | |
1561 | w4 = w4->next; | |
1562 | } | |
1563 | if (w4) | |
1564 | { | |
1565 | s4 = word_string(w4); | |
1566 | if (safe_printf(0, op->hyperlink_begin)) | |
1567 | { | |
1568 | fprintf(stderr, TOO_MANY_ARGS, "hyperlink_begin"); | |
1569 | } | |
1570 | printf("%s", s4); | |
1571 | if (safe_printf(0, op->hyperlink_end)) | |
1572 | { | |
1573 | fprintf(stderr, TOO_MANY_ARGS, "hyperlink_end"); | |
1574 | } | |
1575 | return TRUE; | |
1576 | } | |
1577 | ||
1578 | } | |
1579 | else | |
1580 | { | |
1581 | return FALSE; | |
1582 | } | |
1583 | w3 = w3->next; | |
1584 | } | |
1585 | } | |
1586 | w2 = w2->next; | |
1132 | 1587 | } |
1133 | w2 = w2->next; | |
1134 | } | |
1135 | ||
1588 | ||
1136 | 1589 | } |
1137 | 1590 | } |
1138 | w=w->next; | |
1591 | w = w->next; | |
1139 | 1592 | } |
1140 | 1593 | return TRUE; |
1141 | 1594 | } |
1146 | 1599 | * Args: Word, paragraph align info, and numeric param if any. |
1147 | 1600 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1148 | 1601 | *=======================================================================*/ |
1149 | static int | |
1150 | cmd_f (Word *w, int align, char has_param, int num) | |
1151 | { | |
1152 | char *name; | |
1153 | ||
1154 | /* no param exit early XX */ | |
1155 | if (!has_param) | |
1156 | return FALSE; | |
1157 | FontEntry *e = lookup_font(num); | |
1158 | name = e ? e->name : NULL; | |
1159 | if (!e || !name) { | |
1160 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1161 | printf("invalid font number %d",num); | |
1162 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1163 | } else { | |
1164 | if (op->fonttable_begin != NULL) | |
1165 | { | |
1166 | // TOBEDONE: WHAT'S THIS ??? | |
1167 | name = my_malloc(12); | |
1168 | sprintf(name, "%d", num); | |
1169 | } | |
1170 | ||
1171 | /* we are going to output entities, so should not output font */ | |
1172 | if(strstr(name,"Symbol") == NULL) | |
1173 | attr_push(ATTR_FONTFACE,name); | |
1174 | ||
1175 | desc = my_iconv_close(desc); | |
1176 | char *encoding = default_encoding; | |
1177 | if (e->encoding && *e->encoding) { | |
1178 | encoding = e->encoding; | |
1179 | attr_push(ATTR_ENCODING, encoding); | |
1180 | } | |
1181 | desc = my_iconv_open(output_encoding, encoding); | |
1182 | set_current_encoding(encoding); | |
1183 | } | |
1184 | ||
1185 | return FALSE; | |
1602 | static int | |
1603 | cmd_f(Word *w, int align, char has_param, int num) | |
1604 | { | |
1605 | char *name; | |
1606 | ||
1607 | /* no param exit early XX */ | |
1608 | if (!has_param) | |
1609 | { | |
1610 | return FALSE; | |
1611 | } | |
1612 | FontEntry *e = lookup_font(num); | |
1613 | name = e ? e->name : NULL; | |
1614 | if (!e || !name) | |
1615 | { | |
1616 | if (safe_printf(0, op->comment_begin)) | |
1617 | { | |
1618 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
1619 | } | |
1620 | printf("invalid font number %d", num); | |
1621 | if (safe_printf(0, op->comment_end)) | |
1622 | { | |
1623 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
1624 | } | |
1625 | } | |
1626 | else | |
1627 | { | |
1628 | if (op->fonttable_begin != NULL) | |
1629 | { | |
1630 | // TOBEDONE: WHAT'S THIS ??? | |
1631 | name = my_malloc(12); | |
1632 | snprintf(name, 12, "%d", num); | |
1633 | } | |
1634 | ||
1635 | /* we are going to output entities, so should not output font */ | |
1636 | if (strstr(name, "Symbol") == NULL) | |
1637 | { | |
1638 | attr_push(ATTR_FONTFACE, name); | |
1639 | } | |
1640 | ||
1641 | desc = my_iconv_close(desc); | |
1642 | char *encoding = default_encoding; | |
1643 | if (e->encoding && *e->encoding) | |
1644 | { | |
1645 | encoding = e->encoding; | |
1646 | attr_push(ATTR_ENCODING, encoding); | |
1647 | } | |
1648 | desc = my_iconv_open(output_encoding, encoding); | |
1649 | set_current_encoding(encoding); | |
1650 | } | |
1651 | ||
1652 | return FALSE; | |
1186 | 1653 | } |
1187 | 1654 | |
1188 | 1655 | /*======================================================================== |
1191 | 1658 | * Args: Word, paragraph align info, and numeric param if any. |
1192 | 1659 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1193 | 1660 | *=======================================================================*/ |
1194 | static int | |
1195 | cmd_deff (Word *w, int align, char has_param, int num) | |
1196 | { | |
1197 | if (has_param) | |
1198 | default_font_number = num; | |
1199 | return FALSE; | |
1661 | static int | |
1662 | cmd_deff(Word *w, int align, char has_param, int num) | |
1663 | { | |
1664 | if (has_param) | |
1665 | { | |
1666 | default_font_number = num; | |
1667 | } | |
1668 | return FALSE; | |
1200 | 1669 | } |
1201 | 1670 | |
1202 | 1671 | /*======================================================================== |
1206 | 1675 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1207 | 1676 | *=======================================================================*/ |
1208 | 1677 | |
1209 | static int | |
1210 | cmd_highlight (Word *w, int align, char has_param, int num) | |
1678 | static int | |
1679 | cmd_highlight(Word *w, int align, char has_param, int num) | |
1211 | 1680 | { |
1212 | 1681 | char str[40]; |
1213 | 1682 | |
1214 | if (!has_param || num<0 || num>=total_colors) | |
1215 | { | |
1216 | warning_handler ("font background color change attempted is invalid"); | |
1683 | if (!has_param || num < 0 || num >= total_colors) | |
1684 | { | |
1685 | warning_handler("font background color change attempted is invalid"); | |
1217 | 1686 | } |
1218 | 1687 | else |
1219 | 1688 | { |
1220 | sprintf(str,"#%02x%02x%02x", | |
1221 | color_table[num].r, | |
1222 | color_table[num].g, | |
1223 | color_table[num].b); | |
1224 | attr_push(ATTR_BACKGROUND,str); | |
1689 | snprintf(str, 40, "#%02x%02x%02x", | |
1690 | color_table[num].r, | |
1691 | color_table[num].g, | |
1692 | color_table[num].b); | |
1693 | attr_push(ATTR_BACKGROUND, str); | |
1225 | 1694 | } |
1226 | 1695 | return FALSE; |
1227 | 1696 | } |
1235 | 1704 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1236 | 1705 | *=======================================================================*/ |
1237 | 1706 | |
1238 | static int | |
1239 | cmd_tab (Word *w, int align, char has_param, int param) | |
1707 | static int | |
1708 | cmd_tab(Word *w, int align, char has_param, int param) | |
1240 | 1709 | { |
1241 | 1710 | /* Tab presents a genuine problem |
1242 | * since some output formats don't have | |
1243 | * an equivalent. As a kludge fix, I shall | |
1711 | * since some output formats don't have | |
1712 | * an equivalent. As a kludge fix, I shall | |
1244 | 1713 | * assume the font is fixed width and that |
1245 | 1714 | * the tabstops are 8 characters apart. |
1246 | 1715 | */ |
1247 | int need= 8-(total_chars_this_line%8); | |
1716 | int need = 8 - (total_chars_this_line % 8); | |
1248 | 1717 | total_chars_this_line += need; |
1249 | while(need>0) { | |
1250 | if (safe_printf(0, op->forced_space)) fprintf(stderr, TOO_MANY_ARGS, "forced_space"); | |
1718 | while (need > 0) | |
1719 | { | |
1720 | if (safe_printf(0, op->forced_space)) | |
1721 | { | |
1722 | fprintf(stderr, TOO_MANY_ARGS, "forced_space"); | |
1723 | } | |
1251 | 1724 | need--; |
1252 | 1725 | } |
1253 | 1726 | printf("\n"); |
1262 | 1735 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1263 | 1736 | *=======================================================================*/ |
1264 | 1737 | |
1265 | static int | |
1266 | cmd_plain (Word *w, int align, char has_param, int param) { | |
1738 | static int | |
1739 | cmd_plain(Word *w, int align, char has_param, int param) | |
1740 | { | |
1267 | 1741 | attr_pop_all(); |
1268 | 1742 | return FALSE; |
1269 | 1743 | } |
1275 | 1749 | * Args: Word, paragraph align info, and numeric param if any. |
1276 | 1750 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1277 | 1751 | *=======================================================================*/ |
1278 | static int | |
1279 | cmd_fnil (Word *w, int align, char has_param, int param) { | |
1280 | attr_push(ATTR_FONTFACE,FONTNIL_STR); | |
1752 | static int | |
1753 | cmd_fnil(Word *w, int align, char has_param, int param) | |
1754 | { | |
1755 | attr_push(ATTR_FONTFACE, FONTNIL_STR); | |
1281 | 1756 | return FALSE; |
1282 | 1757 | } |
1283 | 1758 | |
1289 | 1764 | * Args: Word, paragraph align info, and numeric param if any. |
1290 | 1765 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1291 | 1766 | *=======================================================================*/ |
1292 | static int | |
1293 | cmd_froman (Word *w, int align, char has_param, int param) { | |
1294 | attr_push(ATTR_FONTFACE,FONTROMAN_STR); | |
1767 | static int | |
1768 | cmd_froman(Word *w, int align, char has_param, int param) | |
1769 | { | |
1770 | attr_push(ATTR_FONTFACE, FONTROMAN_STR); | |
1295 | 1771 | return FALSE; |
1296 | 1772 | } |
1297 | 1773 | |
1303 | 1779 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1304 | 1780 | *=======================================================================*/ |
1305 | 1781 | |
1306 | static int | |
1307 | cmd_fswiss (Word *w, int align, char has_param, int param) { | |
1308 | attr_push(ATTR_FONTFACE,FONTSWISS_STR); | |
1782 | static int | |
1783 | cmd_fswiss(Word *w, int align, char has_param, int param) | |
1784 | { | |
1785 | attr_push(ATTR_FONTFACE, FONTSWISS_STR); | |
1309 | 1786 | return FALSE; |
1310 | 1787 | } |
1311 | 1788 | |
1317 | 1794 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1318 | 1795 | *=======================================================================*/ |
1319 | 1796 | |
1320 | static int | |
1321 | cmd_fmodern (Word *w, int align, char has_param, int param) { | |
1322 | attr_push(ATTR_FONTFACE,FONTMODERN_STR); | |
1797 | static int | |
1798 | cmd_fmodern(Word *w, int align, char has_param, int param) | |
1799 | { | |
1800 | attr_push(ATTR_FONTFACE, FONTMODERN_STR); | |
1323 | 1801 | return FALSE; |
1324 | 1802 | } |
1325 | 1803 | |
1331 | 1809 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1332 | 1810 | *=======================================================================*/ |
1333 | 1811 | |
1334 | static int | |
1335 | cmd_fscript (Word *w, int align, char has_param, int param) { | |
1336 | attr_push(ATTR_FONTFACE,FONTSCRIPT_STR); | |
1812 | static int | |
1813 | cmd_fscript(Word *w, int align, char has_param, int param) | |
1814 | { | |
1815 | attr_push(ATTR_FONTFACE, FONTSCRIPT_STR); | |
1337 | 1816 | return FALSE; |
1338 | 1817 | } |
1339 | 1818 | |
1344 | 1823 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1345 | 1824 | *=======================================================================*/ |
1346 | 1825 | |
1347 | static int | |
1348 | cmd_fdecor (Word *w, int align, char has_param, int param) { | |
1349 | attr_push(ATTR_FONTFACE,FONTDECOR_STR); | |
1826 | static int | |
1827 | cmd_fdecor(Word *w, int align, char has_param, int param) | |
1828 | { | |
1829 | attr_push(ATTR_FONTFACE, FONTDECOR_STR); | |
1350 | 1830 | return FALSE; |
1351 | 1831 | } |
1352 | 1832 | |
1357 | 1837 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1358 | 1838 | *=======================================================================*/ |
1359 | 1839 | |
1360 | static int | |
1361 | cmd_ftech (Word *w, int align, char has_param, int param) { | |
1362 | attr_push(ATTR_FONTFACE,FONTTECH_STR); | |
1840 | static int | |
1841 | cmd_ftech(Word *w, int align, char has_param, int param) | |
1842 | { | |
1843 | attr_push(ATTR_FONTFACE, FONTTECH_STR); | |
1363 | 1844 | return FALSE; |
1364 | 1845 | } |
1365 | 1846 | |
1370 | 1851 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1371 | 1852 | *=======================================================================*/ |
1372 | 1853 | |
1373 | static int | |
1374 | cmd_expand (Word *w, int align, char has_param, int param) { | |
1375 | char str[10]; | |
1376 | if (has_param) { | |
1377 | sprintf(str, "%d", param/4); | |
1378 | if (!param) | |
1854 | static int | |
1855 | cmd_expand(Word *w, int align, char has_param, int param) | |
1856 | { | |
1857 | char str[20]; | |
1858 | if (has_param) | |
1859 | { | |
1860 | snprintf(str, 20, "%d", param / 4); | |
1861 | if (!param) | |
1862 | { | |
1379 | 1863 | attr_pop(ATTR_EXPAND); |
1380 | else | |
1864 | } | |
1865 | else | |
1866 | { | |
1381 | 1867 | attr_push(ATTR_EXPAND, str); |
1868 | } | |
1382 | 1869 | } |
1383 | 1870 | return FALSE; |
1384 | 1871 | } |
1391 | 1878 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1392 | 1879 | *=======================================================================*/ |
1393 | 1880 | |
1394 | static int | |
1395 | cmd_emboss (Word *w, int align, char has_param, int param) { | |
1396 | char str[10]; | |
1881 | static int | |
1882 | cmd_emboss(Word *w, int align, char has_param, int param) | |
1883 | { | |
1884 | char str[20]; | |
1397 | 1885 | if (has_param && !param) |
1398 | 1886 | #ifdef SUPPORT_UNNESTED |
1399 | 1887 | attr_find_pop(ATTR_EMBOSS); |
1402 | 1890 | #endif |
1403 | 1891 | else |
1404 | 1892 | { |
1405 | sprintf(str, "%d", param); | |
1893 | snprintf(str, 20, "%d", param); | |
1406 | 1894 | attr_push(ATTR_EMBOSS, str); |
1407 | 1895 | } |
1408 | 1896 | return FALSE; |
1416 | 1904 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1417 | 1905 | *=======================================================================*/ |
1418 | 1906 | |
1419 | static int | |
1420 | cmd_engrave (Word *w, int align, char has_param, int param) { | |
1421 | char str[10]; | |
1422 | if (has_param && !param) | |
1907 | static int | |
1908 | cmd_engrave(Word *w, int align, char has_param, int param) | |
1909 | { | |
1910 | char str[20]; | |
1911 | if (has_param && !param) | |
1912 | { | |
1423 | 1913 | attr_pop(ATTR_ENGRAVE); |
1914 | } | |
1424 | 1915 | else |
1425 | 1916 | { |
1426 | sprintf(str, "%d", param); | |
1917 | snprintf(str, 20, "%d", param); | |
1427 | 1918 | attr_push(ATTR_ENGRAVE, str); |
1428 | 1919 | } |
1429 | 1920 | return FALSE; |
1436 | 1927 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1437 | 1928 | *=======================================================================*/ |
1438 | 1929 | |
1439 | static int | |
1440 | cmd_caps (Word *w, int align, char has_param, int param) { | |
1930 | static int | |
1931 | cmd_caps(Word *w, int align, char has_param, int param) | |
1932 | { | |
1441 | 1933 | if (has_param && !param) |
1934 | { | |
1442 | 1935 | attr_pop(ATTR_CAPS); |
1443 | else | |
1444 | attr_push(ATTR_CAPS,NULL); | |
1936 | } | |
1937 | else | |
1938 | { | |
1939 | attr_push(ATTR_CAPS, NULL); | |
1940 | } | |
1445 | 1941 | return FALSE; |
1446 | 1942 | } |
1447 | 1943 | |
1452 | 1948 | * Args: Word, paragraph align info, and numeric param if any. |
1453 | 1949 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1454 | 1950 | *=======================================================================*/ |
1455 | static int | |
1456 | cmd_scaps (Word *w, int align, char has_param, int param) { | |
1951 | static int | |
1952 | cmd_scaps(Word *w, int align, char has_param, int param) | |
1953 | { | |
1457 | 1954 | if (has_param && !param) |
1955 | { | |
1458 | 1956 | attr_pop(ATTR_SMALLCAPS); |
1459 | else | |
1460 | attr_push(ATTR_SMALLCAPS,NULL); | |
1957 | } | |
1958 | else | |
1959 | { | |
1960 | attr_push(ATTR_SMALLCAPS, NULL); | |
1961 | } | |
1461 | 1962 | return FALSE; |
1462 | 1963 | } |
1463 | 1964 | |
1468 | 1969 | * Args: Word, paragraph align info, and numeric param if any. |
1469 | 1970 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1470 | 1971 | *=======================================================================*/ |
1471 | static int | |
1472 | cmd_bullet (Word *w, int align, char has_param, int param) { | |
1473 | if (op->chars.bullet) { | |
1474 | if (safe_printf(0, op->chars.bullet)) fprintf(stderr, TOO_MANY_ARGS, "chars.bullet"); | |
1972 | static int | |
1973 | cmd_bullet(Word *w, int align, char has_param, int param) | |
1974 | { | |
1975 | if (op->chars.bullet) | |
1976 | { | |
1977 | if (safe_printf(0, op->chars.bullet)) | |
1978 | { | |
1979 | fprintf(stderr, TOO_MANY_ARGS, "chars.bullet"); | |
1980 | } | |
1475 | 1981 | ++total_chars_this_line; /* \tab */ |
1476 | 1982 | } |
1477 | 1983 | return FALSE; |
1483 | 1989 | * Args: Word, paragraph align info, and numeric param if any. |
1484 | 1990 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1485 | 1991 | *=======================================================================*/ |
1486 | static int | |
1487 | cmd_ldblquote (Word *w, int align, char has_param, int param) { | |
1488 | if (op->chars.left_dbl_quote) { | |
1489 | if (safe_printf(0, op->chars.left_dbl_quote)) fprintf(stderr, TOO_MANY_ARGS, "chars.left_dbl_quote"); | |
1992 | static int | |
1993 | cmd_ldblquote(Word *w, int align, char has_param, int param) | |
1994 | { | |
1995 | if (op->chars.left_dbl_quote) | |
1996 | { | |
1997 | if (safe_printf(0, op->chars.left_dbl_quote)) | |
1998 | { | |
1999 | fprintf(stderr, TOO_MANY_ARGS, "chars.left_dbl_quote"); | |
2000 | } | |
1490 | 2001 | ++total_chars_this_line; /* \tab */ |
1491 | 2002 | } |
1492 | 2003 | return FALSE; |
1500 | 2011 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1501 | 2012 | *=======================================================================*/ |
1502 | 2013 | |
1503 | static int | |
1504 | cmd_rdblquote (Word *w, int align, char has_param, int param) { | |
1505 | if (op->chars.right_dbl_quote) { | |
1506 | if (safe_printf(0, op->chars.right_dbl_quote)) fprintf(stderr, TOO_MANY_ARGS, "chars.right_dbl_quote"); | |
2014 | static int | |
2015 | cmd_rdblquote(Word *w, int align, char has_param, int param) | |
2016 | { | |
2017 | if (op->chars.right_dbl_quote) | |
2018 | { | |
2019 | if (safe_printf(0, op->chars.right_dbl_quote)) | |
2020 | { | |
2021 | fprintf(stderr, TOO_MANY_ARGS, "chars.right_dbl_quote"); | |
2022 | } | |
1507 | 2023 | ++total_chars_this_line; /* \tab */ |
1508 | 2024 | } |
1509 | 2025 | return FALSE; |
1516 | 2032 | * Args: Word, paragraph align info, and numeric param if any. |
1517 | 2033 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1518 | 2034 | *=======================================================================*/ |
1519 | static int | |
1520 | cmd_lquote (Word *w, int align, char has_param, int param) { | |
1521 | if (op->chars.left_quote) { | |
1522 | if (safe_printf(0, op->chars.left_quote)) fprintf(stderr, TOO_MANY_ARGS, "chars.left_quote"); | |
2035 | static int | |
2036 | cmd_lquote(Word *w, int align, char has_param, int param) | |
2037 | { | |
2038 | if (op->chars.left_quote) | |
2039 | { | |
2040 | if (safe_printf(0, op->chars.left_quote)) | |
2041 | { | |
2042 | fprintf(stderr, TOO_MANY_ARGS, "chars.left_quote"); | |
2043 | } | |
1523 | 2044 | ++total_chars_this_line; /* \tab */ |
1524 | 2045 | } |
1525 | 2046 | return FALSE; |
1533 | 2054 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1534 | 2055 | *=======================================================================*/ |
1535 | 2056 | |
1536 | static int | |
1537 | cmd_nonbreaking_space (Word *w, int align, char has_param, int param) { | |
1538 | if (op->chars.nonbreaking_space) { | |
1539 | if (safe_printf(0, op->chars.nonbreaking_space)) fprintf(stderr, TOO_MANY_ARGS, "chars.nonbreaking_space"); | |
2057 | static int | |
2058 | cmd_nonbreaking_space(Word *w, int align, char has_param, int param) | |
2059 | { | |
2060 | if (op->chars.nonbreaking_space) | |
2061 | { | |
2062 | if (safe_printf(0, op->chars.nonbreaking_space)) | |
2063 | { | |
2064 | fprintf(stderr, TOO_MANY_ARGS, "chars.nonbreaking_space"); | |
2065 | } | |
1540 | 2066 | ++total_chars_this_line; /* \tab */ |
1541 | 2067 | } |
1542 | 2068 | return FALSE; |
1550 | 2076 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1551 | 2077 | *=======================================================================*/ |
1552 | 2078 | |
1553 | static int | |
1554 | cmd_nonbreaking_hyphen (Word *w, int align, char has_param, int param) { | |
1555 | if (op->chars.nonbreaking_hyphen) { | |
1556 | if (safe_printf(0, op->chars.nonbreaking_hyphen)) fprintf(stderr, TOO_MANY_ARGS, "chars.nonbreaking_hyphen"); | |
2079 | static int | |
2080 | cmd_nonbreaking_hyphen(Word *w, int align, char has_param, int param) | |
2081 | { | |
2082 | if (op->chars.nonbreaking_hyphen) | |
2083 | { | |
2084 | if (safe_printf(0, op->chars.nonbreaking_hyphen)) | |
2085 | { | |
2086 | fprintf(stderr, TOO_MANY_ARGS, "chars.nonbreaking_hyphen"); | |
2087 | } | |
1557 | 2088 | ++total_chars_this_line; /* \tab */ |
1558 | 2089 | } |
1559 | 2090 | return FALSE; |
1567 | 2098 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1568 | 2099 | *=======================================================================*/ |
1569 | 2100 | |
1570 | static int | |
1571 | cmd_optional_hyphen (Word *w, int align, char has_param, int param) { | |
1572 | if (op->chars.optional_hyphen) { | |
1573 | if (safe_printf(0, op->chars.optional_hyphen)) fprintf(stderr, TOO_MANY_ARGS, "chars.optional_hyphen"); | |
2101 | static int | |
2102 | cmd_optional_hyphen(Word *w, int align, char has_param, int param) | |
2103 | { | |
2104 | if (op->chars.optional_hyphen) | |
2105 | { | |
2106 | if (safe_printf(0, op->chars.optional_hyphen)) | |
2107 | { | |
2108 | fprintf(stderr, TOO_MANY_ARGS, "chars.optional_hyphen"); | |
2109 | } | |
1574 | 2110 | ++total_chars_this_line; /* \tab */ |
1575 | 2111 | } |
1576 | 2112 | return FALSE; |
1583 | 2119 | * Args: Word, paragraph align info, and numeric param if any. |
1584 | 2120 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1585 | 2121 | *=======================================================================*/ |
1586 | static int | |
1587 | cmd_emdash (Word *w, int align, char has_param, int param) { | |
1588 | if (op->chars.emdash) { | |
1589 | if (safe_printf(0, op->chars.emdash)) fprintf(stderr, TOO_MANY_ARGS, "chars.emdash"); | |
2122 | static int | |
2123 | cmd_emdash(Word *w, int align, char has_param, int param) | |
2124 | { | |
2125 | if (op->chars.emdash) | |
2126 | { | |
2127 | if (safe_printf(0, op->chars.emdash)) | |
2128 | { | |
2129 | fprintf(stderr, TOO_MANY_ARGS, "chars.emdash"); | |
2130 | } | |
1590 | 2131 | ++total_chars_this_line; /* \tab */ |
1591 | 2132 | } |
1592 | 2133 | return FALSE; |
1600 | 2141 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1601 | 2142 | *=======================================================================*/ |
1602 | 2143 | |
1603 | static int | |
1604 | cmd_endash (Word *w, int align, char has_param, int param) { | |
1605 | if (op->chars.endash) { | |
1606 | if (safe_printf(0, op->chars.endash)) fprintf(stderr, TOO_MANY_ARGS, "chars.endash"); | |
2144 | static int | |
2145 | cmd_endash(Word *w, int align, char has_param, int param) | |
2146 | { | |
2147 | if (op->chars.endash) | |
2148 | { | |
2149 | if (safe_printf(0, op->chars.endash)) | |
2150 | { | |
2151 | fprintf(stderr, TOO_MANY_ARGS, "chars.endash"); | |
2152 | } | |
1607 | 2153 | ++total_chars_this_line; /* \tab */ |
1608 | 2154 | } |
1609 | 2155 | return FALSE; |
1617 | 2163 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1618 | 2164 | *=======================================================================*/ |
1619 | 2165 | |
1620 | static int | |
1621 | cmd_rquote (Word *w, int align, char has_param, int param) { | |
1622 | if (op->chars.right_quote) { | |
1623 | if (safe_printf(0, op->chars.right_quote)) fprintf(stderr, TOO_MANY_ARGS, "chars.right_quote"); | |
2166 | static int | |
2167 | cmd_rquote(Word *w, int align, char has_param, int param) | |
2168 | { | |
2169 | if (op->chars.right_quote) | |
2170 | { | |
2171 | if (safe_printf(0, op->chars.right_quote)) | |
2172 | { | |
2173 | fprintf(stderr, TOO_MANY_ARGS, "chars.right_quote"); | |
2174 | } | |
1624 | 2175 | ++total_chars_this_line; /* \tab */ |
1625 | 2176 | } |
1626 | 2177 | return FALSE; |
1633 | 2184 | * Args: Word, paragraph align info, and numeric param if any. |
1634 | 2185 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1635 | 2186 | *=======================================================================*/ |
1636 | static int | |
1637 | cmd_par (Word *w, int align, char has_param, int param) { | |
1638 | if (op->line_break) { | |
1639 | if (safe_printf(0, op->line_break)) fprintf(stderr, TOO_MANY_ARGS, "line_break"); | |
2187 | static int | |
2188 | cmd_par(Word *w, int align, char has_param, int param) | |
2189 | { | |
2190 | if (op->line_break) | |
2191 | { | |
2192 | if (safe_printf(0, op->line_break)) | |
2193 | { | |
2194 | fprintf(stderr, TOO_MANY_ARGS, "line_break"); | |
2195 | } | |
1640 | 2196 | total_chars_this_line = 0; /* \tab */ |
1641 | 2197 | } |
1642 | 2198 | return FALSE; |
1650 | 2206 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1651 | 2207 | *=======================================================================*/ |
1652 | 2208 | |
1653 | static int | |
1654 | cmd_line (Word *w, int align, char has_param, int param) { | |
1655 | if (op->line_break) { | |
1656 | if (safe_printf(0, op->line_break)) fprintf(stderr, TOO_MANY_ARGS, "line_break"); | |
2209 | static int | |
2210 | cmd_line(Word *w, int align, char has_param, int param) | |
2211 | { | |
2212 | if (op->line_break) | |
2213 | { | |
2214 | if (safe_printf(0, op->line_break)) | |
2215 | { | |
2216 | fprintf(stderr, TOO_MANY_ARGS, "line_break"); | |
2217 | } | |
1657 | 2218 | total_chars_this_line = 0; /* \tab */ |
1658 | 2219 | } |
1659 | 2220 | return FALSE; |
1667 | 2228 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1668 | 2229 | *=======================================================================*/ |
1669 | 2230 | |
1670 | static int cmd_page (Word *w, int align, char has_param, int param) { | |
1671 | if (op->page_break) { | |
1672 | if (safe_printf(0, op->page_break)) fprintf(stderr, TOO_MANY_ARGS, "page_break"); | |
2231 | static int cmd_page(Word *w, int align, char has_param, int param) | |
2232 | { | |
2233 | if (op->page_break) | |
2234 | { | |
2235 | if (safe_printf(0, op->page_break)) | |
2236 | { | |
2237 | fprintf(stderr, TOO_MANY_ARGS, "page_break"); | |
2238 | } | |
1673 | 2239 | total_chars_this_line = 0; /* \tab */ |
1674 | 2240 | } |
1675 | 2241 | return FALSE; |
1683 | 2249 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1684 | 2250 | *=======================================================================*/ |
1685 | 2251 | |
1686 | static int cmd_intbl (Word *w, int align, char has_param, int param) { | |
2252 | static int cmd_intbl(Word *w, int align, char has_param, int param) | |
2253 | { | |
1687 | 2254 | ++coming_pars_that_are_tabular; |
1688 | 2255 | |
1689 | 2256 | check_for_table(); |
1699 | 2266 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1700 | 2267 | *=======================================================================*/ |
1701 | 2268 | |
1702 | static int cmd_ulnone (Word *w, int align, char has_param, int param) | |
1703 | { | |
1704 | ||
1705 | #ifdef BINARY_ATTRS | |
1706 | attr_remove_underlining()) fprintf(stderr, TOO_MANY_ARGS, ); | |
1707 | #else | |
1708 | do { | |
1709 | int attr = attr_read(); | |
1710 | if (attr==ATTR_UNDERLINE || | |
1711 | attr==ATTR_DOT_UL || | |
1712 | attr==ATTR_DASH_UL || | |
1713 | attr==ATTR_DOT_DASH_UL || | |
1714 | attr==ATTR_2DOT_DASH_UL || | |
1715 | attr==ATTR_WORD_UL || | |
1716 | attr==ATTR_WAVE_UL || | |
1717 | attr==ATTR_THICK_UL || | |
1718 | attr==ATTR_DOUBLE_UL) | |
1719 | { | |
1720 | /* Top attr is some kind of underline. Pop it */ | |
1721 | if (!attr_pop(attr)) { | |
1722 | /* ?? Have to break, else we're looping */ | |
1723 | break; | |
1724 | } | |
1725 | } else { | |
1726 | /* Top attr not underline, done */ | |
1727 | break; | |
1728 | } | |
1729 | } while (1); | |
1730 | #endif | |
2269 | static int cmd_ulnone(Word *w, int align, char has_param, int param) | |
2270 | { | |
2271 | attr_find_pop(ATTR_UNDERLINE); | |
2272 | attr_find_pop(ATTR_DOT_UL); | |
2273 | attr_find_pop(ATTR_DASH_UL); | |
2274 | attr_find_pop(ATTR_DOT_DASH_UL); | |
2275 | attr_find_pop(ATTR_2DOT_DASH_UL); | |
2276 | attr_find_pop(ATTR_WORD_UL); | |
2277 | attr_find_pop(ATTR_WAVE_UL); | |
2278 | attr_find_pop(ATTR_THICK_UL); | |
2279 | attr_find_pop(ATTR_DOUBLE_UL); | |
1731 | 2280 | return FALSE; |
1732 | 2281 | } |
1733 | 2282 | |
1738 | 2287 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1739 | 2288 | *=======================================================================*/ |
1740 | 2289 | |
1741 | static int cmd_ul (Word *w, int align, char has_param, int param) { | |
1742 | if (has_param && param == 0) { | |
2290 | static int cmd_ul(Word *w, int align, char has_param, int param) | |
2291 | { | |
2292 | if (has_param && param == 0) | |
2293 | { | |
1743 | 2294 | cmd_ulnone(w, align, has_param, param); |
1744 | } else { | |
2295 | } | |
2296 | else | |
2297 | { | |
1745 | 2298 | attr_push(ATTR_UNDERLINE, NULL); |
1746 | 2299 | } |
1747 | 2300 | return FALSE; |
1754 | 2307 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1755 | 2308 | *=======================================================================*/ |
1756 | 2309 | |
1757 | static int cmd_uld (Word *w, int align, char has_param, int param) { | |
2310 | static int cmd_uld(Word *w, int align, char has_param, int param) | |
2311 | { | |
1758 | 2312 | attr_push(ATTR_DOUBLE_UL, NULL); |
1759 | 2313 | return FALSE; |
1760 | 2314 | } |
1766 | 2320 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1767 | 2321 | *=======================================================================*/ |
1768 | 2322 | |
1769 | static int cmd_uldb (Word *w, int align, char has_param, int param) { | |
2323 | static int cmd_uldb(Word *w, int align, char has_param, int param) | |
2324 | { | |
1770 | 2325 | attr_push(ATTR_DOT_UL, NULL); |
1771 | 2326 | return FALSE; |
1772 | 2327 | } |
1779 | 2334 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1780 | 2335 | *=======================================================================*/ |
1781 | 2336 | |
1782 | static int cmd_uldash (Word *w, int align, char has_param, int param) { | |
2337 | static int cmd_uldash(Word *w, int align, char has_param, int param) | |
2338 | { | |
1783 | 2339 | attr_push(ATTR_DASH_UL, NULL); |
1784 | 2340 | return FALSE; |
1785 | 2341 | } |
1792 | 2348 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1793 | 2349 | *=======================================================================*/ |
1794 | 2350 | |
1795 | static int cmd_uldashd (Word *w, int align, char has_param, int param) { | |
1796 | attr_push(ATTR_DOT_DASH_UL,NULL); | |
2351 | static int cmd_uldashd(Word *w, int align, char has_param, int param) | |
2352 | { | |
2353 | attr_push(ATTR_DOT_DASH_UL, NULL); | |
1797 | 2354 | return FALSE; |
1798 | 2355 | } |
1799 | 2356 | |
1805 | 2362 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1806 | 2363 | *=======================================================================*/ |
1807 | 2364 | |
1808 | static int cmd_uldashdd (Word *w, int align, char has_param, int param) { | |
1809 | attr_push(ATTR_2DOT_DASH_UL,NULL); | |
2365 | static int cmd_uldashdd(Word *w, int align, char has_param, int param) | |
2366 | { | |
2367 | attr_push(ATTR_2DOT_DASH_UL, NULL); | |
1810 | 2368 | return FALSE; |
1811 | 2369 | } |
1812 | 2370 | |
1818 | 2376 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1819 | 2377 | *=======================================================================*/ |
1820 | 2378 | |
1821 | static int cmd_ulw (Word *w, int align, char has_param, int param) { | |
1822 | attr_push(ATTR_WORD_UL,NULL); | |
2379 | static int cmd_ulw(Word *w, int align, char has_param, int param) | |
2380 | { | |
2381 | attr_push(ATTR_WORD_UL, NULL); | |
1823 | 2382 | return FALSE; |
1824 | 2383 | } |
1825 | 2384 | |
1831 | 2390 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1832 | 2391 | *=======================================================================*/ |
1833 | 2392 | |
1834 | static int cmd_ulth (Word *w, int align, char has_param, int param) { | |
1835 | attr_push(ATTR_THICK_UL,NULL); | |
2393 | static int cmd_ulth(Word *w, int align, char has_param, int param) | |
2394 | { | |
2395 | attr_push(ATTR_THICK_UL, NULL); | |
1836 | 2396 | return FALSE; |
1837 | 2397 | } |
1838 | 2398 | |
1844 | 2404 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1845 | 2405 | *=======================================================================*/ |
1846 | 2406 | |
1847 | static int cmd_ulthd (Word *w, int align, char has_param, int param) { | |
2407 | static int cmd_ulthd(Word *w, int align, char has_param, int param) | |
2408 | { | |
1848 | 2409 | attr_push(ATTR_THICK_UL, NULL); |
1849 | 2410 | return FALSE; |
1850 | 2411 | } |
1857 | 2418 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1858 | 2419 | *=======================================================================*/ |
1859 | 2420 | |
1860 | static int cmd_ulthdash (Word *w, int align, char has_param, int param) { | |
2421 | static int cmd_ulthdash(Word *w, int align, char has_param, int param) | |
2422 | { | |
1861 | 2423 | attr_push(ATTR_THICK_UL, NULL); |
1862 | 2424 | return FALSE; |
1863 | 2425 | } |
1870 | 2432 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1871 | 2433 | *=======================================================================*/ |
1872 | 2434 | |
1873 | static int cmd_ulwave (Word *w, int align, char has_param, int param) { | |
1874 | attr_push(ATTR_WAVE_UL,NULL); | |
2435 | static int cmd_ulwave(Word *w, int align, char has_param, int param) | |
2436 | { | |
2437 | attr_push(ATTR_WAVE_UL, NULL); | |
1875 | 2438 | return FALSE; |
1876 | 2439 | } |
1877 | 2440 | |
1883 | 2446 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1884 | 2447 | *=======================================================================*/ |
1885 | 2448 | |
1886 | static int cmd_strike (Word *w, int align, char has_param, int param) { | |
1887 | if (has_param && param==0) | |
2449 | static int cmd_strike(Word *w, int align, char has_param, int param) | |
2450 | { | |
2451 | if (has_param && param == 0) | |
2452 | { | |
1888 | 2453 | attr_pop(ATTR_STRIKE); |
2454 | } | |
1889 | 2455 | else |
1890 | attr_push(ATTR_STRIKE,NULL); | |
2456 | { | |
2457 | attr_push(ATTR_STRIKE, NULL); | |
2458 | } | |
1891 | 2459 | return FALSE; |
1892 | 2460 | } |
1893 | 2461 | |
1898 | 2466 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1899 | 2467 | *=======================================================================*/ |
1900 | 2468 | |
1901 | static int cmd_strikedl (Word *w, int align, char has_param, int param) { | |
1902 | if (has_param && param==0) | |
2469 | static int cmd_strikedl(Word *w, int align, char has_param, int param) | |
2470 | { | |
2471 | if (has_param && param == 0) | |
2472 | { | |
1903 | 2473 | attr_pop(ATTR_DBL_STRIKE); |
2474 | } | |
1904 | 2475 | else |
1905 | attr_push(ATTR_DBL_STRIKE,NULL); | |
2476 | { | |
2477 | attr_push(ATTR_DBL_STRIKE, NULL); | |
2478 | } | |
1906 | 2479 | return FALSE; |
1907 | 2480 | } |
1908 | 2481 | |
1914 | 2487 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1915 | 2488 | *=======================================================================*/ |
1916 | 2489 | |
1917 | static int cmd_striked (Word *w, int align, char has_param, int param) { | |
1918 | if (has_param && param==0) | |
2490 | static int cmd_striked(Word *w, int align, char has_param, int param) | |
2491 | { | |
2492 | if (has_param && param == 0) | |
2493 | { | |
1919 | 2494 | attr_pop(ATTR_DBL_STRIKE); |
2495 | } | |
1920 | 2496 | else |
1921 | attr_push(ATTR_DBL_STRIKE,NULL); | |
2497 | { | |
2498 | attr_push(ATTR_DBL_STRIKE, NULL); | |
2499 | } | |
1922 | 2500 | return FALSE; |
1923 | 2501 | } |
1924 | 2502 | |
1930 | 2508 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1931 | 2509 | *=======================================================================*/ |
1932 | 2510 | |
1933 | static int cmd_rtf (Word *w, int align, char has_param, int param) { | |
2511 | static int cmd_rtf(Word *w, int align, char has_param, int param) | |
2512 | { | |
1934 | 2513 | return FALSE; |
1935 | 2514 | } |
1936 | 2515 | |
1941 | 2520 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1942 | 2521 | *=======================================================================*/ |
1943 | 2522 | |
1944 | static int cmd_shppict (Word *w, int align, char has_param, int param) | |
2523 | static int cmd_shppict(Word *w, int align, char has_param, int param) | |
1945 | 2524 | { |
1946 | 2525 | return FALSE; |
1947 | 2526 | } |
1953 | 2532 | * Returns: Flag, true only if rest of Words on line should be ignored. |
1954 | 2533 | *=======================================================================*/ |
1955 | 2534 | |
1956 | static int cmd_up (Word *w, int align, char has_param, int param) { | |
1957 | if (has_param && param==0) | |
2535 | static int cmd_up(Word *w, int align, char has_param, int param) | |
2536 | { | |
2537 | if (has_param && param == 0) | |
2538 | { | |
1958 | 2539 | attr_pop(ATTR_SUPER); |
2540 | } | |
1959 | 2541 | else |
1960 | attr_push(ATTR_SUPER,NULL); | |
2542 | { | |
2543 | attr_push(ATTR_SUPER, NULL); | |
2544 | } | |
1961 | 2545 | return FALSE; |
1962 | 2546 | } |
1963 | 2547 | |
1968 | 2552 | * Returns: Flag, always false |
1969 | 2553 | *=======================================================================*/ |
1970 | 2554 | |
1971 | static int cmd_u (Word *w, int align, char has_param, int param) { | |
1972 | /* TODO: Unicode characters won't be correctly preprocessed if sizeof(int) < 4 | |
1973 | * and document have unicode character which value is greater than 65536 | |
1974 | */ | |
1975 | ||
1976 | short done=0; | |
2555 | static int cmd_u(Word *w, int align, char has_param, int param) | |
2556 | { | |
2557 | /* TODO: Unicode characters won't be correctly preprocessed if sizeof(int) < 4 | |
2558 | * and document have unicode character which value is greater than 65536 | |
2559 | */ | |
2560 | ||
2561 | short done = 0; | |
1977 | 2562 | long unicode_number = (long) param; /* On 16bit architectures int is too small to store unicode characters. - AF */ |
1978 | char tmp[12]; /* Number of characters that can be in int type (including '\0'). If int size is greater than 4 bytes change this value. - AF */ | |
2563 | char tmp[20]; /* Number of characters that can be in int type (including '\0'). If int size is greater than 4 bytes change this value. - AF */ | |
1979 | 2564 | const char *alias; |
1980 | 2565 | #define DEBUG 0 |
1981 | 2566 | #if DEBUG |
1982 | 2567 | char *str; |
1983 | 2568 | if (has_param == TRUE) |
1984 | 2569 | { |
1985 | fprintf(stderr,"param is %d (x%x) (0%o)\n", param, | |
1986 | param, param); | |
2570 | fprintf(stderr, "param is %d (x%x) (0%o)\n", param, | |
2571 | param, param); | |
1987 | 2572 | } |
1988 | 2573 | if (w->hash_index) |
1989 | 2574 | { |
1990 | str=hash_get_string (w->hash_index); | |
1991 | fprintf(stderr,"string is %s\n", str); | |
2575 | str = hash_get_string(w->hash_index); | |
2576 | fprintf(stderr, "string is %s\n", str); | |
1992 | 2577 | } |
1993 | 2578 | #endif |
1994 | 2579 | /* 0.20.3 - daved added missing function call for unprocessed chars */ |
1997 | 2582 | printf("%s", alias); |
1998 | 2583 | done++; |
1999 | 2584 | } |
2000 | else | |
2001 | if(!done && op->unisymbol_print) | |
2002 | { | |
2003 | if (unicode_number < 0) | |
2004 | { | |
2005 | /* RTF spec: Unicode values beyond 32767 are represented by negative numbers */ | |
2006 | unicode_number += 65536; | |
2007 | } | |
2008 | sprintf(tmp, "%ld", unicode_number); | |
2009 | ||
2010 | if (safe_printf(1, op->unisymbol_print, tmp)) fprintf(stderr, TOO_MANY_ARGS, "unisymbol_print"); | |
2011 | done++; | |
2012 | } | |
2013 | ||
2585 | else if (!done && op->unisymbol_print) | |
2586 | { | |
2587 | if (unicode_number < 0) | |
2588 | { | |
2589 | /* RTF spec: Unicode values beyond 32767 are represented by negative numbers */ | |
2590 | unicode_number += 65536; | |
2591 | } | |
2592 | snprintf(tmp, 20, "%ld", unicode_number); | |
2593 | ||
2594 | if (safe_printf(1, op->unisymbol_print, tmp)) | |
2595 | { | |
2596 | fprintf(stderr, TOO_MANY_ARGS, "unisymbol_print"); | |
2597 | } | |
2598 | done++; | |
2599 | } | |
2600 | ||
2014 | 2601 | /* |
2015 | 2602 | ** if we know how to represent the unicode character in the |
2016 | 2603 | ** output language, we need to skip the next word, otherwise |
2017 | 2604 | ** we will output that alternative. |
2018 | 2605 | */ |
2019 | 2606 | if (done) |
2020 | return(SKIP_ONE_WORD); | |
2021 | return(FALSE); | |
2607 | { | |
2608 | return (SKIP_ONE_WORD); | |
2609 | } | |
2610 | return (FALSE); | |
2022 | 2611 | } |
2023 | 2612 | |
2024 | 2613 | /*======================================================================== |
2028 | 2617 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2029 | 2618 | *=======================================================================*/ |
2030 | 2619 | |
2031 | static int cmd_dn (Word *w, int align, char has_param, int param) { | |
2032 | if (has_param && param==0) | |
2620 | static int cmd_dn(Word *w, int align, char has_param, int param) | |
2621 | { | |
2622 | if (has_param && param == 0) | |
2623 | { | |
2033 | 2624 | attr_pop(ATTR_SUB); |
2625 | } | |
2034 | 2626 | else |
2035 | attr_push(ATTR_SUB,NULL); | |
2627 | { | |
2628 | attr_push(ATTR_SUB, NULL); | |
2629 | } | |
2036 | 2630 | return FALSE; |
2037 | 2631 | } |
2038 | 2632 | |
2043 | 2637 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2044 | 2638 | *=======================================================================*/ |
2045 | 2639 | |
2046 | static int cmd_nosupersub (Word *w, int align, char has_param, int param) { | |
2640 | static int cmd_nosupersub(Word *w, int align, char has_param, int param) | |
2641 | { | |
2047 | 2642 | attr_pop(ATTR_SUPER); |
2048 | 2643 | attr_pop(ATTR_SUB); |
2049 | 2644 | return FALSE; |
2056 | 2651 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2057 | 2652 | *=======================================================================*/ |
2058 | 2653 | |
2059 | static int cmd_super (Word *w, int align, char has_param, int param) { | |
2060 | if (has_param && param==0) | |
2654 | static int cmd_super(Word *w, int align, char has_param, int param) | |
2655 | { | |
2656 | if (has_param && param == 0) | |
2657 | { | |
2061 | 2658 | attr_pop(ATTR_SUPER); |
2659 | } | |
2062 | 2660 | else |
2063 | attr_push(ATTR_SUPER,NULL); | |
2661 | { | |
2662 | attr_push(ATTR_SUPER, NULL); | |
2663 | } | |
2064 | 2664 | return FALSE; |
2065 | 2665 | } |
2066 | 2666 | |
2071 | 2671 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2072 | 2672 | *=======================================================================*/ |
2073 | 2673 | |
2074 | static int cmd_sub (Word *w, int align, char has_param, int param) { | |
2075 | if (has_param && param==0) | |
2674 | static int cmd_sub(Word *w, int align, char has_param, int param) | |
2675 | { | |
2676 | if (has_param && param == 0) | |
2677 | { | |
2076 | 2678 | attr_pop(ATTR_SUB); |
2679 | } | |
2077 | 2680 | else |
2078 | attr_push(ATTR_SUB,NULL); | |
2681 | { | |
2682 | attr_push(ATTR_SUB, NULL); | |
2683 | } | |
2079 | 2684 | return FALSE; |
2080 | 2685 | } |
2081 | 2686 | |
2086 | 2691 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2087 | 2692 | *=======================================================================*/ |
2088 | 2693 | |
2089 | static int cmd_shad (Word *w, int align, char has_param, int param) { | |
2090 | if (has_param && param==0) | |
2694 | static int cmd_shad(Word *w, int align, char has_param, int param) | |
2695 | { | |
2696 | if (has_param && param == 0) | |
2697 | { | |
2091 | 2698 | attr_pop(ATTR_SHADOW); |
2699 | } | |
2092 | 2700 | else |
2093 | attr_push(ATTR_SHADOW,NULL); | |
2701 | { | |
2702 | attr_push(ATTR_SHADOW, NULL); | |
2703 | } | |
2094 | 2704 | return FALSE; |
2095 | 2705 | } |
2096 | 2706 | |
2102 | 2712 | *=======================================================================*/ |
2103 | 2713 | #define SUPPORT_UNNESTED |
2104 | 2714 | |
2105 | static int | |
2106 | cmd_b (Word *w, int align, char has_param, int param) { | |
2107 | if (has_param && param==0) { | |
2715 | static int | |
2716 | cmd_b(Word *w, int align, char has_param, int param) | |
2717 | { | |
2718 | if (has_param && param == 0) | |
2719 | { | |
2108 | 2720 | #ifdef SUPPORT_UNNESTED |
2109 | 2721 | attr_find_pop(ATTR_BOLD); |
2110 | 2722 | #else |
2112 | 2724 | #endif |
2113 | 2725 | } |
2114 | 2726 | else |
2115 | attr_push(ATTR_BOLD,NULL); | |
2727 | { | |
2728 | attr_push(ATTR_BOLD, NULL); | |
2729 | } | |
2116 | 2730 | return FALSE; |
2117 | 2731 | } |
2118 | 2732 | |
2123 | 2737 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2124 | 2738 | *=======================================================================*/ |
2125 | 2739 | |
2126 | static int cmd_i (Word *w, int align, char has_param, int param) { | |
2127 | if (has_param && param==0) | |
2740 | static int cmd_i(Word *w, int align, char has_param, int param) | |
2741 | { | |
2742 | if (has_param && param == 0) | |
2128 | 2743 | #ifdef SUPPORT_UNNESTED |
2129 | 2744 | attr_find_pop(ATTR_ITALIC); |
2130 | 2745 | #else |
2131 | 2746 | attr_pop(ATTR_ITALIC); |
2132 | 2747 | #endif |
2133 | 2748 | else |
2134 | attr_push(ATTR_ITALIC,NULL); | |
2749 | { | |
2750 | attr_push(ATTR_ITALIC, NULL); | |
2751 | } | |
2135 | 2752 | return FALSE; |
2136 | 2753 | } |
2137 | 2754 | |
2141 | 2758 | * Args: Word, paragraph align info, and numeric param if any. |
2142 | 2759 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2143 | 2760 | *=======================================================================*/ |
2144 | static int cmd_s (Word *w, int align, char has_param, int param) { | |
2761 | static int cmd_s(Word *w, int align, char has_param, int param) | |
2762 | { | |
2145 | 2763 | return FALSE; |
2146 | 2764 | } |
2147 | 2765 | |
2152 | 2770 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2153 | 2771 | *=======================================================================*/ |
2154 | 2772 | |
2155 | static int cmd_sect (Word *w, int align, char has_param, int param) { | |
2773 | static int cmd_sect(Word *w, int align, char has_param, int param) | |
2774 | { | |
2156 | 2775 | /* XX kludge */ |
2157 | if (op->paragraph_begin) { | |
2158 | if (safe_printf(0, op->paragraph_begin)) fprintf(stderr, TOO_MANY_ARGS, "paragraph_begin"); | |
2776 | if (op->paragraph_begin) | |
2777 | { | |
2778 | if (safe_printf(0, op->paragraph_begin)) | |
2779 | { | |
2780 | fprintf(stderr, TOO_MANY_ARGS, "paragraph_begin"); | |
2781 | } | |
2159 | 2782 | } |
2160 | 2783 | return FALSE; |
2161 | 2784 | } |
2167 | 2790 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2168 | 2791 | *=======================================================================*/ |
2169 | 2792 | |
2170 | static int cmd_shp (Word *w, int align, char has_param, int param) { | |
2171 | if (op->comment_begin) { | |
2172 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
2793 | static int cmd_shp(Word *w, int align, char has_param, int param) | |
2794 | { | |
2795 | if (op->comment_begin) | |
2796 | { | |
2797 | if (safe_printf(0, op->comment_begin)) | |
2798 | { | |
2799 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
2800 | } | |
2173 | 2801 | printf("Drawn Shape (ignored-not implemented yet)"); |
2174 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
2802 | if (safe_printf(0, op->comment_end)) | |
2803 | { | |
2804 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
2805 | } | |
2175 | 2806 | } |
2176 | 2807 | |
2177 | 2808 | return FALSE; |
2184 | 2815 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2185 | 2816 | *=======================================================================*/ |
2186 | 2817 | |
2187 | static int cmd_outl (Word *w, int align, char has_param, int param) { | |
2188 | if (has_param && param==0) | |
2818 | static int cmd_outl(Word *w, int align, char has_param, int param) | |
2819 | { | |
2820 | if (has_param && param == 0) | |
2821 | { | |
2189 | 2822 | attr_pop(ATTR_OUTLINE); |
2823 | } | |
2190 | 2824 | else |
2191 | attr_push(ATTR_OUTLINE,NULL); | |
2825 | { | |
2826 | attr_push(ATTR_OUTLINE, NULL); | |
2827 | } | |
2192 | 2828 | return FALSE; |
2193 | 2829 | } |
2194 | 2830 | |
2199 | 2835 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2200 | 2836 | *=======================================================================*/ |
2201 | 2837 | |
2202 | static int cmd_ansi (Word *w, int align, char has_param, int param) { | |
2203 | default_encoding = "CP1252"; | |
2204 | return FALSE; | |
2838 | static int cmd_ansi(Word *w, int align, char has_param, int param) | |
2839 | { | |
2840 | default_encoding = "CP1252"; | |
2841 | return FALSE; | |
2205 | 2842 | } |
2206 | 2843 | |
2207 | 2844 | /*======================================================================== |
2211 | 2848 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2212 | 2849 | *=======================================================================*/ |
2213 | 2850 | |
2214 | static int cmd_ansicpg (Word *w, int align, char has_param, int param) | |
2215 | { | |
2216 | default_encoding = cptoencoding(param); | |
2217 | had_ansicpg = 1; | |
2851 | static int cmd_ansicpg(Word *w, int align, char has_param, int param) | |
2852 | { | |
2853 | default_encoding = cptoencoding(param); | |
2854 | had_ansicpg = 1; | |
2218 | 2855 | return FALSE; |
2219 | 2856 | } |
2220 | 2857 | |
2225 | 2862 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2226 | 2863 | *=======================================================================*/ |
2227 | 2864 | |
2228 | static int cmd_pc (Word *w, int align, char has_param, int param) | |
2229 | { | |
2230 | default_encoding = "CP437"; | |
2231 | return FALSE; | |
2865 | static int cmd_pc(Word *w, int align, char has_param, int param) | |
2866 | { | |
2867 | default_encoding = "CP437"; | |
2868 | return FALSE; | |
2232 | 2869 | } |
2233 | 2870 | |
2234 | 2871 | /*======================================================================== |
2238 | 2875 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2239 | 2876 | *=======================================================================*/ |
2240 | 2877 | |
2241 | static int cmd_pca (Word *w, int align, char has_param, int param) | |
2242 | { | |
2243 | default_encoding = "CP850"; | |
2244 | return FALSE; | |
2878 | static int cmd_pca(Word *w, int align, char has_param, int param) | |
2879 | { | |
2880 | default_encoding = "CP850"; | |
2881 | return FALSE; | |
2245 | 2882 | } |
2246 | 2883 | |
2247 | 2884 | /*======================================================================== |
2251 | 2888 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2252 | 2889 | *=======================================================================*/ |
2253 | 2890 | |
2254 | static int cmd_mac (Word *w, int align, char has_param, int param) | |
2255 | { | |
2256 | default_encoding = "MAC"; | |
2257 | return FALSE; | |
2891 | static int cmd_mac(Word *w, int align, char has_param, int param) | |
2892 | { | |
2893 | default_encoding = "MAC"; | |
2894 | return FALSE; | |
2258 | 2895 | } |
2259 | 2896 | |
2260 | 2897 | /*======================================================================== |
2264 | 2901 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2265 | 2902 | *=======================================================================*/ |
2266 | 2903 | |
2267 | static int cmd_colortbl (Word *w, int align, char has_param, int param) { | |
2268 | if (w->next) { | |
2904 | static int cmd_colortbl(Word *w, int align, char has_param, int param) | |
2905 | { | |
2906 | if (w->next) | |
2907 | { | |
2269 | 2908 | process_color_table(w->next); |
2270 | 2909 | } |
2271 | 2910 | return TRUE; |
2278 | 2917 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2279 | 2918 | *=======================================================================*/ |
2280 | 2919 | |
2281 | static int cmd_fonttbl (Word *w, int align, char has_param, int param) { | |
2282 | if (w->next) { | |
2920 | static int cmd_fonttbl(Word *w, int align, char has_param, int param) | |
2921 | { | |
2922 | if (w->next) | |
2923 | { | |
2283 | 2924 | process_font_table(w->next); |
2284 | 2925 | } |
2285 | 2926 | return TRUE; |
2292 | 2933 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2293 | 2934 | *=======================================================================*/ |
2294 | 2935 | |
2295 | static int cmd_header (Word *w, int align, char has_param, int param) { | |
2936 | static int cmd_header(Word *w, int align, char has_param, int param) | |
2937 | { | |
2296 | 2938 | return TRUE; |
2297 | 2939 | } |
2298 | 2940 | |
2303 | 2945 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2304 | 2946 | *=======================================================================*/ |
2305 | 2947 | |
2306 | static int cmd_headerl (Word *w, int align, char has_param, int param) { | |
2948 | static int cmd_headerl(Word *w, int align, char has_param, int param) | |
2949 | { | |
2307 | 2950 | return TRUE; |
2308 | 2951 | } |
2309 | 2952 | |
2314 | 2957 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2315 | 2958 | *=======================================================================*/ |
2316 | 2959 | |
2317 | static int cmd_headerr (Word *w, int align, char has_param, int param) { | |
2960 | static int cmd_headerr(Word *w, int align, char has_param, int param) | |
2961 | { | |
2318 | 2962 | return TRUE; |
2319 | 2963 | } |
2320 | 2964 | |
2325 | 2969 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2326 | 2970 | *=======================================================================*/ |
2327 | 2971 | |
2328 | static int cmd_headerf (Word *w, int align, char has_param, int param) { | |
2972 | static int cmd_headerf(Word *w, int align, char has_param, int param) | |
2973 | { | |
2329 | 2974 | return TRUE; |
2330 | 2975 | } |
2331 | 2976 | |
2336 | 2981 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2337 | 2982 | *=======================================================================*/ |
2338 | 2983 | |
2339 | static int cmd_footer (Word *w, int align, char has_param, int param) { | |
2984 | static int cmd_footer(Word *w, int align, char has_param, int param) | |
2985 | { | |
2340 | 2986 | return TRUE; |
2341 | 2987 | } |
2342 | 2988 | |
2347 | 2993 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2348 | 2994 | *=======================================================================*/ |
2349 | 2995 | |
2350 | static int cmd_footerl (Word *w, int align, char has_param, int param) { | |
2996 | static int cmd_footerl(Word *w, int align, char has_param, int param) | |
2997 | { | |
2351 | 2998 | return TRUE; |
2352 | 2999 | } |
2353 | 3000 | |
2358 | 3005 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2359 | 3006 | *=======================================================================*/ |
2360 | 3007 | |
2361 | static int cmd_footerr (Word *w, int align, char has_param, int param) { | |
3008 | static int cmd_footerr(Word *w, int align, char has_param, int param) | |
3009 | { | |
2362 | 3010 | return TRUE; |
2363 | 3011 | } |
2364 | 3012 | |
2369 | 3017 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2370 | 3018 | *=======================================================================*/ |
2371 | 3019 | |
2372 | static int cmd_footerf (Word *w, int align, char has_param, int param) { | |
3020 | static int cmd_footerf(Word *w, int align, char has_param, int param) | |
3021 | { | |
2373 | 3022 | return TRUE; |
2374 | 3023 | } |
2375 | 3024 | |
2376 | 3025 | /*======================================================================== |
2377 | 3026 | * Name: cmd_ignore |
2378 | * Purpose: Dummy function to get rid of subgroups | |
2379 | * Args: Word, paragraph align info, and numeric param if any. | |
2380 | * Returns: Flag, true only if rest of Words on line should be ignored. | |
2381 | *=======================================================================*/ | |
2382 | ||
2383 | static int cmd_ignore (Word *w, int align, char has_param, int param) | |
3027 | * Purpose: Dummy function to get rid of subgroups | |
3028 | * Args: Word, paragraph align info, and numeric param if any. | |
3029 | * Returns: Flag, true only if rest of Words on line should be ignored. | |
3030 | *=======================================================================*/ | |
3031 | ||
3032 | static int cmd_ignore(Word *w, int align, char has_param, int param) | |
2384 | 3033 | { |
2385 | 3034 | return TRUE; |
2386 | 3035 | } |
2387 | 3036 | |
2388 | /*======================================================================== | |
2389 | * Name: cmd_maybe_ignore | |
2390 | * Purpose: Called when encountering {\* which specifies that the whole | |
2391 | * group should be discarded if the immediately following command is | |
2392 | * not known. | |
2393 | * Args: Word, paragraph align info, and numeric param if any. | |
2394 | * Returns: Flag, true only if rest of Words on line should be ignored. | |
2395 | *=======================================================================*/ | |
2396 | ||
2397 | static int cmd_maybe_ignore (Word *w, int align, char has_param, int param) | |
2398 | { | |
2399 | /* If the next command is known, we let it decide what to do | |
3037 | /*======================================================================== | |
3038 | * Name: cmd_maybe_ignore | |
3039 | * Purpose: Called when encountering {\* which specifies that the whole | |
3040 | * group should be discarded if the immediately following command is | |
3041 | * not known. | |
3042 | * Args: Word, paragraph align info, and numeric param if any. | |
3043 | * Returns: Flag, true only if rest of Words on line should be ignored. | |
3044 | *=======================================================================*/ | |
3045 | ||
3046 | static int cmd_maybe_ignore(Word *w, int align, char has_param, int param) | |
3047 | { | |
3048 | /* If the next command is known, we let it decide what to do | |
2400 | 3049 | * (which may still be to discard the group. If it is not found |
2401 | 3050 | * we return TRUE to discard the next elements. |
2402 | 3051 | */ |
2403 | if(w && w->next) | |
3052 | if (w && w->next) | |
2404 | 3053 | { |
2405 | 3054 | int hasparam, param; |
2406 | 3055 | const char *s = word_string(w->next); |
2407 | 3056 | if (s && s[0] == '\\' && find_command(s + 1, &hasparam, ¶m)) |
3057 | { | |
2408 | 3058 | return FALSE; |
2409 | } | |
2410 | ||
3059 | } | |
3060 | } | |
3061 | ||
2411 | 3062 | return TRUE; |
2412 | 3063 | } |
2413 | 3064 | |
2414 | 3065 | /*======================================================================== |
2415 | 3066 | * Name: cmd_blipuid |
2416 | * Purpose: Dummy function to get rid of uid | |
2417 | * Args: Word, paragraph align info, and numeric param if any. | |
2418 | * Returns: Flag, true only if rest of Words on line should be ignored. | |
2419 | *=======================================================================*/ | |
2420 | ||
2421 | static int cmd_blipuid (Word *w, int align, char has_param, int param) | |
2422 | { | |
2423 | CHECK_PARAM_NOT_NULL (w); | |
3067 | * Purpose: Dummy function to get rid of uid | |
3068 | * Args: Word, paragraph align info, and numeric param if any. | |
3069 | * Returns: Flag, true only if rest of Words on line should be ignored. | |
3070 | *=======================================================================*/ | |
3071 | ||
3072 | static int cmd_blipuid(Word *w, int align, char has_param, int param) | |
3073 | { | |
3074 | CHECK_PARAM_NOT_NULL(w); | |
2424 | 3075 | return TRUE; |
2425 | 3076 | } |
2426 | 3077 | |
2431 | 3082 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2432 | 3083 | *=======================================================================*/ |
2433 | 3084 | |
2434 | static int cmd_info (Word *w, int align, char has_param, int param) { | |
2435 | process_info_group (w->next); | |
3085 | static int cmd_info(Word *w, int align, char has_param, int param) | |
3086 | { | |
3087 | process_info_group(w->next); | |
2436 | 3088 | return TRUE; |
2437 | 3089 | } |
2438 | 3090 | |
2443 | 3095 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2444 | 3096 | *=======================================================================*/ |
2445 | 3097 | |
2446 | static int cmd_pict (Word *w, int align, char has_param, int param) | |
2447 | { | |
2448 | within_picture=TRUE; | |
3098 | static int cmd_pict(Word *w, int align, char has_param, int param) | |
3099 | { | |
3100 | within_picture = TRUE; | |
2449 | 3101 | picture_width = picture_height = 0; |
2450 | 3102 | picture_type = PICT_WB; |
2451 | return FALSE; | |
3103 | return FALSE; | |
2452 | 3104 | } |
2453 | 3105 | /*======================================================================== |
2454 | 3106 | * Name: cmd_picprop |
2457 | 3109 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2458 | 3110 | *=======================================================================*/ |
2459 | 3111 | |
2460 | static int cmd_picprop (Word *w, int align, char has_param, int param) | |
2461 | { | |
2462 | return TRUE; | |
3112 | static int cmd_picprop(Word *w, int align, char has_param, int param) | |
3113 | { | |
3114 | return TRUE; | |
2463 | 3115 | } |
2464 | 3116 | |
2465 | 3117 | |
2470 | 3122 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2471 | 3123 | *=======================================================================*/ |
2472 | 3124 | |
2473 | static int cmd_bin (Word *w, int align, char has_param, int param) { | |
2474 | return FALSE; | |
3125 | static int cmd_bin(Word *w, int align, char has_param, int param) | |
3126 | { | |
3127 | return FALSE; | |
2475 | 3128 | } |
2476 | 3129 | |
2477 | 3130 | |
2482 | 3135 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2483 | 3136 | *=======================================================================*/ |
2484 | 3137 | |
2485 | static int cmd_macpict (Word *w, int align, char has_param, int param) { | |
3138 | static int cmd_macpict(Word *w, int align, char has_param, int param) | |
3139 | { | |
2486 | 3140 | picture_type = PICT_MAC; |
2487 | return FALSE; | |
3141 | return FALSE; | |
2488 | 3142 | } |
2489 | 3143 | |
2490 | 3144 | /*======================================================================== |
2494 | 3148 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2495 | 3149 | *=======================================================================*/ |
2496 | 3150 | |
2497 | static int cmd_jpegblip (Word *w, int align, char has_param, int param) { | |
3151 | static int cmd_jpegblip(Word *w, int align, char has_param, int param) | |
3152 | { | |
2498 | 3153 | picture_type = PICT_JPEG; |
2499 | return FALSE; | |
3154 | return FALSE; | |
2500 | 3155 | } |
2501 | 3156 | |
2502 | 3157 | /*======================================================================== |
2506 | 3161 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2507 | 3162 | *=======================================================================*/ |
2508 | 3163 | |
2509 | static int cmd_pngblip (Word *w, int align, char has_param, int param) { | |
3164 | static int cmd_pngblip(Word *w, int align, char has_param, int param) | |
3165 | { | |
2510 | 3166 | picture_type = PICT_PNG; |
2511 | return FALSE; | |
3167 | return FALSE; | |
2512 | 3168 | } |
2513 | 3169 | |
2514 | 3170 | /*======================================================================== |
2518 | 3174 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2519 | 3175 | *=======================================================================*/ |
2520 | 3176 | |
2521 | static int cmd_emfblip (Word *w, int align, char has_param, int param) { | |
3177 | static int cmd_emfblip(Word *w, int align, char has_param, int param) | |
3178 | { | |
2522 | 3179 | picture_type = PICT_EMF; |
2523 | return FALSE; | |
3180 | return FALSE; | |
2524 | 3181 | } |
2525 | 3182 | |
2526 | 3183 | /*======================================================================== |
2530 | 3187 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2531 | 3188 | *=======================================================================*/ |
2532 | 3189 | |
2533 | static int cmd_pnmetafile (Word *w, int align, char has_param, int param) { | |
3190 | static int cmd_pnmetafile(Word *w, int align, char has_param, int param) | |
3191 | { | |
2534 | 3192 | picture_type = PICT_PM; |
2535 | return FALSE; | |
3193 | return FALSE; | |
2536 | 3194 | } |
2537 | 3195 | |
2538 | 3196 | /*======================================================================== |
2542 | 3200 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2543 | 3201 | *=======================================================================*/ |
2544 | 3202 | |
2545 | static int cmd_wmetafile (Word *w, int align, char has_param, int param) { | |
3203 | static int cmd_wmetafile(Word *w, int align, char has_param, int param) | |
3204 | { | |
2546 | 3205 | picture_type = PICT_WM; |
2547 | if (within_picture && has_param) { | |
2548 | picture_wmetafile_type=param; | |
2549 | switch(param) { | |
2550 | case 1: picture_wmetafile_type_str="MM_TEXT"; break; | |
2551 | case 2: picture_wmetafile_type_str="MM_LOMETRIC"; break; | |
2552 | case 3: picture_wmetafile_type_str="MM_HIMETRIC"; break; | |
2553 | case 4: picture_wmetafile_type_str="MM_LOENGLISH"; break; | |
2554 | case 5: picture_wmetafile_type_str="MM_HIENGLISH"; break; | |
2555 | case 6: picture_wmetafile_type_str="MM_TWIPS"; break; | |
2556 | case 7: picture_wmetafile_type_str="MM_ISOTROPIC"; break; | |
2557 | case 8: picture_wmetafile_type_str="MM_ANISOTROPIC"; break; | |
2558 | default: picture_wmetafile_type_str="default:MM_TEXT"; break; | |
2559 | } | |
2560 | } | |
2561 | return FALSE; | |
3206 | if (within_picture && has_param) | |
3207 | { | |
3208 | picture_wmetafile_type = param; | |
3209 | switch (param) | |
3210 | { | |
3211 | case 1: | |
3212 | picture_wmetafile_type_str = "MM_TEXT"; | |
3213 | break; | |
3214 | case 2: | |
3215 | picture_wmetafile_type_str = "MM_LOMETRIC"; | |
3216 | break; | |
3217 | case 3: | |
3218 | picture_wmetafile_type_str = "MM_HIMETRIC"; | |
3219 | break; | |
3220 | case 4: | |
3221 | picture_wmetafile_type_str = "MM_LOENGLISH"; | |
3222 | break; | |
3223 | case 5: | |
3224 | picture_wmetafile_type_str = "MM_HIENGLISH"; | |
3225 | break; | |
3226 | case 6: | |
3227 | picture_wmetafile_type_str = "MM_TWIPS"; | |
3228 | break; | |
3229 | case 7: | |
3230 | picture_wmetafile_type_str = "MM_ISOTROPIC"; | |
3231 | break; | |
3232 | case 8: | |
3233 | picture_wmetafile_type_str = "MM_ANISOTROPIC"; | |
3234 | break; | |
3235 | default: | |
3236 | picture_wmetafile_type_str = "default:MM_TEXT"; | |
3237 | break; | |
3238 | } | |
3239 | } | |
3240 | return FALSE; | |
2562 | 3241 | } |
2563 | 3242 | |
2564 | 3243 | /*======================================================================== |
2568 | 3247 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2569 | 3248 | *=======================================================================*/ |
2570 | 3249 | |
2571 | static int cmd_wbmbitspixel (Word *w, int align, char has_param, int param) { | |
2572 | if (within_picture && has_param) | |
3250 | static int cmd_wbmbitspixel(Word *w, int align, char has_param, int param) | |
3251 | { | |
3252 | if (within_picture && has_param) | |
3253 | { | |
2573 | 3254 | picture_bits_per_pixel = param; |
2574 | return FALSE; | |
3255 | } | |
3256 | return FALSE; | |
2575 | 3257 | } |
2576 | 3258 | |
2577 | 3259 | /*======================================================================== |
2581 | 3263 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2582 | 3264 | *=======================================================================*/ |
2583 | 3265 | |
2584 | static int cmd_picw (Word *w, int align, char has_param, int param) { | |
2585 | if (within_picture && has_param) | |
3266 | static int cmd_picw(Word *w, int align, char has_param, int param) | |
3267 | { | |
3268 | if (within_picture && has_param) | |
3269 | { | |
2586 | 3270 | picture_width = param; |
2587 | return FALSE; | |
3271 | } | |
3272 | return FALSE; | |
2588 | 3273 | } |
2589 | 3274 | |
2590 | 3275 | /*======================================================================== |
2594 | 3279 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2595 | 3280 | *=======================================================================*/ |
2596 | 3281 | |
2597 | static int cmd_pich (Word *w, int align, char has_param, int param) { | |
2598 | if (within_picture && has_param) | |
3282 | static int cmd_pich(Word *w, int align, char has_param, int param) | |
3283 | { | |
3284 | if (within_picture && has_param) | |
3285 | { | |
2599 | 3286 | picture_height = param; |
2600 | return FALSE; | |
3287 | } | |
3288 | return FALSE; | |
2601 | 3289 | } |
2602 | 3290 | |
2603 | 3291 | |
2608 | 3296 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2609 | 3297 | *=======================================================================*/ |
2610 | 3298 | |
2611 | static int cmd_xe (Word *w, int align, char has_param, int param) { | |
2612 | process_index_entry (w); | |
2613 | return TRUE; | |
3299 | static int cmd_xe(Word *w, int align, char has_param, int param) | |
3300 | { | |
3301 | process_index_entry(w); | |
3302 | return TRUE; | |
2614 | 3303 | } |
2615 | 3304 | |
2616 | 3305 | /*======================================================================== |
2620 | 3309 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2621 | 3310 | *=======================================================================*/ |
2622 | 3311 | |
2623 | static int cmd_tc (Word *w, int align, char has_param, int param) { | |
2624 | process_toc_entry (w, TRUE); | |
2625 | return TRUE; | |
3312 | static int cmd_tc(Word *w, int align, char has_param, int param) | |
3313 | { | |
3314 | process_toc_entry(w, TRUE); | |
3315 | return TRUE; | |
2626 | 3316 | } |
2627 | 3317 | |
2628 | 3318 | /*======================================================================== |
2632 | 3322 | * Returns: Flag, true only if rest of Words on line should be ignored. |
2633 | 3323 | *=======================================================================*/ |
2634 | 3324 | |
2635 | static int cmd_tcn (Word *w, int align, char has_param, int param) { | |
2636 | process_toc_entry (w, FALSE); | |
2637 | return TRUE; | |
3325 | static int cmd_tcn(Word *w, int align, char has_param, int param) | |
3326 | { | |
3327 | process_toc_entry(w, FALSE); | |
3328 | return TRUE; | |
2638 | 3329 | } |
2639 | 3330 | |
2640 | 3331 | |
2641 | 3332 | /* All of the possible commands that RTF might recognize. */ |
2642 | static HashItem hashArray_other [] = { | |
2643 | /* 0.21.7 | |
2644 | * the "*" command was ignored in earlier versions, but included pictures | |
2645 | * seem to often start with \*\shppict{\pict so if "*" is ignored, so is | |
2646 | * the picture, so I have defined a new function "cmd_maybe_ignore" which | |
2647 | * tests whether the next word is shppict and if so does not ignore what | |
2648 | * follows. On simple tests this seems to work. - daved | |
2649 | */ | |
3333 | static HashItem hashArray_other [] = | |
3334 | { | |
3335 | /* 0.21.7 | |
3336 | * the "*" command was ignored in earlier versions, but included pictures | |
3337 | * seem to often start with \*\shppict{\pict so if "*" is ignored, so is | |
3338 | * the picture, so I have defined a new function "cmd_maybe_ignore" which | |
3339 | * tests whether the next word is shppict and if so does not ignore what | |
3340 | * follows. On simple tests this seems to work. - daved | |
3341 | */ | |
2650 | 3342 | #if 0 |
2651 | 3343 | { "*", cmd_ignore, NULL }, |
2652 | 3344 | #else |
2657 | 3349 | { "~", cmd_nonbreaking_space, NULL }, |
2658 | 3350 | { NULL, NULL, NULL} |
2659 | 3351 | }; |
2660 | static HashItem hashArray_a [] = { | |
3352 | static HashItem hashArray_a [] = | |
3353 | { | |
2661 | 3354 | { "ansi", &cmd_ansi , NULL }, |
2662 | 3355 | { "ansicpg", &cmd_ansicpg , NULL }, |
2663 | 3356 | { NULL, NULL, NULL} |
2664 | 3357 | }; |
2665 | static HashItem hashArray_b [] = { | |
3358 | static HashItem hashArray_b [] = | |
3359 | { | |
2666 | 3360 | { "b", &cmd_b, NULL }, |
2667 | 3361 | { "bullet", &cmd_bullet, NULL }, |
2668 | 3362 | { "bin", &cmd_bin, "picture is binary" }, |
2691 | 3385 | #endif |
2692 | 3386 | { NULL, NULL, NULL} |
2693 | 3387 | }; |
2694 | static HashItem hashArray_c [] = { | |
3388 | static HashItem hashArray_c [] = | |
3389 | { | |
2695 | 3390 | { "caps", &cmd_caps, NULL }, |
2696 | 3391 | { "cb", cmd_cb, NULL }, |
2697 | 3392 | { "cf", cmd_cf, NULL }, |
2727 | 3422 | { "cs", NULL, "character style (not implemented)"}, |
2728 | 3423 | { NULL, NULL, NULL} |
2729 | 3424 | }; |
2730 | static HashItem hashArray_d [] = { | |
3425 | static HashItem hashArray_d [] = | |
3426 | { | |
2731 | 3427 | { "deff", cmd_deff, "Default Font" }, |
2732 | 3428 | { "dn", &cmd_dn, NULL }, |
2733 | 3429 | #if 0 |
2735 | 3431 | #endif |
2736 | 3432 | { NULL, NULL, NULL} |
2737 | 3433 | }; |
2738 | static HashItem hashArray_e [] = { | |
3434 | static HashItem hashArray_e [] = | |
3435 | { | |
2739 | 3436 | { "emdash", cmd_emdash, NULL }, |
2740 | 3437 | { "endash", cmd_endash, NULL }, |
2741 | 3438 | { "embo", &cmd_emboss, NULL }, |
2744 | 3441 | { "emfblip", &cmd_emfblip, NULL }, |
2745 | 3442 | { NULL, NULL, NULL} |
2746 | 3443 | }; |
2747 | static HashItem hashArray_f [] = { | |
3444 | static HashItem hashArray_f [] = | |
3445 | { | |
2748 | 3446 | { "f", cmd_f, NULL }, |
2749 | 3447 | { "fdecor", cmd_fdecor, NULL }, |
2750 | 3448 | { "fmodern", cmd_fmodern, NULL }, |
2762 | 3460 | { "footerr", cmd_footerr, NULL }, |
2763 | 3461 | { NULL, NULL, NULL} |
2764 | 3462 | }; |
2765 | static HashItem hashArray_h [] = { | |
3463 | static HashItem hashArray_h [] = | |
3464 | { | |
2766 | 3465 | { "highlight", &cmd_highlight, NULL }, |
2767 | 3466 | { "header", cmd_header, NULL }, |
2768 | 3467 | { "headerf", cmd_headerf, NULL }, |
2771 | 3470 | { "hl", cmd_ignore, "hyperlink within object" }, |
2772 | 3471 | { NULL, NULL, NULL} |
2773 | 3472 | }; |
2774 | static HashItem hashArray_i [] = { | |
3473 | static HashItem hashArray_i [] = | |
3474 | { | |
2775 | 3475 | { "i", &cmd_i, NULL }, |
2776 | 3476 | { "info", &cmd_info, NULL }, |
2777 | 3477 | { "insrsid", NULL, "Revision Mark (ignore)" }, |
2779 | 3479 | { "impr", &cmd_engrave, NULL }, |
2780 | 3480 | { NULL, NULL, NULL} |
2781 | 3481 | }; |
2782 | static HashItem hashArray_j [] = { | |
3482 | static HashItem hashArray_j [] = | |
3483 | { | |
2783 | 3484 | { "jpegblip", &cmd_jpegblip, NULL }, |
2784 | 3485 | { NULL, NULL, NULL} |
2785 | 3486 | }; |
2786 | static HashItem hashArray_l [] = { | |
3487 | static HashItem hashArray_l [] = | |
3488 | { | |
2787 | 3489 | { "ldblquote", &cmd_ldblquote, NULL }, |
2788 | 3490 | { "line", &cmd_line, NULL }, |
2789 | 3491 | { "lquote", &cmd_lquote, NULL }, |
2790 | 3492 | { NULL, NULL, NULL} |
2791 | 3493 | }; |
2792 | static HashItem hashArray_m [] = { | |
3494 | static HashItem hashArray_m [] = | |
3495 | { | |
2793 | 3496 | { "mac", &cmd_mac , NULL }, |
2794 | 3497 | { "macpict", &cmd_macpict, NULL }, |
2795 | 3498 | { NULL, NULL, NULL} |
2796 | 3499 | }; |
2797 | static HashItem hashArray_n [] = { | |
3500 | static HashItem hashArray_n [] = | |
3501 | { | |
2798 | 3502 | { "nosupersub", &cmd_nosupersub, NULL }, |
2799 | 3503 | { "nonshppict", &cmd_ignore, NULL }, |
2800 | 3504 | { NULL, NULL, NULL} |
2801 | 3505 | }; |
2802 | static HashItem hashArray_o [] = { | |
3506 | static HashItem hashArray_o [] = | |
3507 | { | |
2803 | 3508 | { "outl", &cmd_outl, NULL }, |
2804 | 3509 | { NULL, NULL, NULL} |
2805 | 3510 | }; |
2806 | static HashItem hashArray_p [] = { | |
3511 | static HashItem hashArray_p [] = | |
3512 | { | |
2807 | 3513 | { "page", &cmd_page, NULL }, |
2808 | 3514 | { "par", &cmd_par, NULL }, |
2809 | 3515 | { "pc", &cmd_pc , NULL }, |
2829 | 3535 | #endif |
2830 | 3536 | { NULL, NULL, NULL} |
2831 | 3537 | }; |
2832 | static HashItem hashArray_r [] = { | |
3538 | static HashItem hashArray_r [] = | |
3539 | { | |
2833 | 3540 | { "rdblquote", &cmd_rdblquote, NULL }, |
2834 | 3541 | { "rquote", &cmd_rquote, NULL }, |
2835 | 3542 | { "rtf", &cmd_rtf, NULL }, |
2836 | 3543 | { NULL, NULL, NULL} |
2837 | 3544 | }; |
2838 | static HashItem hashArray_s [] = { | |
3545 | static HashItem hashArray_s [] = | |
3546 | { | |
2839 | 3547 | { "s", cmd_s, "style" }, |
2840 | 3548 | { "sect", &cmd_sect, "section break"}, |
2841 | 3549 | { "scaps", &cmd_scaps, NULL }, |
2853 | 3561 | #endif |
2854 | 3562 | { NULL, NULL, NULL} |
2855 | 3563 | }; |
2856 | static HashItem hashArray_t [] = { | |
3564 | static HashItem hashArray_t [] = | |
3565 | { | |
2857 | 3566 | { "tab", &cmd_tab, NULL }, |
2858 | 3567 | { "tc", cmd_tc, "TOC entry" }, |
2859 | 3568 | { "tcn", cmd_tcn, "TOC entry" }, |
2860 | 3569 | { "trowd", NULL, "start new row in table" }, |
2861 | 3570 | { NULL, NULL, NULL} |
2862 | 3571 | }; |
2863 | static HashItem hashArray_u [] = { | |
3572 | static HashItem hashArray_u [] = | |
3573 | { | |
2864 | 3574 | { "u", &cmd_u, NULL }, |
2865 | 3575 | { "ul", &cmd_ul, NULL }, |
2866 | 3576 | { "up", &cmd_up, NULL }, |
2878 | 3588 | { NULL, NULL, NULL} |
2879 | 3589 | }; |
2880 | 3590 | |
2881 | static HashItem hashArray_v [] = { | |
3591 | static HashItem hashArray_v [] = | |
3592 | { | |
2882 | 3593 | { "v", NULL, "Hidden Text" }, |
2883 | 3594 | { NULL, NULL, NULL } |
2884 | 3595 | }; |
2885 | 3596 | |
2886 | static HashItem hashArray_w [] = { | |
3597 | static HashItem hashArray_w [] = | |
3598 | { | |
2887 | 3599 | { "wbmbitspixel", &cmd_wbmbitspixel, NULL }, |
2888 | 3600 | { "wmetafile", &cmd_wmetafile, NULL }, |
2889 | 3601 | { NULL, NULL, NULL} |
2890 | 3602 | }; |
2891 | 3603 | |
2892 | static HashItem hashArray_x [] = { | |
3604 | static HashItem hashArray_x [] = | |
3605 | { | |
2893 | 3606 | { "xe", cmd_xe, "index entry" }, |
2894 | 3607 | { NULL, NULL, NULL} |
2895 | 3608 | }; |
2896 | 3609 | |
2897 | static HashItem *hash [26] = { | |
3610 | static HashItem *hash [26] = | |
3611 | { | |
2898 | 3612 | hashArray_a, |
2899 | 3613 | hashArray_b, |
2900 | 3614 | hashArray_c, |
2918 | 3632 | hashArray_u, |
2919 | 3633 | hashArray_v, |
2920 | 3634 | hashArray_w, |
2921 | hashArray_x, | |
3635 | hashArray_x, | |
2922 | 3636 | NULL, NULL |
2923 | 3637 | }; |
2924 | 3638 | |
2946 | 3660 | /* Look for a parameter */ |
2947 | 3661 | *hasparamp = FALSE; |
2948 | 3662 | p = cmdpp; |
2949 | while (*p && (!isdigit(*p) && *p != '-')) | |
3663 | while (*p && (!isdigit(*p) && *p != '-')) | |
3664 | { | |
2950 | 3665 | p++; |
2951 | if (*p && (isdigit(*p) || *p == '-')) { | |
2952 | *hasparamp = TRUE; | |
3666 | } | |
3667 | if (*p && (isdigit(*p) || *p == '-')) | |
3668 | { | |
3669 | *hasparamp = TRUE; | |
2953 | 3670 | *paramp = atoi(p); |
2954 | 3671 | } |
2955 | 3672 | len = p - cmdpp; |
2956 | 3673 | |
2957 | 3674 | /* Generate a hash index */ |
2958 | 3675 | ch = tolower(*cmdpp); |
2959 | if (ch >= 'a' && ch <= 'z') | |
3676 | if (ch >= 'a' && ch <= 'z') | |
3677 | { | |
2960 | 3678 | hip = hash[ch - 'a']; |
3679 | } | |
2961 | 3680 | else |
3681 | { | |
2962 | 3682 | hip = hashArray_other; |
2963 | ||
2964 | if (!hip) { | |
2965 | if (debug_mode) { | |
2966 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
3683 | } | |
3684 | ||
3685 | if (!hip) | |
3686 | { | |
3687 | if (debug_mode) | |
3688 | { | |
3689 | if (safe_printf(0, op->comment_begin)) | |
3690 | { | |
3691 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
3692 | } | |
2967 | 3693 | printf("Unfamiliar RTF command: %s (HashIndex not found)", cmdpp); |
2968 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
3694 | if (safe_printf(0, op->comment_end)) | |
3695 | { | |
3696 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
3697 | } | |
2969 | 3698 | } |
2970 | 3699 | return NULL; |
2971 | 3700 | } |
2972 | 3701 | |
2973 | while (hip->name) { | |
3702 | while (hip->name) | |
3703 | { | |
2974 | 3704 | /* Don't change the order of tests ! */ |
2975 | 3705 | if (!strncmp(cmdpp, hip->name, len) && hip->name[len] == 0) |
3706 | { | |
2976 | 3707 | return hip; |
3708 | } | |
2977 | 3709 | hip++; |
2978 | 3710 | } |
2979 | 3711 | |
2980 | if (debug_mode) { | |
2981 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
3712 | if (debug_mode) | |
3713 | { | |
3714 | if (safe_printf(0, op->comment_begin)) | |
3715 | { | |
3716 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
3717 | } | |
2982 | 3718 | printf("Unfamiliar RTF command: %s", cmdpp); |
2983 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
3719 | if (safe_printf(0, op->comment_end)) | |
3720 | { | |
3721 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
3722 | } | |
2984 | 3723 | } |
2985 | 3724 | return NULL; |
2986 | 3725 | } |
3004 | 3743 | * Returns: None. |
3005 | 3744 | *=======================================================================*/ |
3006 | 3745 | |
3007 | void | |
3008 | print_with_special_exprs (const char *s) { | |
3746 | void | |
3747 | print_with_special_exprs(const char *s) | |
3748 | { | |
3009 | 3749 | int ch; |
3010 | 3750 | int state; |
3011 | 3751 | |
3012 | enum { SMALL=0, BIG=1 }; | |
3752 | enum { SMALL = 0, BIG = 1 }; | |
3013 | 3753 | |
3014 | 3754 | CHECK_PARAM_NOT_NULL(s); |
3015 | 3755 | |
3016 | // Not sure that there are cases where the flush is needed, | |
3017 | // but this is conceivable, and can't hurt in any case. | |
3018 | flush_iconv_input(); | |
3019 | ||
3020 | maybeopeniconv(); | |
3021 | ||
3022 | state=SMALL; /* Pacify gcc, st001906 - 0.19.6 */ | |
3023 | if (simulate_smallcaps) { | |
3024 | if (*s >= 'a' && *s <= 'z') { | |
3025 | state=SMALL; | |
3026 | if (safe_printf(0, op->smaller_begin)) fprintf(stderr, TOO_MANY_ARGS, "smaller_begin"); | |
3756 | // Not sure that there are cases where the flush is needed, | |
3757 | // but this is conceivable, and can't hurt in any case. | |
3758 | flush_iconv_input(); | |
3759 | ||
3760 | maybeopeniconv(); | |
3761 | ||
3762 | state = SMALL; /* Pacify gcc, st001906 - 0.19.6 */ | |
3763 | if (simulate_smallcaps) | |
3764 | { | |
3765 | if (*s >= 'a' && *s <= 'z') | |
3766 | { | |
3767 | state = SMALL; | |
3768 | if (safe_printf(0, op->smaller_begin)) | |
3769 | { | |
3770 | fprintf(stderr, TOO_MANY_ARGS, "smaller_begin"); | |
3771 | } | |
3027 | 3772 | } |
3028 | 3773 | else |
3029 | state=BIG; | |
3030 | } | |
3031 | ||
3032 | while ((ch=*s)) { | |
3774 | { | |
3775 | state = BIG; | |
3776 | } | |
3777 | } | |
3778 | ||
3779 | while ((ch = *s)) | |
3780 | { | |
3033 | 3781 | const char *post_trans = NULL; |
3034 | 3782 | |
3035 | 3783 | if (simulate_allcaps || simulate_smallcaps) |
3036 | ch = toupper (ch); | |
3037 | ||
3038 | if (ch >= 0x20 && ch < 0x80) { | |
3039 | post_trans= op_translate_char(op, current_encoding, ch); | |
3040 | if(post_trans) | |
3041 | printf("%s",post_trans); | |
3784 | { | |
3785 | ch = toupper(ch); | |
3786 | } | |
3787 | ||
3788 | if (ch >= 0x20 && ch < 0x80) | |
3789 | { | |
3790 | post_trans = op_translate_char(op, current_encoding, ch); | |
3791 | if (post_trans) | |
3792 | { | |
3793 | printf("%s", post_trans); | |
3794 | my_free(post_trans); | |
3795 | } | |
3042 | 3796 | } |
3043 | 3797 | |
3044 | 3798 | s++; |
3045 | 3799 | |
3046 | if (simulate_smallcaps) { | |
3800 | if (simulate_smallcaps) | |
3801 | { | |
3047 | 3802 | ch = *s; |
3048 | if (ch >= 'a' && ch <= 'z') { | |
3049 | if (state==BIG) | |
3050 | if (safe_printf(0, op->smaller_begin)) fprintf(stderr, TOO_MANY_ARGS, "smaller_begin"); | |
3051 | state=SMALL; | |
3803 | if (ch >= 'a' && ch <= 'z') | |
3804 | { | |
3805 | if (state == BIG) | |
3806 | if (safe_printf(0, op->smaller_begin)) | |
3807 | { | |
3808 | fprintf(stderr, TOO_MANY_ARGS, "smaller_begin"); | |
3809 | } | |
3810 | state = SMALL; | |
3052 | 3811 | } |
3053 | 3812 | else |
3054 | 3813 | { |
3055 | if (state==SMALL) | |
3056 | if (safe_printf(0, op->smaller_end)) fprintf(stderr, TOO_MANY_ARGS, "smaller_end"); | |
3057 | state=BIG; | |
3814 | if (state == SMALL) | |
3815 | if (safe_printf(0, op->smaller_end)) | |
3816 | { | |
3817 | fprintf(stderr, TOO_MANY_ARGS, "smaller_end"); | |
3818 | } | |
3819 | state = BIG; | |
3058 | 3820 | } |
3059 | 3821 | } |
3060 | 3822 | } |
3063 | 3825 | |
3064 | 3826 | |
3065 | 3827 | /*======================================================================== |
3066 | * Name: | |
3067 | * Purpose: | |
3828 | * Name: | |
3829 | * Purpose: | |
3068 | 3830 | * Args: None. |
3069 | 3831 | * Returns: None. |
3070 | 3832 | *=======================================================================*/ |
3071 | 3833 | |
3072 | static void | |
3834 | static void | |
3073 | 3835 | begin_table() |
3074 | 3836 | { |
3075 | within_table=TRUE; | |
3837 | within_table = TRUE; | |
3076 | 3838 | have_printed_row_begin = FALSE; |
3077 | 3839 | have_printed_cell_begin = FALSE; |
3078 | 3840 | have_printed_row_end = FALSE; |
3079 | 3841 | have_printed_cell_end = FALSE; |
3080 | 3842 | attrstack_push(); |
3081 | 3843 | starting_body(); |
3082 | if (safe_printf(0, op->table_begin)) fprintf(stderr, TOO_MANY_ARGS, "table_begin"); | |
3844 | if (safe_printf(0, op->table_begin)) | |
3845 | { | |
3846 | fprintf(stderr, TOO_MANY_ARGS, "table_begin"); | |
3847 | } | |
3083 | 3848 | } |
3084 | 3849 | |
3085 | 3850 | |
3090 | 3855 | * Returns: None. |
3091 | 3856 | *=======================================================================*/ |
3092 | 3857 | |
3093 | void | |
3094 | end_table () | |
3095 | { | |
3096 | if (within_table) { | |
3097 | if (!have_printed_cell_end) { | |
3098 | attr_pop_dump(); | |
3099 | if (safe_printf(0, op->table_cell_end)) fprintf(stderr, TOO_MANY_ARGS, "table_cell_end"); | |
3100 | } | |
3101 | if (!have_printed_row_end) { | |
3102 | if (safe_printf(0, op->table_row_end)) fprintf(stderr, TOO_MANY_ARGS, "table_row_end"); | |
3103 | } | |
3104 | if (safe_printf(0, op->table_end)) fprintf(stderr, TOO_MANY_ARGS, "table_end"); | |
3105 | within_table=FALSE; | |
3858 | void | |
3859 | end_table() | |
3860 | { | |
3861 | if (within_table) | |
3862 | { | |
3863 | if (!have_printed_cell_end) | |
3864 | { | |
3865 | attr_pop_all(); | |
3866 | if (safe_printf(0, op->table_cell_end)) | |
3867 | { | |
3868 | fprintf(stderr, TOO_MANY_ARGS, "table_cell_end"); | |
3869 | } | |
3870 | } | |
3871 | if (!have_printed_row_end) | |
3872 | { | |
3873 | if (safe_printf(0, op->table_row_end)) | |
3874 | { | |
3875 | fprintf(stderr, TOO_MANY_ARGS, "table_row_end"); | |
3876 | } | |
3877 | } | |
3878 | if (safe_printf(0, op->table_end)) | |
3879 | { | |
3880 | fprintf(stderr, TOO_MANY_ARGS, "table_end"); | |
3881 | } | |
3882 | within_table = FALSE; | |
3106 | 3883 | have_printed_row_begin = FALSE; |
3107 | 3884 | have_printed_cell_begin = FALSE; |
3108 | 3885 | have_printed_row_end = FALSE; |
3134 | 3911 | } |
3135 | 3912 | |
3136 | 3913 | /*======================================================================== |
3137 | * Name: | |
3138 | * Purpose: | |
3914 | * Name: | |
3915 | * Purpose: | |
3139 | 3916 | * Args: None. |
3140 | 3917 | * Returns: None. |
3141 | 3918 | *=======================================================================*/ |
3142 | 3919 | |
3143 | void | |
3144 | starting_text() { | |
3145 | if (within_table) { | |
3146 | if (!have_printed_row_begin) { | |
3147 | if (safe_printf(0, op->table_row_begin)) fprintf(stderr, TOO_MANY_ARGS, "table_row_begin"); | |
3148 | have_printed_row_begin=TRUE; | |
3149 | have_printed_row_end=FALSE; | |
3150 | have_printed_cell_begin=FALSE; | |
3151 | } | |
3152 | if (!have_printed_cell_begin) { | |
3153 | if (safe_printf(0, op->table_cell_begin)) fprintf(stderr, TOO_MANY_ARGS, "table_cell_begin"); | |
3920 | void | |
3921 | starting_text() | |
3922 | { | |
3923 | if (within_table) | |
3924 | { | |
3925 | if (!have_printed_row_begin) | |
3926 | { | |
3927 | if (safe_printf(0, op->table_row_begin)) | |
3928 | { | |
3929 | fprintf(stderr, TOO_MANY_ARGS, "table_row_begin"); | |
3930 | } | |
3931 | have_printed_row_begin = TRUE; | |
3932 | have_printed_row_end = FALSE; | |
3933 | have_printed_cell_begin = FALSE; | |
3934 | } | |
3935 | if (!have_printed_cell_begin) | |
3936 | { | |
3937 | if (safe_printf(0, op->table_cell_begin)) | |
3938 | { | |
3939 | fprintf(stderr, TOO_MANY_ARGS, "table_cell_begin"); | |
3940 | } | |
3154 | 3941 | attrstack_express_all(); |
3155 | have_printed_cell_begin=TRUE; | |
3156 | have_printed_cell_end=FALSE; | |
3157 | } | |
3158 | } | |
3159 | } | |
3160 | ||
3161 | ||
3162 | ||
3163 | ||
3164 | /*======================================================================== | |
3165 | * Name: | |
3166 | * Purpose: | |
3942 | have_printed_cell_begin = TRUE; | |
3943 | have_printed_cell_end = FALSE; | |
3944 | } | |
3945 | } | |
3946 | } | |
3947 | ||
3948 | ||
3949 | ||
3950 | ||
3951 | /*======================================================================== | |
3952 | * Name: | |
3953 | * Purpose: | |
3167 | 3954 | * Args: None. |
3168 | 3955 | * Returns: None. |
3169 | 3956 | *=======================================================================*/ |
3170 | 3957 | |
3171 | 3958 | static void |
3172 | starting_paragraph_align (int align) | |
3959 | starting_paragraph_align(int align) | |
3173 | 3960 | { |
3174 | 3961 | if (within_header && align != ALIGN_LEFT) |
3962 | { | |
3175 | 3963 | starting_body(); |
3176 | ||
3177 | switch (align) | |
3964 | } | |
3965 | ||
3966 | switch (align) | |
3178 | 3967 | { |
3179 | 3968 | case ALIGN_CENTER: |
3180 | if (safe_printf(0, op->center_begin)) fprintf(stderr, TOO_MANY_ARGS, "center_begin"); | |
3969 | if (safe_printf(0, op->center_begin)) | |
3970 | { | |
3971 | fprintf(stderr, TOO_MANY_ARGS, "center_begin"); | |
3972 | } | |
3181 | 3973 | break; |
3182 | 3974 | case ALIGN_LEFT: |
3183 | 3975 | break; |
3184 | 3976 | case ALIGN_RIGHT: |
3185 | if (safe_printf(0, op->align_right_begin)) fprintf(stderr, TOO_MANY_ARGS, "align_right_begin"); | |
3977 | if (safe_printf(0, op->align_right_begin)) | |
3978 | { | |
3979 | fprintf(stderr, TOO_MANY_ARGS, "align_right_begin"); | |
3980 | } | |
3186 | 3981 | break; |
3187 | 3982 | case ALIGN_JUSTIFY: |
3188 | if (safe_printf(0, op->justify_begin)) fprintf(stderr, TOO_MANY_ARGS, "justify_begin"); /* But this is correct */ | |
3983 | if (safe_printf(0, op->justify_begin)) | |
3984 | { | |
3985 | fprintf(stderr, TOO_MANY_ARGS, "justify_begin"); /* But this is correct */ | |
3986 | } | |
3189 | 3987 | break; |
3190 | 3988 | } |
3191 | 3989 | } |
3193 | 3991 | |
3194 | 3992 | |
3195 | 3993 | /*======================================================================== |
3196 | * Name: | |
3197 | * Purpose: | |
3994 | * Name: | |
3995 | * Purpose: | |
3198 | 3996 | * Args: None. |
3199 | 3997 | * Returns: None. |
3200 | 3998 | *=======================================================================*/ |
3201 | 3999 | |
3202 | 4000 | static void |
3203 | ending_paragraph_align (int align) | |
3204 | { | |
3205 | switch (align) { | |
4001 | ending_paragraph_align(int align) | |
4002 | { | |
4003 | switch (align) | |
4004 | { | |
3206 | 4005 | case ALIGN_CENTER: |
3207 | if (safe_printf(0, op->center_end)) fprintf(stderr, TOO_MANY_ARGS, "center_end"); | |
4006 | if (safe_printf(0, op->center_end)) | |
4007 | { | |
4008 | fprintf(stderr, TOO_MANY_ARGS, "center_end"); | |
4009 | } | |
3208 | 4010 | break; |
3209 | 4011 | case ALIGN_LEFT: |
3210 | 4012 | break; |
3211 | 4013 | case ALIGN_RIGHT: |
3212 | if (safe_printf(0, op->align_right_end)) fprintf(stderr, TOO_MANY_ARGS, "align_right_end"); | |
4014 | if (safe_printf(0, op->align_right_end)) | |
4015 | { | |
4016 | fprintf(stderr, TOO_MANY_ARGS, "align_right_end"); | |
4017 | } | |
3213 | 4018 | break; |
3214 | 4019 | case ALIGN_JUSTIFY: |
3215 | if (safe_printf(0, op->justify_end)) fprintf(stderr, TOO_MANY_ARGS, "justify_end"); | |
4020 | if (safe_printf(0, op->justify_end)) | |
4021 | { | |
4022 | fprintf(stderr, TOO_MANY_ARGS, "justify_end"); | |
4023 | } | |
3216 | 4024 | break; |
3217 | 4025 | } |
3218 | 4026 | } |
3224 | 4032 | static void |
3225 | 4033 | flush_iconv_input() |
3226 | 4034 | { |
3227 | /* fprintf(stderr, "flush_iconv_input: iconv_cur %d\n", iconv_cur);*/ | |
3228 | if (iconv_cur <= 0) { | |
3229 | iconv_cur = 0; | |
3230 | return; | |
3231 | } | |
3232 | maybeopeniconv(); | |
3233 | if (!my_iconv_is_valid(desc)) { | |
3234 | fprintf(stderr, "unrtf: flush: iconv not ready!\n"); | |
3235 | return; | |
3236 | } | |
3237 | ||
3238 | char obuf[IIBS]; | |
3239 | size_t isiz = iconv_cur; | |
3240 | char *ip = iconv_buffer; | |
3241 | while (isiz > 0) { | |
3242 | size_t osiz; | |
3243 | char *ocp; | |
3244 | ||
3245 | osiz = IIBS; | |
3246 | ocp = obuf; | |
3247 | errno = 0; | |
3248 | if(my_iconv(desc, &ip, &isiz, &ocp, &osiz) == (size_t)-1 && errno != E2BIG) { | |
3249 | if (errno == EINVAL) { | |
3250 | // Incomplete input sequence. Copy it to the | |
3251 | // beginning of the buffer and leave it around | |
3252 | // (more data probably coming) | |
3253 | // iconv leaves ip pointing at the | |
3254 | // beginning of the sequence. | |
3255 | int cnt = iconv_cur - (ip - iconv_buffer); | |
3256 | /* fprintf(stderr, "flush_iconv: incomp. input remain %d\n", cnt);*/ | |
3257 | memcpy(obuf, ip, cnt); | |
3258 | memcpy(iconv_buffer, obuf, cnt); | |
3259 | iconv_cur = cnt; | |
3260 | return; | |
3261 | } else { | |
3262 | /* fprintf(stderr, "flush_iconv: rem. %d errno %d\n", isiz, errno);*/ | |
3263 | iconv_cur = 0; | |
3264 | return; | |
3265 | } | |
3266 | } | |
3267 | /* fprintf(stderr, "flush_iconv: ok: isiz %d out %d errno %d\n", | |
3268 | isiz, IIBS - osiz, errno); */ | |
3269 | ||
3270 | ||
3271 | /* fwrite(obuf, 1, IIBS - osiz, stdout);*/ | |
3272 | char *out = op_translate_buffer(op, obuf, IIBS - osiz); | |
3273 | if (out == 0) { | |
3274 | iconv_cur = 0; | |
3275 | return; | |
3276 | } | |
3277 | fprintf(stdout, "%s", out); | |
3278 | my_free(out); | |
3279 | } | |
3280 | iconv_cur = 0; | |
4035 | /* fprintf(stderr, "flush_iconv_input: iconv_cur %d\n", iconv_cur);*/ | |
4036 | if (iconv_cur <= 0) | |
4037 | { | |
4038 | iconv_cur = 0; | |
4039 | return; | |
4040 | } | |
4041 | maybeopeniconv(); | |
4042 | if (!my_iconv_is_valid(desc)) | |
4043 | { | |
4044 | fprintf(stderr, "unrtf: flush: iconv not ready!\n"); | |
4045 | return; | |
4046 | } | |
4047 | ||
4048 | char obuf[IIBS]; | |
4049 | size_t isiz = iconv_cur; | |
4050 | char *ip = iconv_buffer; | |
4051 | while (isiz > 0) | |
4052 | { | |
4053 | size_t osiz; | |
4054 | char *ocp; | |
4055 | ||
4056 | osiz = IIBS; | |
4057 | ocp = obuf; | |
4058 | errno = 0; | |
4059 | if (my_iconv(desc, &ip, &isiz, &ocp, &osiz) == (size_t) - 1 && errno != E2BIG) | |
4060 | { | |
4061 | if (errno == EINVAL) | |
4062 | { | |
4063 | // Incomplete input sequence. Copy it to the | |
4064 | // beginning of the buffer and leave it around | |
4065 | // (more data probably coming) | |
4066 | // iconv leaves ip pointing at the | |
4067 | // beginning of the sequence. | |
4068 | int cnt = iconv_cur - (ip - iconv_buffer); | |
4069 | /* fprintf(stderr, "flush_iconv: incomp. input remain %d\n", cnt);*/ | |
4070 | memcpy(obuf, ip, cnt); | |
4071 | memcpy(iconv_buffer, obuf, cnt); | |
4072 | iconv_cur = cnt; | |
4073 | return; | |
4074 | } | |
4075 | else | |
4076 | { | |
4077 | /* fprintf(stderr, "flush_iconv: rem. %d errno %d\n", isiz, errno);*/ | |
4078 | iconv_cur = 0; | |
4079 | return; | |
4080 | } | |
4081 | } | |
4082 | /* fprintf(stderr, "flush_iconv: ok: isiz %d out %d errno %d\n", | |
4083 | isiz, IIBS - osiz, errno); */ | |
4084 | ||
4085 | ||
4086 | /* fwrite(obuf, 1, IIBS - osiz, stdout);*/ | |
4087 | char *out = op_translate_buffer(op, obuf, IIBS - osiz); | |
4088 | if (out == 0) | |
4089 | { | |
4090 | iconv_cur = 0; | |
4091 | return; | |
4092 | } | |
4093 | fprintf(stdout, "%s", out); | |
4094 | my_free(out); | |
4095 | } | |
4096 | iconv_cur = 0; | |
3281 | 4097 | } |
3282 | 4098 | |
3283 | 4099 | static void |
3284 | 4100 | accumulate_iconv_input(int ch) |
3285 | 4101 | { |
3286 | /* fprintf(stderr, "accumulate_iconv_input: 0x%x\n", ch);*/ | |
3287 | if (iconv_cur >= IIBS-1) | |
3288 | flush_iconv_input(); | |
3289 | iconv_buffer[iconv_cur++] = ch; | |
3290 | } | |
3291 | ||
3292 | /*======================================================================== | |
3293 | * Name: | |
4102 | /* fprintf(stderr, "accumulate_iconv_input: 0x%x\n", ch);*/ | |
4103 | if (iconv_cur >= IIBS - 1) | |
4104 | { | |
4105 | flush_iconv_input(); | |
4106 | } | |
4107 | iconv_buffer[iconv_cur++] = ch; | |
4108 | } | |
4109 | ||
4110 | /*======================================================================== | |
4111 | * Name: | |
3294 | 4112 | * Purpose: Recursive routine to produce the output in the target |
3295 | 4113 | * format given on a tree of words. |
3296 | 4114 | * Args: Word* (the tree). |
3298 | 4116 | *=======================================================================*/ |
3299 | 4117 | |
3300 | 4118 | static void |
3301 | word_print_core (Word *w, int groupdepth) | |
4119 | word_print_core(Word *w, int groupdepth) | |
3302 | 4120 | { |
3303 | 4121 | const char *s; |
3304 | 4122 | const char *alias; |
3305 | FILE *pictfile=NULL; | |
3306 | int is_cell_group=FALSE; | |
3307 | int paragraph_begined=FALSE; | |
3308 | int paragraph_align=ALIGN_LEFT; | |
3309 | ||
3310 | if (groupdepth > MAX_GROUP_DEPTH) { | |
3311 | warning_handler ("Max group depth reached"); | |
4123 | FILE *pictfile = NULL; | |
4124 | int is_cell_group = FALSE; | |
4125 | int paragraph_begined = FALSE; | |
4126 | int paragraph_align = ALIGN_LEFT; | |
4127 | ||
4128 | if (groupdepth > MAX_GROUP_DEPTH) | |
4129 | { | |
4130 | warning_handler("Max group depth reached"); | |
3312 | 4131 | return; |
3313 | } | |
4132 | } | |
3314 | 4133 | CHECK_PARAM_NOT_NULL(w); |
3315 | 4134 | |
3316 | 4135 | //if (!coming_pars_that_are_tabular && within_table) { |
3317 | //end_table(); | |
4136 | //end_table(); | |
3318 | 4137 | //} |
3319 | 4138 | //else if (coming_pars_that_are_tabular && !within_table) { |
3320 | //begin_table(); | |
4139 | //begin_table(); | |
3321 | 4140 | //} |
3322 | 4141 | check_for_table(); |
3323 | 4142 | |
3324 | 4143 | /* Mark our place in the stack */ |
3325 | 4144 | attrstack_push(); |
3326 | 4145 | |
3327 | while (w) { | |
3328 | ||
3329 | s = word_string (w); | |
3330 | // If we have hex data and we're getting out of the hex area | |
3331 | // flush it. | |
3332 | if (iconv_cur > 0 && s && strncmp(s, "\\'", 2)) | |
3333 | flush_iconv_input(); | |
3334 | ||
3335 | if (s) { | |
4146 | while (w) | |
4147 | { | |
4148 | ||
4149 | s = word_string(w); | |
4150 | // If we have hex data and we're getting out of the hex area | |
4151 | // flush it. | |
4152 | if (iconv_cur > 0 && s && strncmp(s, "\\'", 2)) | |
4153 | { | |
4154 | flush_iconv_input(); | |
4155 | } | |
4156 | ||
4157 | if (s) | |
4158 | { | |
3336 | 4159 | |
3337 | 4160 | /*--Ignore whitespace in header--------------------*/ |
3338 | if (*s==' ' && within_header) { | |
4161 | if (*s == ' ' && within_header) | |
4162 | { | |
3339 | 4163 | /* no op */ |
3340 | } | |
4164 | } | |
3341 | 4165 | else |
3342 | /*--Handle word -----------------------------------*/ | |
3343 | if (s[0] != '\\') | |
3344 | { | |
3345 | starting_body(); | |
3346 | starting_text(); | |
3347 | ||
3348 | if (!paragraph_begined) { | |
3349 | starting_paragraph_align (paragraph_align); | |
3350 | paragraph_begined=TRUE; | |
3351 | } | |
3352 | ||
3353 | /*----------------------------------------*/ | |
3354 | if (within_picture) | |
4166 | /*--Handle word -----------------------------------*/ | |
4167 | if (s[0] != '\\') | |
3355 | 4168 | { |
3356 | if (within_picture_depth == 0) | |
3357 | within_picture_depth = groupdepth; | |
3358 | 4169 | starting_body(); |
3359 | if (!pictfile && !nopict_mode) { | |
3360 | char *ext=NULL; | |
3361 | switch (picture_type) { | |
3362 | case PICT_WB: ext="bmp"; break; | |
3363 | case PICT_WM: ext="wmf"; break; | |
3364 | case PICT_MAC: ext="pict"; break; | |
3365 | case PICT_JPEG: ext="jpg"; break; | |
3366 | case PICT_PNG: ext="png"; break; | |
3367 | case PICT_DI: ext="dib"; break; /* Device independent bitmap=??? */ | |
3368 | case PICT_PM: ext="pmm"; break; /* OS/2 metafile=??? */ | |
3369 | case PICT_EMF: ext="emf"; break; /* Enhanced MetaFile */ | |
4170 | starting_text(); | |
4171 | ||
4172 | if (!paragraph_begined) | |
4173 | { | |
4174 | starting_paragraph_align(paragraph_align); | |
4175 | paragraph_begined = TRUE; | |
4176 | } | |
4177 | ||
4178 | /*----------------------------------------*/ | |
4179 | if (within_picture) | |
4180 | { | |
4181 | if (within_picture_depth == 0) | |
4182 | { | |
4183 | within_picture_depth = groupdepth; | |
3370 | 4184 | } |
3371 | sprintf(picture_path, "pict%03d.%s", | |
3372 | picture_file_number++,ext); | |
3373 | pictfile=fopen(picture_path,"wb"); | |
3374 | } | |
3375 | ||
3376 | if (s[0]!=' ') { | |
3377 | const char *s2; | |
3378 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
3379 | printf("picture data found, "); | |
3380 | if (picture_wmetafile_type_str) { | |
3381 | printf("WMF type is %s, ", | |
3382 | picture_wmetafile_type_str); | |
4185 | starting_body(); | |
4186 | if (!pictfile && !nopict_mode) | |
4187 | { | |
4188 | char *ext = NULL; | |
4189 | switch (picture_type) | |
4190 | { | |
4191 | case PICT_WB: | |
4192 | ext = "bmp"; | |
4193 | break; | |
4194 | case PICT_WM: | |
4195 | ext = "wmf"; | |
4196 | break; | |
4197 | case PICT_MAC: | |
4198 | ext = "pict"; | |
4199 | break; | |
4200 | case PICT_JPEG: | |
4201 | ext = "jpg"; | |
4202 | break; | |
4203 | case PICT_PNG: | |
4204 | ext = "png"; | |
4205 | break; | |
4206 | case PICT_DI: | |
4207 | ext = "dib"; | |
4208 | break; /* Device independent bitmap=??? */ | |
4209 | case PICT_PM: | |
4210 | ext = "pmm"; | |
4211 | break; /* OS/2 metafile=??? */ | |
4212 | case PICT_EMF: | |
4213 | ext = "emf"; | |
4214 | break; /* Enhanced MetaFile */ | |
4215 | } | |
4216 | snprintf(picture_path, 255, "pict%03d.%s", | |
4217 | picture_file_number++, ext); | |
4218 | pictfile = fopen(picture_path, "wb"); | |
3383 | 4219 | } |
3384 | printf("picture dimensions are %d by %d, depth %d", | |
3385 | picture_width, picture_height, picture_bits_per_pixel); | |
3386 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
3387 | if (picture_width && picture_height && picture_bits_per_pixel) { | |
3388 | s2=s; | |
3389 | /* Convert hex char pairs. Guard against odd byte count from garbled file */ | |
3390 | while (*s2 && *(s2+1)) { | |
3391 | unsigned int tmp,value; | |
3392 | tmp=tolower(*s2++); | |
3393 | if (tmp>'9') tmp-=('a'-10); | |
3394 | else tmp-='0'; | |
3395 | value=16*tmp; | |
3396 | tmp=tolower(*s2++); | |
3397 | if (tmp>'9') tmp-=('a'-10); | |
3398 | else tmp-='0'; | |
3399 | value+=tmp; | |
3400 | if (pictfile) { | |
3401 | fprintf(pictfile,"%c", value); | |
4220 | ||
4221 | if (s[0] != ' ') | |
4222 | { | |
4223 | const char *s2; | |
4224 | if (safe_printf(0, op->comment_begin)) | |
4225 | { | |
4226 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
4227 | } | |
4228 | printf("picture data found, "); | |
4229 | if (picture_wmetafile_type_str) | |
4230 | { | |
4231 | printf("WMF type is %s, ", | |
4232 | picture_wmetafile_type_str); | |
4233 | } | |
4234 | printf("picture dimensions are %d by %d, depth %d", | |
4235 | picture_width, picture_height, picture_bits_per_pixel); | |
4236 | if (safe_printf(0, op->comment_end)) | |
4237 | { | |
4238 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
4239 | } | |
4240 | if (picture_width && picture_height && picture_bits_per_pixel) | |
4241 | { | |
4242 | s2 = s; | |
4243 | /* Convert hex char pairs. Guard against odd byte count from garbled file */ | |
4244 | while (*s2 && *(s2 + 1)) | |
4245 | { | |
4246 | unsigned int tmp, value; | |
4247 | tmp = tolower(*s2++); | |
4248 | if (tmp > '9') | |
4249 | { | |
4250 | tmp -= ('a' - 10); | |
4251 | } | |
4252 | else | |
4253 | { | |
4254 | tmp -= '0'; | |
4255 | } | |
4256 | value = 16 * tmp; | |
4257 | tmp = tolower(*s2++); | |
4258 | if (tmp > '9') | |
4259 | { | |
4260 | tmp -= ('a' - 10); | |
4261 | } | |
4262 | else | |
4263 | { | |
4264 | tmp -= '0'; | |
4265 | } | |
4266 | value += tmp; | |
4267 | if (pictfile) | |
4268 | { | |
4269 | fprintf(pictfile, "%c", value); | |
4270 | } | |
3402 | 4271 | } |
3403 | 4272 | } |
3404 | 4273 | } |
3405 | 4274 | } |
4275 | /*----------------------------------------*/ | |
4276 | else | |
4277 | { | |
4278 | total_chars_this_line += strlen(s); | |
4279 | ||
4280 | if (op->word_begin) | |
4281 | if (safe_printf(0, op->word_begin)) | |
4282 | { | |
4283 | fprintf(stderr, TOO_MANY_ARGS, "word_begin"); | |
4284 | } | |
4285 | ||
4286 | print_with_special_exprs(s); | |
4287 | ||
4288 | if (op->word_end) | |
4289 | if (safe_printf(0, op->word_end)) | |
4290 | { | |
4291 | fprintf(stderr, TOO_MANY_ARGS, "word_end"); | |
4292 | } | |
4293 | } | |
4294 | ||
4295 | ||
3406 | 4296 | } |
3407 | /*----------------------------------------*/ | |
3408 | else { | |
3409 | total_chars_this_line += strlen(s); | |
3410 | ||
3411 | if (op->word_begin) | |
3412 | if (safe_printf(0, op->word_begin)) fprintf(stderr, TOO_MANY_ARGS, "word_begin"); | |
3413 | ||
3414 | print_with_special_exprs (s); | |
3415 | ||
3416 | if (op->word_end) | |
3417 | if (safe_printf(0, op->word_end)) fprintf(stderr, TOO_MANY_ARGS, "word_end"); | |
3418 | } | |
3419 | ||
3420 | ||
3421 | } | |
3422 | 4297 | /* output an escaped backslash */ |
3423 | 4298 | /* do we need special handling for latex? */ |
3424 | 4299 | /* we do for troff where we want the string for 92 */ |
3425 | else if (*(s+1) == '\\') | |
3426 | { | |
3427 | s++; | |
3428 | if ((alias = get_alias(op, 92)) != NULL) | |
4300 | else if (*(s + 1) == '\\') | |
3429 | 4301 | { |
3430 | printf("%s", alias); | |
4302 | s++; | |
4303 | if ((alias = get_alias(op, 92)) != NULL) | |
4304 | { | |
4305 | printf("%s", alias); | |
4306 | } | |
4307 | else | |
4308 | { | |
4309 | putchar('\\'); | |
4310 | } | |
3431 | 4311 | } |
4312 | else if (*(s + 1) == '{') | |
4313 | { | |
4314 | s++; | |
4315 | putchar('{'); | |
4316 | } | |
4317 | else if (*(s + 1) == '}') | |
4318 | { | |
4319 | s++; | |
4320 | putchar('}'); | |
4321 | } | |
4322 | /*---Handle RTF keywords---------------------------*/ | |
3432 | 4323 | else |
3433 | 4324 | { |
3434 | putchar('\\'); | |
4325 | s++; | |
4326 | /*----Paragraph alignment----------------------------------------------------*/ | |
4327 | if (!strcmp("ql", s)) | |
4328 | { | |
4329 | paragraph_align = ALIGN_LEFT; | |
4330 | } | |
4331 | else if (!strcmp("qr", s)) | |
4332 | { | |
4333 | paragraph_align = ALIGN_RIGHT; | |
4334 | } | |
4335 | else if (!strcmp("qj", s)) | |
4336 | { | |
4337 | paragraph_align = ALIGN_JUSTIFY; | |
4338 | } | |
4339 | else if (!strcmp("qc", s)) | |
4340 | { | |
4341 | paragraph_align = ALIGN_CENTER; | |
4342 | } | |
4343 | else if (!strcmp("pard", s)) | |
4344 | { | |
4345 | /* Clear out all font attributes. | |
4346 | */ | |
4347 | attr_pop_all(); | |
4348 | ||
4349 | if (coming_pars_that_are_tabular) | |
4350 | { | |
4351 | --coming_pars_that_are_tabular; | |
4352 | } | |
4353 | ||
4354 | /* Clear out all paragraph attributes. | |
4355 | */ | |
4356 | ending_paragraph_align(paragraph_align); | |
4357 | paragraph_align = ALIGN_LEFT; | |
4358 | paragraph_begined = FALSE; | |
4359 | } | |
4360 | /*----Table keywords---------------------------------------------------------*/ | |
4361 | else if (!strcmp(s, "cell")) | |
4362 | { | |
4363 | ||
4364 | is_cell_group = TRUE; | |
4365 | if (!have_printed_cell_begin) | |
4366 | { | |
4367 | /* Need this with empty cells */ | |
4368 | if (safe_printf(0, op->table_cell_begin)) | |
4369 | { | |
4370 | fprintf(stderr, TOO_MANY_ARGS, "table_cell_begin"); | |
4371 | } | |
4372 | attrstack_express_all(); | |
4373 | } | |
4374 | attr_pop_all(); | |
4375 | if (safe_printf(0, op->table_cell_end)) | |
4376 | { | |
4377 | fprintf(stderr, TOO_MANY_ARGS, "table_cell_end"); | |
4378 | } | |
4379 | have_printed_cell_begin = FALSE; | |
4380 | have_printed_cell_end = TRUE; | |
4381 | } | |
4382 | else if (!strcmp(s, "row")) | |
4383 | { | |
4384 | ||
4385 | if (within_table) | |
4386 | { | |
4387 | if (safe_printf(0, op->table_row_end)) | |
4388 | { | |
4389 | fprintf(stderr, TOO_MANY_ARGS, "table_row_end"); | |
4390 | } | |
4391 | have_printed_row_begin = FALSE; | |
4392 | have_printed_row_end = TRUE; | |
4393 | } | |
4394 | else | |
4395 | { | |
4396 | if (debug_mode) | |
4397 | { | |
4398 | if (safe_printf(0, op->comment_begin)) | |
4399 | { | |
4400 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
4401 | } | |
4402 | printf("end of table row"); | |
4403 | if (safe_printf(0, op->comment_end)) | |
4404 | { | |
4405 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
4406 | } | |
4407 | } | |
4408 | } | |
4409 | } | |
4410 | ||
4411 | /*----Special chars---------------------------------------------------------*/ | |
4412 | else if (*s == '\'' && s[1] && s[2]) | |
4413 | { | |
4414 | /* \'XX is a hex char code expression */ | |
4415 | ||
4416 | int ch = h2toi(&s[1]); | |
4417 | accumulate_iconv_input(ch); | |
4418 | } | |
4419 | else | |
4420 | /*----Search the RTF command hash-------------------------------------------*/ | |
4421 | { | |
4422 | int have_param = FALSE, param = 0; | |
4423 | HashItem *hip = find_command(s, &have_param, ¶m); | |
4424 | if (hip) | |
4425 | { | |
4426 | int terminate_group; | |
4427 | ||
4428 | if (hip->func) | |
4429 | { | |
4430 | terminate_group = hip->func(w, paragraph_align, have_param, param); | |
4431 | /* daved - 0.19.4 - unicode support may need to skip only one word */ | |
4432 | if (terminate_group == SKIP_ONE_WORD) | |
4433 | { | |
4434 | w = w->next; | |
4435 | } | |
4436 | else if (terminate_group) | |
4437 | while (w) | |
4438 | { | |
4439 | w = w->next; | |
4440 | } | |
4441 | } | |
4442 | ||
4443 | if (hip->debug_print && debug_mode) | |
4444 | { | |
4445 | if (safe_printf(0, op->comment_begin)) | |
4446 | { | |
4447 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
4448 | } | |
4449 | printf("%s", hip->debug_print); | |
4450 | if (safe_printf(0, op->comment_end)) | |
4451 | { | |
4452 | fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
4453 | } | |
4454 | } | |
4455 | ||
4456 | } | |
4457 | } | |
3435 | 4458 | } |
4459 | /*-------------------------------------------------------------------------*/ | |
4460 | } | |
4461 | else | |
4462 | { | |
4463 | ||
4464 | Word *child; | |
4465 | ||
4466 | child = w->child; | |
4467 | ||
4468 | if (!paragraph_begined) | |
4469 | { | |
4470 | starting_paragraph_align(paragraph_align); | |
4471 | paragraph_begined = TRUE; | |
3436 | 4472 | } |
3437 | else if (*(s+1) == '{') | |
4473 | ||
4474 | if (child) | |
3438 | 4475 | { |
3439 | s++; | |
3440 | putchar('{'); | |
4476 | word_print_core(child, groupdepth + 1); | |
3441 | 4477 | } |
3442 | else if (*(s+1) == '}') | |
4478 | } | |
4479 | ||
4480 | if (w) | |
4481 | { | |
4482 | w = w->next; | |
4483 | } | |
4484 | } | |
4485 | ||
4486 | if (within_picture && within_picture_depth == groupdepth) | |
4487 | { | |
4488 | within_picture_depth = 0; | |
4489 | if (pictfile) | |
4490 | { | |
4491 | fclose(pictfile); | |
4492 | if (safe_printf(0, op->imagelink_begin)) | |
3443 | 4493 | { |
3444 | s++; | |
3445 | putchar('}'); | |
4494 | fprintf(stderr, TOO_MANY_ARGS, "imagelink_begin"); | |
3446 | 4495 | } |
3447 | /*---Handle RTF keywords---------------------------*/ | |
3448 | else { | |
3449 | s++; | |
3450 | /*----Paragraph alignment----------------------------------------------------*/ | |
3451 | if (!strcmp ("ql", s)) | |
3452 | paragraph_align = ALIGN_LEFT; | |
3453 | else if (!strcmp ("qr", s)) | |
3454 | paragraph_align = ALIGN_RIGHT; | |
3455 | else if (!strcmp ("qj", s)) | |
3456 | paragraph_align = ALIGN_JUSTIFY; | |
3457 | else if (!strcmp ("qc", s)) | |
3458 | paragraph_align = ALIGN_CENTER; | |
3459 | else if (!strcmp ("pard", s)) | |
3460 | { | |
3461 | /* Clear out all font attributes. | |
3462 | */ | |
3463 | attr_pop_all(); | |
3464 | ||
3465 | if (coming_pars_that_are_tabular) { | |
3466 | --coming_pars_that_are_tabular; | |
3467 | } | |
3468 | ||
3469 | /* Clear out all paragraph attributes. | |
3470 | */ | |
3471 | ending_paragraph_align(paragraph_align); | |
3472 | paragraph_align = ALIGN_LEFT; | |
3473 | paragraph_begined = FALSE; | |
3474 | } | |
3475 | /*----Table keywords---------------------------------------------------------*/ | |
3476 | else | |
3477 | if (!strcmp (s, "cell")) { | |
3478 | ||
3479 | is_cell_group=TRUE; | |
3480 | if (!have_printed_cell_begin) { | |
3481 | /* Need this with empty cells */ | |
3482 | if (safe_printf(0, op->table_cell_begin)) fprintf(stderr, TOO_MANY_ARGS, "table_cell_begin"); | |
3483 | attrstack_express_all(); | |
3484 | } | |
3485 | attr_pop_dump(); | |
3486 | if (safe_printf(0, op->table_cell_end)) fprintf(stderr, TOO_MANY_ARGS, "table_cell_end"); | |
3487 | have_printed_cell_begin = FALSE; | |
3488 | have_printed_cell_end=TRUE; | |
3489 | } | |
3490 | else if (!strcmp (s, "row")) { | |
3491 | ||
3492 | if (within_table) { | |
3493 | if (safe_printf(0, op->table_row_end)) fprintf(stderr, TOO_MANY_ARGS, "table_row_end"); | |
3494 | have_printed_row_begin = FALSE; | |
3495 | have_printed_row_end=TRUE; | |
3496 | } else { | |
3497 | if (debug_mode) { | |
3498 | if (safe_printf(0, op->comment_begin)) fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
3499 | printf("end of table row"); | |
3500 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
3501 | } | |
3502 | } | |
3503 | } | |
3504 | ||
3505 | /*----Special chars---------------------------------------------------------*/ | |
3506 | else if (*s == '\'' && s[1] && s[2]) { | |
3507 | /* \'XX is a hex char code expression */ | |
3508 | ||
3509 | int ch = h2toi (&s[1]); | |
3510 | accumulate_iconv_input(ch); | |
3511 | } | |
3512 | else | |
3513 | /*----Search the RTF command hash-------------------------------------------*/ | |
3514 | { | |
3515 | int have_param = FALSE, param = 0; | |
3516 | HashItem *hip = find_command(s, &have_param, ¶m); | |
3517 | if (hip) { | |
3518 | int terminate_group; | |
3519 | ||
3520 | if (hip->func) { | |
3521 | terminate_group = hip->func (w,paragraph_align, have_param, param); | |
3522 | /* daved - 0.19.4 - unicode support may need to skip only one word */ | |
3523 | if (terminate_group == SKIP_ONE_WORD) | |
3524 | w=w->next; | |
3525 | else | |
3526 | if (terminate_group) | |
3527 | while(w) w=w->next; | |
3528 | } | |
3529 | ||
3530 | if (hip->debug_print && debug_mode) { | |
3531 | if (safe_printf(0, op->comment_begin)) | |
3532 | fprintf(stderr, TOO_MANY_ARGS, "comment_begin"); | |
3533 | printf("%s", hip->debug_print); | |
3534 | if (safe_printf(0, op->comment_end)) fprintf(stderr, TOO_MANY_ARGS, "comment_end"); | |
3535 | } | |
3536 | ||
3537 | } | |
3538 | } | |
4496 | printf("%s", picture_path); | |
4497 | if (safe_printf(0, op->imagelink_end)) | |
4498 | { | |
4499 | fprintf(stderr, TOO_MANY_ARGS, "imagelink_end"); | |
3539 | 4500 | } |
3540 | /*-------------------------------------------------------------------------*/ | |
3541 | } else { | |
3542 | ||
3543 | Word *child; | |
3544 | ||
3545 | child = w->child; | |
3546 | ||
3547 | if (!paragraph_begined) { | |
3548 | starting_paragraph_align (paragraph_align); | |
3549 | paragraph_begined=TRUE; | |
3550 | } | |
3551 | ||
3552 | if (child) | |
3553 | word_print_core (child, groupdepth+1); | |
3554 | } | |
3555 | ||
3556 | if (w) | |
3557 | w = w->next; | |
3558 | } | |
3559 | ||
3560 | if (within_picture && within_picture_depth == groupdepth) | |
3561 | { | |
3562 | within_picture_depth = 0; | |
3563 | if(pictfile) | |
3564 | { | |
3565 | fclose(pictfile); | |
3566 | if (safe_printf(0, op->imagelink_begin)) fprintf(stderr, TOO_MANY_ARGS, "imagelink_begin"); | |
3567 | printf("%s", picture_path); | |
3568 | if (safe_printf(0, op->imagelink_end)) fprintf(stderr, TOO_MANY_ARGS, "imagelink_end"); | |
3569 | } | |
3570 | within_picture=FALSE; | |
4501 | } | |
4502 | within_picture = FALSE; | |
3571 | 4503 | } |
3572 | 4504 | |
3573 | 4505 | /* Undo font attributes UNLESS we're doing table cells |
3575 | 4507 | */ |
3576 | 4508 | |
3577 | 4509 | if (!is_cell_group) |
4510 | { | |
3578 | 4511 | attr_pop_all(); |
4512 | } | |
3579 | 4513 | else |
4514 | { | |
3580 | 4515 | attr_drop_all(); |
4516 | } | |
3581 | 4517 | |
3582 | 4518 | /* Undo paragraph alignment |
3583 | 4519 | */ |
3584 | 4520 | if (paragraph_begined) |
3585 | ending_paragraph_align (paragraph_align); | |
4521 | { | |
4522 | ending_paragraph_align(paragraph_align); | |
4523 | } | |
3586 | 4524 | |
3587 | 4525 | attrstack_drop(); |
3588 | 4526 | |
3589 | // Flush iconv input | |
3590 | flush_iconv_input(); | |
3591 | iconv_cur = 0; | |
3592 | ||
3593 | // If there is an encoding in the stacks, restore it, else | |
3594 | // restore default. | |
3595 | desc = my_iconv_close(desc); | |
3596 | char *encoding = attr_get_param(ATTR_ENCODING); | |
3597 | if (!encoding || !*encoding) | |
3598 | encoding = default_encoding; | |
3599 | desc = my_iconv_open(output_encoding, encoding); | |
3600 | set_current_encoding(encoding); | |
3601 | } | |
3602 | ||
3603 | ||
3604 | /*======================================================================== | |
3605 | * Name: | |
3606 | * Purpose: | |
4527 | // Flush iconv input | |
4528 | flush_iconv_input(); | |
4529 | iconv_cur = 0; | |
4530 | ||
4531 | // If there is an encoding in the stacks, restore it, else | |
4532 | // restore default. | |
4533 | desc = my_iconv_close(desc); | |
4534 | char *encoding = attr_get_param(ATTR_ENCODING); | |
4535 | if (!encoding || !*encoding) | |
4536 | { | |
4537 | encoding = default_encoding; | |
4538 | } | |
4539 | desc = my_iconv_open(output_encoding, encoding); | |
4540 | set_current_encoding(encoding); | |
4541 | } | |
4542 | ||
4543 | ||
4544 | /*======================================================================== | |
4545 | * Name: | |
4546 | * Purpose: | |
3607 | 4547 | * Args: None. |
3608 | 4548 | * Returns: None. |
3609 | 4549 | *=======================================================================*/ |
3610 | 4550 | |
3611 | void | |
3612 | word_print (Word *w) | |
3613 | { | |
3614 | CHECK_PARAM_NOT_NULL (w); | |
3615 | ||
3616 | if (!inline_mode) { | |
3617 | if (safe_printf(0, op->document_begin)) fprintf(stderr, TOO_MANY_ARGS, "document_begin"); | |
3618 | if (safe_printf(0, op->header_begin)) fprintf(stderr, TOO_MANY_ARGS, "header_begin"); | |
3619 | if (safe_printf(0, op->utf8_encoding)) fprintf(stderr, TOO_MANY_ARGS, "utf8_encoding"); | |
3620 | } | |
3621 | ||
3622 | print_banner (); | |
3623 | ||
3624 | within_header=TRUE; | |
3625 | have_printed_body=FALSE; | |
3626 | within_table=FALSE; | |
3627 | simulate_allcaps=FALSE; | |
3628 | word_print_core (w, 1); | |
4551 | void | |
4552 | word_print(Word *w) | |
4553 | { | |
4554 | CHECK_PARAM_NOT_NULL(w); | |
4555 | ||
4556 | if (!inline_mode) | |
4557 | { | |
4558 | if (safe_printf(0, op->document_begin)) | |
4559 | { | |
4560 | fprintf(stderr, TOO_MANY_ARGS, "document_begin"); | |
4561 | } | |
4562 | if (safe_printf(0, op->header_begin)) | |
4563 | { | |
4564 | fprintf(stderr, TOO_MANY_ARGS, "header_begin"); | |
4565 | } | |
4566 | if (safe_printf(0, op->utf8_encoding)) | |
4567 | { | |
4568 | fprintf(stderr, TOO_MANY_ARGS, "utf8_encoding"); | |
4569 | } | |
4570 | } | |
4571 | ||
4572 | if (!quiet) | |
4573 | { | |
4574 | print_banner(); | |
4575 | } | |
4576 | ||
4577 | within_header = TRUE; | |
4578 | have_printed_body = FALSE; | |
4579 | within_table = FALSE; | |
4580 | simulate_allcaps = FALSE; | |
4581 | word_print_core(w, 1); | |
3629 | 4582 | end_table(); |
3630 | 4583 | |
3631 | if (!inline_mode) { | |
3632 | if (safe_printf(0, op->body_end)) fprintf(stderr, TOO_MANY_ARGS, "body_end"); | |
3633 | if (safe_printf(0, op->document_end)) fprintf(stderr, TOO_MANY_ARGS, "document_end"); | |
3634 | } | |
3635 | } | |
4584 | if (!inline_mode) | |
4585 | { | |
4586 | if (safe_printf(0, op->body_end)) | |
4587 | { | |
4588 | fprintf(stderr, TOO_MANY_ARGS, "body_end"); | |
4589 | } | |
4590 | if (safe_printf(0, op->document_end)) | |
4591 | { | |
4592 | fprintf(stderr, TOO_MANY_ARGS, "document_end"); | |
4593 | } | |
4594 | } | |
4595 | } |
38 | 38 | |
39 | 39 | #include "word.h" |
40 | 40 | |
41 | enum { | |
42 | CHARSET_ANSI=1, | |
41 | enum | |
42 | { | |
43 | CHARSET_ANSI = 1, | |
43 | 44 | CHARSET_MAC, |
44 | 45 | CHARSET_CP437, |
45 | 46 | CHARSET_CP850, |
46 | 47 | }; |
47 | 48 | |
48 | extern void word_print (Word*); | |
49 | extern void word_print(Word *); | |
49 | 50 | #define FONT_GREEK "cp1253" |
50 | 51 | #define FONT_SYMBOL "SYMBOL" |
51 | 52 |
30 | 30 | * 10 Oct 00, tuorfa@yahoo.com: added usage() |
31 | 31 | * 15 Oct 00, tuorfa@yahoo.com: improved output readability |
32 | 32 | * 22 Sep 01, tuorfa@yahoo.com: removed mention of line number in handlers |
33 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
33 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
34 | 34 | * 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux |
35 | 35 | * 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp |
36 | 36 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
63 | 63 | *=======================================================================*/ |
64 | 64 | |
65 | 65 | void |
66 | usage () | |
66 | usage() | |
67 | 67 | { |
68 | 68 | fprintf(stderr, "Usage: %s\n", USAGE); |
69 | 69 | exit(-3); |
79 | 79 | *=======================================================================*/ |
80 | 80 | |
81 | 81 | void |
82 | error_handler (char* message) | |
82 | error_handler(char *message) | |
83 | 83 | { |
84 | 84 | #if 1 |
85 | 85 | fprintf(stderr, "Error (line %d): %s\n", lineno, message); |
98 | 98 | *=======================================================================*/ |
99 | 99 | |
100 | 100 | void |
101 | warning_handler (char* message) | |
101 | warning_handler(char *message) | |
102 | 102 | { |
103 | 103 | fprintf(stderr, "Warning: %s\n", message); |
104 | 104 | } |
42 | 42 | |
43 | 43 | |
44 | 44 | extern void usage(void); |
45 | extern void error_handler (char*); | |
46 | extern void warning_handler (char*); | |
45 | extern void error_handler(char *); | |
46 | extern void warning_handler(char *); | |
47 | 47 | |
48 | 48 | |
49 | 49 |
32 | 32 | * 08 Apr 01, tuorfa@yahoo.com: check for out of memory after malloc. |
33 | 33 | * 21 Apr 01, tuorfa@yahoo.com: signed to conversion unsigned bug |
34 | 34 | * 03 Aug 01, tuorfa@yahoo.com: fixes for using 16-bit compiler |
35 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
35 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
36 | 36 | * 08 Oct 03, daved@physiol.usyd.edu.au: some type fixes |
37 | 37 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requsted by ZT Smith |
38 | 38 | * 06 Jan 06, marcossamaral@terra.com.br: changes hash_stats function |
61 | 61 | #include "malloc.h" |
62 | 62 | |
63 | 63 | |
64 | typedef struct _hi { | |
64 | typedef struct _hi | |
65 | { | |
65 | 66 | struct _hi *next; |
66 | 67 | char str[1]; |
67 | 68 | } HashItem; |
80 | 81 | *=======================================================================*/ |
81 | 82 | |
82 | 83 | unsigned long |
83 | hash_stats () | |
84 | hash_stats() | |
84 | 85 | { |
85 | 86 | int i; |
86 | unsigned long total=0; | |
87 | unsigned long total = 0; | |
87 | 88 | HashItem *hi; |
88 | for (i=0; i<256; i++) { | |
89 | for (i = 0; i < 256; i++) | |
90 | { | |
89 | 91 | hi = hash[i]; |
90 | while (hi) { | |
92 | while (hi) | |
93 | { | |
91 | 94 | total++; |
92 | 95 | hi = hi->next; |
93 | 96 | } |
105 | 108 | *=======================================================================*/ |
106 | 109 | |
107 | 110 | static HashItem * |
108 | hashitem_new (char *str) | |
111 | hashitem_new(char *str) | |
109 | 112 | { |
110 | 113 | HashItem *hi; |
111 | 114 | |
112 | /* We already have a char[1], so allocating strlen() does | |
113 | yield space for the ending 0 */ | |
114 | unsigned int l = sizeof(HashItem)+strlen(str); | |
115 | hi=(HashItem*) my_malloc(l); | |
115 | /* We already have a char[1], so allocating strlen() does | |
116 | yield space for the ending 0 */ | |
117 | unsigned int l = sizeof(HashItem) + strlen(str); | |
118 | hi = (HashItem *) my_malloc(l); | |
116 | 119 | if (!hi) |
120 | { | |
117 | 121 | error_handler("Out of memory"); |
122 | } | |
118 | 123 | strcpy(hi->str, str); |
119 | 124 | hi->next = NULL; |
120 | 125 | |
131 | 136 | *=======================================================================*/ |
132 | 137 | |
133 | 138 | const char * |
134 | hash_store (char *str) | |
139 | hash_store(char *str) | |
135 | 140 | { |
136 | unsigned char ch = (unsigned char)*str; | |
141 | unsigned char ch = (unsigned char) * str; | |
137 | 142 | HashItem *hi; |
138 | 143 | |
139 | if (ch=='\\' && *(str+1)) | |
140 | ch = *(str+1); | |
144 | if (ch == '\\' && *(str + 1)) | |
145 | { | |
146 | ch = *(str + 1); | |
147 | } | |
141 | 148 | hi = hash[ch]; |
142 | while (hi) { | |
149 | while (hi) | |
150 | { | |
143 | 151 | if (!strcmp(hi->str, str)) |
152 | { | |
144 | 153 | return hi->str; |
154 | } | |
145 | 155 | hi = hi->next; |
146 | 156 | } |
147 | 157 | /* not in hash */ |
33 | 33 | *---------------------------------------------------------------------- |
34 | 34 | * Changes: |
35 | 35 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
36 | * 06 Jan 06, marcossamaral@terra.com.br: changes hash_stats() | |
36 | * 06 Jan 06, marcossamaral@terra.com.br: changes hash_stats() | |
37 | 37 | * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3 |
38 | 38 | * 07 Oct 11, jf@dockes.org, added _HASH_H_INCLUDED_ |
39 | 39 | * Further: see VCS log |
40 | 40 | *--------------------------------------------------------------------*/ |
41 | 41 | |
42 | 42 | |
43 | extern unsigned long hash_stats (void); | |
43 | extern unsigned long hash_stats(void); | |
44 | 44 | /* Store/find string, returns address of stored copy */ |
45 | extern const char *hash_store (char *); | |
45 | extern const char *hash_store(char *); | |
46 | 46 | |
47 | 47 | #endif /* _HASH_H_INCLUDED_ */ |
6 | 6 | the Free Software Foundation; either version 3 of the License, or |
7 | 7 | (at your option) any later version. |
8 | 8 | |
9 | This program is distributed in the hope that it will be useful, | |
9 | This program is distributed in the hope that it will be useful, | |
10 | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | 12 | GNU General Public License for more details. |
27 | 27 | *---------------------------------------------------------------------- |
28 | 28 | * Changes: |
29 | 29 | * 14 Oct 00, tuorfa@yahoo.com: added -nopict option |
30 | * 15 Oct 00, tuorfa@yahoo.com: added verify_file_type() | |
30 | * 15 Oct 00, tuorfa@yahoo.com: added verify_file_type() | |
31 | 31 | * 08 Apr 01, tuorfa@yahoo.com: more GNU-like switches implemented |
32 | 32 | * 24 Jul 01, tuorfa@yahoo.com: removed verify_file_type() |
33 | 33 | * 03 Aug 01, tuorfa@yahoo.com: added --inline switch |
34 | 34 | * 08 Sep 01, tuorfa@yahoo.com: added use of UnRTF |
35 | 35 | * 19 Sep 01, tuorfa@yahoo.com: addition of output personalities |
36 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
36 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
37 | 37 | * 23 Sep 01, tuorfa@yahoo.com: added wpml switch |
38 | 38 | * 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux |
39 | 39 | * 07 Jan 04, tuorfa@yahoo.com: removed broken PS support |
40 | 40 | * 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp |
41 | 41 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
42 | * 06 Jan 06, marcossamaral@terra.com.br: includes verbose mode | |
42 | * 06 Jan 06, marcossamaral@terra.com.br: includes verbose mode | |
43 | 43 | * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3 |
44 | 44 | * 17 Dec 07, daved@physiol.usyd.edu.au: support for --noremap from |
45 | 45 | * David Santinoli |
68 | 68 | #include <string.h> |
69 | 69 | #endif |
70 | 70 | |
71 | #ifdef HAVE_UNISTD_H | |
71 | 72 | #include <unistd.h> |
73 | #endif | |
72 | 74 | |
73 | 75 | #include "defs.h" |
74 | 76 | #include "error.h" |
111 | 113 | OutputPersonality * |
112 | 114 | get_config(char *name, OutputPersonality *op) |
113 | 115 | { |
114 | char *configfile = 0; | |
115 | if(!path_checked && check_dirs() == 0) | |
116 | { | |
117 | fprintf(stderr,"No config directories. Searched: %s\n", search_path); | |
118 | exit(1); | |
119 | } | |
120 | configfile = search_in_path(name, "conf"); | |
121 | if (configfile == NULL) | |
122 | { | |
123 | fprintf(stderr, "failed to find %s.conf in search path dirs\n", name); | |
124 | exit(1); | |
125 | } | |
126 | op = user_init(op, configfile); | |
127 | free(configfile); | |
128 | return op; | |
116 | char *configfile = 0; | |
117 | if (!path_checked && check_dirs() == 0) | |
118 | { | |
119 | fprintf(stderr, "No config directories. Searched: %s\n", search_path); | |
120 | exit(1); | |
121 | } | |
122 | configfile = search_in_path(name, "conf"); | |
123 | if (configfile == NULL) | |
124 | { | |
125 | fprintf(stderr, "failed to find %s.conf in search path dirs\n", name); | |
126 | exit(1); | |
127 | } | |
128 | op = user_init(op, configfile); | |
129 | free(configfile); | |
130 | return op; | |
129 | 131 | } |
130 | 132 | |
131 | 133 | /*======================================================================== |
136 | 138 | *=======================================================================*/ |
137 | 139 | |
138 | 140 | int |
139 | main (int argc, char **argv) | |
141 | main(int argc, char **argv) | |
140 | 142 | { |
141 | 143 | FILE *f; |
142 | Word * word; | |
144 | Word *word; | |
143 | 145 | char *path = NULL; |
144 | char *env_path_p = '\0'; | |
146 | char *env_path_p = NULL; | |
145 | 147 | |
146 | 148 | int i; |
147 | nopict_mode = debug_mode = dump_mode = inline_mode = no_remap_mode = FALSE; | |
149 | nopict_mode = debug_mode = dump_mode = inline_mode = no_remap_mode = quiet = FALSE; | |
148 | 150 | /* initialize search path to compiled-in value */ |
149 | 151 | search_path = DEFAULT_UNRTF_SEARCH_PATH; |
150 | 152 | |
151 | if((env_path_p = getenv("UNRTF_SEARCH_PATH")) != NULL) | |
152 | { | |
153 | if(verbose_mode) | |
153 | if ((env_path_p = getenv("UNRTF_SEARCH_PATH")) != NULL) | |
154 | { | |
155 | if (verbose_mode) | |
156 | { | |
154 | 157 | fprintf(stderr, "got environment path: %s\n", env_path_p); |
155 | search_path=env_path_p; | |
158 | } | |
159 | search_path = env_path_p; | |
156 | 160 | } |
157 | 161 | |
158 | 162 | /* Handle arguments */ |
159 | 163 | |
160 | for (i = 1; i < argc; i++) { | |
161 | if (!strcmp("--dump", argv[i])) dump_mode = TRUE; | |
162 | else if (!strcmp("-d", argv[i])) dump_mode = TRUE; | |
163 | else if (!strcmp("--debug", argv[i])) debug_mode = TRUE; | |
164 | else if (!strcmp("--verbose", argv[i])) verbose_mode = TRUE; | |
165 | else if (!strcmp("--quiet", argv[i])) quiet = TRUE; | |
166 | else if (!strcmp("--simple", argv[i])) simple_mode = TRUE; | |
167 | else if (!strcmp("--noremap", argv[i])) no_remap_mode = TRUE; | |
164 | for (i = 1; i < argc; i++) | |
165 | { | |
166 | if (!strcmp("--dump", argv[i])) | |
167 | { | |
168 | dump_mode = TRUE; | |
169 | } | |
170 | else if (!strcmp("-d", argv[i])) | |
171 | { | |
172 | dump_mode = TRUE; | |
173 | } | |
174 | else if (!strcmp("--debug", argv[i])) | |
175 | { | |
176 | debug_mode = TRUE; | |
177 | } | |
178 | else if (!strcmp("--verbose", argv[i])) | |
179 | { | |
180 | verbose_mode = TRUE; | |
181 | } | |
182 | else if (!strcmp("--quiet", argv[i])) | |
183 | { | |
184 | quiet = TRUE; | |
185 | } | |
186 | else if (!strcmp("--simple", argv[i])) | |
187 | { | |
188 | simple_mode = TRUE; | |
189 | } | |
190 | else if (!strcmp("--noremap", argv[i])) | |
191 | { | |
192 | no_remap_mode = TRUE; | |
193 | } | |
168 | 194 | else if (!strcmp("-t", argv[i])) |
169 | 195 | { |
170 | 196 | if ((i + 1) < argc && *argv[i + 1] != '-') |
172 | 198 | i++; |
173 | 199 | op = get_config(argv[i], op); |
174 | 200 | } |
175 | } | |
201 | } | |
176 | 202 | else if (!strcmp("-P", argv[i])) |
177 | 203 | { |
178 | if(i+1 > argc) | |
179 | { | |
180 | fprintf(stderr,"-P needs a path argument\n"); | |
204 | if (i + 1 > argc) | |
205 | { | |
206 | fprintf(stderr, "-P needs a path argument\n"); | |
181 | 207 | exit(1); |
182 | 208 | } |
183 | search_path=argv[++i]; | |
184 | } | |
185 | else if (!strcmp("--inline", argv[i])) inline_mode = TRUE; | |
186 | else if (!strcmp("--help", argv[i])) { | |
209 | search_path = argv[++i]; | |
210 | } | |
211 | else if (!strcmp("--inline", argv[i])) | |
212 | { | |
213 | inline_mode = TRUE; | |
214 | } | |
215 | else if (!strcmp("--help", argv[i])) | |
216 | { | |
187 | 217 | usage(); |
188 | 218 | } |
189 | else if (!strcmp("--version", argv[i])) { | |
219 | else if (!strcmp("--version", argv[i])) | |
220 | { | |
190 | 221 | fprintf(stderr, "%s\n", PACKAGE_VERSION); |
191 | 222 | fprintf(stderr, "search path is: %s\n", search_path); |
192 | 223 | exit(0); |
193 | 224 | } |
194 | else if (!strcmp("--nopict", argv[i])) nopict_mode = TRUE; | |
195 | else if (!strcmp("-n", argv[i])) nopict_mode = TRUE; | |
225 | else if (!strcmp("--nopict", argv[i])) | |
226 | { | |
227 | nopict_mode = TRUE; | |
228 | } | |
229 | else if (!strcmp("-n", argv[i])) | |
230 | { | |
231 | nopict_mode = TRUE; | |
232 | } | |
196 | 233 | else if (!strncmp("--", argv[i], 2)) |
234 | { | |
197 | 235 | op = get_config(&argv[i][2], op); |
236 | } | |
198 | 237 | else |
199 | 238 | { |
200 | if (*argv[i] == '-') usage(); | |
201 | ||
202 | if (path) | |
239 | if (*argv[i] == '-') | |
240 | { | |
203 | 241 | usage(); |
204 | else | |
242 | } | |
243 | ||
244 | if (path) | |
245 | { | |
246 | usage(); | |
247 | } | |
248 | else | |
249 | { | |
205 | 250 | path = argv[i]; |
251 | } | |
206 | 252 | } |
207 | 253 | } |
208 | 254 | |
209 | 255 | |
210 | 256 | |
211 | 257 | if (op == NULL) |
258 | { | |
212 | 259 | op = get_config(DEFAULT_OUTPUT, op); |
213 | if(!path_checked && check_dirs() == 0) | |
214 | { | |
215 | fprintf(stderr,"no config directories\n"); | |
260 | } | |
261 | if (op == NULL) { | |
262 | fprintf(stderr, "Initialization error: no output format\n"); | |
216 | 263 | exit(1); |
217 | 264 | } |
218 | ||
219 | ||
220 | ||
265 | if (!path_checked && check_dirs() == 0) | |
266 | { | |
267 | fprintf(stderr, "no config directories\n"); | |
268 | exit(1); | |
269 | } | |
270 | ||
271 | ||
272 | ||
221 | 273 | /* Program information */ |
222 | if (verbose_mode || debug_mode) { | |
274 | if (verbose_mode || debug_mode) | |
275 | { | |
223 | 276 | fprintf(stderr, "This is UnRTF "); |
224 | 277 | fprintf(stderr, "version %s\n", PACKAGE_VERSION); |
225 | 278 | fprintf(stderr, "By Dave Davey, Marcos Serrou do Amaral and Arkadiusz Firus\n"); |
227 | 280 | show_dirs(); |
228 | 281 | } |
229 | 282 | |
230 | if (debug_mode) fprintf(stderr, "Debug mode.\n"); | |
231 | if (dump_mode) fprintf(stderr, "Dump mode.\n"); | |
283 | if (debug_mode) | |
284 | { | |
285 | fprintf(stderr, "Debug mode.\n"); | |
286 | } | |
287 | if (dump_mode) | |
288 | { | |
289 | fprintf(stderr, "Dump mode.\n"); | |
290 | } | |
232 | 291 | |
233 | 292 | /* Open file for reading. Append ".rtf" to file name if not supplied. */ |
234 | 293 | if (path == NULL) |
294 | { | |
235 | 295 | f = stdin; |
296 | } | |
236 | 297 | else |
237 | 298 | { |
238 | 299 | f = fopen(path, "r"); |
239 | if (!f) { | |
300 | if (!f) | |
301 | { | |
240 | 302 | char path2[200]; |
241 | 303 | strcpy(path2, path); |
242 | 304 | strcat(path2, ".rtf"); |
243 | 305 | f = fopen(path2, "r"); |
244 | 306 | if (!f) |
307 | { | |
245 | 308 | error_handler("Cannot open input file"); |
246 | } | |
247 | } | |
248 | ||
249 | if (verbose_mode || debug_mode) fprintf(stderr, "Processing %s...\n", path); | |
309 | } | |
310 | } | |
311 | } | |
312 | ||
313 | if (verbose_mode || debug_mode) | |
314 | { | |
315 | fprintf(stderr, "Processing %s...\n", path); | |
316 | } | |
250 | 317 | |
251 | 318 | /* Keep track of lines processed. This is arbitrary to the user as |
252 | 319 | * RTF ignores newlines. May be helpful in error tracking. */ |
256 | 323 | * the end of the file. */ |
257 | 324 | word = word_read(f); |
258 | 325 | |
259 | if (dump_mode) { | |
326 | if (dump_mode) | |
327 | { | |
260 | 328 | word_dump(word); |
261 | 329 | printf("\n"); |
262 | } else { | |
263 | /* Should we also optimize word before dump? - AF */ | |
330 | } | |
331 | else | |
332 | { | |
333 | /* Should we also optimize word before dump? - AF */ | |
264 | 334 | word = optimize_word(word, 1); |
265 | 335 | word_print(word); |
266 | 336 | } |
268 | 338 | fclose(f); |
269 | 339 | |
270 | 340 | /* marcossamaral - 0.19.9 */ |
271 | if(verbose_mode || debug_mode) { | |
272 | unsigned long total=0; | |
341 | if (verbose_mode || debug_mode) | |
342 | { | |
343 | unsigned long total = 0; | |
273 | 344 | total = hash_stats(); |
274 | 345 | fprintf(stderr, "Done.\n"); |
275 | fprintf(stderr, "%lu words were hashed.\n", total); | |
276 | } | |
277 | ||
278 | if (debug_mode) { | |
279 | fprintf(stderr, "Total memory allocated %ld bytes.\n", | |
280 | total_malloced()); | |
346 | fprintf(stderr, "%lu words were hashed.\n", total); | |
347 | } | |
348 | ||
349 | if (debug_mode) | |
350 | { | |
351 | fprintf(stderr, "Total memory allocated %ld bytes.\n", | |
352 | total_malloced()); | |
281 | 353 | } |
282 | 354 | |
283 | 355 | /* May as well */ |
29 | 29 | * Changes: |
30 | 30 | * 14 Aug 01, tuorfa@yahoo.com: added Turbo C support. |
31 | 31 | * 16 Aug 01, Lars Unger <l.unger@tu-bs.de>: added Amiga/GCC support. |
32 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
32 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
33 | 33 | * 28 Sep 01, tuorfa@yahoo.com: removed Turbo C support. |
34 | 34 | * 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux |
35 | 35 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
56 | 56 | #include "error.h" |
57 | 57 | #include "malloc.h" |
58 | 58 | |
59 | static unsigned long count=0; | |
59 | static unsigned long count = 0; | |
60 | 60 | |
61 | 61 | /*======================================================================== |
62 | 62 | * Name: my_malloc |
65 | 65 | * Returns: Pointer. |
66 | 66 | *=======================================================================*/ |
67 | 67 | |
68 | char * | |
69 | my_malloc (unsigned long size) { | |
68 | char * | |
69 | my_malloc(unsigned long size) | |
70 | { | |
70 | 71 | char *ptr; |
71 | 72 | |
72 | ptr = malloc (size); | |
73 | ptr = malloc(size); | |
73 | 74 | if (ptr) |
75 | { | |
74 | 76 | count += size; |
77 | } | |
75 | 78 | |
76 | 79 | return ptr; |
77 | 80 | } |
83 | 86 | * Returns: None. |
84 | 87 | *=======================================================================*/ |
85 | 88 | |
86 | void | |
87 | my_free (char* ptr) { | |
89 | void | |
90 | my_free(char *ptr) | |
91 | { | |
88 | 92 | CHECK_PARAM_NOT_NULL(ptr); |
89 | 93 | |
90 | free (ptr); | |
94 | free(ptr); | |
91 | 95 | } |
92 | 96 | |
93 | 97 | #if 1 /* AK3 - AF */ |
103 | 107 | char *new_ptr = my_malloc(new_size); |
104 | 108 | |
105 | 109 | if (new_ptr != NULL) |
110 | { | |
106 | 111 | memcpy(new_ptr, ptr, old_size); |
112 | } | |
107 | 113 | |
108 | 114 | my_free(ptr); |
109 | 115 | |
119 | 125 | * Returns: Amount. |
120 | 126 | *=======================================================================*/ |
121 | 127 | |
122 | unsigned long | |
123 | total_malloced (void) { | |
128 | unsigned long | |
129 | total_malloced(void) | |
130 | { | |
124 | 131 | return count; |
125 | 132 | } |
126 | 133 | |
134 | 141 | *=======================================================================*/ |
135 | 142 | |
136 | 143 | char * |
137 | my_strdup (char *src) { | |
144 | my_strdup(char *src) | |
145 | { | |
138 | 146 | unsigned long len; |
139 | 147 | char *ptr; |
140 | 148 | |
141 | 149 | CHECK_PARAM_NOT_NULL(src); |
142 | 150 | |
143 | 151 | len = strlen(src); |
144 | ptr = my_malloc (len+1); | |
152 | ptr = my_malloc(len + 1); | |
145 | 153 | if (!ptr) |
146 | error_handler ("out of memory in strdup()"); | |
154 | { | |
155 | error_handler("out of memory in strdup()"); | |
156 | } | |
147 | 157 | |
148 | strcpy (ptr, src); | |
158 | strcpy(ptr, src); | |
149 | 159 | return ptr; |
150 | 160 | } |
161 | ||
162 | #ifndef _WIN32 | |
151 | 163 | /* added by daved */ |
152 | 164 | #include <sys/types.h> |
153 | 165 | #undef malloc |
154 | ||
155 | void *malloc (); | |
156 | ||
166 | ||
167 | void *malloc(); | |
168 | ||
157 | 169 | /* Allocate an N-byte block of memory from the heap. |
158 | 170 | If N is zero, allocate a 1-byte block. */ |
159 | 171 | |
160 | 172 | void * |
161 | rpl_malloc (size_t n) | |
162 | { | |
163 | if (n == 0) | |
164 | n = 1; | |
165 | return malloc (n); | |
166 | } | |
173 | rpl_malloc(size_t n) | |
174 | { | |
175 | if (n == 0) | |
176 | { | |
177 | n = 1; | |
178 | } | |
179 | return malloc(n); | |
180 | } | |
181 | #endif⏎ |
31 | 31 | * 09 Nov 08, arkadiusz.firus@gmail.com: added my_realloc |
32 | 32 | *--------------------------------------------------------------------*/ |
33 | 33 | |
34 | extern char * my_malloc (unsigned long); | |
35 | extern void my_free (char*); | |
36 | extern char * my_realloc(char*, unsigned long, unsigned long); | |
37 | extern unsigned long total_malloced (void); | |
38 | extern char * my_strdup (char*); | |
34 | extern char *my_malloc(unsigned long); | |
35 | extern void my_free(char *); | |
36 | extern char *my_realloc(char *, unsigned long, unsigned long); | |
37 | extern unsigned long total_malloced(void); | |
38 | extern char *my_strdup(char *); | |
39 | 39 |
11 | 11 | |
12 | 12 | #include <stdio.h> |
13 | 13 | #include <string.h> |
14 | #ifndef _WIN32 | |
14 | 15 | #include <unistd.h> |
16 | #endif | |
15 | 17 | #include <stdlib.h> |
16 | 18 | #include <errno.h> |
17 | 19 | |
23 | 25 | |
24 | 26 | extern int verbose_mode; |
25 | 27 | |
26 | /* Convert from charmap file entry to charmap table one. | |
27 | 1st byte in table entry is code length | |
28 | /* Convert from charmap file entry to charmap table one. | |
29 | 1st byte in table entry is code length | |
28 | 30 | */ |
29 | 31 | static char * |
30 | 32 | get_code_str(FILE *f, iconv_t desc) |
34 | 36 | char *obuf; |
35 | 37 | |
36 | 38 | char *utf8 = get_unicode_utf8(f); |
37 | if (utf8 == NULL || *utf8 == 0) { | |
39 | if (utf8 == NULL || *utf8 == 0) | |
40 | { | |
38 | 41 | /* fprintf(stderr, "get_code_str: NULL entry\n");*/ |
42 | my_free(utf8); | |
39 | 43 | return NULL; |
40 | 44 | } |
41 | #if 0 /* debug */ | |
45 | #if 0 /* debug */ | |
42 | 46 | fprintf(stderr, "get_code_str: utf8: "); |
43 | 47 | for (ocp = utf8; *ocp; ocp++) |
44 | fprintf(stderr, "%x", (unsigned)*ocp); | |
48 | { | |
49 | fprintf(stderr, "%x", (unsigned)*ocp); | |
50 | } | |
45 | 51 | fprintf(stderr, "\n"); |
46 | #endif | |
52 | #endif | |
47 | 53 | |
48 | 54 | obytes = 10; |
49 | 55 | ibytes = strlen(utf8); |
50 | 56 | obuf = malloc(obytes); |
51 | 57 | if (obuf == NULL) |
58 | { | |
59 | my_free(utf8); | |
52 | 60 | return NULL; |
61 | } | |
53 | 62 | icp = utf8; |
54 | 63 | ocp0 = ocp = obuf + 1; |
55 | if (iconv(desc, &icp, &ibytes, &ocp, &obytes) == -1) { | |
64 | if (iconv(desc, &icp, &ibytes, &ocp, &obytes) == -1) | |
65 | { | |
56 | 66 | /* fprintf(stderr, "unrtf: my_iconv: iconv error\n");*/ |
67 | my_free(utf8); | |
57 | 68 | return NULL; |
58 | 69 | } |
59 | 70 | |
69 | 80 | FILE *f; |
70 | 81 | my_iconv_t cd = MY_ICONV_T_CLEAR; |
71 | 82 | int c, i; |
72 | /* fprintf(stderr, "my_iconv_open: from %s to %s\n", fromcode, tocode);*/ | |
73 | if ((cd.desc = iconv_open(tocode, fromcode)) == (iconv_t) -1) { | |
74 | char *path = search_in_path(fromcode, "charmap"); | |
75 | if (path == NULL) { | |
76 | return cd; | |
77 | } | |
78 | if((f = fopen(path, "r")) == NULL && verbose_mode) | |
79 | fprintf(stderr, "failed to open charmap file %s\n", path); | |
80 | ||
81 | if (f != NULL) { | |
82 | /* Open iconv utf8->tocode conversion */ | |
83 | iconv_t desc; | |
84 | if ((desc = iconv_open(tocode, "UTF-8")) == (iconv_t) -1) { | |
85 | fclose(f); | |
86 | return cd; | |
87 | } | |
88 | cd.char_table = (char **)my_malloc(char_table_size * | |
89 | sizeof(char *)); | |
90 | c = fgetc(f); | |
91 | ||
92 | for (i = 0; i < char_table_size && c != EOF; i++) | |
93 | { | |
94 | if (c == '<') | |
95 | cd.char_table[i] = get_code_str(f, desc); | |
96 | leave_line(f);//read up to including \n or eof | |
97 | c = fgetc(f); | |
98 | } | |
99 | iconv_close(desc); | |
100 | fclose(f); | |
101 | } | |
102 | ||
103 | my_free(path); | |
83 | /* fprintf(stderr, "my_iconv_open: from %s to %s\n", fromcode, tocode);*/ | |
84 | if ((cd.desc = iconv_open(tocode, fromcode)) == (iconv_t) - 1) | |
85 | { | |
86 | char *path = search_in_path(fromcode, "charmap"); | |
87 | if (path == NULL) | |
88 | { | |
89 | return cd; | |
90 | } | |
91 | if ((f = fopen(path, "r")) == NULL && verbose_mode) | |
92 | { | |
93 | fprintf(stderr, "failed to open charmap file %s\n", path); | |
94 | } | |
95 | ||
96 | if (f != NULL) | |
97 | { | |
98 | /* Open iconv utf8->tocode conversion */ | |
99 | iconv_t desc; | |
100 | if ((desc = iconv_open(tocode, "UTF-8")) == (iconv_t) - 1) | |
101 | { | |
102 | fclose(f); | |
103 | return cd; | |
104 | } | |
105 | cd.char_table = (char **)my_malloc(char_table_size * | |
106 | sizeof(char *)); | |
107 | c = fgetc(f); | |
108 | ||
109 | for (i = 0; i < char_table_size && c != EOF; i++) | |
110 | { | |
111 | if (c == '<') | |
112 | { | |
113 | cd.char_table[i] = get_code_str(f, desc); | |
114 | } | |
115 | leave_line(f);//read up to including \n or eof | |
116 | c = fgetc(f); | |
117 | } | |
118 | iconv_close(desc); | |
119 | fclose(f); | |
120 | } | |
121 | ||
122 | my_free(path); | |
104 | 123 | } |
105 | 124 | |
106 | 125 | return cd; |
112 | 131 | int c, i; |
113 | 132 | size_t result = 0; |
114 | 133 | **outbuf = 0; |
115 | if (cd.desc == (iconv_t) -1) { | |
116 | if (cd.char_table != NULL) | |
117 | { | |
118 | while (*inbytesleft > 0 && *outbytesleft > 0) | |
119 | { | |
120 | c = **(unsigned char**)inbuf; | |
121 | if (cd.char_table[c] != NULL) | |
122 | { | |
123 | for (i = 0; i < cd.char_table[c][0] && *outbytesleft > 0; i++) | |
134 | if (cd.desc == (iconv_t) - 1) | |
135 | { | |
136 | if (cd.char_table != NULL) | |
137 | { | |
138 | while (*inbytesleft > 0 && *outbytesleft > 0) | |
139 | { | |
140 | c = **(unsigned char **)inbuf; | |
141 | if (cd.char_table[c] != NULL) | |
124 | 142 | { |
125 | **outbuf = cd.char_table[c][i+1]; | |
126 | (*outbytesleft)--; | |
127 | (*outbuf)++; | |
143 | for (i = 0; i < cd.char_table[c][0] && *outbytesleft > 0; i++) | |
144 | { | |
145 | **outbuf = cd.char_table[c][i + 1]; | |
146 | (*outbytesleft)--; | |
147 | (*outbuf)++; | |
148 | } | |
128 | 149 | } |
129 | } else { | |
130 | /* fprintf(stderr, "my_iconv: no conversion for 0x%x\n", | |
131 | (unsigned)c);*/ | |
132 | errno = EILSEQ; | |
133 | return (size_t)-1; | |
134 | } | |
135 | ||
136 | (*inbuf)++; | |
137 | (*inbytesleft)--; | |
138 | result++; | |
139 | } | |
140 | ||
141 | if (*outbytesleft == 0 && *inbytesleft > 0) { | |
142 | errno = E2BIG; | |
143 | result = (size_t)-1; | |
144 | } | |
145 | } | |
150 | else | |
151 | { | |
152 | /* fprintf(stderr, "my_iconv: no conversion for 0x%x\n", | |
153 | (unsigned)c);*/ | |
154 | errno = EILSEQ; | |
155 | return (size_t) - 1; | |
156 | } | |
157 | ||
158 | (*inbuf)++; | |
159 | (*inbytesleft)--; | |
160 | result++; | |
161 | } | |
162 | ||
163 | if (*outbytesleft == 0 && *inbytesleft > 0) | |
164 | { | |
165 | errno = E2BIG; | |
166 | result = (size_t) - 1; | |
167 | } | |
168 | } | |
146 | 169 | } |
147 | 170 | else |
171 | { | |
148 | 172 | result = iconv(cd.desc, inbuf, inbytesleft, outbuf, outbytesleft); |
173 | } | |
149 | 174 | |
150 | 175 | return result; |
151 | 176 | } |
159 | 184 | { |
160 | 185 | for (i = 0; i < char_table_size; i++) |
161 | 186 | { |
162 | if (cd.char_table[i] != NULL) | |
163 | my_free(cd.char_table[i]); | |
187 | if (cd.char_table[i] != NULL) | |
188 | { | |
189 | my_free(cd.char_table[i]); | |
190 | } | |
164 | 191 | } |
165 | 192 | |
166 | 193 | my_free((void *)cd.char_table); |
167 | 194 | cd.char_table = NULL; |
168 | 195 | } |
169 | 196 | |
170 | if (cd.desc != (iconv_t) -1) | |
197 | if (cd.desc != (iconv_t) - 1) | |
171 | 198 | { |
172 | 199 | iconv_close(cd.desc); |
173 | cd.desc = (iconv_t) -1; | |
200 | cd.desc = (iconv_t) - 1; | |
174 | 201 | } |
175 | 202 | |
176 | 203 | return cd; |
177 | 204 | } |
178 | 205 | |
179 | int | |
180 | my_iconv_is_valid (my_iconv_t cd) | |
181 | { | |
182 | if (cd.desc != (iconv_t) -1 || cd.char_table != NULL) | |
206 | int | |
207 | my_iconv_is_valid(my_iconv_t cd) | |
208 | { | |
209 | if (cd.desc != (iconv_t) - 1 || cd.char_table != NULL) | |
210 | { | |
183 | 211 | return 1; |
212 | } | |
184 | 213 | |
185 | 214 | return 0; |
186 | 215 | } |
188 | 217 | void |
189 | 218 | my_iconv_t_make_invalid(my_iconv_t *cd) |
190 | 219 | { |
191 | cd->desc = (iconv_t) -1; | |
220 | cd->desc = (iconv_t) - 1; | |
192 | 221 | cd->char_table = NULL; |
193 | 222 | } |
194 | 223 |
27 | 27 | *---------------------------------------------------------------------- |
28 | 28 | * Changes: |
29 | 29 | * 22 Sep 01, tuorfa@yahoo.com: addition of functions to change font size |
30 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
30 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
31 | 31 | * 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux |
32 | 32 | * 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp |
33 | 33 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
34 | * 06 Jan 06, marcossamaral@terra.com.br: changes in STDOUT | |
34 | * 06 Jan 06, marcossamaral@terra.com.br: changes in STDOUT | |
35 | 35 | * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3 |
36 | 36 | * 17 Dec 07, daved@physiol.usyd.edu.au: added support for --noremap from |
37 | 37 | * David Santinoli |
57 | 57 | #include <string.h> |
58 | 58 | #endif |
59 | 59 | |
60 | #ifndef _WIN32 | |
60 | 61 | #include <arpa/inet.h> |
62 | #endif | |
61 | 63 | |
62 | 64 | #include "malloc.h" |
63 | 65 | #include "defs.h" |
75 | 77 | * Returns: Output personality struct. |
76 | 78 | *=======================================================================*/ |
77 | 79 | |
78 | OutputPersonality* | |
79 | op_create () | |
80 | OutputPersonality * | |
81 | op_create() | |
80 | 82 | { |
81 | OutputPersonality* new_op; | |
82 | ||
83 | new_op = (OutputPersonality*) my_malloc (sizeof(OutputPersonality)); | |
83 | OutputPersonality *new_op; | |
84 | ||
85 | new_op = (OutputPersonality *) my_malloc(sizeof(OutputPersonality)); | |
84 | 86 | if (!new_op) |
85 | error_handler ("cannot allocate output personality"); | |
86 | ||
87 | memset ((void*) new_op, 0, sizeof (OutputPersonality)); | |
87 | { | |
88 | error_handler("cannot allocate output personality"); | |
89 | } | |
90 | ||
91 | memset((void *) new_op, 0, sizeof(OutputPersonality)); | |
88 | 92 | return new_op; |
89 | 93 | } |
90 | 94 | |
97 | 101 | *=======================================================================*/ |
98 | 102 | |
99 | 103 | void |
100 | op_free (OutputPersonality *op) | |
104 | op_free(OutputPersonality *op) | |
101 | 105 | { |
102 | 106 | CHECK_PARAM_NOT_NULL(op); |
103 | 107 | |
104 | my_free ((void*) op); | |
108 | my_free((void *) op); | |
105 | 109 | } |
106 | 110 | |
107 | 111 | |
113 | 117 | * computation of Symbol code point in fields). |
114 | 118 | * We cache a local iconv descriptor for efficiency. |
115 | 119 | * Args: OutputPersonality, encoding, character. |
116 | * Returns: String. | |
120 | * Returns: malloced string to be freed by caller. | |
117 | 121 | *=======================================================================*/ |
118 | 122 | const char * |
119 | op_translate_char (OutputPersonality *op, char *encoding, int ch) | |
123 | op_translate_char(OutputPersonality *op, char *encoding, int ch) | |
120 | 124 | { |
121 | static my_iconv_t m_desc = MY_ICONV_T_CLEAR; | |
122 | static char *m_encoding = NULL; | |
123 | const char *result = NULL; | |
124 | static char output_buffer[2]={ 0, 0 }; | |
125 | ||
126 | CHECK_PARAM_NOT_NULL(op); | |
127 | ||
128 | if (ch < 0 || ch > 255) { | |
129 | fprintf(stderr, "op_translate_char called with bad char 0x%x\n", | |
130 | ch); | |
131 | return NULL; | |
132 | } | |
133 | if (no_remap_mode == TRUE && ch < 256) { | |
134 | /* Kept for historical reason, makes no sense in a multi-encoding | |
135 | document */ | |
136 | output_buffer[0] = ch; | |
137 | result = output_buffer; | |
138 | } else { | |
139 | if (!m_encoding || strcasecmp(encoding, m_encoding)) { | |
140 | // Using UTF-32BE to avoid BOM | |
141 | if (my_iconv_is_valid(m_desc)) | |
142 | my_iconv_close(m_desc); | |
143 | m_desc = my_iconv_open("UTF-32BE", encoding); | |
144 | if (!my_iconv_is_valid(m_desc)) { | |
145 | return NULL; | |
146 | } | |
147 | if (m_encoding) | |
148 | my_free(m_encoding); | |
149 | m_encoding = my_strdup(encoding); | |
150 | } | |
151 | size_t inbytes = 1, outbytes = 4; | |
152 | char inbuf[1]; | |
153 | uint32_t outbuf; | |
154 | char *icp = inbuf, *ocp = (char*)&outbuf; | |
155 | int unicode; | |
156 | inbuf[0] = ch; | |
157 | ||
158 | if (my_iconv(m_desc, &icp, &inbytes, &ocp, &outbytes) == -1) | |
159 | { | |
160 | /* fprintf(stderr, "unrtf: iconv error %s->UTF-32BE for 0x%x\n", | |
161 | encoding, ch);*/ | |
162 | return NULL; | |
163 | } | |
164 | ||
165 | /* Conversion from UTF-32BE string to int */ | |
166 | unicode = ntohl(outbuf); | |
125 | static my_iconv_t m_desc = MY_ICONV_T_CLEAR; | |
126 | static char *m_encoding = NULL; | |
127 | char *result = NULL; | |
128 | ||
129 | CHECK_PARAM_NOT_NULL(op); | |
130 | ||
131 | if (ch < 0 || ch > 255) | |
132 | { | |
133 | fprintf(stderr, "op_translate_char called with bad char 0x%x\n", | |
134 | ch); | |
135 | return NULL; | |
136 | } | |
137 | if (no_remap_mode == TRUE && ch < 256) | |
138 | { | |
139 | /* Kept for historical reason, makes no sense in a multi-encoding | |
140 | document */ | |
141 | result = my_malloc(2); | |
142 | if (result) | |
143 | { | |
144 | result[0] = ch; | |
145 | result[1] = 0; | |
146 | } | |
147 | } | |
148 | else | |
149 | { | |
150 | if (!m_encoding || strcasecmp(encoding, m_encoding)) | |
151 | { | |
152 | // Using UTF-32BE to avoid BOM | |
153 | if (my_iconv_is_valid(m_desc)) | |
154 | { | |
155 | my_iconv_close(m_desc); | |
156 | } | |
157 | m_desc = my_iconv_open("UTF-32BE", encoding); | |
158 | if (!my_iconv_is_valid(m_desc)) | |
159 | { | |
160 | return NULL; | |
161 | } | |
162 | if (m_encoding) | |
163 | { | |
164 | my_free(m_encoding); | |
165 | } | |
166 | m_encoding = my_strdup(encoding); | |
167 | } | |
168 | size_t inbytes = 1, outbytes = 4; | |
169 | char inbuf[1]; | |
170 | uint32_t outbuf; | |
171 | char *icp = inbuf, *ocp = (char *)&outbuf; | |
172 | int unicode; | |
173 | inbuf[0] = ch; | |
174 | ||
175 | if (my_iconv(m_desc, &icp, &inbytes, &ocp, &outbytes) == -1) | |
176 | { | |
177 | /* fprintf(stderr, "unrtf: iconv error %s->UTF-32BE for 0x%x\n", | |
178 | encoding, ch);*/ | |
179 | return NULL; | |
180 | } | |
181 | ||
182 | /* Conversion from UTF-32BE string to int */ | |
183 | #ifdef _WIN32 | |
184 | unicode = unrtf_ntohl(outbuf); | |
185 | #else | |
186 | unicode = ntohl(outbuf); | |
187 | #endif | |
167 | 188 | #if 0 |
168 | if (unicode != ch) | |
169 | fprintf(stderr, "op_translate: 0x%x -> unicode 0x%x\n", | |
170 | (unsigned)ch, (unsigned)unicode); | |
171 | #endif | |
172 | /* Output Unicode value as decided by output personality */ | |
173 | result = get_alias(op, unicode); /* Try for ie, entity */ | |
174 | if (result == NULL) { | |
175 | if (ch > 127 && op->unisymbol_print) { | |
176 | /* TODO: memory leak here. Impossible to fix easily as we can | |
177 | return either a static or allocated buffer */ | |
178 | result = assemble_string(op->unisymbol_print, unicode); | |
179 | } else { | |
180 | /* Single byte unicode char needs no translation ever?*/ | |
181 | output_buffer[0] = ch; | |
182 | result = output_buffer; | |
183 | } | |
184 | } | |
185 | } | |
186 | ||
187 | return result; | |
189 | if (unicode != ch) | |
190 | fprintf(stderr, "op_translate: 0x%x -> unicode 0x%x\n", | |
191 | (unsigned)ch, (unsigned)unicode); | |
192 | #endif | |
193 | /* Output Unicode value as decided by output personality */ | |
194 | result = get_alias(op, unicode); /* Try for ie, entity */ | |
195 | if (result) | |
196 | result = strdup(result); | |
197 | if (result == NULL) | |
198 | { | |
199 | if (ch > 127 && op->unisymbol_print) | |
200 | { | |
201 | result = assemble_string(op->unisymbol_print, unicode); | |
202 | } | |
203 | else | |
204 | { | |
205 | /* Single byte unicode char needs no translation ever?*/ | |
206 | result = my_malloc(2); | |
207 | if (result) | |
208 | { | |
209 | result[0] = ch; | |
210 | result[1] = 0; | |
211 | } | |
212 | } | |
213 | } | |
214 | } | |
215 | ||
216 | return result; | |
188 | 217 | } |
189 | 218 | |
190 | 219 | /*======================================================================== |
191 | 220 | * Name: op_translate_buffer |
192 | 221 | * Purpose: Translate buffer built out of \' commands in convert.c |
193 | * The data comes in as UTF-32BE, which we change to unicode positions | |
222 | * The data comes in as UTF-32BE, which we change to unicode positions | |
194 | 223 | * (just the byte order), then transform according to outputpersonality |
195 | 224 | * TOBEDONE: have a way to specify direct UTF-8 output for a personality |
196 | 225 | * (then produce utf-8 in convert.c and do nothing special here. |
197 | * | |
226 | * | |
198 | 227 | * Args: OutputPersonality, encoding, character. |
199 | 228 | * Returns: malloced string. |
200 | 229 | *=======================================================================*/ |
201 | 230 | char * |
202 | 231 | op_translate_buffer(OutputPersonality *op, char *buffer, int bytescnt) |
203 | 232 | { |
204 | int wordcnt = bytescnt / 4; | |
205 | int i; | |
206 | int opos = 0; | |
207 | char *out = 0; | |
208 | int outsz; | |
209 | if ((out = (char *)allocmem(out, 1, &outsz, 1000, 100000)) == NULL) { | |
210 | fprintf(stderr, "unrtf: out of memory (op_translate_buffer 1, %d)\n", outsz); | |
211 | return NULL; | |
212 | } | |
213 | ||
214 | for (i = 0; i < wordcnt; i++) { | |
215 | char tbuf[2]; | |
216 | const char *result; | |
217 | int incsz; | |
218 | int unicode = ntohl(*(int*)(buffer + 4 * i)); | |
219 | ||
220 | result = get_alias(op, unicode); /* Try for ie, entity */ | |
221 | if (result != NULL) { | |
222 | incsz = strlen(result); | |
223 | } else { | |
224 | if (unicode > 127 && op->unisymbol_print) { | |
225 | /* TODO: fix memory leak */ | |
226 | result = assemble_string(op->unisymbol_print, unicode); | |
227 | incsz = strlen(result); | |
228 | } else { | |
229 | /* Single byte unicode char needs no translation ever?*/ | |
230 | tbuf[0] = unicode; | |
231 | tbuf[1] = 0; | |
232 | result = tbuf; | |
233 | incsz = 1; | |
234 | } | |
235 | } | |
236 | if (opos + incsz + 1 >= outsz) { | |
237 | if ((out = (char *)allocmem(out, 1, &outsz, 1000, 100000)) == NULL) { | |
238 | fprintf(stderr, "unrtf: out of memory (op_translate_buffer 2, %d)\n", outsz); | |
239 | return NULL; | |
240 | } | |
241 | } | |
242 | strcpy(out + opos, result); | |
243 | opos += incsz; | |
244 | } | |
245 | return out; | |
233 | int wordcnt = bytescnt / 4; | |
234 | int i; | |
235 | int opos = 0; | |
236 | char *out = 0; | |
237 | int outsz; | |
238 | if ((out = (char *)allocmem(out, 1, &outsz, 1000, 100000)) == NULL) | |
239 | { | |
240 | fprintf(stderr, "unrtf: out of memory (op_translate_buffer 1, %d)\n", outsz); | |
241 | return NULL; | |
242 | } | |
243 | out[0] = 0; | |
244 | ||
245 | for (i = 0; i < wordcnt; i++) | |
246 | { | |
247 | char tbuf[2]; | |
248 | const char *result; | |
249 | int freeresult = 0; | |
250 | int incsz; | |
251 | #ifdef _WIN32 | |
252 | int unicode = unrtf_ntohl(*(int *)(buffer + 4 * i)); | |
253 | #else | |
254 | int unicode = ntohl(*(int *)(buffer + 4 * i)); | |
255 | #endif | |
256 | ||
257 | result = get_alias(op, unicode); /* Try for ie, entity */ | |
258 | if (result != NULL) | |
259 | { | |
260 | incsz = strlen(result); | |
261 | } | |
262 | else | |
263 | { | |
264 | if (unicode > 127 && op->unisymbol_print) | |
265 | { | |
266 | result = assemble_string(op->unisymbol_print, unicode); | |
267 | freeresult = 1; | |
268 | incsz = strlen(result); | |
269 | } | |
270 | else | |
271 | { | |
272 | /* Single byte unicode char needs no translation ever?*/ | |
273 | tbuf[0] = unicode; | |
274 | tbuf[1] = 0; | |
275 | result = tbuf; | |
276 | incsz = 1; | |
277 | } | |
278 | } | |
279 | if (opos + incsz + 1 >= outsz) | |
280 | { | |
281 | if ((out = (char *)allocmem(out, 1, &outsz, 1000, 100000)) == NULL) | |
282 | { | |
283 | fprintf(stderr, "unrtf: out of memory (op_translate_buffer 2, %d)\n", outsz); | |
284 | return NULL; | |
285 | } | |
286 | } | |
287 | strcpy(out + opos, result); | |
288 | if (freeresult) | |
289 | my_free(result); | |
290 | opos += incsz; | |
291 | } | |
292 | return out; | |
246 | 293 | } |
247 | 294 | |
248 | 295 | /*======================================================================== |
249 | * Name: op_begin_std_fontsize | |
296 | * Name: op_begin_std_fontsize | |
250 | 297 | * Purpose: Prints whatever is necessary to perform a change in the |
251 | 298 | * current font size. |
252 | 299 | * Args: OutputPersonality, desired size. |
254 | 301 | *=======================================================================*/ |
255 | 302 | |
256 | 303 | void |
257 | op_begin_std_fontsize (OutputPersonality *op, int size) | |
304 | op_begin_std_fontsize(OutputPersonality *op, int size) | |
258 | 305 | { |
259 | 306 | int found_std_expr = FALSE; |
260 | 307 | |
262 | 309 | |
263 | 310 | /* Look for an exact match with a standard point size. |
264 | 311 | */ |
265 | switch (size) { | |
312 | switch (size) | |
313 | { | |
266 | 314 | case 8: |
267 | if (op->fontsize8_begin) { | |
268 | if (safe_printf(0, op->fontsize8_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize8_begin"); | |
315 | if (op->fontsize8_begin) | |
316 | { | |
317 | if (safe_printf(0, op->fontsize8_begin)) | |
318 | { | |
319 | fprintf(stderr, TOO_MANY_ARGS, "fontsize8_begin"); | |
320 | } | |
269 | 321 | found_std_expr = TRUE; |
270 | 322 | } |
271 | 323 | break; |
272 | 324 | case 10: |
273 | if (op->fontsize10_begin) { | |
274 | if (safe_printf(0, op->fontsize10_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize10_begin"); | |
325 | if (op->fontsize10_begin) | |
326 | { | |
327 | if (safe_printf(0, op->fontsize10_begin)) | |
328 | { | |
329 | fprintf(stderr, TOO_MANY_ARGS, "fontsize10_begin"); | |
330 | } | |
275 | 331 | found_std_expr = TRUE; |
276 | 332 | } |
277 | 333 | break; |
278 | 334 | case 12: |
279 | if (op->fontsize12_begin) { | |
280 | if (safe_printf(0, op->fontsize12_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize12_begin"); | |
335 | if (op->fontsize12_begin) | |
336 | { | |
337 | if (safe_printf(0, op->fontsize12_begin)) | |
338 | { | |
339 | fprintf(stderr, TOO_MANY_ARGS, "fontsize12_begin"); | |
340 | } | |
281 | 341 | found_std_expr = TRUE; |
282 | 342 | } |
283 | 343 | break; |
284 | 344 | case 14: |
285 | if (op->fontsize14_begin) { | |
286 | if (safe_printf(0, op->fontsize14_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize14_begin"); | |
345 | if (op->fontsize14_begin) | |
346 | { | |
347 | if (safe_printf(0, op->fontsize14_begin)) | |
348 | { | |
349 | fprintf(stderr, TOO_MANY_ARGS, "fontsize14_begin"); | |
350 | } | |
287 | 351 | found_std_expr = TRUE; |
288 | 352 | } |
289 | 353 | break; |
290 | 354 | case 18: |
291 | if (op->fontsize18_begin) { | |
292 | if (safe_printf(0, op->fontsize18_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize18_begin"); | |
355 | if (op->fontsize18_begin) | |
356 | { | |
357 | if (safe_printf(0, op->fontsize18_begin)) | |
358 | { | |
359 | fprintf(stderr, TOO_MANY_ARGS, "fontsize18_begin"); | |
360 | } | |
293 | 361 | found_std_expr = TRUE; |
294 | 362 | } |
295 | 363 | break; |
296 | 364 | case 24: |
297 | if (op->fontsize24_begin) { | |
298 | if (safe_printf(0, op->fontsize24_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize24_begin"); | |
365 | if (op->fontsize24_begin) | |
366 | { | |
367 | if (safe_printf(0, op->fontsize24_begin)) | |
368 | { | |
369 | fprintf(stderr, TOO_MANY_ARGS, "fontsize24_begin"); | |
370 | } | |
299 | 371 | found_std_expr = TRUE; |
300 | 372 | } |
301 | 373 | break; |
302 | 374 | case 36: |
303 | if (op->fontsize36_begin) { | |
304 | if (safe_printf(0, op->fontsize36_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize36_begin"); | |
375 | if (op->fontsize36_begin) | |
376 | { | |
377 | if (safe_printf(0, op->fontsize36_begin)) | |
378 | { | |
379 | fprintf(stderr, TOO_MANY_ARGS, "fontsize36_begin"); | |
380 | } | |
305 | 381 | found_std_expr = TRUE; |
306 | 382 | } |
307 | 383 | break; |
308 | 384 | case 48: |
309 | if (op->fontsize48_begin) { | |
310 | if (safe_printf(0, op->fontsize48_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize48_begin"); | |
385 | if (op->fontsize48_begin) | |
386 | { | |
387 | if (safe_printf(0, op->fontsize48_begin)) | |
388 | { | |
389 | fprintf(stderr, TOO_MANY_ARGS, "fontsize48_begin"); | |
390 | } | |
311 | 391 | found_std_expr = TRUE; |
312 | 392 | } |
313 | 393 | break; |
316 | 396 | /* If no exact match, try to write out a change to the |
317 | 397 | * exact point size. |
318 | 398 | */ |
319 | if (!found_std_expr) { | |
320 | if (op->fontsize_begin) { | |
399 | if (!found_std_expr) | |
400 | { | |
401 | if (op->fontsize_begin) | |
402 | { | |
321 | 403 | char expr[16]; |
322 | sprintf (expr, "%d", size); | |
323 | if (safe_printf (1, op->fontsize_begin, expr)) fprintf(stderr, TOO_MANY_ARGS, "fontsize_begin"); | |
324 | } else { | |
404 | snprintf(expr, 16, "%d", size); | |
405 | if (safe_printf(1, op->fontsize_begin, expr)) | |
406 | { | |
407 | fprintf(stderr, TOO_MANY_ARGS, "fontsize_begin"); | |
408 | } | |
409 | } | |
410 | else | |
411 | { | |
325 | 412 | /* If we cannot write out a change for the exact |
326 | 413 | * point size, we must approximate to a standard |
327 | 414 | * size. |
328 | 415 | */ |
329 | if (size<9 && op->fontsize8_begin) { | |
330 | if (safe_printf(0, op->fontsize8_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize8_begin"); | |
331 | } else if (size<11 && op->fontsize10_begin) { | |
332 | if (safe_printf(0, op->fontsize10_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize10_begin"); | |
333 | } else if (size<13 && op->fontsize12_begin) { | |
334 | if (safe_printf(0, op->fontsize12_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize12_begin"); | |
335 | } else if (size<16 && op->fontsize14_begin) { | |
336 | if (safe_printf(0, op->fontsize14_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize14_begin"); | |
337 | } else if (size<21 && op->fontsize18_begin) { | |
338 | if (safe_printf(0, op->fontsize18_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize18_begin"); | |
339 | } else if (size<30 && op->fontsize24_begin) { | |
340 | if (safe_printf(0, op->fontsize24_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize24_begin"); | |
341 | } else if (size<42 && op->fontsize36_begin) { | |
342 | if (safe_printf(0, op->fontsize36_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize36_begin"); | |
343 | } else if (size>40 && op->fontsize48_begin) { | |
344 | if (safe_printf(0, op->fontsize48_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize48_begin"); | |
345 | } else { | |
416 | if (size < 9 && op->fontsize8_begin) | |
417 | { | |
418 | if (safe_printf(0, op->fontsize8_begin)) | |
419 | { | |
420 | fprintf(stderr, TOO_MANY_ARGS, "fontsize8_begin"); | |
421 | } | |
422 | } | |
423 | else if (size < 11 && op->fontsize10_begin) | |
424 | { | |
425 | if (safe_printf(0, op->fontsize10_begin)) | |
426 | { | |
427 | fprintf(stderr, TOO_MANY_ARGS, "fontsize10_begin"); | |
428 | } | |
429 | } | |
430 | else if (size < 13 && op->fontsize12_begin) | |
431 | { | |
432 | if (safe_printf(0, op->fontsize12_begin)) | |
433 | { | |
434 | fprintf(stderr, TOO_MANY_ARGS, "fontsize12_begin"); | |
435 | } | |
436 | } | |
437 | else if (size < 16 && op->fontsize14_begin) | |
438 | { | |
439 | if (safe_printf(0, op->fontsize14_begin)) | |
440 | { | |
441 | fprintf(stderr, TOO_MANY_ARGS, "fontsize14_begin"); | |
442 | } | |
443 | } | |
444 | else if (size < 21 && op->fontsize18_begin) | |
445 | { | |
446 | if (safe_printf(0, op->fontsize18_begin)) | |
447 | { | |
448 | fprintf(stderr, TOO_MANY_ARGS, "fontsize18_begin"); | |
449 | } | |
450 | } | |
451 | else if (size < 30 && op->fontsize24_begin) | |
452 | { | |
453 | if (safe_printf(0, op->fontsize24_begin)) | |
454 | { | |
455 | fprintf(stderr, TOO_MANY_ARGS, "fontsize24_begin"); | |
456 | } | |
457 | } | |
458 | else if (size < 42 && op->fontsize36_begin) | |
459 | { | |
460 | if (safe_printf(0, op->fontsize36_begin)) | |
461 | { | |
462 | fprintf(stderr, TOO_MANY_ARGS, "fontsize36_begin"); | |
463 | } | |
464 | } | |
465 | else if (size > 40 && op->fontsize48_begin) | |
466 | { | |
467 | if (safe_printf(0, op->fontsize48_begin)) | |
468 | { | |
469 | fprintf(stderr, TOO_MANY_ARGS, "fontsize48_begin"); | |
470 | } | |
471 | } | |
472 | else | |
473 | { | |
346 | 474 | /* If we can't even produce a good approximation, |
347 | 475 | * just try to get a font size near 12 point. |
348 | 476 | */ |
349 | if (op->fontsize12_begin) { | |
350 | if (safe_printf(0, op->fontsize12_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize12_begin"); | |
351 | } else if (op->fontsize14_begin) { | |
352 | if (safe_printf(0, op->fontsize14_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize14_begin"); | |
353 | } else if (op->fontsize10_begin) { | |
354 | if (safe_printf(0, op->fontsize10_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize10_begin"); | |
355 | } else if (op->fontsize18_begin) { | |
356 | if (safe_printf(0, op->fontsize18_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize18_begin"); | |
357 | } else if (op->fontsize8_begin) { | |
358 | if (safe_printf(0, op->fontsize8_begin)) fprintf(stderr, TOO_MANY_ARGS, "fontsize8_begin"); | |
359 | } else { | |
360 | error_handler ("output personality lacks sufficient font size change capability"); | |
477 | if (op->fontsize12_begin) | |
478 | { | |
479 | if (safe_printf(0, op->fontsize12_begin)) | |
480 | { | |
481 | fprintf(stderr, TOO_MANY_ARGS, "fontsize12_begin"); | |
482 | } | |
483 | } | |
484 | else if (op->fontsize14_begin) | |
485 | { | |
486 | if (safe_printf(0, op->fontsize14_begin)) | |
487 | { | |
488 | fprintf(stderr, TOO_MANY_ARGS, "fontsize14_begin"); | |
489 | } | |
490 | } | |
491 | else if (op->fontsize10_begin) | |
492 | { | |
493 | if (safe_printf(0, op->fontsize10_begin)) | |
494 | { | |
495 | fprintf(stderr, TOO_MANY_ARGS, "fontsize10_begin"); | |
496 | } | |
497 | } | |
498 | else if (op->fontsize18_begin) | |
499 | { | |
500 | if (safe_printf(0, op->fontsize18_begin)) | |
501 | { | |
502 | fprintf(stderr, TOO_MANY_ARGS, "fontsize18_begin"); | |
503 | } | |
504 | } | |
505 | else if (op->fontsize8_begin) | |
506 | { | |
507 | if (safe_printf(0, op->fontsize8_begin)) | |
508 | { | |
509 | fprintf(stderr, TOO_MANY_ARGS, "fontsize8_begin"); | |
510 | } | |
511 | } | |
512 | else | |
513 | { | |
514 | error_handler("output personality lacks sufficient font size change capability"); | |
361 | 515 | } |
362 | 516 | } |
363 | 517 | } |
366 | 520 | |
367 | 521 | |
368 | 522 | /*======================================================================== |
369 | * Name: op_end_std_fontsize | |
523 | * Name: op_end_std_fontsize | |
370 | 524 | * Purpose: Prints whatever is necessary to perform a change in the |
371 | 525 | * current font size. |
372 | 526 | * Args: OutputPersonality, desired size. |
374 | 528 | *=======================================================================*/ |
375 | 529 | |
376 | 530 | void |
377 | op_end_std_fontsize (OutputPersonality *op, int size) | |
531 | op_end_std_fontsize(OutputPersonality *op, int size) | |
378 | 532 | { |
379 | 533 | int found_std_expr = FALSE; |
380 | 534 | |
382 | 536 | |
383 | 537 | /* Look for an exact match with a standard point size. |
384 | 538 | */ |
385 | switch (size) { | |
539 | switch (size) | |
540 | { | |
386 | 541 | case 8: |
387 | if (op->fontsize8_end) { | |
388 | if (safe_printf(0, op->fontsize8_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize8_end"); | |
542 | if (op->fontsize8_end) | |
543 | { | |
544 | if (safe_printf(0, op->fontsize8_end)) | |
545 | { | |
546 | fprintf(stderr, TOO_MANY_ARGS, "fontsize8_end"); | |
547 | } | |
389 | 548 | found_std_expr = TRUE; |
390 | 549 | } |
391 | 550 | break; |
392 | 551 | case 10: |
393 | if (op->fontsize10_end) { | |
394 | if (safe_printf(0, op->fontsize10_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize10_end"); | |
552 | if (op->fontsize10_end) | |
553 | { | |
554 | if (safe_printf(0, op->fontsize10_end)) | |
555 | { | |
556 | fprintf(stderr, TOO_MANY_ARGS, "fontsize10_end"); | |
557 | } | |
395 | 558 | found_std_expr = TRUE; |
396 | 559 | } |
397 | 560 | break; |
398 | 561 | case 12: |
399 | if (op->fontsize12_end) { | |
400 | if (safe_printf(0, op->fontsize12_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize12_end"); | |
562 | if (op->fontsize12_end) | |
563 | { | |
564 | if (safe_printf(0, op->fontsize12_end)) | |
565 | { | |
566 | fprintf(stderr, TOO_MANY_ARGS, "fontsize12_end"); | |
567 | } | |
401 | 568 | found_std_expr = TRUE; |
402 | 569 | } |
403 | 570 | break; |
404 | 571 | case 14: |
405 | if (op->fontsize14_end) { | |
406 | if (safe_printf(0, op->fontsize14_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize14_end"); | |
572 | if (op->fontsize14_end) | |
573 | { | |
574 | if (safe_printf(0, op->fontsize14_end)) | |
575 | { | |
576 | fprintf(stderr, TOO_MANY_ARGS, "fontsize14_end"); | |
577 | } | |
407 | 578 | found_std_expr = TRUE; |
408 | 579 | } |
409 | 580 | break; |
410 | 581 | case 18: |
411 | if (op->fontsize18_end) { | |
412 | if (safe_printf(0, op->fontsize18_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize18_end"); | |
582 | if (op->fontsize18_end) | |
583 | { | |
584 | if (safe_printf(0, op->fontsize18_end)) | |
585 | { | |
586 | fprintf(stderr, TOO_MANY_ARGS, "fontsize18_end"); | |
587 | } | |
413 | 588 | found_std_expr = TRUE; |
414 | 589 | } |
415 | 590 | break; |
416 | 591 | case 24: |
417 | if (op->fontsize24_end) { | |
418 | if (safe_printf(0, op->fontsize24_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize24_end"); | |
592 | if (op->fontsize24_end) | |
593 | { | |
594 | if (safe_printf(0, op->fontsize24_end)) | |
595 | { | |
596 | fprintf(stderr, TOO_MANY_ARGS, "fontsize24_end"); | |
597 | } | |
419 | 598 | found_std_expr = TRUE; |
420 | 599 | } |
421 | 600 | break; |
422 | 601 | case 36: |
423 | if (op->fontsize36_end) { | |
424 | if (safe_printf(0, op->fontsize36_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize36_end"); | |
602 | if (op->fontsize36_end) | |
603 | { | |
604 | if (safe_printf(0, op->fontsize36_end)) | |
605 | { | |
606 | fprintf(stderr, TOO_MANY_ARGS, "fontsize36_end"); | |
607 | } | |
425 | 608 | found_std_expr = TRUE; |
426 | 609 | } |
427 | 610 | break; |
428 | 611 | case 48: |
429 | if (op->fontsize48_end) { | |
430 | if (safe_printf(0, op->fontsize48_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize48_end"); | |
612 | if (op->fontsize48_end) | |
613 | { | |
614 | if (safe_printf(0, op->fontsize48_end)) | |
615 | { | |
616 | fprintf(stderr, TOO_MANY_ARGS, "fontsize48_end"); | |
617 | } | |
431 | 618 | found_std_expr = TRUE; |
432 | 619 | } |
433 | 620 | break; |
436 | 623 | /* If no exact match, try to write out a change to the |
437 | 624 | * exact point size. |
438 | 625 | */ |
439 | if (!found_std_expr) { | |
440 | if (op->fontsize_end) { | |
626 | if (!found_std_expr) | |
627 | { | |
628 | if (op->fontsize_end) | |
629 | { | |
441 | 630 | char expr[16]; |
442 | sprintf (expr, "%d", size); | |
443 | if (safe_printf(1, op->fontsize_end, expr)) fprintf(stderr, TOO_MANY_ARGS, "fontsize_end"); | |
444 | } else { | |
631 | snprintf(expr, 16, "%d", size); | |
632 | if (safe_printf(1, op->fontsize_end, expr)) | |
633 | { | |
634 | fprintf(stderr, TOO_MANY_ARGS, "fontsize_end"); | |
635 | } | |
636 | } | |
637 | else | |
638 | { | |
445 | 639 | /* If we cannot write out a change for the exact |
446 | 640 | * point size, we must approximate to a standard |
447 | 641 | * size. |
448 | 642 | */ |
449 | if (size<9 && op->fontsize8_end) { | |
450 | if (safe_printf(0, op->fontsize8_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize8_end"); | |
451 | } else | |
452 | if (size<11 && op->fontsize10_end) { | |
453 | if (safe_printf(0, op->fontsize10_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize10_end"); | |
454 | } else | |
455 | if (size<13 && op->fontsize12_end) { | |
456 | if (safe_printf(0, op->fontsize12_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize12_end"); | |
457 | } else | |
458 | if (size<16 && op->fontsize14_end) { | |
459 | if (safe_printf(0, op->fontsize14_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize14_end"); | |
460 | } else | |
461 | if (size<21 && op->fontsize18_end) { | |
462 | if (safe_printf(0, op->fontsize18_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize18_end"); | |
463 | } else | |
464 | if (size<30 && op->fontsize24_end) { | |
465 | if (safe_printf(0, op->fontsize24_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize24_end"); | |
466 | } else | |
467 | if (size<42 && op->fontsize36_end) { | |
468 | if (safe_printf(0, op->fontsize36_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize36_end"); | |
469 | } else | |
470 | if (size>40 && op->fontsize48_end) { | |
471 | if (safe_printf(0, op->fontsize48_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize48_end"); | |
472 | } else { | |
473 | /* If we can't even produce a good approximation, | |
474 | * just try to get a font size near 12 point. | |
475 | */ | |
476 | if (op->fontsize12_end) { | |
477 | if (safe_printf(0, op->fontsize12_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize12_end"); | |
478 | } else if (op->fontsize14_end) { | |
479 | if (safe_printf(0, op->fontsize14_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize14_end"); | |
480 | } else if (op->fontsize10_end) { | |
481 | if (safe_printf(0, op->fontsize10_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize10_end"); | |
482 | } else if (op->fontsize18_end) { | |
483 | if (safe_printf(0, op->fontsize18_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize18_end"); | |
484 | } else if (op->fontsize8_end) { | |
485 | if (safe_printf(0, op->fontsize8_end)) fprintf(stderr, TOO_MANY_ARGS, "fontsize8_end"); | |
486 | } else { | |
487 | error_handler ("output personality lacks sufficient font size change capability"); | |
643 | if (size < 9 && op->fontsize8_end) | |
644 | { | |
645 | if (safe_printf(0, op->fontsize8_end)) | |
646 | { | |
647 | fprintf(stderr, TOO_MANY_ARGS, "fontsize8_end"); | |
648 | } | |
649 | } | |
650 | else if (size < 11 && op->fontsize10_end) | |
651 | { | |
652 | if (safe_printf(0, op->fontsize10_end)) | |
653 | { | |
654 | fprintf(stderr, TOO_MANY_ARGS, "fontsize10_end"); | |
655 | } | |
656 | } | |
657 | else if (size < 13 && op->fontsize12_end) | |
658 | { | |
659 | if (safe_printf(0, op->fontsize12_end)) | |
660 | { | |
661 | fprintf(stderr, TOO_MANY_ARGS, "fontsize12_end"); | |
662 | } | |
663 | } | |
664 | else if (size < 16 && op->fontsize14_end) | |
665 | { | |
666 | if (safe_printf(0, op->fontsize14_end)) | |
667 | { | |
668 | fprintf(stderr, TOO_MANY_ARGS, "fontsize14_end"); | |
669 | } | |
670 | } | |
671 | else if (size < 21 && op->fontsize18_end) | |
672 | { | |
673 | if (safe_printf(0, op->fontsize18_end)) | |
674 | { | |
675 | fprintf(stderr, TOO_MANY_ARGS, "fontsize18_end"); | |
676 | } | |
677 | } | |
678 | else if (size < 30 && op->fontsize24_end) | |
679 | { | |
680 | if (safe_printf(0, op->fontsize24_end)) | |
681 | { | |
682 | fprintf(stderr, TOO_MANY_ARGS, "fontsize24_end"); | |
683 | } | |
684 | } | |
685 | else if (size < 42 && op->fontsize36_end) | |
686 | { | |
687 | if (safe_printf(0, op->fontsize36_end)) | |
688 | { | |
689 | fprintf(stderr, TOO_MANY_ARGS, "fontsize36_end"); | |
690 | } | |
691 | } | |
692 | else if (size > 40 && op->fontsize48_end) | |
693 | { | |
694 | if (safe_printf(0, op->fontsize48_end)) | |
695 | { | |
696 | fprintf(stderr, TOO_MANY_ARGS, "fontsize48_end"); | |
697 | } | |
698 | } | |
699 | else | |
700 | { | |
701 | /* If we can't even produce a good approximation, | |
702 | * just try to get a font size near 12 point. | |
703 | */ | |
704 | if (op->fontsize12_end) | |
705 | { | |
706 | if (safe_printf(0, op->fontsize12_end)) | |
707 | { | |
708 | fprintf(stderr, TOO_MANY_ARGS, "fontsize12_end"); | |
709 | } | |
710 | } | |
711 | else if (op->fontsize14_end) | |
712 | { | |
713 | if (safe_printf(0, op->fontsize14_end)) | |
714 | { | |
715 | fprintf(stderr, TOO_MANY_ARGS, "fontsize14_end"); | |
716 | } | |
717 | } | |
718 | else if (op->fontsize10_end) | |
719 | { | |
720 | if (safe_printf(0, op->fontsize10_end)) | |
721 | { | |
722 | fprintf(stderr, TOO_MANY_ARGS, "fontsize10_end"); | |
723 | } | |
724 | } | |
725 | else if (op->fontsize18_end) | |
726 | { | |
727 | if (safe_printf(0, op->fontsize18_end)) | |
728 | { | |
729 | fprintf(stderr, TOO_MANY_ARGS, "fontsize18_end"); | |
730 | } | |
731 | } | |
732 | else if (op->fontsize8_end) | |
733 | { | |
734 | if (safe_printf(0, op->fontsize8_end)) | |
735 | { | |
736 | fprintf(stderr, TOO_MANY_ARGS, "fontsize8_end"); | |
737 | } | |
738 | } | |
739 | else | |
740 | { | |
741 | error_handler("output personality lacks sufficient font size change capability"); | |
488 | 742 | } |
489 | 743 | } |
490 | 744 | } |
41 | 41 | |
42 | 42 | typedef Collection Aliases; |
43 | 43 | |
44 | typedef struct { | |
44 | typedef struct | |
45 | { | |
45 | 46 | char *comment_begin; |
46 | 47 | char *comment_end; |
47 | 48 | |
182 | 183 | |
183 | 184 | char *outline_begin; |
184 | 185 | char *outline_end; |
186 | ||
187 | char *all_caps_begin; | |
188 | char *all_caps_end; | |
185 | 189 | |
186 | 190 | char *small_caps_begin; |
187 | 191 | char *small_caps_end; |
215 | 219 | /* XX These should really be replaced by references |
216 | 220 | * to one of the charsets. |
217 | 221 | */ |
218 | struct { | |
222 | struct | |
223 | { | |
219 | 224 | char *bullet; |
220 | 225 | char *left_quote; |
221 | 226 | char *right_quote; |
243 | 248 | OutputPersonality; |
244 | 249 | |
245 | 250 | |
246 | extern OutputPersonality* op_create(void); | |
247 | extern void op_free (OutputPersonality*); | |
248 | extern const char *op_translate_char (OutputPersonality *op, char *encoding, int ch); | |
249 | extern char *op_translate_buffer(OutputPersonality *op, char *buffer, | |
251 | extern OutputPersonality *op_create(void); | |
252 | extern void op_free(OutputPersonality *); | |
253 | extern const char *op_translate_char(OutputPersonality *op, char *encoding, int ch); | |
254 | extern char *op_translate_buffer(OutputPersonality *op, char *buffer, | |
250 | 255 | int bytescnt); |
251 | 256 | |
252 | extern void op_begin_std_fontsize (OutputPersonality*, int); | |
253 | extern void op_end_std_fontsize (OutputPersonality*, int); | |
257 | extern void op_begin_std_fontsize(OutputPersonality *, int); | |
258 | extern void op_end_std_fontsize(OutputPersonality *, int); | |
254 | 259 | |
255 | 260 | void add_alias(OutputPersonality *op, int nr, char *text); |
256 | 261 | const char *get_alias(OutputPersonality *op, int nr); |
32 | 32 | * 03 Aug 01, tuorfa@yahoo.com: added input buffering |
33 | 33 | * 19 Sep 01, tuorfa@yahoo.com: cleaned up read_word() |
34 | 34 | * 22 Sep 01, tuorfa@yahoo.com: moved word_dump() to word.c |
35 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
35 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
36 | 36 | * 08 Sep 03, daved@physiol.usyd.edu.au: type fixes; ANSI C fixes |
37 | 37 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
38 | 38 | * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3 |
81 | 81 | * Returns: None. |
82 | 82 | *=======================================================================*/ |
83 | 83 | |
84 | static void my_unget_char (int ch) | |
84 | static void my_unget_char(int ch) | |
85 | 85 | { |
86 | if (ungot_char>=0 && ungot_char2>=0 && ungot_char3>=0) | |
86 | if (ungot_char >= 0 && ungot_char2 >= 0 && ungot_char3 >= 0) | |
87 | { | |
87 | 88 | error_handler("More than 3 ungot chars"); |
89 | } | |
88 | 90 | |
89 | 91 | ungot_char3 = ungot_char2; |
90 | 92 | ungot_char2 = ungot_char; |
92 | 94 | } |
93 | 95 | |
94 | 96 | |
95 | static int last_returned_ch=0; | |
97 | static int last_returned_ch = 0; | |
96 | 98 | |
97 | 99 | |
98 | 100 | #define READ_BUF_LEN 2048 |
112 | 114 | * Returns: Character, or EOF. |
113 | 115 | *=======================================================================*/ |
114 | 116 | |
115 | static int my_getchar (FILE* f) | |
117 | static int my_getchar(FILE *f) | |
116 | 118 | { |
117 | 119 | int ch; |
118 | 120 | |
119 | 121 | CHECK_PARAM_NOT_NULL(f); |
120 | 122 | |
121 | if (ungot_char>=0) { | |
122 | ch = ungot_char; | |
123 | ungot_char = ungot_char2; | |
123 | if (ungot_char >= 0) | |
124 | { | |
125 | ch = ungot_char; | |
126 | ungot_char = ungot_char2; | |
124 | 127 | ungot_char2 = ungot_char3; |
125 | 128 | ungot_char3 = -1; |
126 | 129 | last_returned_ch = ch; |
127 | if(ch > 255) | |
130 | if (ch > 255) | |
128 | 131 | { |
129 | 132 | fprintf(stderr, "returning bad ch = '%c' (0%o)\n", |
130 | ch, ch); | |
133 | ch, ch); | |
131 | 134 | } |
132 | 135 | return ch; |
133 | 136 | } |
134 | do { | |
135 | if (read_buf_index >= read_buf_end) { | |
136 | if (!read_buf) { | |
137 | do | |
138 | { | |
139 | if (read_buf_index >= read_buf_end) | |
140 | { | |
141 | if (!read_buf) | |
142 | { | |
137 | 143 | buffer_size = READ_BUF_LEN; |
138 | read_buf = my_malloc (buffer_size); | |
139 | if (!read_buf) { | |
144 | read_buf = my_malloc(buffer_size); | |
145 | if (!read_buf) | |
146 | { | |
140 | 147 | buffer_size /= 4; |
141 | read_buf = my_malloc (buffer_size); | |
142 | if (!read_buf) | |
148 | read_buf = my_malloc(buffer_size); | |
149 | if (!read_buf) | |
150 | { | |
143 | 151 | error_handler("Cannot allocate read buffer"); |
152 | } | |
144 | 153 | } |
145 | 154 | } |
146 | read_buf_end = fread (read_buf, 1, buffer_size, f); | |
155 | read_buf_end = fread(read_buf, 1, buffer_size, f); | |
147 | 156 | read_buf_index = 0; |
148 | 157 | if (!read_buf_end) |
158 | { | |
149 | 159 | return EOF; |
160 | } | |
150 | 161 | } |
151 | 162 | ch = read_buf [read_buf_index++]; |
152 | 163 | |
153 | if (ch=='\n') { | |
164 | if (ch == '\n') | |
165 | { | |
154 | 166 | lineno++; |
155 | 167 | /* Convert \(newline) into \par here */ |
156 | if (last_returned_ch=='\\') { | |
157 | my_unget_char (' '); | |
158 | my_unget_char ('r'); | |
159 | my_unget_char ('a'); | |
168 | if (last_returned_ch == '\\') | |
169 | { | |
170 | my_unget_char(' '); | |
171 | my_unget_char('r'); | |
172 | my_unget_char('a'); | |
160 | 173 | ch = 'p'; |
161 | 174 | break; |
162 | 175 | } |
163 | 176 | } |
164 | } | |
165 | while (ch=='\r' /* || ch=='\n' */ ); | |
166 | ||
167 | if (ch=='\t') ch = ' '; | |
177 | } | |
178 | while (ch == '\r' /* || ch=='\n' */); | |
179 | ||
180 | if (ch == '\t') | |
181 | { | |
182 | ch = ' '; | |
183 | } | |
168 | 184 | |
169 | 185 | last_returned_ch = ch; |
170 | if(ch > 255) | |
171 | { | |
172 | fprintf(stderr,"returning bad ch '%c' (0%o)\n", ch, ch); | |
186 | if (ch > 255) | |
187 | { | |
188 | fprintf(stderr, "returning bad ch '%c' (0%o)\n", ch, ch); | |
173 | 189 | exit(1); |
174 | 190 | } |
175 | 191 | return ch; |
183 | 199 | * Returns: None. |
184 | 200 | *=======================================================================*/ |
185 | 201 | |
186 | static void my_skip (FILE *f, long n) | |
202 | static void my_skip(FILE *f, long n) | |
187 | 203 | { |
188 | 204 | n += read_buf_index; |
189 | 205 | if (n >= 0 && n < read_buf_end) |
193 | 209 | } |
194 | 210 | read_buf_end = read_buf_index = 0; |
195 | 211 | if (fseek(f, n - read_buf_end, SEEK_CUR)) |
212 | { | |
196 | 213 | error_handler("Cannot seek"); |
214 | } | |
197 | 215 | return; |
198 | 216 | } |
199 | 217 | |
212 | 230 | *=======================================================================*/ |
213 | 231 | |
214 | 232 | static int |
215 | expand_word_buffer () | |
233 | expand_word_buffer() | |
216 | 234 | { |
217 | 235 | char *new_ptr; |
218 | 236 | unsigned long old_length; |
219 | 237 | if (!input_str) |
238 | { | |
220 | 239 | error_handler("No input buffer allocated"); |
240 | } | |
221 | 241 | old_length = current_max_length; |
222 | 242 | current_max_length *= 2; |
223 | new_ptr = my_malloc (current_max_length); | |
243 | new_ptr = my_malloc(current_max_length); | |
224 | 244 | if (!new_ptr) |
245 | { | |
225 | 246 | error_handler("Out of memory while resizing buffer"); |
226 | ||
227 | memcpy (new_ptr, input_str, old_length); | |
247 | } | |
248 | ||
249 | memcpy(new_ptr, input_str, old_length); | |
228 | 250 | my_free(input_str); |
229 | 251 | input_str = new_ptr; |
230 | 252 | return TRUE; |
241 | 263 | * Note: The word buffer is static and local to this file. |
242 | 264 | *=======================================================================*/ |
243 | 265 | |
244 | static int | |
245 | read_word (FILE *f) | |
266 | static int | |
267 | read_word(FILE *f) | |
246 | 268 | { |
247 | 269 | int ch, ch2; |
248 | unsigned long ix=0; | |
249 | int have_whitespace=FALSE; | |
250 | int is_control_word=FALSE; | |
251 | int has_numeric_param=FALSE; /* if is_control_word==TRUE */ | |
252 | int need_unget=FALSE; | |
270 | unsigned long ix = 0; | |
271 | int have_whitespace = FALSE; | |
272 | int is_control_word = FALSE; | |
273 | int has_numeric_param = FALSE; /* if is_control_word==TRUE */ | |
274 | int need_unget = FALSE; | |
253 | 275 | |
254 | 276 | CHECK_PARAM_NOT_NULL(f); |
255 | 277 | |
256 | current_max_length = 10; /* XX */ | |
257 | ||
258 | /* Get some storage for a word. | |
259 | */ | |
260 | input_str = my_malloc (current_max_length); | |
261 | if (!input_str) | |
262 | error_handler("Cannot allocate word storage"); | |
263 | ||
264 | do { | |
278 | if (input_str == NULL) | |
279 | { | |
280 | /* Get some storage for a word. | |
281 | */ | |
282 | current_max_length = 10; /* XX */ | |
283 | input_str = my_malloc(current_max_length); | |
284 | if (!input_str) | |
285 | { | |
286 | error_handler("Cannot allocate word storage"); | |
287 | } | |
288 | } | |
289 | ||
290 | do | |
291 | { | |
265 | 292 | ch = my_getchar(f); |
266 | } | |
267 | while (ch=='\n'); | |
268 | ||
269 | if (ch==' ') | |
293 | } | |
294 | while (ch == '\n'); | |
295 | ||
296 | if (ch == ' ') | |
270 | 297 | { |
271 | 298 | /* Compress multiple space chars down to one. |
272 | 299 | */ |
273 | while (ch == ' ') { | |
300 | while (ch == ' ') | |
301 | { | |
274 | 302 | ch = my_getchar(f); |
275 | have_whitespace=TRUE; | |
276 | } | |
277 | if (have_whitespace) { | |
278 | my_unget_char (ch); | |
279 | input_str[0]=' '; | |
280 | input_str[1]=0; | |
303 | have_whitespace = TRUE; | |
304 | } | |
305 | if (have_whitespace) | |
306 | { | |
307 | my_unget_char(ch); | |
308 | input_str[0] = ' '; | |
309 | input_str[1] = 0; | |
281 | 310 | return 1; |
282 | 311 | } |
283 | 312 | } |
284 | 313 | |
285 | switch(ch) | |
286 | { | |
287 | case EOF: | |
314 | switch (ch) | |
315 | { | |
316 | case EOF: | |
288 | 317 | return 0; |
289 | 318 | |
290 | 319 | case '\\': |
292 | 321 | |
293 | 322 | /* Look for two-character command words. |
294 | 323 | */ |
295 | switch (ch2) | |
324 | switch (ch2) | |
296 | 325 | { |
297 | 326 | case '\n': |
298 | strcpy (input_str, "\\par"); | |
327 | strcpy(input_str, "\\par"); | |
299 | 328 | return 4; |
300 | 329 | case '~': |
301 | 330 | case '{': |
310 | 339 | case '\'': |
311 | 340 | /* Preserve \'## expressions (hex char exprs) for later. |
312 | 341 | */ |
313 | input_str[0]='\\'; | |
314 | input_str[1]='\''; | |
315 | ix=2; | |
316 | if(ix==current_max_length) { | |
317 | if (!expand_word_buffer ()) | |
342 | input_str[0] = '\\'; | |
343 | input_str[1] = '\''; | |
344 | ix = 2; | |
345 | if (ix == current_max_length) | |
346 | { | |
347 | if (!expand_word_buffer()) | |
348 | { | |
318 | 349 | error_handler("Word too long"); |
350 | } | |
319 | 351 | } |
320 | 352 | ch = my_getchar(f); |
321 | input_str[ix++]=ch; | |
322 | if(ix==current_max_length) { | |
323 | if (!expand_word_buffer ()) | |
353 | input_str[ix++] = ch; | |
354 | if (ix == current_max_length) | |
355 | { | |
356 | if (!expand_word_buffer()) | |
357 | { | |
324 | 358 | error_handler("Word too long"); |
359 | } | |
325 | 360 | } |
326 | 361 | ch = my_getchar(f); |
327 | input_str[ix++]=ch; | |
328 | if(ix==current_max_length) { | |
329 | if (!expand_word_buffer ()) | |
362 | input_str[ix++] = ch; | |
363 | if (ix == current_max_length) | |
364 | { | |
365 | if (!expand_word_buffer()) | |
366 | { | |
330 | 367 | error_handler("Word too long"); |
331 | } | |
332 | input_str[ix]=0; | |
368 | } | |
369 | } | |
370 | input_str[ix] = 0; | |
333 | 371 | return ix; |
334 | 372 | } |
335 | 373 | |
336 | is_control_word=TRUE; | |
337 | ix=1; | |
338 | input_str[0]=ch; | |
339 | ch=ch2; | |
374 | is_control_word = TRUE; | |
375 | ix = 1; | |
376 | input_str[0] = ch; | |
377 | ch = ch2; | |
340 | 378 | break; |
341 | 379 | |
342 | 380 | case '\t': |
343 | 381 | /* In RTF, a tab char is the same as \tab. |
344 | 382 | */ |
345 | strcpy (input_str, "\\tab"); | |
383 | strcpy(input_str, "\\tab"); | |
346 | 384 | return 4; |
347 | 385 | |
348 | 386 | case '{': |
349 | 387 | case '}': |
350 | 388 | case ';': |
351 | input_str[0]=ch; | |
352 | input_str[1]=0; | |
389 | input_str[0] = ch; | |
390 | input_str[1] = 0; | |
353 | 391 | return 1; |
354 | 392 | |
355 | 393 | } |
356 | 394 | |
357 | while (ch!=EOF) | |
395 | while (ch != EOF) | |
358 | 396 | { |
359 | 397 | /* Several chars always ends a word, and we need to save them. |
360 | 398 | */ |
361 | if (ch=='\t' || ch=='{' || ch=='}' || ch=='\\') { | |
362 | need_unget=TRUE; | |
399 | if (ch == '\t' || ch == '{' || ch == '}' || ch == '\\') | |
400 | { | |
401 | need_unget = TRUE; | |
363 | 402 | break; |
364 | 403 | } |
365 | 404 | |
366 | /* A newline always ends a command word; we don't save it. | |
405 | /* A newline always ends a command word; we don't save it. | |
367 | 406 | * A newline is ignored if this is not a command word. |
368 | 407 | */ |
369 | if (ch=='\n') { | |
370 | if (is_control_word) | |
408 | if (ch == '\n') | |
409 | { | |
410 | if (is_control_word) | |
411 | { | |
371 | 412 | break; |
372 | ch = my_getchar(f); | |
373 | continue; | |
374 | } | |
375 | ||
376 | /* A semicolon always ends a command word; we do save it. | |
413 | } | |
414 | ch = my_getchar(f); | |
415 | continue; | |
416 | } | |
417 | ||
418 | /* A semicolon always ends a command word; we do save it. | |
377 | 419 | * A semicolon never ends a regular word. |
378 | 420 | */ |
379 | if (ch==';') { | |
380 | if (is_control_word) { | |
381 | need_unget=TRUE; | |
421 | if (ch == ';') | |
422 | { | |
423 | if (is_control_word) | |
424 | { | |
425 | need_unget = TRUE; | |
382 | 426 | break; |
383 | 427 | } |
384 | 428 | } |
387 | 431 | * any word, and if it does not follow a command, |
388 | 432 | * then it is a word in itself. |
389 | 433 | */ |
390 | if (ch==' ') { | |
434 | if (ch == ' ') | |
435 | { | |
391 | 436 | if (!is_control_word) |
392 | need_unget=TRUE; | |
437 | { | |
438 | need_unget = TRUE; | |
439 | } | |
393 | 440 | break; |
394 | 441 | } |
395 | 442 | |
396 | 443 | /* Identify a control word's numeric parameter. |
397 | 444 | */ |
398 | if (is_control_word) { | |
399 | if (!has_numeric_param && (isdigit(ch) || ch=='-')) | |
445 | if (is_control_word) | |
446 | { | |
447 | if (!has_numeric_param && (isdigit(ch) || ch == '-')) | |
448 | { | |
400 | 449 | has_numeric_param = TRUE; |
401 | else | |
402 | if (has_numeric_param && !isdigit(ch)) { | |
403 | if (ch!=' ') | |
404 | need_unget=TRUE; | |
450 | } | |
451 | else if (has_numeric_param && !isdigit(ch)) | |
452 | { | |
453 | if (ch != ' ') | |
454 | { | |
455 | need_unget = TRUE; | |
456 | } | |
405 | 457 | break; |
406 | 458 | } |
407 | 459 | } |
408 | ||
460 | ||
409 | 461 | input_str[ix++] = ch; |
410 | if (ix==current_max_length) { | |
411 | if (!expand_word_buffer ()) | |
462 | if (ix == current_max_length) | |
463 | { | |
464 | if (!expand_word_buffer()) | |
465 | { | |
412 | 466 | error_handler("Word too long"); |
413 | } | |
414 | ch = my_getchar (f); | |
467 | } | |
468 | } | |
469 | ch = my_getchar(f); | |
415 | 470 | } |
416 | 471 | |
417 | 472 | if (need_unget) |
473 | { | |
418 | 474 | my_unget_char(ch); |
419 | ||
420 | input_str[ix]=0; | |
475 | } | |
476 | ||
477 | input_str[ix] = 0; | |
421 | 478 | |
422 | 479 | if (!memcmp(input_str, "\\bin", 4) && isdigit(input_str[4])) |
480 | { | |
423 | 481 | my_skip(f, atoi(input_str + 4)); |
482 | } | |
424 | 483 | |
425 | 484 | return ix; |
426 | 485 | } |
429 | 488 | |
430 | 489 | /*======================================================================== |
431 | 490 | * Name: word_read |
432 | * Purpose: This is the recursive metareader which pieces together the | |
491 | * Purpose: This is the recursive metareader which pieces together the | |
433 | 492 | * structure of Word objects. |
434 | 493 | * Args: Input file. |
435 | 494 | * Returns: Tree of Word objects. |
436 | 495 | *=======================================================================*/ |
437 | 496 | |
438 | 497 | Word * |
439 | word_read (FILE* f) { | |
440 | Word * prev_word = NULL; | |
441 | Word * first_word = NULL; | |
442 | Word * new_word = NULL; /* temp */ | |
498 | word_read(FILE *f) | |
499 | { | |
500 | Word *prev_word = NULL; | |
501 | Word *first_word = NULL; | |
502 | Word *new_word = NULL; /* temp */ | |
443 | 503 | |
444 | 504 | CHECK_PARAM_NOT_NULL(f); |
445 | 505 | |
446 | do { | |
506 | do | |
507 | { | |
447 | 508 | if (!read_word(f)) |
509 | { | |
448 | 510 | return first_word; |
449 | ||
450 | if (input_str[0] == '{') { | |
511 | } | |
512 | ||
513 | if (input_str[0] == '{') | |
514 | { | |
451 | 515 | /* Process subwords */ |
452 | 516 | |
453 | 517 | /* Create a dummy word to point to a sublist */ |
454 | 518 | new_word = word_new(NULL); |
455 | 519 | if (!new_word) |
520 | { | |
456 | 521 | error_handler("Cannot allocate word"); |
522 | } | |
457 | 523 | |
458 | 524 | /* Get the sublist */ |
459 | 525 | new_word->child = word_read(f); |
460 | 526 | |
461 | } else if (input_str[0] == '}') { | |
527 | } | |
528 | else if (input_str[0] == '}') | |
529 | { | |
462 | 530 | return first_word; |
463 | } else { | |
531 | } | |
532 | else | |
533 | { | |
464 | 534 | new_word = word_new(input_str); |
465 | 535 | } |
466 | 536 | |
467 | 537 | if (prev_word) |
538 | { | |
468 | 539 | prev_word->next = new_word; |
540 | } | |
469 | 541 | |
470 | 542 | if (!first_word) |
543 | { | |
471 | 544 | first_word = new_word; |
545 | } | |
472 | 546 | |
473 | 547 | prev_word = new_word; |
474 | 548 | |
475 | 549 | /* Free up the memory allocated by read_word. */ |
476 | 550 | my_free(input_str); |
477 | 551 | input_str = NULL; |
478 | } while (1); | |
552 | } | |
553 | while (1); | |
479 | 554 | } |
38 | 38 | #include "word.h" |
39 | 39 | #include <stdio.h> |
40 | 40 | |
41 | extern Word *word_read(FILE*); | |
41 | extern Word *word_read(FILE *); | |
42 | 42 | |
43 | 43 | |
44 | 44 | #endif /* _PARSE_H_INCLUDED_ */ |
0 | #ifdef HAVE_CONFIG_H | |
1 | #include "config.h" | |
2 | #endif | |
3 | ||
0 | 4 | #include <stdio.h> |
1 | 5 | #include <string.h> |
6 | #ifdef HAVE_UNISTD_H | |
2 | 7 | #include <unistd.h> |
8 | #else | |
9 | #include "safeunistd.h" | |
10 | #endif | |
11 | ||
3 | 12 | #include <stdlib.h> |
4 | 13 | |
5 | 14 | #include "path.h" |
13 | 22 | |
14 | 23 | char *search_in_path(const char *name, char *suffix) |
15 | 24 | { |
16 | int maxplen = 0; | |
17 | int l; | |
18 | char *fullname = 0; | |
19 | char *path = 0; | |
20 | struct path_dir *path_dir_p; | |
25 | int maxplen = 0; | |
26 | int l; | |
27 | char *fullname = 0; | |
28 | char *path = 0; | |
29 | struct path_dir *path_dir_p; | |
21 | 30 | |
22 | if (n_path_dirs == 0) { | |
23 | fprintf(stderr,"no directories to search for %s\n", name); | |
31 | if (n_path_dirs == 0) | |
32 | { | |
33 | fprintf(stderr, "no directories to search for %s\n", name); | |
34 | return NULL; | |
35 | } | |
36 | l = strlen(name) + (suffix ? strlen(suffix) : 0) + 2; | |
37 | if ((fullname = my_malloc(l)) == NULL) | |
38 | { | |
39 | fprintf(stderr, "Out of memory\n"); | |
40 | return NULL; | |
41 | } | |
42 | strcpy(fullname, name); | |
43 | if (suffix && *suffix && suffix[0] != '.') | |
44 | { | |
45 | strcat(fullname, "."); | |
46 | } | |
47 | if (suffix && *suffix) | |
48 | { | |
49 | strcat(fullname, suffix); | |
50 | } | |
51 | maxplen = 0; | |
52 | ||
53 | for (path_dir_p = &topdir; path_dir_p->dir_name; | |
54 | path_dir_p = path_dir_p->next) | |
55 | { | |
56 | l = strlen(path_dir_p->dir_name); | |
57 | if (maxplen < l) | |
58 | { | |
59 | maxplen = l; | |
60 | } | |
61 | } | |
62 | maxplen += strlen(fullname) + 2; /* final 0 + possible '/' */ | |
63 | if ((path = my_malloc(maxplen)) == NULL) | |
64 | { | |
65 | fprintf(stderr, "Out of memory\n"); | |
66 | return NULL; | |
67 | } | |
68 | ||
69 | for (path_dir_p = &topdir; path_dir_p->dir_name; | |
70 | path_dir_p = path_dir_p->next) | |
71 | { | |
72 | ||
73 | strcpy(path, path_dir_p->dir_name); | |
74 | ||
75 | if (path[strlen(path) - 1] != '/') | |
76 | { | |
77 | strcat(path, "/"); | |
78 | } | |
79 | strcat(path, fullname); | |
80 | /* fprintf(stderr, "Testing for [%s]\n", path); */ | |
81 | if (access(path, F_OK | R_OK)) | |
82 | { | |
83 | continue; | |
84 | } | |
85 | my_free(fullname); | |
86 | return path; | |
87 | } | |
88 | my_free(fullname); | |
89 | my_free(path); | |
24 | 90 | return NULL; |
25 | } | |
26 | l = strlen(name) + (suffix?strlen(suffix):0) + 2; | |
27 | if ((fullname = my_malloc(l)) == NULL) { | |
28 | fprintf(stderr, "Out of memory\n"); | |
29 | return NULL; | |
30 | } | |
31 | strcpy(fullname, name); | |
32 | if (suffix && *suffix && suffix[0] != '.') | |
33 | strcat(fullname, "."); | |
34 | if (suffix && *suffix) | |
35 | strcat(fullname, suffix); | |
36 | maxplen = 0; | |
37 | ||
38 | for(path_dir_p = &topdir; path_dir_p->dir_name; | |
39 | path_dir_p = path_dir_p->next) { | |
40 | l = strlen(path_dir_p->dir_name); | |
41 | if (maxplen < l) | |
42 | maxplen = l; | |
43 | } | |
44 | maxplen += strlen(fullname) + 2; /* final 0 + possible '/' */ | |
45 | if ((path = my_malloc(maxplen)) == NULL) { | |
46 | fprintf(stderr, "Out of memory\n"); | |
47 | return NULL; | |
48 | } | |
49 | ||
50 | for (path_dir_p = &topdir; path_dir_p->dir_name; | |
51 | path_dir_p = path_dir_p->next) { | |
52 | ||
53 | strcpy(path, path_dir_p->dir_name); | |
54 | ||
55 | if(path[strlen(path)-1] != '/') | |
56 | strcat(path, "/"); | |
57 | strcat(path, fullname); | |
58 | /* fprintf(stderr, "Testing for [%s]\n", path); */ | |
59 | if(access(path, F_OK|R_OK)) | |
60 | continue; | |
61 | my_free(fullname); | |
62 | return path; | |
63 | } | |
64 | my_free(fullname); | |
65 | my_free(path); | |
66 | return NULL; | |
67 | 91 | } |
68 | 92 | |
69 | 93 | int check_dirs() |
70 | 94 | { |
71 | char *p; | |
72 | char *colon; | |
73 | char *dir_name; | |
74 | struct path_dir *path_dir_p = &topdir; | |
95 | char *p; | |
96 | char *colon; | |
97 | char *dir_name; | |
98 | struct path_dir *path_dir_p = &topdir; | |
75 | 99 | |
76 | /*fprintf(stderr, "check_dirs: search_path: [%s]\n", search_path);*/ | |
100 | /*fprintf(stderr, "check_dirs: search_path: [%s]\n", search_path);*/ | |
77 | 101 | |
78 | for (p = search_path; *p != '\0';) { | |
79 | dir_name = p; | |
80 | if((colon = strchr(p, ':')) != NULL) { | |
81 | p = colon; | |
82 | *p++ = '\0'; | |
83 | } else | |
84 | p += strlen(p); | |
102 | for (p = search_path; *p != '\0';) | |
103 | { | |
104 | dir_name = p; | |
105 | if ((colon = strchr(p, ':')) != NULL) | |
106 | { | |
107 | p = colon; | |
108 | *p++ = '\0'; | |
109 | } | |
110 | else | |
111 | { | |
112 | p += strlen(p); | |
113 | } | |
85 | 114 | |
86 | if(access(dir_name, R_OK|X_OK)) | |
87 | continue; | |
88 | path_dir_p->dir_name = dir_name; | |
89 | if((path_dir_p->next = (struct path_dir *)malloc(sizeof(struct path_dir))) == NULL) | |
90 | { | |
91 | fprintf(stderr,"Out of memory\n"); | |
92 | exit(1); | |
93 | } | |
94 | path_dir_p = path_dir_p->next; | |
95 | path_dir_p->dir_name = 0; | |
96 | n_path_dirs++; | |
97 | } | |
98 | path_checked = 1; | |
99 | return(n_path_dirs); | |
115 | if (access(dir_name, R_OK | X_OK)) | |
116 | { | |
117 | continue; | |
118 | } | |
119 | path_dir_p->dir_name = dir_name; | |
120 | if ((path_dir_p->next = (struct path_dir *)malloc(sizeof(struct path_dir))) == NULL) | |
121 | { | |
122 | fprintf(stderr, "Out of memory\n"); | |
123 | exit(1); | |
124 | } | |
125 | path_dir_p = path_dir_p->next; | |
126 | path_dir_p->dir_name = 0; | |
127 | n_path_dirs++; | |
128 | } | |
129 | path_checked = 1; | |
130 | return (n_path_dirs); | |
100 | 131 | } |
101 | 132 | |
102 | 133 | void show_dirs() |
103 | 134 | { |
104 | struct path_dir *path_dir_p; | |
105 | if(n_path_dirs == 0) { | |
106 | fprintf(stderr,"no directories to show\n"); | |
107 | exit(1); | |
108 | } | |
109 | fprintf(stderr,"show_dirs: %d directories\n", n_path_dirs); | |
110 | for(path_dir_p = &topdir; path_dir_p->dir_name; | |
111 | path_dir_p = path_dir_p->next) | |
112 | fprintf(stderr,"directory = %s\n", path_dir_p->dir_name); | |
135 | struct path_dir *path_dir_p; | |
136 | if (n_path_dirs == 0) | |
137 | { | |
138 | fprintf(stderr, "no directories to show\n"); | |
139 | exit(1); | |
140 | } | |
141 | fprintf(stderr, "show_dirs: %d directories\n", n_path_dirs); | |
142 | for (path_dir_p = &topdir; path_dir_p->dir_name; | |
143 | path_dir_p = path_dir_p->next) | |
144 | { | |
145 | fprintf(stderr, "directory = %s\n", path_dir_p->dir_name); | |
146 | } | |
113 | 147 | } |
0 | 0 | #ifndef _PATH_H_INCLUDED_ |
1 | 1 | #define _PATH_H_INCLUDED_ |
2 | 2 | |
3 | #ifndef DEFAULT_UNRTF_SEARCH_PATH | |
3 | 4 | #define DEFAULT_UNRTF_SEARCH_PATH CONFIG_DIR |
5 | #endif | |
4 | 6 | |
5 | 7 | extern char *search_path; |
6 | 8 | extern int path_checked; |
7 | 9 | |
8 | 10 | struct path_dir |
9 | 11 | { |
10 | char *dir_name; | |
11 | struct path_dir *next; | |
12 | char *dir_name; | |
13 | struct path_dir *next; | |
12 | 14 | }; |
13 | 15 | |
14 | 16 | extern int check_dirs(); |
26 | 26 | int |
27 | 27 | get_unicode(char *string) |
28 | 28 | { |
29 | unsigned long uc; | |
30 | if (string[0] == 'U' || string[0] == 'u') | |
31 | string++; | |
32 | uc = strtoul(string, 0, 16); | |
33 | return uc; | |
29 | unsigned long uc; | |
30 | if (string[0] == 'U' || string[0] == 'u') | |
31 | { | |
32 | string++; | |
33 | } | |
34 | uc = strtoul(string, 0, 16); | |
35 | return uc; | |
34 | 36 | } |
35 | 37 | |
36 | 38 | /*======================================================================== |
42 | 44 | char * |
43 | 45 | unicode_to_utf8(unsigned int uc) |
44 | 46 | { |
45 | unsigned char *string = NULL; | |
47 | unsigned char *string = NULL; | |
46 | 48 | if (uc < 0x7f) |
47 | 49 | { |
48 | 50 | string = (unsigned char *)my_malloc(2 * sizeof(char)); |
51 | 53 | } |
52 | 54 | else if (uc < 0x7ff) |
53 | 55 | { |
54 | string = (unsigned char *)my_malloc(3 * sizeof(char)); | |
56 | string = (unsigned char *)my_malloc(3 * sizeof(char)); | |
55 | 57 | string[0] = (unsigned char) 192 + (uc / 64); |
56 | 58 | string[1] = (unsigned char) 128 + (uc % 64); |
57 | 59 | string[2] = '\0'; |
58 | 60 | } |
59 | 61 | else if (uc < 0xffff) |
60 | 62 | { |
61 | string = (unsigned char *)my_malloc(4 * sizeof(char)); | |
63 | string = (unsigned char *)my_malloc(4 * sizeof(char)); | |
62 | 64 | string[0] = (unsigned char) 224 + (uc / (64 * 64)); |
63 | 65 | string[1] = (unsigned char) 128 + ((uc / 64) % 64); |
64 | 66 | string[2] = (unsigned char) 128 + (uc % 64); |
66 | 68 | } |
67 | 69 | else if (uc < 0x1FFFFF) |
68 | 70 | { |
69 | string = (unsigned char *)my_malloc(5 * sizeof(char)); | |
71 | string = (unsigned char *)my_malloc(5 * sizeof(char)); | |
70 | 72 | string[0] = (unsigned char) 240 + (uc / (64 * 64 * 64)); |
71 | 73 | string[1] = (unsigned char) 128 + ((uc / (64 * 64)) % 64); |
72 | 74 | string[2] = (unsigned char) 128 + ((uc / 64) % 64); |
75 | 77 | } |
76 | 78 | else if (uc < 0x3FFFFFF) |
77 | 79 | { |
78 | string = (unsigned char *)my_malloc(6 * sizeof(char)); | |
80 | string = (unsigned char *)my_malloc(6 * sizeof(char)); | |
79 | 81 | string[0] = (unsigned char) 248 + (uc / (64 * 64 * 64 * 64)); |
80 | 82 | string[1] = (unsigned char) 128 + ((uc / (64 * 64 * 64)) % 64); |
81 | 83 | string[2] = (unsigned char) 128 + ((uc / (64 * 64)) % 64); |
85 | 87 | } |
86 | 88 | else if (uc < 0x7FFFFFFF) |
87 | 89 | { |
88 | string = (unsigned char *)my_malloc(7 * sizeof(char)); | |
90 | string = (unsigned char *)my_malloc(7 * sizeof(char)); | |
89 | 91 | string[0] = (unsigned char) 252 + (uc / (64 * 64 * 64 * 64 * 64)); |
90 | 92 | string[1] = (unsigned char) 128 + ((uc / (64 * 64 * 64 * 64)) % 64); |
91 | 93 | string[2] = (unsigned char) 128 + ((uc / (64 * 64 * 64)) % 64); |
101 | 103 | /*======================================================================== |
102 | 104 | * Name get_unicode_int |
103 | 105 | * Purpose: Reads unicode character (in format <UN...N> and translates |
104 | it to printable unicode character. | |
106 | it to printable unicode character. We are reading from our charmaps, | |
107 | not from the rtf file. | |
105 | 108 | * Caution: This function should be executed after char '<' was read. |
106 | 109 | It reads until char '>' was found or EOL or EOF. |
107 | 110 | * Args: File to read from. |
108 | * Returns: Unicode character encoded in UTF-8 | |
111 | * Returns: integer Unicode code point | |
109 | 112 | *=======================================================================*/ |
110 | 113 | |
111 | 114 | int |
112 | 115 | get_unicode_int(FILE *file) |
113 | 116 | { |
114 | int allocated = 5, len = 0; | |
115 | char c, *unicode_number = my_malloc(allocated * sizeof(char)); | |
117 | #define MAX_CHARMAP_UC_LEN 20 | |
118 | char unicode_number[MAX_CHARMAP_UC_LEN]; | |
119 | int len = 0; | |
120 | char c; | |
116 | 121 | |
117 | 122 | c = fgetc(file); |
118 | 123 | |
122 | 127 | c = fgetc(file); |
123 | 128 | len++; |
124 | 129 | |
125 | if (len == allocated) | |
130 | if (len == MAX_CHARMAP_UC_LEN-1) | |
126 | 131 | { |
127 | allocated *= 2; | |
128 | unicode_number = my_realloc(unicode_number, allocated / 2, allocated); | |
132 | fprintf(stderr, "Buffer overflow in get_unicode_int\n"); | |
133 | return 0; | |
129 | 134 | } |
130 | 135 | } |
131 | 136 | |
132 | 137 | if (c != '>') |
138 | { | |
133 | 139 | ungetc(c, file); |
140 | } | |
134 | 141 | |
135 | 142 | unicode_number[len] = '\0'; |
136 | 143 | return get_unicode(unicode_number); |
139 | 146 | char * |
140 | 147 | get_unicode_utf8(FILE *file) |
141 | 148 | { |
142 | int uc = get_unicode_int(file); | |
143 | return unicode_to_utf8(uc); | |
149 | int uc = get_unicode_int(file); | |
150 | return unicode_to_utf8(uc); | |
144 | 151 | } |
59 | 59 | my_FILE *f = (my_FILE *) malloc(sizeof(my_FILE)); |
60 | 60 | |
61 | 61 | if ((f->file = fopen(file_name, "r")) == NULL || (f->name = my_malloc((strlen(file_name) + 1) * sizeof(char))) == NULL) |
62 | return NULL; | |
62 | { | |
63 | return NULL; | |
64 | } | |
63 | 65 | |
64 | 66 | f->line_nr = 1; |
65 | 67 | strcpy(f->name, file_name); |
105 | 107 | C = fgetc(F); \ |
106 | 108 | if (feof(F) || ferror(F)) \ |
107 | 109 | goto inputend; \ |
108 | } | |
110 | } | |
109 | 111 | |
110 | 112 | char * |
111 | 113 | give_definition(my_FILE *file) |
115 | 117 | unsigned long def_buffer_length = STANDARD_BUFFER_LENGTH, chars_nr = 0; |
116 | 118 | |
117 | 119 | if ((def = my_malloc(def_buffer_length)) == NULL) |
120 | { | |
118 | 121 | return NULL; |
122 | } | |
119 | 123 | |
120 | 124 | GETC_OR_END(file->file, c); |
121 | 125 | |
122 | 126 | while (c == '\t' || c == '#') |
123 | 127 | { |
124 | 128 | if (c == '#') |
129 | { | |
125 | 130 | leave_line(file->file); |
131 | } | |
126 | 132 | else |
127 | 133 | { |
128 | 134 | GETC_OR_END(file->file, c); |
135 | 141 | |
136 | 142 | for (i = 0; unicode_char[i] != '\0'; i++) |
137 | 143 | ADD_CHAR(unicode_char[i]) |
138 | GETC_OR_END(file->file, c); | |
144 | GETC_OR_END(file->file, c); | |
139 | 145 | c2 = 0; |
140 | 146 | c3 = 0; |
141 | 147 | c4 = 0; |
146 | 152 | { |
147 | 153 | ADD_CHAR('<'); |
148 | 154 | } |
149 | /* daved - 0.21.3 - allow escaping a backslash */ | |
155 | /* daved - 0.21.3 - allow escaping a backslash */ | |
150 | 156 | if (c == '\\' && c2 == '\\') |
151 | 157 | { |
152 | 158 | ADD_CHAR('\\'); |
156 | 162 | } |
157 | 163 | else |
158 | 164 | |
159 | /* daved - support \n in definitions */ | |
160 | if (c == 'n' && c2 == '\\') | |
161 | { | |
162 | ADD_CHAR('\n'); | |
163 | } | |
164 | else | |
165 | if ((c != '<' && c != '\\') || (c == '\\' && c2 == '\\')) | |
166 | { | |
167 | ADD_CHAR(c) | |
168 | } | |
165 | /* daved - support \n in definitions */ | |
166 | if (c == 'n' && c2 == '\\') | |
167 | { | |
168 | ADD_CHAR('\n'); | |
169 | } | |
170 | else if ((c != '<' && c != '\\') || (c == '\\' && c2 == '\\')) | |
171 | { | |
172 | ADD_CHAR(c) | |
173 | } | |
169 | 174 | |
170 | 175 | c4 = c3; |
171 | 176 | c3 = c2; |
188 | 193 | } |
189 | 194 | |
190 | 195 | if (chars_nr > 0) |
196 | { | |
191 | 197 | def[chars_nr - 1] = '\0'; |
198 | } | |
192 | 199 | else |
200 | { | |
193 | 201 | def[0] = '\0'; |
202 | } | |
194 | 203 | |
195 | 204 | return def; |
196 | 205 | } |
205 | 214 | *=======================================================================*/ |
206 | 215 | |
207 | 216 | int |
208 | match_name (char *name, OutputPersonality *op, my_FILE *file) | |
217 | match_name(char *name, OutputPersonality *op, my_FILE *file) | |
209 | 218 | { |
210 | 219 | struct definition |
211 | 220 | { |
229 | 238 | i = strtol(name, &endptr, 10); |
230 | 239 | |
231 | 240 | if (*endptr == '\0') |
241 | { | |
232 | 242 | add_alias(op, i, give_definition(file)); |
243 | } | |
233 | 244 | else if (name[0] == '<' && name[1] == 'U') |
245 | { | |
234 | 246 | add_alias(op, get_unicode(&name[2]), give_definition(file)); |
247 | } | |
235 | 248 | else |
236 | { | |
249 | { | |
237 | 250 | fprintf(stderr, "unrtf: unknown name \"%s\" in line %d of \"%s\"\n", name, file->line_nr, file->name); |
238 | 251 | return 1; |
239 | 252 | } |
240 | 253 | } |
241 | else | |
242 | if ((*defs[i].variable = give_definition(file)) == NULL) | |
243 | return -1; | |
254 | else if ((*defs[i].variable = give_definition(file)) == NULL) | |
255 | { | |
256 | return -1; | |
257 | } | |
244 | 258 | |
245 | 259 | return 0; |
246 | 260 | } |
253 | 267 | *=======================================================================*/ |
254 | 268 | |
255 | 269 | OutputPersonality * |
256 | user_init (OutputPersonality *op, char *definitions_file_path) | |
257 | { | |
258 | my_FILE *f; | |
270 | user_init(OutputPersonality *op, char *definitions_file_path) | |
271 | { | |
272 | my_FILE *f = NULL; | |
259 | 273 | char name_buffer[BUFFER_SIZE]; |
274 | int err = 1; | |
260 | 275 | |
261 | 276 | if (op == NULL) |
277 | { | |
262 | 278 | op = op_create(); |
279 | } | |
263 | 280 | |
264 | 281 | if ((f = my_fopen(definitions_file_path, "r")) == NULL) |
265 | 282 | { |
266 | 283 | perror(definitions_file_path); |
267 | return op; | |
268 | } | |
269 | ||
270 | while (fgets(name_buffer, BUFFER_SIZE - 1, f->file) != NULL | |
271 | && !feof(f->file) && !ferror(f->file)) | |
272 | { | |
273 | if (name_buffer[strlen(name_buffer) - 1] != '\n') | |
274 | leave_line(f->file); | |
284 | goto out; | |
285 | } | |
286 | ||
287 | while (fgets(name_buffer, BUFFER_SIZE - 1, f->file) != NULL | |
288 | && !feof(f->file) && !ferror(f->file)) | |
289 | { | |
290 | int ll = strlen(name_buffer); | |
291 | if (ll <= 0 || name_buffer[ll - 1] != '\n') | |
292 | { | |
293 | /* Something is very wrong. There is no reason to continue | |
294 | parsing a bad config file. Bail out */ | |
295 | fprintf(stderr, "%s: bad line at %d\n", definitions_file_path, | |
296 | f->line_nr); | |
297 | goto out; | |
298 | } | |
275 | 299 | |
276 | 300 | f->line_nr++; |
277 | 301 | |
278 | 302 | if (name_buffer[0] != '#' && name_buffer[0] != '\n') |
279 | 303 | { |
280 | name_buffer[strlen(name_buffer) - 1] = '\0'; | |
304 | name_buffer[ll - 1] = '\0'; | |
281 | 305 | |
282 | 306 | if (match_name(name_buffer, op, f) == -1) |
283 | 307 | { |
284 | my_fclose(f); | |
285 | free(f); | |
286 | return NULL; | |
308 | goto out; | |
287 | 309 | } |
288 | 310 | } |
289 | 311 | } |
290 | 312 | |
291 | my_fclose(f); | |
292 | free(f); | |
293 | ||
294 | return op; | |
295 | } | |
296 | ||
313 | err = 0; | |
314 | out: | |
315 | if (f) { | |
316 | my_fclose(f); | |
317 | free(f); | |
318 | } | |
319 | ||
320 | return err ? NULL : op; | |
321 | } | |
322 |
112 | 112 | DEFS_ARRAY_ENTRY(shadow_end, op),\ |
113 | 113 | DEFS_ARRAY_ENTRY(outline_begin, op),\ |
114 | 114 | DEFS_ARRAY_ENTRY(outline_end, op),\ |
115 | DEFS_ARRAY_ENTRY(all_caps_begin, op),\ | |
116 | DEFS_ARRAY_ENTRY(all_caps_end, op),\ | |
115 | 117 | DEFS_ARRAY_ENTRY(small_caps_begin, op),\ |
116 | 118 | DEFS_ARRAY_ENTRY(small_caps_end, op),\ |
117 | 119 | DEFS_ARRAY_ENTRY(pointlist_begin, op),\ |
157 | 159 | #ifndef _USER |
158 | 160 | |
159 | 161 | |
160 | extern OutputPersonality* user_init(OutputPersonality *, char *tags_file_path); | |
162 | extern OutputPersonality *user_init(OutputPersonality *, char *tags_file_path); | |
161 | 163 | |
162 | 164 | |
163 | 165 | #define _USER |
26 | 26 | * Purpose: Utility functions. |
27 | 27 | *---------------------------------------------------------------------- |
28 | 28 | * Changes: |
29 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
29 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
30 | 30 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
31 | 31 | * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3 |
32 | 32 | * 09 Nov 08, arkadiusz.firus@gmail.com: added leave_line |
62 | 62 | |
63 | 63 | /* Convert a two-char hexadecimal expression to an integer */ |
64 | 64 | int |
65 | h2toi (const char *s) { | |
65 | h2toi(const char *s) | |
66 | { | |
66 | 67 | int tmp; |
67 | 68 | int ch; |
68 | 69 | tmp = tolower(*s++); |
69 | if (tmp>'9') tmp-=('a'-10); | |
70 | else tmp-='0'; | |
71 | ch=16*tmp; | |
70 | if (tmp > '9') | |
71 | { | |
72 | tmp -= ('a' - 10); | |
73 | } | |
74 | else | |
75 | { | |
76 | tmp -= '0'; | |
77 | } | |
78 | ch = 16 * tmp; | |
72 | 79 | tmp = tolower(*s++); |
73 | if (tmp>'9') tmp-=('a'-10); | |
74 | else tmp-='0'; | |
75 | ch+=tmp; | |
80 | if (tmp > '9') | |
81 | { | |
82 | tmp -= ('a' - 10); | |
83 | } | |
84 | else | |
85 | { | |
86 | tmp -= '0'; | |
87 | } | |
88 | ch += tmp; | |
76 | 89 | return ch; |
77 | 90 | } |
78 | 91 | |
84 | 97 | *=======================================================================*/ |
85 | 98 | |
86 | 99 | void |
87 | leave_line (FILE *f) | |
100 | leave_line(FILE *f) | |
88 | 101 | { |
89 | 102 | int c; |
90 | 103 | |
91 | 104 | do |
92 | 105 | { |
93 | 106 | c = fgetc(f); |
94 | } while (c != '\n' && c != EOF); | |
107 | } | |
108 | while (c != '\n' && c != EOF); | |
95 | 109 | |
96 | 110 | return; |
97 | 111 | } |
103 | 117 | * Returns: String. |
104 | 118 | *=======================================================================*/ |
105 | 119 | char * |
106 | concatenate (const char *s1, const char *s2) | |
120 | concatenate(const char *s1, const char *s2) | |
107 | 121 | { |
108 | 122 | char *result; |
109 | 123 | |
110 | 124 | if ((result = my_malloc((strlen(s1) + strlen(s2) + 1) * sizeof(char))) == 0) |
111 | return 0; | |
125 | { | |
126 | return 0; | |
127 | } | |
112 | 128 | strcpy(result, s1); |
113 | 129 | strcat(result, s2); |
114 | 130 | |
125 | 141 | /* |
126 | 142 | * Note: This is designed for programs that use contiguous blocks of |
127 | 143 | * increasing size. The problem when using a simple realloc is that a lot of |
128 | * memory is lost to fragmentation if many fixed size reallocations are | |
144 | * memory is lost to fragmentation if many fixed size reallocations are | |
129 | 145 | * performed. |
130 | * This routine doubles the memory space every time it is called, | |
131 | * Algorithm: | |
146 | * This routine doubles the memory space every time it is called, | |
147 | * Algorithm: | |
132 | 148 | * - 1st call (cp = 0), allocate min *sz |
133 | 149 | * - next calls double current size |
134 | 150 | * - Until current size is maxinc * sz, then increment by maxinc*sz everytime |
136 | 152 | void * |
137 | 153 | allocmem |
138 | 154 | ( |
139 | void *cp, /* The array to grow. may be NULL */ | |
140 | int sz, /* Unit size in bytes */ | |
141 | int *np, /* Pointer to current allocation number */ | |
142 | int min, /* Number to allocate the first time */ | |
143 | int maxinc /* Maximum increment */ | |
155 | void *cp, /* The array to grow. may be NULL */ | |
156 | int sz, /* Unit size in bytes */ | |
157 | int *np, /* Pointer to current allocation number */ | |
158 | int min, /* Number to allocate the first time */ | |
159 | int maxinc /* Maximum increment */ | |
144 | 160 | ) |
145 | 161 | { |
146 | int inc; | |
162 | int inc; | |
147 | 163 | |
148 | if (cp == NULL) { | |
149 | cp = malloc(min * sz); | |
150 | if (cp) | |
151 | *np = min; | |
152 | else | |
153 | *np = 0; | |
154 | return(cp); | |
155 | } | |
156 | if (*np > maxinc) | |
157 | inc = maxinc; | |
158 | else | |
159 | inc = *np; | |
160 | cp = realloc(cp, (*np + inc) * sz); | |
161 | if (cp) | |
162 | *np += inc; | |
163 | return cp; | |
164 | if (cp == NULL) | |
165 | { | |
166 | cp = malloc(min * sz); | |
167 | if (cp) | |
168 | { | |
169 | *np = min; | |
170 | } | |
171 | else | |
172 | { | |
173 | *np = 0; | |
174 | } | |
175 | return (cp); | |
176 | } | |
177 | if (*np > maxinc) | |
178 | { | |
179 | inc = maxinc; | |
180 | } | |
181 | else | |
182 | { | |
183 | inc = *np; | |
184 | } | |
185 | cp = realloc(cp, (*np + inc) * sz); | |
186 | if (cp) | |
187 | { | |
188 | *np += inc; | |
189 | } | |
190 | return cp; | |
164 | 191 | } |
38 | 38 | #include <stdio.h> |
39 | 39 | #endif |
40 | 40 | |
41 | extern int h2toi (const char *); | |
41 | extern int h2toi(const char *); | |
42 | 42 | |
43 | void leave_line (FILE *f); | |
44 | extern char *concatenate (const char *, const char *); | |
43 | void leave_line(FILE *f); | |
44 | extern char *concatenate(const char *, const char *); | |
45 | 45 | |
46 | 46 | /* Help managing a growing contiguous array */ |
47 | 47 | extern void * |
48 | 48 | allocmem |
49 | 49 | ( |
50 | void *cp, /* The array to grow. Can be NULL */ | |
51 | int sz, /* Unit size in bytes */ | |
52 | int *np, /* Pointer to current allocation number (units) */ | |
53 | int min, /* Number of units to allocate the first time */ | |
54 | int maxinc /* Maximum increment in units (maxinc*sz bytes) */ | |
50 | void *cp, /* The array to grow. Can be NULL */ | |
51 | int sz, /* Unit size in bytes */ | |
52 | int *np, /* Pointer to current allocation number (units) */ | |
53 | int min, /* Number of units to allocate the first time */ | |
54 | int maxinc /* Maximum increment in units (maxinc*sz bytes) */ | |
55 | 55 | ); |
56 | 56 | |
57 | 57 | #endif /* _UTIL_H_INCLUDED_ */ |
42 | 42 | * 21 Apr 01, tuorfa@yahoo.com: fix for words getting lost after \par |
43 | 43 | * 24 Jul 01, tuorfa@yahoo.com: moved conversion code to convert.c |
44 | 44 | * 22 Sep 01, tuorfa@yahoo.com: moved word_dump to here from parse.c |
45 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
45 | * 22 Sep 01, tuorfa@yahoo.com: added function-level comment blocks | |
46 | 46 | * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith |
47 | 47 | * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3 |
48 | 48 | *--------------------------------------------------------------------*/ |
77 | 77 | |
78 | 78 | |
79 | 79 | /* For word_dump */ |
80 | static int indent_level=0; | |
80 | static int indent_level = 0; | |
81 | 81 | |
82 | 82 | |
83 | 83 | /*======================================================================== |
89 | 89 | *=======================================================================*/ |
90 | 90 | |
91 | 91 | const char * |
92 | word_string (Word *w) { | |
92 | word_string(Word *w) | |
93 | { | |
93 | 94 | CHECK_PARAM_NOT_NULL(w); |
94 | 95 | return w->str; |
95 | 96 | } |
103 | 104 | * Returns: Word*. |
104 | 105 | *=======================================================================*/ |
105 | 106 | |
106 | Word * | |
107 | word_new (char *str) { | |
108 | Word * w; | |
107 | Word * | |
108 | word_new(char *str) | |
109 | { | |
110 | Word *w; | |
109 | 111 | |
110 | 112 | w = (Word *) my_malloc(sizeof(Word)); |
111 | 113 | if (!w) |
112 | error_handler ("out of memory"); | |
113 | memset ((void*) w, 0, sizeof(Word)); | |
114 | if (!w) error_handler ("cannot allocate a Word"); | |
115 | ||
116 | if (str) w->str = hash_store (str); | |
114 | { | |
115 | error_handler("out of memory"); | |
116 | } | |
117 | memset((void *) w, 0, sizeof(Word)); | |
118 | if (!w) | |
119 | { | |
120 | error_handler("cannot allocate a Word"); | |
121 | } | |
122 | ||
123 | if (str) | |
124 | { | |
125 | w->str = hash_store(str); | |
126 | } | |
117 | 127 | |
118 | 128 | return w; |
119 | 129 | } |
126 | 136 | * Returns: None. |
127 | 137 | *=======================================================================*/ |
128 | 138 | |
129 | void word_free (Word *w) { | |
139 | void word_free(Word *w) | |
140 | { | |
130 | 141 | Word *prev; |
131 | 142 | Word *w2; |
132 | 143 | |
133 | 144 | CHECK_PARAM_NOT_NULL(w); |
134 | 145 | |
135 | while (w) { | |
146 | while (w) | |
147 | { | |
136 | 148 | w2 = w->child; |
137 | 149 | if (w2) |
150 | { | |
138 | 151 | word_free(w2); |
152 | } | |
139 | 153 | |
140 | 154 | prev = w; |
141 | 155 | w = w->next; |
142 | my_free((char*) prev); | |
156 | my_free((char *) prev); | |
143 | 157 | } |
144 | 158 | } |
145 | 159 | |
155 | 169 | *=======================================================================*/ |
156 | 170 | |
157 | 171 | static void |
158 | print_indentation (int level) | |
172 | print_indentation(int level) | |
159 | 173 | { |
160 | 174 | int i; |
161 | 175 | |
162 | if (level) { | |
163 | for (i=0;i<level;i+=2) | |
164 | printf (". "); | |
165 | } else { | |
166 | printf ("\n-----------------------------------------------------------------------\n\n"); | |
176 | if (level) | |
177 | { | |
178 | for (i = 0; i < level; i += 2) | |
179 | { | |
180 | printf(". "); | |
181 | } | |
182 | } | |
183 | else | |
184 | { | |
185 | printf("\n-----------------------------------------------------------------------\n\n"); | |
167 | 186 | } |
168 | 187 | } |
169 | 188 | |
178 | 197 | *=======================================================================*/ |
179 | 198 | |
180 | 199 | void |
181 | word_dump (Word *w) | |
200 | word_dump(Word *w) | |
182 | 201 | { |
183 | 202 | const char *s; |
184 | 203 | |
185 | 204 | CHECK_PARAM_NOT_NULL(w); |
186 | 205 | |
187 | printf ("\n"); | |
206 | printf("\n"); | |
188 | 207 | indent_level += 2; |
189 | print_indentation (indent_level); | |
190 | ||
191 | while (w) { | |
192 | s = word_string (w); | |
193 | if (s) { | |
194 | printf ("\"%s\" ", s); | |
195 | } else { | |
196 | if (w->child) { | |
197 | word_dump (w->child); | |
198 | printf ("\n"); | |
199 | print_indentation (indent_level); | |
208 | print_indentation(indent_level); | |
209 | ||
210 | while (w) | |
211 | { | |
212 | s = word_string(w); | |
213 | if (s) | |
214 | { | |
215 | printf("\"%s\" ", s); | |
216 | } | |
217 | else | |
218 | { | |
219 | if (w->child) | |
220 | { | |
221 | word_dump(w->child); | |
222 | printf("\n"); | |
223 | print_indentation(indent_level); | |
200 | 224 | } |
201 | 225 | else |
202 | warning_handler ("Word object has no string and no children"); | |
226 | { | |
227 | warning_handler("Word object has no string and no children"); | |
228 | } | |
203 | 229 | } |
204 | 230 | w = w->next; |
205 | 231 | } |
209 | 235 | |
210 | 236 | /*======================================================================== |
211 | 237 | * Name: optimize_word |
212 | * Purpose: Function tries to optimize Word. | |
238 | * Purpose: Function tries to optimize group by eliminating redundant commands | |
239 | * consecutively setting same attribute to same value. | |
213 | 240 | * Args: Word to optimize. |
214 | 241 | * Returns: Optimized word. |
215 | 242 | *=======================================================================*/ |
222 | 249 | Tag tags_to_opt[] = OPT_ARRAY; |
223 | 250 | Word *root = w, *w2 = 0; |
224 | 251 | |
225 | if (depth > MAX_GROUP_DEPTH) { | |
252 | if (depth > MAX_GROUP_DEPTH) | |
253 | { | |
226 | 254 | /* Have to be reasonable at some point */ |
227 | warning_handler ("Max group depth reached"); | |
255 | warning_handler("Max group depth reached"); | |
228 | 256 | return w; |
229 | } | |
257 | } | |
230 | 258 | for (; w != NULL; w = w->next) |
231 | 259 | { |
232 | 260 | |
238 | 266 | { |
239 | 267 | len = strlen(tags_to_opt[i].name); |
240 | 268 | if (!strncmp(tags_to_opt[i].name, s, len) && (isdigit(s[len]) || s[len] == '-')) |
269 | { | |
241 | 270 | break; |
271 | } | |
242 | 272 | } |
243 | else | |
244 | if (!strcmp(tags_to_opt[i].name, s)) | |
245 | break; | |
273 | else if (!strcmp(tags_to_opt[i].name, s)) | |
274 | { | |
275 | break; | |
276 | } | |
246 | 277 | } |
247 | 278 | |
248 | 279 | if (tags_to_opt[i].name[0] != '\0') |
256 | 287 | w = w2; |
257 | 288 | } |
258 | 289 | else |
290 | { | |
259 | 291 | c = add_to_collection(c, i, s); |
292 | } | |
260 | 293 | } |
261 | 294 | } |
262 | 295 | |
263 | 296 | if (w->child != NULL) |
264 | w->child = optimize_word(w->child, depth+1); | |
297 | { | |
298 | w->child = optimize_word(w->child, depth + 1); | |
299 | } | |
265 | 300 | |
266 | 301 | w2 = w; |
267 | 302 | } |
35 | 35 | * 25 Sep 11, jf@dockes.org: reposition top #ifndef |
36 | 36 | *--------------------------------------------------------------------*/ |
37 | 37 | |
38 | typedef struct _w { | |
38 | typedef struct _w | |
39 | { | |
39 | 40 | const char *str; |
40 | struct _w * next; | |
41 | struct _w * child; | |
41 | struct _w *next; | |
42 | struct _w *child; | |
42 | 43 | } Word; |
43 | 44 | |
44 | extern Word* word_new (char*); | |
45 | extern void word_free (Word*); | |
46 | extern Word* word_read (FILE*); | |
47 | extern const char* word_string (Word*); | |
48 | extern void word_dump (Word*); | |
49 | extern void word_print_html (Word*); | |
45 | extern Word *word_new(char *); | |
46 | extern void word_free(Word *); | |
47 | extern Word *word_read(FILE *); | |
48 | extern const char *word_string(Word *); | |
49 | extern void word_dump(Word *); | |
50 | extern void word_print_html(Word *); | |
50 | 51 | |
51 | 52 | #ifndef MAX_GROUP_DEPTH |
52 | 53 | #define MAX_GROUP_DEPTH 1000 |
53 | 54 | #endif |
54 | ||
55 | extern Word* optimize_word(Word*, int depth); | |
56 | 55 | |
57 | typedef struct _t { | |
56 | extern Word *optimize_word(Word *, int depth); | |
57 | ||
58 | typedef struct _t | |
59 | { | |
58 | 60 | char *name; |
59 | 61 | int has_param; |
60 | 62 | } Tag; |
0 | # Makefile.in generated by automake 1.13.4 from Makefile.am. | |
0 | # Makefile.in generated by automake 1.15.1 from Makefile.am. | |
1 | 1 | # @configure_input@ |
2 | 2 | |
3 | # Copyright (C) 1994-2013 Free Software Foundation, Inc. | |
3 | # Copyright (C) 1994-2017 Free Software Foundation, Inc. | |
4 | 4 | |
5 | 5 | # This Makefile.in is free software; the Free Software Foundation |
6 | 6 | # gives unlimited permission to copy and/or distribute it, |
13 | 13 | |
14 | 14 | @SET_MAKE@ |
15 | 15 | VPATH = @srcdir@ |
16 | am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' | |
16 | am__is_gnu_make = { \ | |
17 | if test -z '$(MAKELEVEL)'; then \ | |
18 | false; \ | |
19 | elif test -n '$(MAKE_HOST)'; then \ | |
20 | true; \ | |
21 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ | |
22 | true; \ | |
23 | else \ | |
24 | false; \ | |
25 | fi; \ | |
26 | } | |
17 | 27 | am__make_running_with_option = \ |
18 | 28 | case $${target_option-} in \ |
19 | 29 | ?) ;; \ |
77 | 87 | build_triplet = @build@ |
78 | 88 | host_triplet = @host@ |
79 | 89 | subdir = tests |
80 | DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ | |
81 | $(top_srcdir)/config/test-driver | |
82 | 90 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
83 | 91 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac |
84 | 92 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
85 | 93 | $(ACLOCAL_M4) |
94 | DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) | |
86 | 95 | mkinstalldirs = $(install_sh) -d |
87 | 96 | CONFIG_HEADER = $(top_builddir)/config.h |
88 | 97 | CONFIG_CLEAN_FILES = |
311 | 320 | TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/config/test-driver |
312 | 321 | TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ |
313 | 322 | $(TEST_LOG_FLAGS) |
323 | am__DIST_COMMON = $(srcdir)/Makefile.in \ | |
324 | $(top_srcdir)/config/test-driver | |
314 | 325 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
315 | 326 | ACLOCAL = @ACLOCAL@ |
316 | 327 | AMTAR = @AMTAR@ |
566 | 577 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ |
567 | 578 | $(am__cd) $(top_srcdir) && \ |
568 | 579 | $(AUTOMAKE) --gnu tests/Makefile |
569 | .PRECIOUS: Makefile | |
570 | 580 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
571 | 581 | @case '$?' in \ |
572 | 582 | *config.status*) \ |
621 | 631 | if test -n "$$am__remaking_logs"; then \ |
622 | 632 | echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ |
623 | 633 | "recursion detected" >&2; \ |
624 | else \ | |
634 | elif test -n "$$redo_logs"; then \ | |
625 | 635 | am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ |
626 | 636 | fi; \ |
627 | 637 | if $(am__make_dryrun); then :; else \ |
920 | 930 | mostlyclean-generic pdf pdf-am ps ps-am recheck tags-am \ |
921 | 931 | uninstall uninstall-am |
922 | 932 | |
933 | .PRECIOUS: Makefile | |
934 | ||
923 | 935 | |
924 | 936 | # ensure that the distributed scripts are executable before distribution. |
925 | 937 | # Could be necessary if checking out CVS. |
36 | 36 | \par }{\impr\cf8\insrsid4857473 This text is formatted with engrave. |
37 | 37 | \par }{\scaps\insrsid4857473 This text is formatted with small caps. |
38 | 38 | \par }{\caps\insrsid4857473 This text is formatted with all caps. |
39 | \par }{\insrsid4857473 BUT THIS TEXT IS WRITTEN SIMPLE WITH THE CAPS LOCK TUNRED ON. | |
39 | \par }{\insrsid4857473 BUT THIS TEXT IS WRITTEN SIMPLE WITH THE CAPS LOCK TURNED ON. | |
40 | 40 | \par }{\v\insrsid4857473 This text is formatted as hidden.}{\insrsid4857473 |
41 | 41 | \par |
42 | 42 | \par Character spacing is 100% |