Codebase list unrtf / upstream/0.21.10-clean
New upstream version 0.21.10-clean Willi Mann 5 years ago
47 changed file(s) with 5959 addition(s) and 2956 deletion(s). Raw diff Collapse all Expand all
283283 - Support EndNote reference citations in convert.c
284284 - Improved handling of some tables
285285 - Fixed --text processing broken in 0.21.8 - outputs/text.conf
286 0.21.10:
287 - added gentoo automake-fix and iconv-detection patches
+170
-172
INSTALL less more
00 Installation Instructions
11 *************************
22
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.
55
66 Copying and distribution of this file, with or without modification,
77 are permitted in any medium without royalty provided the copyright
1111 Basic Installation
1212 ==================
1313
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
1717 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
1919 below. The lack of an optional feature in a given package is not
2020 necessarily a bug. More recommendations for GNU packages can be found
2121 in *note Makefile Conventions: (standards)Makefile Conventions.
2222
23 The `configure' shell script attempts to guess correct values for
23 The 'configure' shell script attempts to guess correct values for
2424 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
2828 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.
3736
3837 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
4140 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
4342 may remove or edit it.
4443
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'.
4948
5049 The simplest way to compile this package is:
5150
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
5655 some messages telling which features it is checking for.
5756
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
6160 the package, generally using the just-built uninstalled binaries.
6261
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
6463 documentation. When installing into a prefix owned by root, it is
6564 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
6766 privileges.
6867
69 5. Optionally, type `make installcheck' to repeat any self-tests, but
68 5. Optionally, type 'make installcheck' to repeat any self-tests, but
7069 this time using the binaries in their final installed location.
7170 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
7372 root privileges, verifies that the installation completed
7473 correctly.
7574
7675 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
8180 for the package's developers. If you use it, you may have to get
8281 all sorts of other programs in order to regenerate files that came
8382 with the distribution.
8483
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
8685 files again. In practice, not all packages have tested that
8786 uninstallation works correctly, even though it is required by the
8887 GNU Coding Standards.
8988
90 8. Some packages, particularly those that use Automake, provide `make
89 8. Some packages, particularly those that use Automake, provide 'make
9190 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.
9392 This target is generally not run by end users.
9493
9594 Compilers and Options
9695 =====================
9796
9897 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'
10099 for details on some of the pertinent environment variables.
101100
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:
105104
106105 ./configure CC=c99 CFLAGS=-g LIBS=-lposix
107106
112111
113112 You can compile the package for more than one kind of computer at the
114113 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
116115 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
122121 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
124123 reconfiguring for another architecture.
125124
126125 On MacOS X 10.5 and later systems, you can create libraries and
127126 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
130129 this:
131130
132131 ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
135134
136135 This is not guaranteed to produce working output in all cases, you
137136 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.
139138
140139 Installation Names
141140 ==================
142141
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
147146 absolute file name.
148147
149148 You can specify separate installation prefixes for
150149 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
152151 PREFIX as the prefix for installing programs and libraries.
153152 Documentation and other data files still use the regular prefix.
154153
155154 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
161160 specifications that were not explicitly provided.
162161
163162 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
165164 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
167166 having to reconfigure or recompile.
168167
169168 The first method involves providing an override variable for each
170 affected directory. For example, `make install
169 affected directory. For example, 'make install
171170 prefix=/alternate/directory' will choose an alternate location for all
172171 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
186185 does not work on platforms that have drive letters. On the other hand,
187186 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.
190189
191190 Optional Features
192191 =================
193192
194193 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
203202 package recognizes.
204203
205 For packages that use the X Window System, `configure' can usually
204 For packages that use the X Window System, 'configure' can usually
206205 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.
209208
210209 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
212211 --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
214213 --disable-silent-rules' sets the default to verbose, which can be
215 overridden with `make V=0'.
214 overridden with 'make V=0'.
216215
217216 Particular systems
218217 ==================
219218
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
222221 order to use an ANSI C compiler:
223222
224223 ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
225224
226225 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
227226
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.
232230
233231 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
237235
238236 ./configure CC="cc"
239237
241239
242240 ./configure CC="cc -nodtk"
243241
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
245243 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:
251249
252250 ./configure --prefix=/boot/common
253251
254252 Specifying the System Type
255253 ==========================
256254
257 There may be some features `configure' cannot figure out
255 There may be some features 'configure' cannot figure out
258256 automatically, but needs to determine by the type of machine the package
259257 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
261259 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:
264262
265263 CPU-COMPANY-SYSTEM
266264
269267 OS
270268 KERNEL-OS
271269
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
274272 need to know the machine type.
275273
276274 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
278276 produce code for.
279277
280278 If you want to _use_ a cross compiler, that generates code for a
281279 platform different from the build platform, you should specify the
282280 "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'.
284282
285283 Sharing Defaults
286284 ================
287285
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.
295293
296294 Defining Variables
297295 ==================
298296
299297 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
301299 configure again during the build, and the customized values of these
302300 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:
304302
305303 ./configure CC=/usr/local2/bin/gcc
306304
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
308306 overridden in the site shell script).
309307
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:
313311
314312 CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
315313
316 `configure' Invocation
314 'configure' Invocation
317315 ======================
318316
319 `configure' recognizes the following options to control how it
317 'configure' recognizes the following options to control how it
320318 operates.
321319
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'
328326 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'
336334 script, and exit.
337335
338 `--cache-file=FILE'
336 '--cache-file=FILE'
339337 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
341339 disable caching.
342340
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'
350348 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
352350 messages will still be shown).
353351
354 `--srcdir=DIR'
352 '--srcdir=DIR'
355353 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'
365363 Run the configure checks, but stop before creating any output
366364 files.
367365
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.
11 # @configure_input@
22
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2017 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
1515
1616 # this is the main Makefile.am
1717 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 }
1929 am__make_running_with_option = \
2030 case $${target_option-} in \
2131 ?) ;; \
7989 build_triplet = @build@
8090 host_triplet = @host@
8191 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
9092 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
9193 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
9294 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
9395 $(ACLOCAL_M4)
96 DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
97 $(am__configure_deps) $(am__DIST_COMMON)
9498 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
9599 configure.lineno config.status.lineno
96100 mkinstalldirs = $(install_sh) -d
154158 CTAGS = ctags
155159 CSCOPE = cscope
156160 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
157168 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
158169 distdir = $(PACKAGE)-$(VERSION)
159170 top_distdir = $(distdir)
318329 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
319330 $(am__cd) $(top_srcdir) && \
320331 $(AUTOMAKE) --gnu Makefile
321 .PRECIOUS: Makefile
322332 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
323333 @case '$?' in \
324334 *config.status*) \
339349 $(am__aclocal_m4_deps):
340350
341351 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
344354
345355 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
346356 @rm -f stamp-h1
524534 ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
525535 || chmod -R a+r "$(distdir)"
526536 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
528538 $(am__post_remove_distdir)
529539
530540 dist-bzip2: distdir
540550 $(am__post_remove_distdir)
541551
542552 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
543556 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
544557 $(am__post_remove_distdir)
545558
546559 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
548564 $(am__post_remove_distdir)
549565
550566 dist-zip: distdir
562578 distcheck: dist
563579 case '$(DIST_ARCHIVES)' in \
564580 *.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) ;;\
566582 *.tar.bz2*) \
567583 bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
568584 *.tar.lz*) \
572588 *.tar.Z*) \
573589 uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
574590 *.shar.gz*) \
575 GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
591 eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
576592 *.zip*) \
577593 unzip $(distdir).zip ;;\
578594 esac
579595 chmod -R a-w $(distdir)
580596 chmod u+w $(distdir)
581 mkdir $(distdir)/_build $(distdir)/_inst
597 mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
582598 chmod a-w $(distdir)
583599 test -d $(distdir)/_build || exit 0; \
584600 dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
585601 && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
586602 && am__cwd=`pwd` \
587 && $(am__cd) $(distdir)/_build \
588 && ../configure --srcdir=.. --prefix="$$dc_install_base" \
603 && $(am__cd) $(distdir)/_build/sub \
604 && ../../configure \
589605 $(AM_DISTCHECK_CONFIGURE_FLAGS) \
590606 $(DISTCHECK_CONFIGURE_FLAGS) \
607 --srcdir=../.. --prefix="$$dc_install_base" \
591608 && $(MAKE) $(AM_MAKEFLAGS) \
592609 && $(MAKE) $(AM_MAKEFLAGS) dvi \
593610 && $(MAKE) $(AM_MAKEFLAGS) check \
762779 mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
763780 uninstall-am
764781
782 .PRECIOUS: Makefile
783
765784
766785 # Tell versions [3.59,3.63) of GNU make to not export all variables.
767786 # 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
02 0.21.9 (2 Jan 2015):
13 Correct text conversion failure introduced in 0.21.8
24 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*)&in;
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.
33
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
1919 If you have problems, you may need to regenerate the build system entirely.
2020 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
2121
22 # Copyright (C) 2002-2013 Free Software Foundation, Inc.
22 # Copyright (C) 2002-2017 Free Software Foundation, Inc.
2323 #
2424 # This file is free software; the Free Software Foundation
2525 # gives unlimited permission to copy and/or distribute it,
3131 # generated from the m4 files accompanying Automake X.Y.
3232 # (This private macro should not be called outside this file.)
3333 AC_DEFUN([AM_AUTOMAKE_VERSION],
34 [am__api_version='1.13'
34 [am__api_version='1.15'
3535 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
3636 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], [],
3838 [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
3939 ])
4040
5050 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
5151 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
5252 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
53 [AM_AUTOMAKE_VERSION([1.13.4])dnl
53 [AM_AUTOMAKE_VERSION([1.15.1])dnl
5454 m4_ifndef([AC_AUTOCONF_VERSION],
5555 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
5656 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
5757
5858 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
5959
60 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
60 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
6161 #
6262 # This file is free software; the Free Software Foundation
6363 # gives unlimited permission to copy and/or distribute it,
102102 # configured tree to be moved without reconfiguration.
103103
104104 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`
109108 ])
110109
111110 # AM_CONDITIONAL -*- Autoconf -*-
112111
113 # Copyright (C) 1997-2013 Free Software Foundation, Inc.
112 # Copyright (C) 1997-2017 Free Software Foundation, Inc.
114113 #
115114 # This file is free software; the Free Software Foundation
116115 # gives unlimited permission to copy and/or distribute it,
141140 Usually this means the macro was only invoked conditionally.]])
142141 fi])])
143142
144 # Copyright (C) 1999-2013 Free Software Foundation, Inc.
143 # Copyright (C) 1999-2017 Free Software Foundation, Inc.
145144 #
146145 # This file is free software; the Free Software Foundation
147146 # gives unlimited permission to copy and/or distribute it,
332331
333332 # Generate code to set up dependency tracking. -*- Autoconf -*-
334333
335 # Copyright (C) 1999-2013 Free Software Foundation, Inc.
334 # Copyright (C) 1999-2017 Free Software Foundation, Inc.
336335 #
337336 # This file is free software; the Free Software Foundation
338337 # gives unlimited permission to copy and/or distribute it,
408407
409408 # Do all the work for Automake. -*- Autoconf -*-
410409
411 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
410 # Copyright (C) 1996-2017 Free Software Foundation, Inc.
412411 #
413412 # This file is free software; the Free Software Foundation
414413 # gives unlimited permission to copy and/or distribute it,
416415
417416 # This macro actually does too much. Some checks are only needed if
418417 # 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 ])
419424
420425 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
421426 # AM_INIT_AUTOMAKE([OPTIONS])
492497 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
493498 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
494499 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.
497502 AC_REQUIRE([AC_PROG_AWK])dnl
498503 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
499504 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
525530 AC_CONFIG_COMMANDS_PRE(dnl
526531 [m4_provide_if([_AM_COMPILER_EXEEXT],
527532 [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.
528578 ])
529579
530580 dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
532582 dnl mangled by Autoconf and run in a shell conditional statement.
533583 m4_define([_AC_COMPILER_EXEEXT],
534584 m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
535
536585
537586 # When config.status generates a header, we must update the stamp-h file.
538587 # This file resides in the same directory as the config header
555604 done
556605 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
557606
558 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
607 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
559608 #
560609 # This file is free software; the Free Software Foundation
561610 # gives unlimited permission to copy and/or distribute it,
566615 # Define $install_sh.
567616 AC_DEFUN([AM_PROG_INSTALL_SH],
568617 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
569 if test x"${install_sh}" != xset; then
618 if test x"${install_sh+set}" != xset; then
570619 case $am_aux_dir in
571620 *\ * | *\ *)
572621 install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
576625 fi
577626 AC_SUBST([install_sh])])
578627
579 # Copyright (C) 2003-2013 Free Software Foundation, Inc.
628 # Copyright (C) 2003-2017 Free Software Foundation, Inc.
580629 #
581630 # This file is free software; the Free Software Foundation
582631 # gives unlimited permission to copy and/or distribute it,
598647 # Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
599648 # From Jim Meyering
600649
601 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
650 # Copyright (C) 1996-2017 Free Software Foundation, Inc.
602651 #
603652 # This file is free software; the Free Software Foundation
604653 # gives unlimited permission to copy and/or distribute it,
633682
634683 # Check to see how 'make' treats includes. -*- Autoconf -*-
635684
636 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
685 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
637686 #
638687 # This file is free software; the Free Software Foundation
639688 # gives unlimited permission to copy and/or distribute it,
683732
684733 # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
685734
686 # Copyright (C) 1997-2013 Free Software Foundation, Inc.
735 # Copyright (C) 1997-2017 Free Software Foundation, Inc.
687736 #
688737 # This file is free software; the Free Software Foundation
689738 # gives unlimited permission to copy and/or distribute it,
722771
723772 # Helper functions for option handling. -*- Autoconf -*-
724773
725 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
774 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
726775 #
727776 # This file is free software; the Free Software Foundation
728777 # gives unlimited permission to copy and/or distribute it,
751800 AC_DEFUN([_AM_IF_OPTION],
752801 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
753802
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
754867 # Check to make sure that the build environment is sane. -*- Autoconf -*-
755868
756 # Copyright (C) 1996-2013 Free Software Foundation, Inc.
869 # Copyright (C) 1996-2017 Free Software Foundation, Inc.
757870 #
758871 # This file is free software; the Free Software Foundation
759872 # gives unlimited permission to copy and/or distribute it,
834947 rm -f conftest.file
835948 ])
836949
837 # Copyright (C) 2009-2013 Free Software Foundation, Inc.
950 # Copyright (C) 2009-2017 Free Software Foundation, Inc.
838951 #
839952 # This file is free software; the Free Software Foundation
840953 # gives unlimited permission to copy and/or distribute it,
8941007 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
8951008 ])
8961009
897 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
1010 # Copyright (C) 2001-2017 Free Software Foundation, Inc.
8981011 #
8991012 # This file is free software; the Free Software Foundation
9001013 # gives unlimited permission to copy and/or distribute it,
9221035 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
9231036 AC_SUBST([INSTALL_STRIP_PROGRAM])])
9241037
925 # Copyright (C) 2006-2013 Free Software Foundation, Inc.
1038 # Copyright (C) 2006-2017 Free Software Foundation, Inc.
9261039 #
9271040 # This file is free software; the Free Software Foundation
9281041 # gives unlimited permission to copy and/or distribute it,
9411054
9421055 # Check how to create a tarball. -*- Autoconf -*-
9431056
944 # Copyright (C) 2004-2013 Free Software Foundation, Inc.
1057 # Copyright (C) 2004-2017 Free Software Foundation, Inc.
9451058 #
9461059 # This file is free software; the Free Software Foundation
9471060 # gives unlimited permission to copy and/or distribute it,
0 outputsdir = ${libdir}/${PACKAGE}
0 outputsdir = ${pkgdatadir}
11 dist_outputs_DATA = SYMBOL.charmap
00 #! /bin/sh
11 # 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.
33 #
44 # Report bugs to <bug-unrtf@gnu.org>.
55 #
579579 # Identity of this package.
580580 PACKAGE_NAME='unrtf'
581581 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'
584584 PACKAGE_BUGREPORT='bug-unrtf@gnu.org'
585585 PACKAGE_URL=''
586586
12771277 # Omit some internal or obsolete options to make the list less imposing.
12781278 # This message is too long to be a string in the A/UX 3.1 sh.
12791279 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.
12811281
12821282 Usage: $0 [OPTION]... [VAR=VALUE]...
12831283
13471347
13481348 if test -n "$ac_init_help"; then
13491349 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:";;
13511351 esac
13521352 cat <<\_ACEOF
13531353
14411441 test -n "$ac_init_help" && exit $ac_status
14421442 if $ac_init_version; then
14431443 cat <<\_ACEOF
1444 unrtf configure 0.21.9
1444 unrtf configure 0.21.10
14451445 generated by GNU Autoconf 2.69
14461446
14471447 Copyright (C) 2012 Free Software Foundation, Inc.
18101810 This file contains any messages produced by compilers while
18111811 running configure, to aid debugging if configure makes a mistake.
18121812
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
18141814 generated by GNU Autoconf 2.69. Invocation command line was
18151815
18161816 $ $0 $@
21932193
21942194 # Initialize automake
21952195
2196 am__api_version='1.13'
2196 am__api_version='1.15'
21972197
21982198 # Find a good install program. We prefer a C program (faster),
21992199 # so one script is as good as another. But avoid the broken or
23652365 ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
23662366 program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
23672367
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`
23702370
23712371 if test x"${MISSING+set}" != xset; then
23722372 case $am_aux_dir in
23852385 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
23862386 fi
23872387
2388 if test x"${install_sh}" != xset; then
2388 if test x"${install_sh+set}" != xset; then
23892389 case $am_aux_dir in
23902390 *\ * | *\ *)
23912391 install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
26792679
26802680 # Define the identity of the package.
26812681 PACKAGE='unrtf'
2682 VERSION='0.21.9'
2682 VERSION='0.21.10'
26832683
26842684
26852685 cat >>confdefs.h <<_ACEOF
27132713 # <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
27142714 mkdir_p='$(MKDIR_P)'
27152715
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.
27182718 # Always define AMTAR for backward compatibility. Yes, it's still used
27192719 # in the wild :-( We should find a proper way to deprecate it ...
27202720 AMTAR='$${TAR-tar}'
27292729
27302730
27312731
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
27322774
27332775
27342776 # AM_MAINTAINER_MODE is a controversial macro.
35553597 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
35563598 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
35573599 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
35583659 DEPDIR="${am__leading_dot}deps"
35593660
35603661 ac_config_commands="$ac_config_commands depfiles"
43264427 ;;
43274428 *-*-darwin*) LIBS="-liconv"
43284429 ;;
4430 *-*-solaris*) LIBS="-liconv"
4431 ;;
43294432 esac
43304433
43314434 ac_config_files="$ac_config_files Makefile doc/Makefile outputs/Makefile patches/Makefile src/Makefile tests/Makefile"
48644967 # report actual input values of CONFIG_FILES etc. instead of their
48654968 # values after options handling.
48664969 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
48684971 generated by GNU Autoconf 2.69. Invocation command line was
48694972
48704973 CONFIG_FILES = $CONFIG_FILES
49305033 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
49315034 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
49325035 ac_cs_version="\\
4933 unrtf config.status 0.21.9
5036 unrtf config.status 0.21.10
49345037 configured by $0, generated by GNU Autoconf 2.69,
49355038 with options \\"\$ac_cs_config\\"
49365039
11 # Process this file with autoconf to produce a configure script.
22
33 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])
55 AC_CONFIG_SRCDIR([src/attr.c])
66 AC_CONFIG_AUX_DIR([config])
77 AC_CONFIG_HEADER([config.h])
4545 *-*-cygwin*) AC_SUBST(LIBS, ["-liconv"]);;
4646 *aix*) AC_SUBST(LIBS, ["-liconv"]);;
4747 *-*-darwin*) AC_SUBST(LIBS, ["-liconv"]);;
48 *-*-solaris*) AC_SUBST(LIBS, ["-liconv"]);;
4849 esac
4950
5051 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.
11 # @configure_input@
22
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2017 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
1313
1414 @SET_MAKE@
1515 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 }
1727 am__make_running_with_option = \
1828 case $${target_option-} in \
1929 ?) ;; \
7787 build_triplet = @build@
7888 host_triplet = @host@
7989 subdir = doc
80 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
81 $(dist_man1_MANS)
8290 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
8391 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
8492 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
8593 $(ACLOCAL_M4)
94 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
8695 mkinstalldirs = $(install_sh) -d
8796 CONFIG_HEADER = $(top_builddir)/config.h
8897 CONFIG_CLEAN_FILES =
138147 NROFF = nroff
139148 MANS = $(dist_man1_MANS)
140149 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
150 am__DIST_COMMON = $(dist_man1_MANS) $(srcdir)/Makefile.in
141151 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
142152 ACLOCAL = @ACLOCAL@
143153 AMTAR = @AMTAR@
252262 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
253263 $(am__cd) $(top_srcdir) && \
254264 $(AUTOMAKE) --gnu doc/Makefile
255 .PRECIOUS: Makefile
256265 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
257266 @case '$?' in \
258267 *config.status*) \
467476 mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \
468477 uninstall-am uninstall-man uninstall-man1
469478
479 .PRECIOUS: Makefile
480
470481
471482 unrtf.1: unrtf.1.in Makefile
472483 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.
11 # @configure_input@
22
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2017 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
1414 @SET_MAKE@
1515
1616 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 }
1828 am__make_running_with_option = \
1929 case $${target_option-} in \
2030 ?) ;; \
7888 build_triplet = @build@
7989 host_triplet = @host@
8090 subdir = outputs
81 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
82 $(dist_outputs_DATA)
8391 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
8492 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
8593 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
8694 $(ACLOCAL_M4)
95 DIST_COMMON = $(srcdir)/Makefile.am $(dist_outputs_DATA) \
96 $(am__DIST_COMMON)
8797 mkinstalldirs = $(install_sh) -d
8898 CONFIG_HEADER = $(top_builddir)/config.h
8999 CONFIG_CLEAN_FILES =
137147 am__installdirs = "$(DESTDIR)$(outputsdir)"
138148 DATA = $(dist_outputs_DATA)
139149 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
150 am__DIST_COMMON = $(srcdir)/Makefile.in
140151 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
141152 ACLOCAL = @ACLOCAL@
142153 AMTAR = @AMTAR@
259270 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu outputs/Makefile'; \
260271 $(am__cd) $(top_srcdir) && \
261272 $(AUTOMAKE) --gnu outputs/Makefile
262 .PRECIOUS: Makefile
263273 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
264274 @case '$?' in \
265275 *config.status*) \
452462 mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \
453463 uninstall-am uninstall-dist_outputsDATA
454464
465 .PRECIOUS: Makefile
466
455467
456468 # Tell versions [3.59,3.63) of GNU make to not export all variables.
457469 # Otherwise a system limit (for SysV at least) may be exceeded.
177177 <s>
178178 dbl_strikethru_end
179179 </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>
180188 emboss_begin
181189 <span style="background:gray"><font color="black">
182190 emboss_end
758766 &hearts;
759767 9839
760768 &diams;
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 &forall;
776 61475
777 \#
778 61476
779 &exist;
780 61475
781 %
782 61478
783 &
784 61479
785 &ni;
786 61480
787 (
788 61481
789 )
790 61482
791 *
792 61483
793 +
794 61484
795 ,
796 61485
797 &mdash;
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 &lt;
828 61501
829 =
830 61502
831 &gt;
832 61503
833 ?
834 61504
835 &cong;
836 61505
837 &Alpha;
838 61506
839 &Beta;
840 61507
841 &Chi;
842 61508
843 &Delta;
844 61509
845 &Epsilon;
846 61510
847 &Phi;
848 61511
849 &Gamma;
850 61512
851 &Eta;
852 61513
853 &Iota;
854 61514
855 &phiv;
856 61515
857 &Kappa;
858 61516
859 &Lambda;
860 61517
861 &Mu;
862 61518
863 &Nu;
864 61519
865 &Omicron;
866 61520
867 &Pi;
868 61521
869 &Theta;
870 61522
871 &Rho;
872 61523
873 &Sigma;
874 61524
875 &Tau;
876 61525
877 &Upsilon;
878 61526
879 &sigmaf;
880 61527
881 &Omega;
882 61528
883 &Xi;
884 61529
885 &Psi;
886 61530
887 &Zeta;
888 61531
889 [
890 61532
891 &there4;
892 61533
893 ]
894 61534
895 &perp;
896 61535
897 _
898 61536
899 &oline;
900 61537
901 &alpha;
902 61538
903 &beta;
904 61539
905 &chi;
906 61540
907 &delta;
908 61541
909 &epsilon;
910 61542
911 &phi;
912 61543
913 &gamma;
914 61544
915 &eta;
916 61545
917 &tau;
918 61546
919 &phiv;
920 61547
921 &kappa;
922 61548
923 &lambda;
924 61549
925 &mu;
926 61550
927 &nu;
928 61551
929 &omicron;
930 61552
931 &pi;
932 61553
933 &theta;
934 61554
935 &rho;
936 61555
937 &sigma;
938 61556
939 &tau;
940 61557
941 &upsilon;
942 61558
943 &piv;
944 61559
945 &omega;
946 61560
947 &xi;
948 61561
949 &psi;
950 61562
951 &zeta;
952 61563
953 {
954 61564
955 |
956 61565
957 }
958 61566
959 &sim;
960 61600
961 &euro;
962 61601
963 &upsih;
964 61602
965 &prime;
966 61603
967 &le;
968 61604
969 &frasl;
970 61605
971 &infin;
972 61606
973 &fnof;
974 61607
975 &clubs;
976 61608
977 &diams;
978 61609
979 &hearts;
980 61610
981 &spades;
982 61611
983 &harr;
984 61612
985 &larr;
986 61613
987 &uarr;
988 61614
989 &rarr;
990 61615
991 &darr;
992 61616
993 &deg;
994 61617
995 &plusmn;
996 61618
997 &Prime;
998 61619
999 &ge;
1000 61620
1001 &times;
1002 61621
1003 &prop;
1004 61622
1005 &part;
1006 61623
1007 &bull;
1008 61624
1009 &divide;
1010 61625
1011 &ne;
1012 61626
1013 &equiv;
1014 61627
1015 &asymp;
1016 61628
1017 &hellip;
1018 # vertical bar
1019 61629
1020 |
1021 61630
1022 &mdash;
1023 61631
1024 &crarr;
1025 61632
1026 &alefsym;
1027 61633
1028 &image;
1029 61634
1030 &real;
1031 61635
1032 &weierp;
1033 61636
1034 &otimes;
1035 61637
1036 &oplus;
1037 61638
1038 &empty;
1039 61639
1040 &cap;
1041 61640
1042 &cup;
1043 61641
1044 &sup;
1045 61642
1046 &supe;
1047 61643
1048 &nsub;
1049 61644
1050 &sub;
1051 61645
1052 &sube;
1053 61646
1054 &isin;
1055 61647
1056 &notin;
1057 61648
1058 &ang;
1059 61649
1060 &nabla;
1061 61650
1062 &reg;
1063 61651
1064 &copy;
1065 61652
1066 &trade;
1067 61653
1068 &prod;
1069 61654
1070 &radic;
1071 61655
1072 &middot;
1073 61656
1074 &not;
1075 61657
1076 &and;
1077 61658
1078 &or;
1079 61659
1080 &hArr;
1081 61660
1082 &lArr;
1083 61661
1084 &uArr;
1085 61662
1086 &rArr;
1087 61663
1088 &dArr;
1089 61664
1090 &loz;
1091 61665
1092 &lang;
1093 61666
1094 &reg;
1095 61667
1096 &copy;
1097 61668
1098 &trade;
1099 61669
1100 &sum;
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 &lceil;
1110 #61674
1111 # large left square bracket middle
1112 61675
1113 # large left square bracket floor
1114 &lfloor;
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 &rang;
1127 61682
1128 # integral
1129 &int;
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 &rceil;
1145 #61690
1146 # large right square bracket middle
1147 61691
1148 # large right square bracket floor
1149 &rfloor;
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.
11 # @configure_input@
22
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2017 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
1616 # this simple Makefile.am just adds the patches to the distributed
1717 # tarball in the release.
1818 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 }
2030 am__make_running_with_option = \
2131 case $${target_option-} in \
2232 ?) ;; \
8090 build_triplet = @build@
8191 host_triplet = @host@
8292 subdir = patches
83 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
8493 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
8594 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
8695 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
8796 $(ACLOCAL_M4)
97 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
8898 mkinstalldirs = $(install_sh) -d
8999 CONFIG_HEADER = $(top_builddir)/config.h
90100 CONFIG_CLEAN_FILES =
109119 *) (install-info --version) >/dev/null 2>&1;; \
110120 esac
111121 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
122 am__DIST_COMMON = $(srcdir)/Makefile.in
112123 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
113124 ACLOCAL = @ACLOCAL@
114125 AMTAR = @AMTAR@
222233 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu patches/Makefile'; \
223234 $(am__cd) $(top_srcdir) && \
224235 $(AUTOMAKE) --gnu patches/Makefile
225 .PRECIOUS: Makefile
226236 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
227237 @case '$?' in \
228238 *config.status*) \
390400 maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
391401 pdf-am ps ps-am tags-am uninstall uninstall-am
392402
403 .PRECIOUS: Makefile
404
393405
394406 # Tell versions [3.59,3.63) of GNU make to not export all variables.
395407 # 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.
11 # @configure_input@
22
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2017 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
1717 # It all works automagically.
1818
1919 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 }
2131 am__make_running_with_option = \
2232 case $${target_option-} in \
2333 ?) ;; \
8292 host_triplet = @host@
8393 bin_PROGRAMS = unrtf$(EXEEXT)
8494 subdir = src
85 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
86 $(top_srcdir)/config/depcomp
8795 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
8896 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
8997 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
9098 $(ACLOCAL_M4)
99 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
91100 mkinstalldirs = $(install_sh) -d
92101 CONFIG_HEADER = $(top_builddir)/config.h
93102 CONFIG_CLEAN_FILES =
155164 done | $(am__uniquify_input)`
156165 ETAGS = etags
157166 CTAGS = ctags
167 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/config/depcomp
158168 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
159169 ACLOCAL = @ACLOCAL@
160170 AMTAR = @AMTAR@
285295 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
286296 $(am__cd) $(top_srcdir) && \
287297 $(AUTOMAKE) --gnu src/Makefile
288 .PRECIOUS: Makefile
289298 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
290299 @case '$?' in \
291300 *config.status*) \
376385 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
377386 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
378387 @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 $@ $<
380389
381390 .c.obj:
382391 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
383392 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
384393 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
385394 @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) '$<'`
387396
388397 ID: $(am__tagged_files)
389398 $(am__define_uniq_tagged_files); mkid -fID $$unique
589598 ps ps-am tags tags-am uninstall uninstall-am \
590599 uninstall-binPROGRAMS
591600
601 .PRECIOUS: Makefile
602
592603
593604 # Tell versions [3.59,3.63) of GNU make to not export all variables.
594605 # Otherwise a system limit (for SysV at least) may be exceeded.
7474 extern int simulate_smallcaps;
7575
7676
77 #define MAX_ATTRS (10000)
77 #define MAX_ATTRS 100
7878
7979
8080 /* For each RTF text block (the text within braces) we must keep
8484 * from parent blocks, all new AttrStacks do the same from
8585 * their parent AttrStack.
8686 */
87 typedef struct _stack {
87 typedef struct _stack
88 {
8889 unsigned char attr_stack[MAX_ATTRS];
89 char *attr_stack_params[MAX_ATTRS];
90 char *attr_stack_params[MAX_ATTRS];
9091 int tos;
91 struct _stack *next;
92 struct _stack *prev;
9293 } AttrStack;
9394
9495 /*@null@*/ static AttrStack *stack_of_stacks = NULL;
9596 /*@null@*/ static AttrStack *stack_of_stacks_top = NULL;
9697
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 }
98178
99179
100180 /*========================================================================
104184 * Returns: None.
105185 *=======================================================================*/
106186
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 };
116202 break;
117203
118204 /* Various underlines, they all resolve to HTML's <u> */
119205 case ATTR_THICK_UL:
120206 case ATTR_WAVE_UL:
121207 case ATTR_DASH_UL:
122 case ATTR_DOT_UL:
208 case ATTR_DOT_UL:
123209 case ATTR_DOT_DASH_UL:
124210 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:
147245 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 };
181309 break;
182310
183311 case ATTR_CAPS:
184312 if (op->simulate_all_caps)
313 {
185314 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:
189327 if (op->simulate_small_caps)
328 {
190329 simulate_smallcaps = TRUE;
191 else {
330 }
331 else
332 {
192333 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 };
194338 }
195339 break;
196340 }
204348 * Returns: None.
205349 *=======================================================================*/
206350
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 };
217366 break;
218367
219368 /* Various underlines, they all resolve to HTML's </u> */
220369 case ATTR_THICK_UL:
221370 case ATTR_WAVE_UL:
222371 case ATTR_DASH_UL:
223 case ATTR_DOT_UL:
372 case ATTR_DOT_UL:
224373 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:
247408 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 };
281472 break;
282473
283474 case ATTR_CAPS:
284475 if (op->simulate_all_caps)
476 {
285477 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:
289490 if (op->simulate_small_caps)
491 {
290492 simulate_smallcaps = FALSE;
291 else {
493 }
494 else
495 {
292496 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 };
294501 }
295502 break;
296503 }
305512 * Returns: None.
306513 *=======================================================================*/
307514
308 void
309 attr_push(int attr, char* param)
515 void attr_push(int attr, char *param)
310516 {
311517 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 {
313525 warning_handler("No stack to push attribute onto");
314526 return;
315527 }
316528
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 {
318537 fprintf(stderr, "Too many attributes!\n");
319538 return;
320539 }
326545
327546 ++stack->tos;
328547 stack->attr_stack[stack->tos] = attr;
329 if (param)
548 if (param)
549 {
330550 stack->attr_stack_params[stack->tos] = my_strdup(param);
551 }
331552 else
553 {
332554 stack->attr_stack_params[stack->tos] = NULL;
555 }
333556
334557 attr_express_begin(attr, param);
335558 }
336559
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 }
337580
338581 /*========================================================================
339582 * Name: attr_get_param
342585 * Returns: string.
343586 *=======================================================================*/
344587
345 char *
346 attr_get_param(int attr)
588 char *
589 attr_get_param(int attr)
347590 {
348591 int i;
349592 AttrStack *stack = stack_of_stacks_top;
350 if (!stack) {
351 if (attr != ATTR_ENCODING) {
593 if (!stack)
594 {
595 if (attr != ATTR_ENCODING)
596 {
352597 /*
353598 * attr_get_param(ATTR_ENCODING) is always called
354599 * called once without a stack being available.
358603 return NULL;
359604 }
360605
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];
372608 }
373609 return NULL;
374610 }
381617 * Returns: None.
382618 *=======================================================================*/
383619
384 void
385 attrstack_copy_all (AttrStack *src, AttrStack *dest)
620 void
621 attrstack_copy_all(AttrStack *src, AttrStack *dest)
386622 {
387623 int i;
388 int total;
389624
390625 CHECK_PARAM_NOT_NULL(src);
391626 CHECK_PARAM_NOT_NULL(dest);
392627
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];
401633 if (param)
402 dest->attr_stack_params[i] = my_strdup (param);
634 {
635 dest->attr_stack_params[i] = my_strdup(param);
636 }
403637 else
638 {
404639 dest->attr_stack_params[i] = NULL;
640 }
405641 }
406642
407643 dest->tos = src->tos;
414650 * Args: Stack whose contents should be unexpressed.
415651 * Returns: None.
416652 * 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>
418654 * which clear attribute info within that block.
419655 *=======================================================================*/
420656
421 void
422 attrstack_unexpress_all (AttrStack *stack)
657 void
658 attrstack_unexpress_all(AttrStack *stack)
423659 {
424660 int i;
425661
426662 CHECK_PARAM_NOT_NULL(stack);
427663
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]);
436667 }
437668 }
438669
444675 * Args: None.
445676 * Returns: None.
446677 *=======================================================================*/
447 void
448 attrstack_push ()
678 void
679 attrstack_push()
449680 {
450681 AttrStack *new_stack;
451682
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 {
456695 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;
460708 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
468713 * Purpose: Removes and undoes the effect of the top attribute of
469714 * the current AttrStack.
470715 * Args: The top attribute's number, for verification.
471716 * Returns: Success/fail flag.
472717 *=======================================================================*/
473718
474 int
475 attr_pop (int attr)
719 int
720 attr_pop(int attr)
476721 {
477722 AttrStack *stack = stack_of_stacks_top;
478723
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");
481727 return FALSE;
482728 }
483729
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);
494733 return TRUE;
495734 }
496735 else
736 {
497737 return FALSE;
738 }
498739 }
499740
500741
507748 * Returns: Attribute number.
508749 *=======================================================================*/
509750
510 int
511 attr_read() {
751 int
752 attr_read()
753 {
512754 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");
515758 return FALSE;
516759 }
517760
518 if(stack->tos>=0)
761 if (stack->tos >= 0)
519762 {
520763 int attr = stack->attr_stack [stack->tos];
521764 return attr;
522765 }
523766 else
767 {
524768 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.
531776 * Args: None.
532777 * Returns: None.
533778 *=======================================================================*/
534779
535 void
536 attr_drop_all ()
780 void
781 attr_drop_all()
537782 {
538783 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");
541787 return;
542788 }
543789
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 }
548797 stack->tos--;
549798 }
550799 }
558807 * Returns: None.
559808 *=======================================================================*/
560809
561 void
562 attrstack_drop ()
810 void
811 attrstack_drop()
563812 {
564813 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");
568817 return;
569818 }
570819
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 {
587824 stack_of_stacks = NULL;
588825 }
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 }
591835 }
592836
593837 /*========================================================================
594838 * Name: attr_pop_all
595 * Purpose: Routine to undo all attributes heretofore applied,
839 * Purpose: Routine to undo all attributes heretofore applied,
596840 * also reversing the order in which they were applied.
597841 * Args: None.
598842 * Returns: None.
599843 *=======================================================================*/
600844
601 void
602 attr_pop_all()
845 void
846 attr_pop_all()
603847 {
604848 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");
607852 return;
608853 }
609854
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 }
619860
620861 /*========================================================================
621862 * Name: attrstack_express_all
623864 * Args: None.
624865 * Returns: None.
625866 * 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>
627868 * which clear attribute info within that block.
628869 *=======================================================================*/
629870
630 void
631 attrstack_express_all() {
871 void
872 attrstack_express_all()
873 {
632874 AttrStack *stack = stack_of_stacks_top;
633875 int i;
634876
635 if (!stack) {
636 warning_handler ("no stack to pop from");
877 if (!stack)
878 {
879 warning_handler("no stack to pop from");
637880 return;
638881 }
639882
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]);
674886 }
675887 }
676888
701913
702914 for (; nr > 0; nr--)
703915 {
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] == '\\'))))
705917 {
706 if (string[i] != '\\' || string[i+1] != '%')
918 if (string[i] != '\\' || string[i + 1] != '%')
919 {
707920 printf("%c", string[i]);
921 }
708922 i++;
709923 }
710924
719933
720934 while (string[i] != '\0')
721935 {
722 if (string[i] != '\\' || (string[i] == '\\' && string[i+1] != '%'))
936 if (string[i] != '\\' || (string[i] == '\\' && string[i + 1] != '%'))
723937 {
724 if (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i-1] == '\\')))
938 if (string[i] != '%' || (string[i] == '%' && (i != 0 && string[i - 1] == '\\')))
939 {
725940 printf("%c", string[i]);
941 }
726942 else
943 {
727944 ret_code = -1;
945 }
728946 }
729947 i++;
730948 }
745963 assemble_string(char *string, int nr)
746964 {
747965
748 char *s, tmp[12];/* Number of characters that can be in int type (including '\0') - AF */
966 char *s, tmp[20];
749967 int i = 0, j = 0;
750968
751969 if (string == NULL)
970 {
752971 return NULL;
753 else {
972 }
973 else
974 {
754975 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];
758981 j++;
759982 }
760983 i++;
761984 }
762985
763 if (string[i] != '\0') {
764 sprintf(tmp, "%d", nr);
986 if (string[i] != '\0')
987 {
988 snprintf(tmp, 20, "%d", nr);
765989 strcpy(&s[j], tmp);
766990 j = j + strlen(tmp);
767991 }
768992
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];
7731000 j++;
7741001 }
775 else {
776 /* More than one char % occured */
1002 else
1003 {
1004 /* More than one char % occured */
7771005 }
7781006 }
7791007 i++;
8071035 }
8081036 else
8091037 {
810 do {
1038 do
1039 {
8111040 if (c->nr == nr)
8121041 {
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 */
8161045 c->text = text;
8171046
8181047 return col;
8191048 }
8201049
821 if (c->next == NULL)
822 break;
1050 if (c->next == NULL)
1051 {
1052 break;
1053 }
8231054 c = c->next;
824 } while (1);
1055 }
1056 while (1);
8251057
8261058 c->next = (Collection *)my_malloc(sizeof(Collection));
8271059 c->next->nr = nr;
8451077 while (c != NULL)
8461078 {
8471079 if (c->nr == nr)
1080 {
8481081 return c->text;
1082 }
8491083
8501084 c = c->next;
8511085 }
8571091 * Name: free_collection
8581092 * Purpose: Release memory used by collection.
8591093 * Args: Needless collection.
860 * Returns:
1094 * Returns:
8611095 *=======================================================================*/
8621096
8631097 void
8721106 c = c2;
8731107 }
8741108 }
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, &param);
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, &param);
932 attr_push(attr, param);
933 }
934
935 return TRUE;
936 }
937 #endif /* SUPPORT_UNNESTED */
3838 * 07 Oct 11, jf@dockes.org: removed unused protocols, added _ATTR_H_INCLUDED_
3939 *--------------------------------------------------------------------*/
4040
41 enum {
42 ATTR_NONE=0,
41 enum
42 {
43 ATTR_NONE = 0,
4344 ATTR_BOLD, ATTR_ITALIC,
4445
45 ATTR_UNDERLINE, ATTR_DOUBLE_UL, ATTR_WORD_UL,
46 ATTR_UNDERLINE, ATTR_DOUBLE_UL, ATTR_WORD_UL,
4647
47 ATTR_THICK_UL, ATTR_WAVE_UL,
48 ATTR_THICK_UL, ATTR_WAVE_UL,
4849
4950 ATTR_DOT_UL, ATTR_DASH_UL, ATTR_DOT_DASH_UL, ATTR_2DOT_DASH_UL,
5051
5556 ATTR_SMALLCAPS,
5657
5758 ATTR_SHADOW,
58 ATTR_OUTLINE,
59 ATTR_EMBOSS,
60 ATTR_ENGRAVE,
59 ATTR_OUTLINE,
60 ATTR_EMBOSS,
61 ATTR_ENGRAVE,
6162
62 ATTR_SUPER, ATTR_SUB,
63 ATTR_STRIKE,
64 ATTR_DBL_STRIKE,
63 ATTR_SUPER, ATTR_SUB,
64 ATTR_STRIKE,
65 ATTR_DBL_STRIKE,
6566
6667 ATTR_EXPAND,
67 ATTR_ENCODING,
68 ATTR_ENCODING,
6869 /* ATTR_CONDENSE */
6970 };
7071
7980 const char *get_from_collection(Collection *c, int nr);
8081 void free_collection(Collection *c);
8182
82 extern void attr_push(int attr, char* param);
83 extern void attr_push(int attr, char *param);
8384
8485 extern void attrstack_push();
8586 extern void attrstack_drop();
9091
9192 extern int attr_read();
9293
93 extern void attr_drop_all ();
94 extern void attr_drop_all();
9495
9596 extern void attr_pop_all();
9697
9798 extern void attr_pop_dump();
9899
99 char * attr_get_param(int attr);
100 char *attr_get_param(int attr);
100101
101102 int safe_printf(int nr, char *string, ...);
102103 char *assemble_string(char *string, int nr);
4747 * 08 Sep 01, tuorfa@yahoo.com: added use of UnRTF
4848 * 11 Sep 01, tuorfa@yahoo.com: added support for JPEG and PNG pictures
4949 * 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
5151 * 23 Sep 01, tuorfa@yahoo.com: fixed translation of \'XX expressions
5252 * 08 Oct 03, daved@physiol.usyd.edu.au: more special character code
5353 * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
102102
103103 #ifdef HAVE_STRING_H
104104 /* For strcasestr() */
105 #define __USE_GNU
105 #define __USE_GNU
106106 #include <string.h>
107107 #endif
108108
119119 #include "convert.h"
120120 #include "attr.h"
121121
122 typedef struct {
122 typedef struct
123 {
123124 char *name;
124 int (*func)(Word*, int, char, int);
125 int (*func)(Word *, int, char, int);
125126 char *debug_print;
126127 } HashItem;
127128 static HashItem *find_command(const char *cmdpp, int *hasparamp, int *paramp);
128129
129130 extern int nopict_mode;
131 extern int quiet;
130132
131133 /*
132134 #define BINARY_ATTRS
138140 */
139141 static int coming_pars_that_are_tabular = 0;
140142 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;
145147 static void check_for_table();
146148
147149
148 /* Previously in word_print_core function
150 /* Previously in word_print_core function
149151 */
150 static int total_chars_this_line=0; /* for simulating \tab */
152 static int total_chars_this_line = 0; /* for simulating \tab */
151153
152154
153155 /* Paragraph alignment (kludge)
154156 */
155 enum {
156 ALIGN_LEFT=0,
157 enum
158 {
159 ALIGN_LEFT = 0,
157160 ALIGN_RIGHT,
158161 ALIGN_CENTER,
159162 ALIGN_JUSTIFY
161164
162165
163166
164 /* This value is set by attr_push and attr_pop
167 /* This value is set by attr_push and attr_pop
165168 */
166169 int simulate_smallcaps;
167170 int simulate_allcaps;
168171
169172
170173 /* Most pictures must be written to files. */
171 enum {
172 PICT_UNKNOWN=0,
174 enum
175 {
176 PICT_UNKNOWN = 0,
173177 PICT_WM,
174178 PICT_MAC,
175179 PICT_PM,
179183 PICT_PNG,
180184 PICT_EMF,
181185 };
182 static int within_picture=FALSE;
186 static int within_picture = FALSE;
183187 static int within_picture_depth;
184 static int picture_file_number=1;
188 static int picture_file_number = 1;
185189 static char picture_path[255];
186190 static int picture_width;
187191 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;
190194 static int picture_wmetafile_type;
191195 static char *picture_wmetafile_type_str;
192196
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;
197201
198202
199203 static const char *hyperlink_base = NULL;
201205
202206 void starting_body();
203207 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;
207211
208212
209213 /*========================================================================
214218 *=======================================================================*/
215219
216220 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 ");
221230 printf("UnRTF, version ");
222231 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;
226238 }
227239
228240
234246 *=======================================================================*/
235247
236248 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 }
243263 }
244264 within_header = FALSE;
245265 have_printed_body = TRUE;
252272 /*-------------------------------------------------------------------*/
253273
254274
255 static char *month_strings[12]= {
275 static char *month_strings[12] =
276 {
256277 #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"
259280 #endif
260281 #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"
263284 #endif
264285 #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"
267288 #endif
268289 #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"
271292 #endif
272293 #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"
275296 #endif
276297 #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"
279300 #endif
280301 };
281302
288309 * Returns: None.
289310 *=======================================================================*/
290311
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;
295316 CHECK_PARAM_NOT_NULL(w);
296317
297318 while (w)
298319 {
299 const char *s = word_string (w);
320 const char *s = word_string(w);
300321 if (!s)
322 {
301323 return;
302 if (*s == '\\') {
324 }
325 if (*s == '\\')
326 {
303327 ++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]);
306331 }
307 else if (!strncmp (s, "mo", 2) && isdigit(s[2]))
332 else if (!strncmp(s, "mo", 2) && isdigit(s[2]))
308333 {
309 month= atoi (&s[2]);
310 if(month > 12)
334 month = atoi(&s[2]);
335 if (month > 12)
311336 {
312337 warning_handler("bogus month");
313338 return;
314339 }
315340 }
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]);
318344 }
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]);
321348 }
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]);
324352 }
325353 }
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 {
332362 printf("%02d:%02d ", hour, minute);
333363 }
334364 }
337367
338368 /*-------------------------------------------------------------------*/
339369
340 typedef struct {
370 typedef struct
371 {
341372 int num;
342373 char *name;
343 char *encoding;
374 char *encoding;
344375 } FontEntry;
345376
346377 static char *default_encoding = "CP1252";
347378 /* current_encoding not NULL to be safe. "" is detected to avoid
348379 free() on 1st call */
349 static char *current_encoding = "";
380 static char *current_encoding = "";
350381 /* Encoding expected by op_translate_buffer. Until we find a way to specify
351382 transparent UTF-8 passthrough */
352383 static char *output_encoding = "UTF-32BE";
354385 static int had_ansicpg;
355386 #define MAX_FONTS (8192)
356387 static FontEntry font_table[MAX_FONTS];
357 static int total_fonts=0;
388 static int total_fonts = 0;
358389
359390 static void flush_iconv_input();
360391 static void accumulate_iconv_input(int ch);
361392
362 static void
393 static void
363394 set_current_encoding(char *encoding)
364395 {
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
371404 maybeopeniconv()
372405 {
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 }
381417 }
382418
383419
388424 * Returns: Font name.
389425 *=======================================================================*/
390426 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;
407449 }
408450
409451 // Extract name and parameter from command. RTF spec says name is max
412454 // Returns 0 for error, 1 if ok no parm, 0 else
413455 static int controlToNameParm(const char *s, char *name, int maxlen, int *parm)
414456 {
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;
433484 }
434485
435486 // translate \fcharset parameter value to code page. See MS RTF doc
436487 static const int fcharsetparmtocp(int parm)
437488 {
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 }
471554 }
472555
473556 // 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;
530808 }
531809
532810 /*========================================================================
537815 *=======================================================================*/
538816
539817 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 }
651902 }
652903
653904
659910 *=======================================================================*/
660911
661912 void
662 process_index_entry (Word *w)
913 process_index_entry(Word *w)
663914 {
664915 Word *w2;
665916
666917 CHECK_PARAM_NOT_NULL(w);
667918
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 }
676936 }
677937 }
678 w=w->next;
938 w = w->next;
679939 }
680940 }
681941
688948 *=======================================================================*/
689949
690950 void
691 process_toc_entry (Word *w, int include_page_num)
951 process_toc_entry(Word *w, int include_page_num)
692952 {
693953 Word *w2;
694954
695955 CHECK_PARAM_NOT_NULL(w);
696956
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 }
708977 }
709978 }
710 w=w->next;
979 w = w->next;
711980 }
712981 }
713982
720989 *=======================================================================*/
721990
722991 void
723 process_info_group (Word *w)
992 process_info_group(Word *w)
724993 {
725994 Word *child;
726995
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)
7331005 {
7341006 child = w->child;
735 if (child) {
1007 if (child)
1008 {
7361009 Word *w2;
7371010 const char *s;
7381011
7391012 s = word_string(child);
740 if(!s)
1013 if (!s)
1014 {
7411015 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 {
7491030 const char *s2 = word_string(w2);
750 if (s2 && s2[0] != '\\')
1031 if (s2 && s2[0] != '\\')
7511032 {
752 print_with_special_exprs (s2);
1033 print_with_special_exprs(s2);
7531034 }
7541035 else if (s2 && s2[1] == '\'' && s2[2] && s2[3])
7551036 {
756 int ch = h2toi (&s2[2]);
1037 int ch = h2toi(&s2[2]);
7571038 accumulate_iconv_input(ch);
7581039 }
7591040
7601041 w2 = w2->next;
7611042 }
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 }
7641048 }
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 {
7691058 const char *s2 = word_string(w2);
770 if (s2 && s2[0] != '\\')
1059 if (s2 && s2[0] != '\\')
1060 {
7711061 printf("%s,", s2);
1062 }
7721063 w2 = w2->next;
7731064 }
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 }
7751069 }
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 {
7801079 const char *s2 = word_string(w2);
781 if (s2 && s2[0] != '\\')
1080 if (s2 && s2[0] != '\\')
1081 {
7821082 printf("%s", s2);
1083 }
7831084 w2 = w2->next;
7841085 }
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 }
7861090 }
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 }
7891097 printf("comments: ");
790 w2=child->next;
791 while (w2) {
1098 w2 = child->next;
1099 while (w2)
1100 {
7921101 const char *s2 = word_string(w2);
793 if (s2 && s2[0] != '\\')
1102 if (s2 && s2[0] != '\\')
1103 {
7941104 printf("%s", s2);
1105 }
7951106 w2 = w2->next;
7961107 }
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 }
7981112 }
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 }
8031124 }
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 }
8081136 }
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 }
8131148 }
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 }
8161155 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 }
8191164 }
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 }
8221171 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 }
8251180 }
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 }
8281187 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 }
8311196 }
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 }
8341203 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 }
8371212 }
8381213 }
8391214
8401215 /* Irregardless of whether we're in inline mode,
8411216 * we want to process the following.
8421217 */
843 if (!strcmp("\\hlinkbase", s)) {
1218 if (!strcmp("\\hlinkbase", s))
1219 {
8441220 const char *linkstr = NULL;
8451221
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 }
8471226 printf("hyperlink base: ");
848 if (child->next) {
1227 if (child->next)
1228 {
8491229 Word *nextword = child->next;
8501230
851 if (nextword)
852 linkstr=word_string (nextword);
1231 if (nextword)
1232 {
1233 linkstr = word_string(nextword);
1234 }
8531235 }
8541236
8551237 if (linkstr)
1238 {
8561239 printf("%s", linkstr);
1240 }
8571241 else
1242 {
8581243 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 }
8601249
8611250 /* Store the pointer, it will remain good. */
862 hyperlink_base = linkstr;
1251 hyperlink_base = linkstr;
8631252 }
864 }
1253 }
8651254 w = w->next;
8661255 }
8671256 }
8701259
8711260 /* RTF color table colors are RGB */
8721261
873 typedef struct {
874 unsigned char r,g,b;
1262 typedef struct
1263 {
1264 unsigned char r, g, b;
8751265 } Color;
8761266
8771267 #define MAX_COLORS (1024)
8781268 static Color color_table[MAX_COLORS];
879 static int total_colors=0;
1269 static int total_colors = 0;
8801270
8811271
8821272 /*========================================================================
8871277 *=======================================================================*/
8881278
8891279 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;
8931283
8941284 CHECK_PARAM_NOT_NULL(w);
8951285
8961286 /* 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
8981288 * will not be used, so here I set it to black.
8991289 */
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 {
9061297 break;
907
908 if (!strncmp("\\red",s,4)) {
1298 }
1299
1300 if (!strncmp("\\red", s, 4))
1301 {
9091302 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 {
9131310 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 {
9171318 b = atoi(&s[5]);
918 while(b>255) b>>=8;
1319 while (b > 255)
1320 {
1321 b >>= 8;
1322 }
9191323 }
9201324 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;
9341348 }
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 }
9451364 }
9461365 }
9471366
9521371 * Returns: Flag, true only if rest of Words on line should be ignored.
9531372 *=======================================================================*/
9541373
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)
9571376 {
9581377 char str[40];
9591378
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");
9631382 }
9641383 else
9651384 {
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);
9711390 }
9721391 return FALSE;
9731392 }
9811400 * Returns: Flag, true only if rest of Words on line should be ignored.
9821401 *=======================================================================*/
9831402
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)
9861405 {
9871406 char str[40];
9881407
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");
9921411 }
9931412 else
9941413 {
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);
10001419 }
10011420 return FALSE;
10021421 }
10081427 * Args: Word, paragraph align info, and numeric param if any.
10091428 * Returns: Flag, true only if rest of Words on line should be ignored.
10101429 *=======================================================================*/
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 {
10131433 char str[20];
10141434
1015 if (!has_param) return FALSE;
1435 if (!has_param)
1436 {
1437 return FALSE;
1438 }
10161439
10171440 /* Note, fs20 means 10pt */
10181441 points /= 2;
10191442
1020 sprintf(str,"%d",points);
1021 attr_push(ATTR_FONTSIZE,str);
1443 snprintf(str, 20, "%d", points);
1444 attr_push(ATTR_FONTSIZE, str);
10221445
10231446 return FALSE;
10241447 }
10331456 * Returns: Flag, true only if rest of Words on line should be ignored.
10341457 *=======================================================================*/
10351458
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 {
10381462 Word *child;
10391463
10401464 CHECK_PARAM_NOT_NULL(w);
1041 maybeopeniconv();
1042 while(w) {
1465 maybeopeniconv();
1466 while (w)
1467 {
10431468 child = w->child;
1044 if (child) {
1469 if (child)
1470 {
10451471 Word *w2;
10461472 const char *s;
10471473
10481474 s = word_string(child);
10491475 if (!s)
1476 {
10501477 return TRUE;
1478 }
10511479
10521480 #if 1 /* daved experimenting with fldrslt */
1053 if(!strcmp("\\fldrslt", s))
1481 if (!strcmp("\\fldrslt", s))
1482 {
10541483 return FALSE;
1484 }
10551485 #endif
10561486
10571487
10581488 if (!strcmp("\\*", s))
10591489 {
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)
10651492 {
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;
11321587 }
1133 w2 = w2->next;
1134 }
1135
1588
11361589 }
11371590 }
1138 w=w->next;
1591 w = w->next;
11391592 }
11401593 return TRUE;
11411594 }
11461599 * Args: Word, paragraph align info, and numeric param if any.
11471600 * Returns: Flag, true only if rest of Words on line should be ignored.
11481601 *=======================================================================*/
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;
11861653 }
11871654
11881655 /*========================================================================
11911658 * Args: Word, paragraph align info, and numeric param if any.
11921659 * Returns: Flag, true only if rest of Words on line should be ignored.
11931660 *=======================================================================*/
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;
12001669 }
12011670
12021671 /*========================================================================
12061675 * Returns: Flag, true only if rest of Words on line should be ignored.
12071676 *=======================================================================*/
12081677
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)
12111680 {
12121681 char str[40];
12131682
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");
12171686 }
12181687 else
12191688 {
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);
12251694 }
12261695 return FALSE;
12271696 }
12351704 * Returns: Flag, true only if rest of Words on line should be ignored.
12361705 *=======================================================================*/
12371706
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)
12401709 {
12411710 /* 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
12441713 * assume the font is fixed width and that
12451714 * the tabstops are 8 characters apart.
12461715 */
1247 int need= 8-(total_chars_this_line%8);
1716 int need = 8 - (total_chars_this_line % 8);
12481717 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 }
12511724 need--;
12521725 }
12531726 printf("\n");
12621735 * Returns: Flag, true only if rest of Words on line should be ignored.
12631736 *=======================================================================*/
12641737
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 {
12671741 attr_pop_all();
12681742 return FALSE;
12691743 }
12751749 * Args: Word, paragraph align info, and numeric param if any.
12761750 * Returns: Flag, true only if rest of Words on line should be ignored.
12771751 *=======================================================================*/
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);
12811756 return FALSE;
12821757 }
12831758
12891764 * Args: Word, paragraph align info, and numeric param if any.
12901765 * Returns: Flag, true only if rest of Words on line should be ignored.
12911766 *=======================================================================*/
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);
12951771 return FALSE;
12961772 }
12971773
13031779 * Returns: Flag, true only if rest of Words on line should be ignored.
13041780 *=======================================================================*/
13051781
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);
13091786 return FALSE;
13101787 }
13111788
13171794 * Returns: Flag, true only if rest of Words on line should be ignored.
13181795 *=======================================================================*/
13191796
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);
13231801 return FALSE;
13241802 }
13251803
13311809 * Returns: Flag, true only if rest of Words on line should be ignored.
13321810 *=======================================================================*/
13331811
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);
13371816 return FALSE;
13381817 }
13391818
13441823 * Returns: Flag, true only if rest of Words on line should be ignored.
13451824 *=======================================================================*/
13461825
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);
13501830 return FALSE;
13511831 }
13521832
13571837 * Returns: Flag, true only if rest of Words on line should be ignored.
13581838 *=======================================================================*/
13591839
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);
13631844 return FALSE;
13641845 }
13651846
13701851 * Returns: Flag, true only if rest of Words on line should be ignored.
13711852 *=======================================================================*/
13721853
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 {
13791863 attr_pop(ATTR_EXPAND);
1380 else
1864 }
1865 else
1866 {
13811867 attr_push(ATTR_EXPAND, str);
1868 }
13821869 }
13831870 return FALSE;
13841871 }
13911878 * Returns: Flag, true only if rest of Words on line should be ignored.
13921879 *=======================================================================*/
13931880
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];
13971885 if (has_param && !param)
13981886 #ifdef SUPPORT_UNNESTED
13991887 attr_find_pop(ATTR_EMBOSS);
14021890 #endif
14031891 else
14041892 {
1405 sprintf(str, "%d", param);
1893 snprintf(str, 20, "%d", param);
14061894 attr_push(ATTR_EMBOSS, str);
14071895 }
14081896 return FALSE;
14161904 * Returns: Flag, true only if rest of Words on line should be ignored.
14171905 *=======================================================================*/
14181906
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 {
14231913 attr_pop(ATTR_ENGRAVE);
1914 }
14241915 else
14251916 {
1426 sprintf(str, "%d", param);
1917 snprintf(str, 20, "%d", param);
14271918 attr_push(ATTR_ENGRAVE, str);
14281919 }
14291920 return FALSE;
14361927 * Returns: Flag, true only if rest of Words on line should be ignored.
14371928 *=======================================================================*/
14381929
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 {
14411933 if (has_param && !param)
1934 {
14421935 attr_pop(ATTR_CAPS);
1443 else
1444 attr_push(ATTR_CAPS,NULL);
1936 }
1937 else
1938 {
1939 attr_push(ATTR_CAPS, NULL);
1940 }
14451941 return FALSE;
14461942 }
14471943
14521948 * Args: Word, paragraph align info, and numeric param if any.
14531949 * Returns: Flag, true only if rest of Words on line should be ignored.
14541950 *=======================================================================*/
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 {
14571954 if (has_param && !param)
1955 {
14581956 attr_pop(ATTR_SMALLCAPS);
1459 else
1460 attr_push(ATTR_SMALLCAPS,NULL);
1957 }
1958 else
1959 {
1960 attr_push(ATTR_SMALLCAPS, NULL);
1961 }
14611962 return FALSE;
14621963 }
14631964
14681969 * Args: Word, paragraph align info, and numeric param if any.
14691970 * Returns: Flag, true only if rest of Words on line should be ignored.
14701971 *=======================================================================*/
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 }
14751981 ++total_chars_this_line; /* \tab */
14761982 }
14771983 return FALSE;
14831989 * Args: Word, paragraph align info, and numeric param if any.
14841990 * Returns: Flag, true only if rest of Words on line should be ignored.
14851991 *=======================================================================*/
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 }
14902001 ++total_chars_this_line; /* \tab */
14912002 }
14922003 return FALSE;
15002011 * Returns: Flag, true only if rest of Words on line should be ignored.
15012012 *=======================================================================*/
15022013
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 }
15072023 ++total_chars_this_line; /* \tab */
15082024 }
15092025 return FALSE;
15162032 * Args: Word, paragraph align info, and numeric param if any.
15172033 * Returns: Flag, true only if rest of Words on line should be ignored.
15182034 *=======================================================================*/
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 }
15232044 ++total_chars_this_line; /* \tab */
15242045 }
15252046 return FALSE;
15332054 * Returns: Flag, true only if rest of Words on line should be ignored.
15342055 *=======================================================================*/
15352056
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 }
15402066 ++total_chars_this_line; /* \tab */
15412067 }
15422068 return FALSE;
15502076 * Returns: Flag, true only if rest of Words on line should be ignored.
15512077 *=======================================================================*/
15522078
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 }
15572088 ++total_chars_this_line; /* \tab */
15582089 }
15592090 return FALSE;
15672098 * Returns: Flag, true only if rest of Words on line should be ignored.
15682099 *=======================================================================*/
15692100
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 }
15742110 ++total_chars_this_line; /* \tab */
15752111 }
15762112 return FALSE;
15832119 * Args: Word, paragraph align info, and numeric param if any.
15842120 * Returns: Flag, true only if rest of Words on line should be ignored.
15852121 *=======================================================================*/
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 }
15902131 ++total_chars_this_line; /* \tab */
15912132 }
15922133 return FALSE;
16002141 * Returns: Flag, true only if rest of Words on line should be ignored.
16012142 *=======================================================================*/
16022143
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 }
16072153 ++total_chars_this_line; /* \tab */
16082154 }
16092155 return FALSE;
16172163 * Returns: Flag, true only if rest of Words on line should be ignored.
16182164 *=======================================================================*/
16192165
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 }
16242175 ++total_chars_this_line; /* \tab */
16252176 }
16262177 return FALSE;
16332184 * Args: Word, paragraph align info, and numeric param if any.
16342185 * Returns: Flag, true only if rest of Words on line should be ignored.
16352186 *=======================================================================*/
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 }
16402196 total_chars_this_line = 0; /* \tab */
16412197 }
16422198 return FALSE;
16502206 * Returns: Flag, true only if rest of Words on line should be ignored.
16512207 *=======================================================================*/
16522208
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 }
16572218 total_chars_this_line = 0; /* \tab */
16582219 }
16592220 return FALSE;
16672228 * Returns: Flag, true only if rest of Words on line should be ignored.
16682229 *=======================================================================*/
16692230
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 }
16732239 total_chars_this_line = 0; /* \tab */
16742240 }
16752241 return FALSE;
16832249 * Returns: Flag, true only if rest of Words on line should be ignored.
16842250 *=======================================================================*/
16852251
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 {
16872254 ++coming_pars_that_are_tabular;
16882255
16892256 check_for_table();
16992266 * Returns: Flag, true only if rest of Words on line should be ignored.
17002267 *=======================================================================*/
17012268
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);
17312280 return FALSE;
17322281 }
17332282
17382287 * Returns: Flag, true only if rest of Words on line should be ignored.
17392288 *=======================================================================*/
17402289
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 {
17432294 cmd_ulnone(w, align, has_param, param);
1744 } else {
2295 }
2296 else
2297 {
17452298 attr_push(ATTR_UNDERLINE, NULL);
17462299 }
17472300 return FALSE;
17542307 * Returns: Flag, true only if rest of Words on line should be ignored.
17552308 *=======================================================================*/
17562309
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 {
17582312 attr_push(ATTR_DOUBLE_UL, NULL);
17592313 return FALSE;
17602314 }
17662320 * Returns: Flag, true only if rest of Words on line should be ignored.
17672321 *=======================================================================*/
17682322
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 {
17702325 attr_push(ATTR_DOT_UL, NULL);
17712326 return FALSE;
17722327 }
17792334 * Returns: Flag, true only if rest of Words on line should be ignored.
17802335 *=======================================================================*/
17812336
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 {
17832339 attr_push(ATTR_DASH_UL, NULL);
17842340 return FALSE;
17852341 }
17922348 * Returns: Flag, true only if rest of Words on line should be ignored.
17932349 *=======================================================================*/
17942350
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);
17972354 return FALSE;
17982355 }
17992356
18052362 * Returns: Flag, true only if rest of Words on line should be ignored.
18062363 *=======================================================================*/
18072364
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);
18102368 return FALSE;
18112369 }
18122370
18182376 * Returns: Flag, true only if rest of Words on line should be ignored.
18192377 *=======================================================================*/
18202378
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);
18232382 return FALSE;
18242383 }
18252384
18312390 * Returns: Flag, true only if rest of Words on line should be ignored.
18322391 *=======================================================================*/
18332392
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);
18362396 return FALSE;
18372397 }
18382398
18442404 * Returns: Flag, true only if rest of Words on line should be ignored.
18452405 *=======================================================================*/
18462406
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 {
18482409 attr_push(ATTR_THICK_UL, NULL);
18492410 return FALSE;
18502411 }
18572418 * Returns: Flag, true only if rest of Words on line should be ignored.
18582419 *=======================================================================*/
18592420
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 {
18612423 attr_push(ATTR_THICK_UL, NULL);
18622424 return FALSE;
18632425 }
18702432 * Returns: Flag, true only if rest of Words on line should be ignored.
18712433 *=======================================================================*/
18722434
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);
18752438 return FALSE;
18762439 }
18772440
18832446 * Returns: Flag, true only if rest of Words on line should be ignored.
18842447 *=======================================================================*/
18852448
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 {
18882453 attr_pop(ATTR_STRIKE);
2454 }
18892455 else
1890 attr_push(ATTR_STRIKE,NULL);
2456 {
2457 attr_push(ATTR_STRIKE, NULL);
2458 }
18912459 return FALSE;
18922460 }
18932461
18982466 * Returns: Flag, true only if rest of Words on line should be ignored.
18992467 *=======================================================================*/
19002468
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 {
19032473 attr_pop(ATTR_DBL_STRIKE);
2474 }
19042475 else
1905 attr_push(ATTR_DBL_STRIKE,NULL);
2476 {
2477 attr_push(ATTR_DBL_STRIKE, NULL);
2478 }
19062479 return FALSE;
19072480 }
19082481
19142487 * Returns: Flag, true only if rest of Words on line should be ignored.
19152488 *=======================================================================*/
19162489
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 {
19192494 attr_pop(ATTR_DBL_STRIKE);
2495 }
19202496 else
1921 attr_push(ATTR_DBL_STRIKE,NULL);
2497 {
2498 attr_push(ATTR_DBL_STRIKE, NULL);
2499 }
19222500 return FALSE;
19232501 }
19242502
19302508 * Returns: Flag, true only if rest of Words on line should be ignored.
19312509 *=======================================================================*/
19322510
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 {
19342513 return FALSE;
19352514 }
19362515
19412520 * Returns: Flag, true only if rest of Words on line should be ignored.
19422521 *=======================================================================*/
19432522
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)
19452524 {
19462525 return FALSE;
19472526 }
19532532 * Returns: Flag, true only if rest of Words on line should be ignored.
19542533 *=======================================================================*/
19552534
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 {
19582539 attr_pop(ATTR_SUPER);
2540 }
19592541 else
1960 attr_push(ATTR_SUPER,NULL);
2542 {
2543 attr_push(ATTR_SUPER, NULL);
2544 }
19612545 return FALSE;
19622546 }
19632547
19682552 * Returns: Flag, always false
19692553 *=======================================================================*/
19702554
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;
19772562 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 */
19792564 const char *alias;
19802565 #define DEBUG 0
19812566 #if DEBUG
19822567 char *str;
19832568 if (has_param == TRUE)
19842569 {
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);
19872572 }
19882573 if (w->hash_index)
19892574 {
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);
19922577 }
19932578 #endif
19942579 /* 0.20.3 - daved added missing function call for unprocessed chars */
19972582 printf("%s", alias);
19982583 done++;
19992584 }
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
20142601 /*
20152602 ** if we know how to represent the unicode character in the
20162603 ** output language, we need to skip the next word, otherwise
20172604 ** we will output that alternative.
20182605 */
20192606 if (done)
2020 return(SKIP_ONE_WORD);
2021 return(FALSE);
2607 {
2608 return (SKIP_ONE_WORD);
2609 }
2610 return (FALSE);
20222611 }
20232612
20242613 /*========================================================================
20282617 * Returns: Flag, true only if rest of Words on line should be ignored.
20292618 *=======================================================================*/
20302619
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 {
20332624 attr_pop(ATTR_SUB);
2625 }
20342626 else
2035 attr_push(ATTR_SUB,NULL);
2627 {
2628 attr_push(ATTR_SUB, NULL);
2629 }
20362630 return FALSE;
20372631 }
20382632
20432637 * Returns: Flag, true only if rest of Words on line should be ignored.
20442638 *=======================================================================*/
20452639
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 {
20472642 attr_pop(ATTR_SUPER);
20482643 attr_pop(ATTR_SUB);
20492644 return FALSE;
20562651 * Returns: Flag, true only if rest of Words on line should be ignored.
20572652 *=======================================================================*/
20582653
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 {
20612658 attr_pop(ATTR_SUPER);
2659 }
20622660 else
2063 attr_push(ATTR_SUPER,NULL);
2661 {
2662 attr_push(ATTR_SUPER, NULL);
2663 }
20642664 return FALSE;
20652665 }
20662666
20712671 * Returns: Flag, true only if rest of Words on line should be ignored.
20722672 *=======================================================================*/
20732673
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 {
20762678 attr_pop(ATTR_SUB);
2679 }
20772680 else
2078 attr_push(ATTR_SUB,NULL);
2681 {
2682 attr_push(ATTR_SUB, NULL);
2683 }
20792684 return FALSE;
20802685 }
20812686
20862691 * Returns: Flag, true only if rest of Words on line should be ignored.
20872692 *=======================================================================*/
20882693
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 {
20912698 attr_pop(ATTR_SHADOW);
2699 }
20922700 else
2093 attr_push(ATTR_SHADOW,NULL);
2701 {
2702 attr_push(ATTR_SHADOW, NULL);
2703 }
20942704 return FALSE;
20952705 }
20962706
21022712 *=======================================================================*/
21032713 #define SUPPORT_UNNESTED
21042714
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 {
21082720 #ifdef SUPPORT_UNNESTED
21092721 attr_find_pop(ATTR_BOLD);
21102722 #else
21122724 #endif
21132725 }
21142726 else
2115 attr_push(ATTR_BOLD,NULL);
2727 {
2728 attr_push(ATTR_BOLD, NULL);
2729 }
21162730 return FALSE;
21172731 }
21182732
21232737 * Returns: Flag, true only if rest of Words on line should be ignored.
21242738 *=======================================================================*/
21252739
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)
21282743 #ifdef SUPPORT_UNNESTED
21292744 attr_find_pop(ATTR_ITALIC);
21302745 #else
21312746 attr_pop(ATTR_ITALIC);
21322747 #endif
21332748 else
2134 attr_push(ATTR_ITALIC,NULL);
2749 {
2750 attr_push(ATTR_ITALIC, NULL);
2751 }
21352752 return FALSE;
21362753 }
21372754
21412758 * Args: Word, paragraph align info, and numeric param if any.
21422759 * Returns: Flag, true only if rest of Words on line should be ignored.
21432760 *=======================================================================*/
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 {
21452763 return FALSE;
21462764 }
21472765
21522770 * Returns: Flag, true only if rest of Words on line should be ignored.
21532771 *=======================================================================*/
21542772
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 {
21562775 /* 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 }
21592782 }
21602783 return FALSE;
21612784 }
21672790 * Returns: Flag, true only if rest of Words on line should be ignored.
21682791 *=======================================================================*/
21692792
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 }
21732801 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 }
21752806 }
21762807
21772808 return FALSE;
21842815 * Returns: Flag, true only if rest of Words on line should be ignored.
21852816 *=======================================================================*/
21862817
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 {
21892822 attr_pop(ATTR_OUTLINE);
2823 }
21902824 else
2191 attr_push(ATTR_OUTLINE,NULL);
2825 {
2826 attr_push(ATTR_OUTLINE, NULL);
2827 }
21922828 return FALSE;
21932829 }
21942830
21992835 * Returns: Flag, true only if rest of Words on line should be ignored.
22002836 *=======================================================================*/
22012837
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;
22052842 }
22062843
22072844 /*========================================================================
22112848 * Returns: Flag, true only if rest of Words on line should be ignored.
22122849 *=======================================================================*/
22132850
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;
22182855 return FALSE;
22192856 }
22202857
22252862 * Returns: Flag, true only if rest of Words on line should be ignored.
22262863 *=======================================================================*/
22272864
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;
22322869 }
22332870
22342871 /*========================================================================
22382875 * Returns: Flag, true only if rest of Words on line should be ignored.
22392876 *=======================================================================*/
22402877
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;
22452882 }
22462883
22472884 /*========================================================================
22512888 * Returns: Flag, true only if rest of Words on line should be ignored.
22522889 *=======================================================================*/
22532890
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;
22582895 }
22592896
22602897 /*========================================================================
22642901 * Returns: Flag, true only if rest of Words on line should be ignored.
22652902 *=======================================================================*/
22662903
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 {
22692908 process_color_table(w->next);
22702909 }
22712910 return TRUE;
22782917 * Returns: Flag, true only if rest of Words on line should be ignored.
22792918 *=======================================================================*/
22802919
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 {
22832924 process_font_table(w->next);
22842925 }
22852926 return TRUE;
22922933 * Returns: Flag, true only if rest of Words on line should be ignored.
22932934 *=======================================================================*/
22942935
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 {
22962938 return TRUE;
22972939 }
22982940
23032945 * Returns: Flag, true only if rest of Words on line should be ignored.
23042946 *=======================================================================*/
23052947
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 {
23072950 return TRUE;
23082951 }
23092952
23142957 * Returns: Flag, true only if rest of Words on line should be ignored.
23152958 *=======================================================================*/
23162959
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 {
23182962 return TRUE;
23192963 }
23202964
23252969 * Returns: Flag, true only if rest of Words on line should be ignored.
23262970 *=======================================================================*/
23272971
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 {
23292974 return TRUE;
23302975 }
23312976
23362981 * Returns: Flag, true only if rest of Words on line should be ignored.
23372982 *=======================================================================*/
23382983
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 {
23402986 return TRUE;
23412987 }
23422988
23472993 * Returns: Flag, true only if rest of Words on line should be ignored.
23482994 *=======================================================================*/
23492995
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 {
23512998 return TRUE;
23522999 }
23533000
23583005 * Returns: Flag, true only if rest of Words on line should be ignored.
23593006 *=======================================================================*/
23603007
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 {
23623010 return TRUE;
23633011 }
23643012
23693017 * Returns: Flag, true only if rest of Words on line should be ignored.
23703018 *=======================================================================*/
23713019
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 {
23733022 return TRUE;
23743023 }
23753024
23763025 /*========================================================================
23773026 * 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)
23843033 {
23853034 return TRUE;
23863035 }
23873036
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
24003049 * (which may still be to discard the group. If it is not found
24013050 * we return TRUE to discard the next elements.
24023051 */
2403 if(w && w->next)
3052 if (w && w->next)
24043053 {
24053054 int hasparam, param;
24063055 const char *s = word_string(w->next);
24073056 if (s && s[0] == '\\' && find_command(s + 1, &hasparam, &param))
3057 {
24083058 return FALSE;
2409 }
2410
3059 }
3060 }
3061
24113062 return TRUE;
24123063 }
24133064
24143065 /*========================================================================
24153066 * 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);
24243075 return TRUE;
24253076 }
24263077
24313082 * Returns: Flag, true only if rest of Words on line should be ignored.
24323083 *=======================================================================*/
24333084
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);
24363088 return TRUE;
24373089 }
24383090
24433095 * Returns: Flag, true only if rest of Words on line should be ignored.
24443096 *=======================================================================*/
24453097
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;
24493101 picture_width = picture_height = 0;
24503102 picture_type = PICT_WB;
2451 return FALSE;
3103 return FALSE;
24523104 }
24533105 /*========================================================================
24543106 * Name: cmd_picprop
24573109 * Returns: Flag, true only if rest of Words on line should be ignored.
24583110 *=======================================================================*/
24593111
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;
24633115 }
24643116
24653117
24703122 * Returns: Flag, true only if rest of Words on line should be ignored.
24713123 *=======================================================================*/
24723124
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;
24753128 }
24763129
24773130
24823135 * Returns: Flag, true only if rest of Words on line should be ignored.
24833136 *=======================================================================*/
24843137
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 {
24863140 picture_type = PICT_MAC;
2487 return FALSE;
3141 return FALSE;
24883142 }
24893143
24903144 /*========================================================================
24943148 * Returns: Flag, true only if rest of Words on line should be ignored.
24953149 *=======================================================================*/
24963150
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 {
24983153 picture_type = PICT_JPEG;
2499 return FALSE;
3154 return FALSE;
25003155 }
25013156
25023157 /*========================================================================
25063161 * Returns: Flag, true only if rest of Words on line should be ignored.
25073162 *=======================================================================*/
25083163
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 {
25103166 picture_type = PICT_PNG;
2511 return FALSE;
3167 return FALSE;
25123168 }
25133169
25143170 /*========================================================================
25183174 * Returns: Flag, true only if rest of Words on line should be ignored.
25193175 *=======================================================================*/
25203176
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 {
25223179 picture_type = PICT_EMF;
2523 return FALSE;
3180 return FALSE;
25243181 }
25253182
25263183 /*========================================================================
25303187 * Returns: Flag, true only if rest of Words on line should be ignored.
25313188 *=======================================================================*/
25323189
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 {
25343192 picture_type = PICT_PM;
2535 return FALSE;
3193 return FALSE;
25363194 }
25373195
25383196 /*========================================================================
25423200 * Returns: Flag, true only if rest of Words on line should be ignored.
25433201 *=======================================================================*/
25443202
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 {
25463205 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;
25623241 }
25633242
25643243 /*========================================================================
25683247 * Returns: Flag, true only if rest of Words on line should be ignored.
25693248 *=======================================================================*/
25703249
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 {
25733254 picture_bits_per_pixel = param;
2574 return FALSE;
3255 }
3256 return FALSE;
25753257 }
25763258
25773259 /*========================================================================
25813263 * Returns: Flag, true only if rest of Words on line should be ignored.
25823264 *=======================================================================*/
25833265
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 {
25863270 picture_width = param;
2587 return FALSE;
3271 }
3272 return FALSE;
25883273 }
25893274
25903275 /*========================================================================
25943279 * Returns: Flag, true only if rest of Words on line should be ignored.
25953280 *=======================================================================*/
25963281
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 {
25993286 picture_height = param;
2600 return FALSE;
3287 }
3288 return FALSE;
26013289 }
26023290
26033291
26083296 * Returns: Flag, true only if rest of Words on line should be ignored.
26093297 *=======================================================================*/
26103298
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;
26143303 }
26153304
26163305 /*========================================================================
26203309 * Returns: Flag, true only if rest of Words on line should be ignored.
26213310 *=======================================================================*/
26223311
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;
26263316 }
26273317
26283318 /*========================================================================
26323322 * Returns: Flag, true only if rest of Words on line should be ignored.
26333323 *=======================================================================*/
26343324
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;
26383329 }
26393330
26403331
26413332 /* 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 */
26503342 #if 0
26513343 { "*", cmd_ignore, NULL },
26523344 #else
26573349 { "~", cmd_nonbreaking_space, NULL },
26583350 { NULL, NULL, NULL}
26593351 };
2660 static HashItem hashArray_a [] = {
3352 static HashItem hashArray_a [] =
3353 {
26613354 { "ansi", &cmd_ansi , NULL },
26623355 { "ansicpg", &cmd_ansicpg , NULL },
26633356 { NULL, NULL, NULL}
26643357 };
2665 static HashItem hashArray_b [] = {
3358 static HashItem hashArray_b [] =
3359 {
26663360 { "b", &cmd_b, NULL },
26673361 { "bullet", &cmd_bullet, NULL },
26683362 { "bin", &cmd_bin, "picture is binary" },
26913385 #endif
26923386 { NULL, NULL, NULL}
26933387 };
2694 static HashItem hashArray_c [] = {
3388 static HashItem hashArray_c [] =
3389 {
26953390 { "caps", &cmd_caps, NULL },
26963391 { "cb", cmd_cb, NULL },
26973392 { "cf", cmd_cf, NULL },
27273422 { "cs", NULL, "character style (not implemented)"},
27283423 { NULL, NULL, NULL}
27293424 };
2730 static HashItem hashArray_d [] = {
3425 static HashItem hashArray_d [] =
3426 {
27313427 { "deff", cmd_deff, "Default Font" },
27323428 { "dn", &cmd_dn, NULL },
27333429 #if 0
27353431 #endif
27363432 { NULL, NULL, NULL}
27373433 };
2738 static HashItem hashArray_e [] = {
3434 static HashItem hashArray_e [] =
3435 {
27393436 { "emdash", cmd_emdash, NULL },
27403437 { "endash", cmd_endash, NULL },
27413438 { "embo", &cmd_emboss, NULL },
27443441 { "emfblip", &cmd_emfblip, NULL },
27453442 { NULL, NULL, NULL}
27463443 };
2747 static HashItem hashArray_f [] = {
3444 static HashItem hashArray_f [] =
3445 {
27483446 { "f", cmd_f, NULL },
27493447 { "fdecor", cmd_fdecor, NULL },
27503448 { "fmodern", cmd_fmodern, NULL },
27623460 { "footerr", cmd_footerr, NULL },
27633461 { NULL, NULL, NULL}
27643462 };
2765 static HashItem hashArray_h [] = {
3463 static HashItem hashArray_h [] =
3464 {
27663465 { "highlight", &cmd_highlight, NULL },
27673466 { "header", cmd_header, NULL },
27683467 { "headerf", cmd_headerf, NULL },
27713470 { "hl", cmd_ignore, "hyperlink within object" },
27723471 { NULL, NULL, NULL}
27733472 };
2774 static HashItem hashArray_i [] = {
3473 static HashItem hashArray_i [] =
3474 {
27753475 { "i", &cmd_i, NULL },
27763476 { "info", &cmd_info, NULL },
27773477 { "insrsid", NULL, "Revision Mark (ignore)" },
27793479 { "impr", &cmd_engrave, NULL },
27803480 { NULL, NULL, NULL}
27813481 };
2782 static HashItem hashArray_j [] = {
3482 static HashItem hashArray_j [] =
3483 {
27833484 { "jpegblip", &cmd_jpegblip, NULL },
27843485 { NULL, NULL, NULL}
27853486 };
2786 static HashItem hashArray_l [] = {
3487 static HashItem hashArray_l [] =
3488 {
27873489 { "ldblquote", &cmd_ldblquote, NULL },
27883490 { "line", &cmd_line, NULL },
27893491 { "lquote", &cmd_lquote, NULL },
27903492 { NULL, NULL, NULL}
27913493 };
2792 static HashItem hashArray_m [] = {
3494 static HashItem hashArray_m [] =
3495 {
27933496 { "mac", &cmd_mac , NULL },
27943497 { "macpict", &cmd_macpict, NULL },
27953498 { NULL, NULL, NULL}
27963499 };
2797 static HashItem hashArray_n [] = {
3500 static HashItem hashArray_n [] =
3501 {
27983502 { "nosupersub", &cmd_nosupersub, NULL },
27993503 { "nonshppict", &cmd_ignore, NULL },
28003504 { NULL, NULL, NULL}
28013505 };
2802 static HashItem hashArray_o [] = {
3506 static HashItem hashArray_o [] =
3507 {
28033508 { "outl", &cmd_outl, NULL },
28043509 { NULL, NULL, NULL}
28053510 };
2806 static HashItem hashArray_p [] = {
3511 static HashItem hashArray_p [] =
3512 {
28073513 { "page", &cmd_page, NULL },
28083514 { "par", &cmd_par, NULL },
28093515 { "pc", &cmd_pc , NULL },
28293535 #endif
28303536 { NULL, NULL, NULL}
28313537 };
2832 static HashItem hashArray_r [] = {
3538 static HashItem hashArray_r [] =
3539 {
28333540 { "rdblquote", &cmd_rdblquote, NULL },
28343541 { "rquote", &cmd_rquote, NULL },
28353542 { "rtf", &cmd_rtf, NULL },
28363543 { NULL, NULL, NULL}
28373544 };
2838 static HashItem hashArray_s [] = {
3545 static HashItem hashArray_s [] =
3546 {
28393547 { "s", cmd_s, "style" },
28403548 { "sect", &cmd_sect, "section break"},
28413549 { "scaps", &cmd_scaps, NULL },
28533561 #endif
28543562 { NULL, NULL, NULL}
28553563 };
2856 static HashItem hashArray_t [] = {
3564 static HashItem hashArray_t [] =
3565 {
28573566 { "tab", &cmd_tab, NULL },
28583567 { "tc", cmd_tc, "TOC entry" },
28593568 { "tcn", cmd_tcn, "TOC entry" },
28603569 { "trowd", NULL, "start new row in table" },
28613570 { NULL, NULL, NULL}
28623571 };
2863 static HashItem hashArray_u [] = {
3572 static HashItem hashArray_u [] =
3573 {
28643574 { "u", &cmd_u, NULL },
28653575 { "ul", &cmd_ul, NULL },
28663576 { "up", &cmd_up, NULL },
28783588 { NULL, NULL, NULL}
28793589 };
28803590
2881 static HashItem hashArray_v [] = {
3591 static HashItem hashArray_v [] =
3592 {
28823593 { "v", NULL, "Hidden Text" },
28833594 { NULL, NULL, NULL }
28843595 };
28853596
2886 static HashItem hashArray_w [] = {
3597 static HashItem hashArray_w [] =
3598 {
28873599 { "wbmbitspixel", &cmd_wbmbitspixel, NULL },
28883600 { "wmetafile", &cmd_wmetafile, NULL },
28893601 { NULL, NULL, NULL}
28903602 };
28913603
2892 static HashItem hashArray_x [] = {
3604 static HashItem hashArray_x [] =
3605 {
28933606 { "xe", cmd_xe, "index entry" },
28943607 { NULL, NULL, NULL}
28953608 };
28963609
2897 static HashItem *hash [26] = {
3610 static HashItem *hash [26] =
3611 {
28983612 hashArray_a,
28993613 hashArray_b,
29003614 hashArray_c,
29183632 hashArray_u,
29193633 hashArray_v,
29203634 hashArray_w,
2921 hashArray_x,
3635 hashArray_x,
29223636 NULL, NULL
29233637 };
29243638
29463660 /* Look for a parameter */
29473661 *hasparamp = FALSE;
29483662 p = cmdpp;
2949 while (*p && (!isdigit(*p) && *p != '-'))
3663 while (*p && (!isdigit(*p) && *p != '-'))
3664 {
29503665 p++;
2951 if (*p && (isdigit(*p) || *p == '-')) {
2952 *hasparamp = TRUE;
3666 }
3667 if (*p && (isdigit(*p) || *p == '-'))
3668 {
3669 *hasparamp = TRUE;
29533670 *paramp = atoi(p);
29543671 }
29553672 len = p - cmdpp;
29563673
29573674 /* Generate a hash index */
29583675 ch = tolower(*cmdpp);
2959 if (ch >= 'a' && ch <= 'z')
3676 if (ch >= 'a' && ch <= 'z')
3677 {
29603678 hip = hash[ch - 'a'];
3679 }
29613680 else
3681 {
29623682 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 }
29673693 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 }
29693698 }
29703699 return NULL;
29713700 }
29723701
2973 while (hip->name) {
3702 while (hip->name)
3703 {
29743704 /* Don't change the order of tests ! */
29753705 if (!strncmp(cmdpp, hip->name, len) && hip->name[len] == 0)
3706 {
29763707 return hip;
3708 }
29773709 hip++;
29783710 }
29793711
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 }
29823718 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 }
29843723 }
29853724 return NULL;
29863725 }
30043743 * Returns: None.
30053744 *=======================================================================*/
30063745
3007 void
3008 print_with_special_exprs (const char *s) {
3746 void
3747 print_with_special_exprs(const char *s)
3748 {
30093749 int ch;
30103750 int state;
30113751
3012 enum { SMALL=0, BIG=1 };
3752 enum { SMALL = 0, BIG = 1 };
30133753
30143754 CHECK_PARAM_NOT_NULL(s);
30153755
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 }
30273772 }
30283773 else
3029 state=BIG;
3030 }
3031
3032 while ((ch=*s)) {
3774 {
3775 state = BIG;
3776 }
3777 }
3778
3779 while ((ch = *s))
3780 {
30333781 const char *post_trans = NULL;
30343782
30353783 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 }
30423796 }
30433797
30443798 s++;
30453799
3046 if (simulate_smallcaps) {
3800 if (simulate_smallcaps)
3801 {
30473802 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;
30523811 }
30533812 else
30543813 {
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;
30583820 }
30593821 }
30603822 }
30633825
30643826
30653827 /*========================================================================
3066 * Name:
3067 * Purpose:
3828 * Name:
3829 * Purpose:
30683830 * Args: None.
30693831 * Returns: None.
30703832 *=======================================================================*/
30713833
3072 static void
3834 static void
30733835 begin_table()
30743836 {
3075 within_table=TRUE;
3837 within_table = TRUE;
30763838 have_printed_row_begin = FALSE;
30773839 have_printed_cell_begin = FALSE;
30783840 have_printed_row_end = FALSE;
30793841 have_printed_cell_end = FALSE;
30803842 attrstack_push();
30813843 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 }
30833848 }
30843849
30853850
30903855 * Returns: None.
30913856 *=======================================================================*/
30923857
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;
31063883 have_printed_row_begin = FALSE;
31073884 have_printed_cell_begin = FALSE;
31083885 have_printed_row_end = FALSE;
31343911 }
31353912
31363913 /*========================================================================
3137 * Name:
3138 * Purpose:
3914 * Name:
3915 * Purpose:
31393916 * Args: None.
31403917 * Returns: None.
31413918 *=======================================================================*/
31423919
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 }
31543941 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:
31673954 * Args: None.
31683955 * Returns: None.
31693956 *=======================================================================*/
31703957
31713958 static void
3172 starting_paragraph_align (int align)
3959 starting_paragraph_align(int align)
31733960 {
31743961 if (within_header && align != ALIGN_LEFT)
3962 {
31753963 starting_body();
3176
3177 switch (align)
3964 }
3965
3966 switch (align)
31783967 {
31793968 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 }
31813973 break;
31823974 case ALIGN_LEFT:
31833975 break;
31843976 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 }
31863981 break;
31873982 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 }
31893987 break;
31903988 }
31913989 }
31933991
31943992
31953993 /*========================================================================
3196 * Name:
3197 * Purpose:
3994 * Name:
3995 * Purpose:
31983996 * Args: None.
31993997 * Returns: None.
32003998 *=======================================================================*/
32013999
32024000 static void
3203 ending_paragraph_align (int align)
3204 {
3205 switch (align) {
4001 ending_paragraph_align(int align)
4002 {
4003 switch (align)
4004 {
32064005 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 }
32084010 break;
32094011 case ALIGN_LEFT:
32104012 break;
32114013 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 }
32134018 break;
32144019 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 }
32164024 break;
32174025 }
32184026 }
32244032 static void
32254033 flush_iconv_input()
32264034 {
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;
32814097 }
32824098
32834099 static void
32844100 accumulate_iconv_input(int ch)
32854101 {
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:
32944112 * Purpose: Recursive routine to produce the output in the target
32954113 * format given on a tree of words.
32964114 * Args: Word* (the tree).
32984116 *=======================================================================*/
32994117
33004118 static void
3301 word_print_core (Word *w, int groupdepth)
4119 word_print_core(Word *w, int groupdepth)
33024120 {
33034121 const char *s;
33044122 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");
33124131 return;
3313 }
4132 }
33144133 CHECK_PARAM_NOT_NULL(w);
33154134
33164135 //if (!coming_pars_that_are_tabular && within_table) {
3317 //end_table();
4136 //end_table();
33184137 //}
33194138 //else if (coming_pars_that_are_tabular && !within_table) {
3320 //begin_table();
4139 //begin_table();
33214140 //}
33224141 check_for_table();
33234142
33244143 /* Mark our place in the stack */
33254144 attrstack_push();
33264145
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 {
33364159
33374160 /*--Ignore whitespace in header--------------------*/
3338 if (*s==' ' && within_header) {
4161 if (*s == ' ' && within_header)
4162 {
33394163 /* no op */
3340 }
4164 }
33414165 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] != '\\')
33554168 {
3356 if (within_picture_depth == 0)
3357 within_picture_depth = groupdepth;
33584169 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;
33704184 }
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");
33834219 }
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 }
34024271 }
34034272 }
34044273 }
34054274 }
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
34064296 }
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 }
34224297 /* output an escaped backslash */
34234298 /* do we need special handling for latex? */
34244299 /* 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) == '\\')
34294301 {
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 }
34314311 }
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---------------------------*/
34324323 else
34334324 {
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, &param);
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 }
34354458 }
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;
34364472 }
3437 else if (*(s+1) == '{')
4473
4474 if (child)
34384475 {
3439 s++;
3440 putchar('{');
4476 word_print_core(child, groupdepth + 1);
34414477 }
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))
34434493 {
3444 s++;
3445 putchar('}');
4494 fprintf(stderr, TOO_MANY_ARGS, "imagelink_begin");
34464495 }
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, &param);
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");
35394500 }
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;
35714503 }
35724504
35734505 /* Undo font attributes UNLESS we're doing table cells
35754507 */
35764508
35774509 if (!is_cell_group)
4510 {
35784511 attr_pop_all();
4512 }
35794513 else
4514 {
35804515 attr_drop_all();
4516 }
35814517
35824518 /* Undo paragraph alignment
35834519 */
35844520 if (paragraph_begined)
3585 ending_paragraph_align (paragraph_align);
4521 {
4522 ending_paragraph_align(paragraph_align);
4523 }
35864524
35874525 attrstack_drop();
35884526
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:
36074547 * Args: None.
36084548 * Returns: None.
36094549 *=======================================================================*/
36104550
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);
36294582 end_table();
36304583
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 }
3838
3939 #include "word.h"
4040
41 enum {
42 CHARSET_ANSI=1,
41 enum
42 {
43 CHARSET_ANSI = 1,
4344 CHARSET_MAC,
4445 CHARSET_CP437,
4546 CHARSET_CP850,
4647 };
4748
48 extern void word_print (Word*);
49 extern void word_print(Word *);
4950 #define FONT_GREEK "cp1253"
5051 #define FONT_SYMBOL "SYMBOL"
5152
3030 * 10 Oct 00, tuorfa@yahoo.com: added usage()
3131 * 15 Oct 00, tuorfa@yahoo.com: improved output readability
3232 * 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
3434 * 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
3535 * 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp
3636 * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
6363 *=======================================================================*/
6464
6565 void
66 usage ()
66 usage()
6767 {
6868 fprintf(stderr, "Usage: %s\n", USAGE);
6969 exit(-3);
7979 *=======================================================================*/
8080
8181 void
82 error_handler (char* message)
82 error_handler(char *message)
8383 {
8484 #if 1
8585 fprintf(stderr, "Error (line %d): %s\n", lineno, message);
9898 *=======================================================================*/
9999
100100 void
101 warning_handler (char* message)
101 warning_handler(char *message)
102102 {
103103 fprintf(stderr, "Warning: %s\n", message);
104104 }
4242
4343
4444 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 *);
4747
4848
4949
3232 * 08 Apr 01, tuorfa@yahoo.com: check for out of memory after malloc.
3333 * 21 Apr 01, tuorfa@yahoo.com: signed to conversion unsigned bug
3434 * 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
3636 * 08 Oct 03, daved@physiol.usyd.edu.au: some type fixes
3737 * 29 Mar 05, daved@physiol.usyd.edu.au: changes requsted by ZT Smith
3838 * 06 Jan 06, marcossamaral@terra.com.br: changes hash_stats function
6161 #include "malloc.h"
6262
6363
64 typedef struct _hi {
64 typedef struct _hi
65 {
6566 struct _hi *next;
6667 char str[1];
6768 } HashItem;
8081 *=======================================================================*/
8182
8283 unsigned long
83 hash_stats ()
84 hash_stats()
8485 {
8586 int i;
86 unsigned long total=0;
87 unsigned long total = 0;
8788 HashItem *hi;
88 for (i=0; i<256; i++) {
89 for (i = 0; i < 256; i++)
90 {
8991 hi = hash[i];
90 while (hi) {
92 while (hi)
93 {
9194 total++;
9295 hi = hi->next;
9396 }
105108 *=======================================================================*/
106109
107110 static HashItem *
108 hashitem_new (char *str)
111 hashitem_new(char *str)
109112 {
110113 HashItem *hi;
111114
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);
116119 if (!hi)
120 {
117121 error_handler("Out of memory");
122 }
118123 strcpy(hi->str, str);
119124 hi->next = NULL;
120125
131136 *=======================================================================*/
132137
133138 const char *
134 hash_store (char *str)
139 hash_store(char *str)
135140 {
136 unsigned char ch = (unsigned char)*str;
141 unsigned char ch = (unsigned char) * str;
137142 HashItem *hi;
138143
139 if (ch=='\\' && *(str+1))
140 ch = *(str+1);
144 if (ch == '\\' && *(str + 1))
145 {
146 ch = *(str + 1);
147 }
141148 hi = hash[ch];
142 while (hi) {
149 while (hi)
150 {
143151 if (!strcmp(hi->str, str))
152 {
144153 return hi->str;
154 }
145155 hi = hi->next;
146156 }
147157 /* not in hash */
3333 *----------------------------------------------------------------------
3434 * Changes:
3535 * 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()
3737 * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
3838 * 07 Oct 11, jf@dockes.org, added _HASH_H_INCLUDED_
3939 * Further: see VCS log
4040 *--------------------------------------------------------------------*/
4141
4242
43 extern unsigned long hash_stats (void);
43 extern unsigned long hash_stats(void);
4444 /* Store/find string, returns address of stored copy */
45 extern const char *hash_store (char *);
45 extern const char *hash_store(char *);
4646
4747 #endif /* _HASH_H_INCLUDED_ */
66 the Free Software Foundation; either version 3 of the License, or
77 (at your option) any later version.
88
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,
1010 but WITHOUT ANY WARRANTY; without even the implied warranty of
1111 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1212 GNU General Public License for more details.
2727 *----------------------------------------------------------------------
2828 * Changes:
2929 * 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()
3131 * 08 Apr 01, tuorfa@yahoo.com: more GNU-like switches implemented
3232 * 24 Jul 01, tuorfa@yahoo.com: removed verify_file_type()
3333 * 03 Aug 01, tuorfa@yahoo.com: added --inline switch
3434 * 08 Sep 01, tuorfa@yahoo.com: added use of UnRTF
3535 * 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
3737 * 23 Sep 01, tuorfa@yahoo.com: added wpml switch
3838 * 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
3939 * 07 Jan 04, tuorfa@yahoo.com: removed broken PS support
4040 * 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp
4141 * 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
4343 * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
4444 * 17 Dec 07, daved@physiol.usyd.edu.au: support for --noremap from
4545 * David Santinoli
6868 #include <string.h>
6969 #endif
7070
71 #ifdef HAVE_UNISTD_H
7172 #include <unistd.h>
73 #endif
7274
7375 #include "defs.h"
7476 #include "error.h"
111113 OutputPersonality *
112114 get_config(char *name, OutputPersonality *op)
113115 {
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;
129131 }
130132
131133 /*========================================================================
136138 *=======================================================================*/
137139
138140 int
139 main (int argc, char **argv)
141 main(int argc, char **argv)
140142 {
141143 FILE *f;
142 Word * word;
144 Word *word;
143145 char *path = NULL;
144 char *env_path_p = '\0';
146 char *env_path_p = NULL;
145147
146148 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;
148150 /* initialize search path to compiled-in value */
149151 search_path = DEFAULT_UNRTF_SEARCH_PATH;
150152
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 {
154157 fprintf(stderr, "got environment path: %s\n", env_path_p);
155 search_path=env_path_p;
158 }
159 search_path = env_path_p;
156160 }
157161
158162 /* Handle arguments */
159163
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 }
168194 else if (!strcmp("-t", argv[i]))
169195 {
170196 if ((i + 1) < argc && *argv[i + 1] != '-')
172198 i++;
173199 op = get_config(argv[i], op);
174200 }
175 }
201 }
176202 else if (!strcmp("-P", argv[i]))
177203 {
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");
181207 exit(1);
182208 }
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 {
187217 usage();
188218 }
189 else if (!strcmp("--version", argv[i])) {
219 else if (!strcmp("--version", argv[i]))
220 {
190221 fprintf(stderr, "%s\n", PACKAGE_VERSION);
191222 fprintf(stderr, "search path is: %s\n", search_path);
192223 exit(0);
193224 }
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 }
196233 else if (!strncmp("--", argv[i], 2))
234 {
197235 op = get_config(&argv[i][2], op);
236 }
198237 else
199238 {
200 if (*argv[i] == '-') usage();
201
202 if (path)
239 if (*argv[i] == '-')
240 {
203241 usage();
204 else
242 }
243
244 if (path)
245 {
246 usage();
247 }
248 else
249 {
205250 path = argv[i];
251 }
206252 }
207253 }
208254
209255
210256
211257 if (op == NULL)
258 {
212259 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");
216263 exit(1);
217264 }
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
221273 /* Program information */
222 if (verbose_mode || debug_mode) {
274 if (verbose_mode || debug_mode)
275 {
223276 fprintf(stderr, "This is UnRTF ");
224277 fprintf(stderr, "version %s\n", PACKAGE_VERSION);
225278 fprintf(stderr, "By Dave Davey, Marcos Serrou do Amaral and Arkadiusz Firus\n");
227280 show_dirs();
228281 }
229282
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 }
232291
233292 /* Open file for reading. Append ".rtf" to file name if not supplied. */
234293 if (path == NULL)
294 {
235295 f = stdin;
296 }
236297 else
237298 {
238299 f = fopen(path, "r");
239 if (!f) {
300 if (!f)
301 {
240302 char path2[200];
241303 strcpy(path2, path);
242304 strcat(path2, ".rtf");
243305 f = fopen(path2, "r");
244306 if (!f)
307 {
245308 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 }
250317
251318 /* Keep track of lines processed. This is arbitrary to the user as
252319 * RTF ignores newlines. May be helpful in error tracking. */
256323 * the end of the file. */
257324 word = word_read(f);
258325
259 if (dump_mode) {
326 if (dump_mode)
327 {
260328 word_dump(word);
261329 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 */
264334 word = optimize_word(word, 1);
265335 word_print(word);
266336 }
268338 fclose(f);
269339
270340 /* 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;
273344 total = hash_stats();
274345 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());
281353 }
282354
283355 /* May as well */
2929 * Changes:
3030 * 14 Aug 01, tuorfa@yahoo.com: added Turbo C support.
3131 * 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
3333 * 28 Sep 01, tuorfa@yahoo.com: removed Turbo C support.
3434 * 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
3535 * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
5656 #include "error.h"
5757 #include "malloc.h"
5858
59 static unsigned long count=0;
59 static unsigned long count = 0;
6060
6161 /*========================================================================
6262 * Name: my_malloc
6565 * Returns: Pointer.
6666 *=======================================================================*/
6767
68 char *
69 my_malloc (unsigned long size) {
68 char *
69 my_malloc(unsigned long size)
70 {
7071 char *ptr;
7172
72 ptr = malloc (size);
73 ptr = malloc(size);
7374 if (ptr)
75 {
7476 count += size;
77 }
7578
7679 return ptr;
7780 }
8386 * Returns: None.
8487 *=======================================================================*/
8588
86 void
87 my_free (char* ptr) {
89 void
90 my_free(char *ptr)
91 {
8892 CHECK_PARAM_NOT_NULL(ptr);
8993
90 free (ptr);
94 free(ptr);
9195 }
9296
9397 #if 1 /* AK3 - AF */
103107 char *new_ptr = my_malloc(new_size);
104108
105109 if (new_ptr != NULL)
110 {
106111 memcpy(new_ptr, ptr, old_size);
112 }
107113
108114 my_free(ptr);
109115
119125 * Returns: Amount.
120126 *=======================================================================*/
121127
122 unsigned long
123 total_malloced (void) {
128 unsigned long
129 total_malloced(void)
130 {
124131 return count;
125132 }
126133
134141 *=======================================================================*/
135142
136143 char *
137 my_strdup (char *src) {
144 my_strdup(char *src)
145 {
138146 unsigned long len;
139147 char *ptr;
140148
141149 CHECK_PARAM_NOT_NULL(src);
142150
143151 len = strlen(src);
144 ptr = my_malloc (len+1);
152 ptr = my_malloc(len + 1);
145153 if (!ptr)
146 error_handler ("out of memory in strdup()");
154 {
155 error_handler("out of memory in strdup()");
156 }
147157
148 strcpy (ptr, src);
158 strcpy(ptr, src);
149159 return ptr;
150160 }
161
162 #ifndef _WIN32
151163 /* added by daved */
152164 #include <sys/types.h>
153165 #undef malloc
154
155 void *malloc ();
156
166
167 void *malloc();
168
157169 /* Allocate an N-byte block of memory from the heap.
158170 If N is zero, allocate a 1-byte block. */
159171
160172 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
3131 * 09 Nov 08, arkadiusz.firus@gmail.com: added my_realloc
3232 *--------------------------------------------------------------------*/
3333
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 *);
3939
1111
1212 #include <stdio.h>
1313 #include <string.h>
14 #ifndef _WIN32
1415 #include <unistd.h>
16 #endif
1517 #include <stdlib.h>
1618 #include <errno.h>
1719
2325
2426 extern int verbose_mode;
2527
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
2830 */
2931 static char *
3032 get_code_str(FILE *f, iconv_t desc)
3436 char *obuf;
3537
3638 char *utf8 = get_unicode_utf8(f);
37 if (utf8 == NULL || *utf8 == 0) {
39 if (utf8 == NULL || *utf8 == 0)
40 {
3841 /* fprintf(stderr, "get_code_str: NULL entry\n");*/
42 my_free(utf8);
3943 return NULL;
4044 }
41 #if 0 /* debug */
45 #if 0 /* debug */
4246 fprintf(stderr, "get_code_str: utf8: ");
4347 for (ocp = utf8; *ocp; ocp++)
44 fprintf(stderr, "%x", (unsigned)*ocp);
48 {
49 fprintf(stderr, "%x", (unsigned)*ocp);
50 }
4551 fprintf(stderr, "\n");
46 #endif
52 #endif
4753
4854 obytes = 10;
4955 ibytes = strlen(utf8);
5056 obuf = malloc(obytes);
5157 if (obuf == NULL)
58 {
59 my_free(utf8);
5260 return NULL;
61 }
5362 icp = utf8;
5463 ocp0 = ocp = obuf + 1;
55 if (iconv(desc, &icp, &ibytes, &ocp, &obytes) == -1) {
64 if (iconv(desc, &icp, &ibytes, &ocp, &obytes) == -1)
65 {
5666 /* fprintf(stderr, "unrtf: my_iconv: iconv error\n");*/
67 my_free(utf8);
5768 return NULL;
5869 }
5970
6980 FILE *f;
7081 my_iconv_t cd = MY_ICONV_T_CLEAR;
7182 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);
104123 }
105124
106125 return cd;
112131 int c, i;
113132 size_t result = 0;
114133 **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)
124142 {
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 }
128149 }
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 }
146169 }
147170 else
171 {
148172 result = iconv(cd.desc, inbuf, inbytesleft, outbuf, outbytesleft);
173 }
149174
150175 return result;
151176 }
159184 {
160185 for (i = 0; i < char_table_size; i++)
161186 {
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 }
164191 }
165192
166193 my_free((void *)cd.char_table);
167194 cd.char_table = NULL;
168195 }
169196
170 if (cd.desc != (iconv_t) -1)
197 if (cd.desc != (iconv_t) - 1)
171198 {
172199 iconv_close(cd.desc);
173 cd.desc = (iconv_t) -1;
200 cd.desc = (iconv_t) - 1;
174201 }
175202
176203 return cd;
177204 }
178205
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 {
183211 return 1;
212 }
184213
185214 return 0;
186215 }
188217 void
189218 my_iconv_t_make_invalid(my_iconv_t *cd)
190219 {
191 cd->desc = (iconv_t) -1;
220 cd->desc = (iconv_t) - 1;
192221 cd->char_table = NULL;
193222 }
194223
2727 *----------------------------------------------------------------------
2828 * Changes:
2929 * 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
3131 * 08 Oct 03, daved@physiol.usyd.edu.au: added stdlib.h for linux
3232 * 25 Sep 04, st001906@hrz1.hrz.tu-darmstadt.de: added stdlib.h for djgpp
3333 * 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
3535 * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
3636 * 17 Dec 07, daved@physiol.usyd.edu.au: added support for --noremap from
3737 * David Santinoli
5757 #include <string.h>
5858 #endif
5959
60 #ifndef _WIN32
6061 #include <arpa/inet.h>
62 #endif
6163
6264 #include "malloc.h"
6365 #include "defs.h"
7577 * Returns: Output personality struct.
7678 *=======================================================================*/
7779
78 OutputPersonality*
79 op_create ()
80 OutputPersonality *
81 op_create()
8082 {
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));
8486 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));
8892 return new_op;
8993 }
9094
97101 *=======================================================================*/
98102
99103 void
100 op_free (OutputPersonality *op)
104 op_free(OutputPersonality *op)
101105 {
102106 CHECK_PARAM_NOT_NULL(op);
103107
104 my_free ((void*) op);
108 my_free((void *) op);
105109 }
106110
107111
113117 * computation of Symbol code point in fields).
114118 * We cache a local iconv descriptor for efficiency.
115119 * Args: OutputPersonality, encoding, character.
116 * Returns: String.
120 * Returns: malloced string to be freed by caller.
117121 *=======================================================================*/
118122 const char *
119 op_translate_char (OutputPersonality *op, char *encoding, int ch)
123 op_translate_char(OutputPersonality *op, char *encoding, int ch)
120124 {
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
167188 #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;
188217 }
189218
190219 /*========================================================================
191220 * Name: op_translate_buffer
192221 * 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
194223 * (just the byte order), then transform according to outputpersonality
195224 * TOBEDONE: have a way to specify direct UTF-8 output for a personality
196225 * (then produce utf-8 in convert.c and do nothing special here.
197 *
226 *
198227 * Args: OutputPersonality, encoding, character.
199228 * Returns: malloced string.
200229 *=======================================================================*/
201230 char *
202231 op_translate_buffer(OutputPersonality *op, char *buffer, int bytescnt)
203232 {
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;
246293 }
247294
248295 /*========================================================================
249 * Name: op_begin_std_fontsize
296 * Name: op_begin_std_fontsize
250297 * Purpose: Prints whatever is necessary to perform a change in the
251298 * current font size.
252299 * Args: OutputPersonality, desired size.
254301 *=======================================================================*/
255302
256303 void
257 op_begin_std_fontsize (OutputPersonality *op, int size)
304 op_begin_std_fontsize(OutputPersonality *op, int size)
258305 {
259306 int found_std_expr = FALSE;
260307
262309
263310 /* Look for an exact match with a standard point size.
264311 */
265 switch (size) {
312 switch (size)
313 {
266314 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 }
269321 found_std_expr = TRUE;
270322 }
271323 break;
272324 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 }
275331 found_std_expr = TRUE;
276332 }
277333 break;
278334 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 }
281341 found_std_expr = TRUE;
282342 }
283343 break;
284344 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 }
287351 found_std_expr = TRUE;
288352 }
289353 break;
290354 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 }
293361 found_std_expr = TRUE;
294362 }
295363 break;
296364 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 }
299371 found_std_expr = TRUE;
300372 }
301373 break;
302374 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 }
305381 found_std_expr = TRUE;
306382 }
307383 break;
308384 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 }
311391 found_std_expr = TRUE;
312392 }
313393 break;
316396 /* If no exact match, try to write out a change to the
317397 * exact point size.
318398 */
319 if (!found_std_expr) {
320 if (op->fontsize_begin) {
399 if (!found_std_expr)
400 {
401 if (op->fontsize_begin)
402 {
321403 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 {
325412 /* If we cannot write out a change for the exact
326413 * point size, we must approximate to a standard
327414 * size.
328415 */
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 {
346474 /* If we can't even produce a good approximation,
347475 * just try to get a font size near 12 point.
348476 */
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");
361515 }
362516 }
363517 }
366520
367521
368522 /*========================================================================
369 * Name: op_end_std_fontsize
523 * Name: op_end_std_fontsize
370524 * Purpose: Prints whatever is necessary to perform a change in the
371525 * current font size.
372526 * Args: OutputPersonality, desired size.
374528 *=======================================================================*/
375529
376530 void
377 op_end_std_fontsize (OutputPersonality *op, int size)
531 op_end_std_fontsize(OutputPersonality *op, int size)
378532 {
379533 int found_std_expr = FALSE;
380534
382536
383537 /* Look for an exact match with a standard point size.
384538 */
385 switch (size) {
539 switch (size)
540 {
386541 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 }
389548 found_std_expr = TRUE;
390549 }
391550 break;
392551 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 }
395558 found_std_expr = TRUE;
396559 }
397560 break;
398561 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 }
401568 found_std_expr = TRUE;
402569 }
403570 break;
404571 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 }
407578 found_std_expr = TRUE;
408579 }
409580 break;
410581 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 }
413588 found_std_expr = TRUE;
414589 }
415590 break;
416591 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 }
419598 found_std_expr = TRUE;
420599 }
421600 break;
422601 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 }
425608 found_std_expr = TRUE;
426609 }
427610 break;
428611 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 }
431618 found_std_expr = TRUE;
432619 }
433620 break;
436623 /* If no exact match, try to write out a change to the
437624 * exact point size.
438625 */
439 if (!found_std_expr) {
440 if (op->fontsize_end) {
626 if (!found_std_expr)
627 {
628 if (op->fontsize_end)
629 {
441630 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 {
445639 /* If we cannot write out a change for the exact
446640 * point size, we must approximate to a standard
447641 * size.
448642 */
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");
488742 }
489743 }
490744 }
4141
4242 typedef Collection Aliases;
4343
44 typedef struct {
44 typedef struct
45 {
4546 char *comment_begin;
4647 char *comment_end;
4748
182183
183184 char *outline_begin;
184185 char *outline_end;
186
187 char *all_caps_begin;
188 char *all_caps_end;
185189
186190 char *small_caps_begin;
187191 char *small_caps_end;
215219 /* XX These should really be replaced by references
216220 * to one of the charsets.
217221 */
218 struct {
222 struct
223 {
219224 char *bullet;
220225 char *left_quote;
221226 char *right_quote;
243248 OutputPersonality;
244249
245250
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,
250255 int bytescnt);
251256
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);
254259
255260 void add_alias(OutputPersonality *op, int nr, char *text);
256261 const char *get_alias(OutputPersonality *op, int nr);
3232 * 03 Aug 01, tuorfa@yahoo.com: added input buffering
3333 * 19 Sep 01, tuorfa@yahoo.com: cleaned up read_word()
3434 * 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
3636 * 08 Sep 03, daved@physiol.usyd.edu.au: type fixes; ANSI C fixes
3737 * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
3838 * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
8181 * Returns: None.
8282 *=======================================================================*/
8383
84 static void my_unget_char (int ch)
84 static void my_unget_char(int ch)
8585 {
86 if (ungot_char>=0 && ungot_char2>=0 && ungot_char3>=0)
86 if (ungot_char >= 0 && ungot_char2 >= 0 && ungot_char3 >= 0)
87 {
8788 error_handler("More than 3 ungot chars");
89 }
8890
8991 ungot_char3 = ungot_char2;
9092 ungot_char2 = ungot_char;
9294 }
9395
9496
95 static int last_returned_ch=0;
97 static int last_returned_ch = 0;
9698
9799
98100 #define READ_BUF_LEN 2048
112114 * Returns: Character, or EOF.
113115 *=======================================================================*/
114116
115 static int my_getchar (FILE* f)
117 static int my_getchar(FILE *f)
116118 {
117119 int ch;
118120
119121 CHECK_PARAM_NOT_NULL(f);
120122
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;
124127 ungot_char2 = ungot_char3;
125128 ungot_char3 = -1;
126129 last_returned_ch = ch;
127 if(ch > 255)
130 if (ch > 255)
128131 {
129132 fprintf(stderr, "returning bad ch = '%c' (0%o)\n",
130 ch, ch);
133 ch, ch);
131134 }
132135 return ch;
133136 }
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 {
137143 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 {
140147 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 {
143151 error_handler("Cannot allocate read buffer");
152 }
144153 }
145154 }
146 read_buf_end = fread (read_buf, 1, buffer_size, f);
155 read_buf_end = fread(read_buf, 1, buffer_size, f);
147156 read_buf_index = 0;
148157 if (!read_buf_end)
158 {
149159 return EOF;
160 }
150161 }
151162 ch = read_buf [read_buf_index++];
152163
153 if (ch=='\n') {
164 if (ch == '\n')
165 {
154166 lineno++;
155167 /* 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');
160173 ch = 'p';
161174 break;
162175 }
163176 }
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 }
168184
169185 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);
173189 exit(1);
174190 }
175191 return ch;
183199 * Returns: None.
184200 *=======================================================================*/
185201
186 static void my_skip (FILE *f, long n)
202 static void my_skip(FILE *f, long n)
187203 {
188204 n += read_buf_index;
189205 if (n >= 0 && n < read_buf_end)
193209 }
194210 read_buf_end = read_buf_index = 0;
195211 if (fseek(f, n - read_buf_end, SEEK_CUR))
212 {
196213 error_handler("Cannot seek");
214 }
197215 return;
198216 }
199217
212230 *=======================================================================*/
213231
214232 static int
215 expand_word_buffer ()
233 expand_word_buffer()
216234 {
217235 char *new_ptr;
218236 unsigned long old_length;
219237 if (!input_str)
238 {
220239 error_handler("No input buffer allocated");
240 }
221241 old_length = current_max_length;
222242 current_max_length *= 2;
223 new_ptr = my_malloc (current_max_length);
243 new_ptr = my_malloc(current_max_length);
224244 if (!new_ptr)
245 {
225246 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);
228250 my_free(input_str);
229251 input_str = new_ptr;
230252 return TRUE;
241263 * Note: The word buffer is static and local to this file.
242264 *=======================================================================*/
243265
244 static int
245 read_word (FILE *f)
266 static int
267 read_word(FILE *f)
246268 {
247269 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;
253275
254276 CHECK_PARAM_NOT_NULL(f);
255277
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 {
265292 ch = my_getchar(f);
266 }
267 while (ch=='\n');
268
269 if (ch==' ')
293 }
294 while (ch == '\n');
295
296 if (ch == ' ')
270297 {
271298 /* Compress multiple space chars down to one.
272299 */
273 while (ch == ' ') {
300 while (ch == ' ')
301 {
274302 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;
281310 return 1;
282311 }
283312 }
284313
285 switch(ch)
286 {
287 case EOF:
314 switch (ch)
315 {
316 case EOF:
288317 return 0;
289318
290319 case '\\':
292321
293322 /* Look for two-character command words.
294323 */
295 switch (ch2)
324 switch (ch2)
296325 {
297326 case '\n':
298 strcpy (input_str, "\\par");
327 strcpy(input_str, "\\par");
299328 return 4;
300329 case '~':
301330 case '{':
310339 case '\'':
311340 /* Preserve \'## expressions (hex char exprs) for later.
312341 */
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 {
318349 error_handler("Word too long");
350 }
319351 }
320352 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 {
324358 error_handler("Word too long");
359 }
325360 }
326361 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 {
330367 error_handler("Word too long");
331 }
332 input_str[ix]=0;
368 }
369 }
370 input_str[ix] = 0;
333371 return ix;
334372 }
335373
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;
340378 break;
341379
342380 case '\t':
343381 /* In RTF, a tab char is the same as \tab.
344382 */
345 strcpy (input_str, "\\tab");
383 strcpy(input_str, "\\tab");
346384 return 4;
347385
348386 case '{':
349387 case '}':
350388 case ';':
351 input_str[0]=ch;
352 input_str[1]=0;
389 input_str[0] = ch;
390 input_str[1] = 0;
353391 return 1;
354392
355393 }
356394
357 while (ch!=EOF)
395 while (ch != EOF)
358396 {
359397 /* Several chars always ends a word, and we need to save them.
360398 */
361 if (ch=='\t' || ch=='{' || ch=='}' || ch=='\\') {
362 need_unget=TRUE;
399 if (ch == '\t' || ch == '{' || ch == '}' || ch == '\\')
400 {
401 need_unget = TRUE;
363402 break;
364403 }
365404
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.
367406 * A newline is ignored if this is not a command word.
368407 */
369 if (ch=='\n') {
370 if (is_control_word)
408 if (ch == '\n')
409 {
410 if (is_control_word)
411 {
371412 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.
377419 * A semicolon never ends a regular word.
378420 */
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;
382426 break;
383427 }
384428 }
387431 * any word, and if it does not follow a command,
388432 * then it is a word in itself.
389433 */
390 if (ch==' ') {
434 if (ch == ' ')
435 {
391436 if (!is_control_word)
392 need_unget=TRUE;
437 {
438 need_unget = TRUE;
439 }
393440 break;
394441 }
395442
396443 /* Identify a control word's numeric parameter.
397444 */
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 {
400449 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 }
405457 break;
406458 }
407459 }
408
460
409461 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 {
412466 error_handler("Word too long");
413 }
414 ch = my_getchar (f);
467 }
468 }
469 ch = my_getchar(f);
415470 }
416471
417472 if (need_unget)
473 {
418474 my_unget_char(ch);
419
420 input_str[ix]=0;
475 }
476
477 input_str[ix] = 0;
421478
422479 if (!memcmp(input_str, "\\bin", 4) && isdigit(input_str[4]))
480 {
423481 my_skip(f, atoi(input_str + 4));
482 }
424483
425484 return ix;
426485 }
429488
430489 /*========================================================================
431490 * 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
433492 * structure of Word objects.
434493 * Args: Input file.
435494 * Returns: Tree of Word objects.
436495 *=======================================================================*/
437496
438497 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 */
443503
444504 CHECK_PARAM_NOT_NULL(f);
445505
446 do {
506 do
507 {
447508 if (!read_word(f))
509 {
448510 return first_word;
449
450 if (input_str[0] == '{') {
511 }
512
513 if (input_str[0] == '{')
514 {
451515 /* Process subwords */
452516
453517 /* Create a dummy word to point to a sublist */
454518 new_word = word_new(NULL);
455519 if (!new_word)
520 {
456521 error_handler("Cannot allocate word");
522 }
457523
458524 /* Get the sublist */
459525 new_word->child = word_read(f);
460526
461 } else if (input_str[0] == '}') {
527 }
528 else if (input_str[0] == '}')
529 {
462530 return first_word;
463 } else {
531 }
532 else
533 {
464534 new_word = word_new(input_str);
465535 }
466536
467537 if (prev_word)
538 {
468539 prev_word->next = new_word;
540 }
469541
470542 if (!first_word)
543 {
471544 first_word = new_word;
545 }
472546
473547 prev_word = new_word;
474548
475549 /* Free up the memory allocated by read_word. */
476550 my_free(input_str);
477551 input_str = NULL;
478 } while (1);
552 }
553 while (1);
479554 }
3838 #include "word.h"
3939 #include <stdio.h>
4040
41 extern Word *word_read(FILE*);
41 extern Word *word_read(FILE *);
4242
4343
4444 #endif /* _PARSE_H_INCLUDED_ */
0 #ifdef HAVE_CONFIG_H
1 #include "config.h"
2 #endif
3
04 #include <stdio.h>
15 #include <string.h>
6 #ifdef HAVE_UNISTD_H
27 #include <unistd.h>
8 #else
9 #include "safeunistd.h"
10 #endif
11
312 #include <stdlib.h>
413
514 #include "path.h"
1322
1423 char *search_in_path(const char *name, char *suffix)
1524 {
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;
2130
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);
2490 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;
6791 }
6892
6993 int check_dirs()
7094 {
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;
7599
76 /*fprintf(stderr, "check_dirs: search_path: [%s]\n", search_path);*/
100 /*fprintf(stderr, "check_dirs: search_path: [%s]\n", search_path);*/
77101
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 }
85114
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);
100131 }
101132
102133 void show_dirs()
103134 {
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 }
113147 }
00 #ifndef _PATH_H_INCLUDED_
11 #define _PATH_H_INCLUDED_
22
3 #ifndef DEFAULT_UNRTF_SEARCH_PATH
34 #define DEFAULT_UNRTF_SEARCH_PATH CONFIG_DIR
5 #endif
46
57 extern char *search_path;
68 extern int path_checked;
79
810 struct path_dir
911 {
10 char *dir_name;
11 struct path_dir *next;
12 char *dir_name;
13 struct path_dir *next;
1214 };
1315
1416 extern int check_dirs();
2626 int
2727 get_unicode(char *string)
2828 {
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;
3436 }
3537
3638 /*========================================================================
4244 char *
4345 unicode_to_utf8(unsigned int uc)
4446 {
45 unsigned char *string = NULL;
47 unsigned char *string = NULL;
4648 if (uc < 0x7f)
4749 {
4850 string = (unsigned char *)my_malloc(2 * sizeof(char));
5153 }
5254 else if (uc < 0x7ff)
5355 {
54 string = (unsigned char *)my_malloc(3 * sizeof(char));
56 string = (unsigned char *)my_malloc(3 * sizeof(char));
5557 string[0] = (unsigned char) 192 + (uc / 64);
5658 string[1] = (unsigned char) 128 + (uc % 64);
5759 string[2] = '\0';
5860 }
5961 else if (uc < 0xffff)
6062 {
61 string = (unsigned char *)my_malloc(4 * sizeof(char));
63 string = (unsigned char *)my_malloc(4 * sizeof(char));
6264 string[0] = (unsigned char) 224 + (uc / (64 * 64));
6365 string[1] = (unsigned char) 128 + ((uc / 64) % 64);
6466 string[2] = (unsigned char) 128 + (uc % 64);
6668 }
6769 else if (uc < 0x1FFFFF)
6870 {
69 string = (unsigned char *)my_malloc(5 * sizeof(char));
71 string = (unsigned char *)my_malloc(5 * sizeof(char));
7072 string[0] = (unsigned char) 240 + (uc / (64 * 64 * 64));
7173 string[1] = (unsigned char) 128 + ((uc / (64 * 64)) % 64);
7274 string[2] = (unsigned char) 128 + ((uc / 64) % 64);
7577 }
7678 else if (uc < 0x3FFFFFF)
7779 {
78 string = (unsigned char *)my_malloc(6 * sizeof(char));
80 string = (unsigned char *)my_malloc(6 * sizeof(char));
7981 string[0] = (unsigned char) 248 + (uc / (64 * 64 * 64 * 64));
8082 string[1] = (unsigned char) 128 + ((uc / (64 * 64 * 64)) % 64);
8183 string[2] = (unsigned char) 128 + ((uc / (64 * 64)) % 64);
8587 }
8688 else if (uc < 0x7FFFFFFF)
8789 {
88 string = (unsigned char *)my_malloc(7 * sizeof(char));
90 string = (unsigned char *)my_malloc(7 * sizeof(char));
8991 string[0] = (unsigned char) 252 + (uc / (64 * 64 * 64 * 64 * 64));
9092 string[1] = (unsigned char) 128 + ((uc / (64 * 64 * 64 * 64)) % 64);
9193 string[2] = (unsigned char) 128 + ((uc / (64 * 64 * 64)) % 64);
101103 /*========================================================================
102104 * Name get_unicode_int
103105 * 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.
105108 * Caution: This function should be executed after char '<' was read.
106109 It reads until char '>' was found or EOL or EOF.
107110 * Args: File to read from.
108 * Returns: Unicode character encoded in UTF-8
111 * Returns: integer Unicode code point
109112 *=======================================================================*/
110113
111114 int
112115 get_unicode_int(FILE *file)
113116 {
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;
116121
117122 c = fgetc(file);
118123
122127 c = fgetc(file);
123128 len++;
124129
125 if (len == allocated)
130 if (len == MAX_CHARMAP_UC_LEN-1)
126131 {
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;
129134 }
130135 }
131136
132137 if (c != '>')
138 {
133139 ungetc(c, file);
140 }
134141
135142 unicode_number[len] = '\0';
136143 return get_unicode(unicode_number);
139146 char *
140147 get_unicode_utf8(FILE *file)
141148 {
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);
144151 }
5959 my_FILE *f = (my_FILE *) malloc(sizeof(my_FILE));
6060
6161 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 }
6365
6466 f->line_nr = 1;
6567 strcpy(f->name, file_name);
105107 C = fgetc(F); \
106108 if (feof(F) || ferror(F)) \
107109 goto inputend; \
108 }
110 }
109111
110112 char *
111113 give_definition(my_FILE *file)
115117 unsigned long def_buffer_length = STANDARD_BUFFER_LENGTH, chars_nr = 0;
116118
117119 if ((def = my_malloc(def_buffer_length)) == NULL)
120 {
118121 return NULL;
122 }
119123
120124 GETC_OR_END(file->file, c);
121125
122126 while (c == '\t' || c == '#')
123127 {
124128 if (c == '#')
129 {
125130 leave_line(file->file);
131 }
126132 else
127133 {
128134 GETC_OR_END(file->file, c);
135141
136142 for (i = 0; unicode_char[i] != '\0'; i++)
137143 ADD_CHAR(unicode_char[i])
138 GETC_OR_END(file->file, c);
144 GETC_OR_END(file->file, c);
139145 c2 = 0;
140146 c3 = 0;
141147 c4 = 0;
146152 {
147153 ADD_CHAR('<');
148154 }
149 /* daved - 0.21.3 - allow escaping a backslash */
155 /* daved - 0.21.3 - allow escaping a backslash */
150156 if (c == '\\' && c2 == '\\')
151157 {
152158 ADD_CHAR('\\');
156162 }
157163 else
158164
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 }
169174
170175 c4 = c3;
171176 c3 = c2;
188193 }
189194
190195 if (chars_nr > 0)
196 {
191197 def[chars_nr - 1] = '\0';
198 }
192199 else
200 {
193201 def[0] = '\0';
202 }
194203
195204 return def;
196205 }
205214 *=======================================================================*/
206215
207216 int
208 match_name (char *name, OutputPersonality *op, my_FILE *file)
217 match_name(char *name, OutputPersonality *op, my_FILE *file)
209218 {
210219 struct definition
211220 {
229238 i = strtol(name, &endptr, 10);
230239
231240 if (*endptr == '\0')
241 {
232242 add_alias(op, i, give_definition(file));
243 }
233244 else if (name[0] == '<' && name[1] == 'U')
245 {
234246 add_alias(op, get_unicode(&name[2]), give_definition(file));
247 }
235248 else
236 {
249 {
237250 fprintf(stderr, "unrtf: unknown name \"%s\" in line %d of \"%s\"\n", name, file->line_nr, file->name);
238251 return 1;
239252 }
240253 }
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 }
244258
245259 return 0;
246260 }
253267 *=======================================================================*/
254268
255269 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;
259273 char name_buffer[BUFFER_SIZE];
274 int err = 1;
260275
261276 if (op == NULL)
277 {
262278 op = op_create();
279 }
263280
264281 if ((f = my_fopen(definitions_file_path, "r")) == NULL)
265282 {
266283 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 }
275299
276300 f->line_nr++;
277301
278302 if (name_buffer[0] != '#' && name_buffer[0] != '\n')
279303 {
280 name_buffer[strlen(name_buffer) - 1] = '\0';
304 name_buffer[ll - 1] = '\0';
281305
282306 if (match_name(name_buffer, op, f) == -1)
283307 {
284 my_fclose(f);
285 free(f);
286 return NULL;
308 goto out;
287309 }
288310 }
289311 }
290312
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
112112 DEFS_ARRAY_ENTRY(shadow_end, op),\
113113 DEFS_ARRAY_ENTRY(outline_begin, op),\
114114 DEFS_ARRAY_ENTRY(outline_end, op),\
115 DEFS_ARRAY_ENTRY(all_caps_begin, op),\
116 DEFS_ARRAY_ENTRY(all_caps_end, op),\
115117 DEFS_ARRAY_ENTRY(small_caps_begin, op),\
116118 DEFS_ARRAY_ENTRY(small_caps_end, op),\
117119 DEFS_ARRAY_ENTRY(pointlist_begin, op),\
157159 #ifndef _USER
158160
159161
160 extern OutputPersonality* user_init(OutputPersonality *, char *tags_file_path);
162 extern OutputPersonality *user_init(OutputPersonality *, char *tags_file_path);
161163
162164
163165 #define _USER
2626 * Purpose: Utility functions.
2727 *----------------------------------------------------------------------
2828 * 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
3030 * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
3131 * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
3232 * 09 Nov 08, arkadiusz.firus@gmail.com: added leave_line
6262
6363 /* Convert a two-char hexadecimal expression to an integer */
6464 int
65 h2toi (const char *s) {
65 h2toi(const char *s)
66 {
6667 int tmp;
6768 int ch;
6869 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;
7279 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;
7689 return ch;
7790 }
7891
8497 *=======================================================================*/
8598
8699 void
87 leave_line (FILE *f)
100 leave_line(FILE *f)
88101 {
89102 int c;
90103
91104 do
92105 {
93106 c = fgetc(f);
94 } while (c != '\n' && c != EOF);
107 }
108 while (c != '\n' && c != EOF);
95109
96110 return;
97111 }
103117 * Returns: String.
104118 *=======================================================================*/
105119 char *
106 concatenate (const char *s1, const char *s2)
120 concatenate(const char *s1, const char *s2)
107121 {
108122 char *result;
109123
110124 if ((result = my_malloc((strlen(s1) + strlen(s2) + 1) * sizeof(char))) == 0)
111 return 0;
125 {
126 return 0;
127 }
112128 strcpy(result, s1);
113129 strcat(result, s2);
114130
125141 /*
126142 * Note: This is designed for programs that use contiguous blocks of
127143 * 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
129145 * 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:
132148 * - 1st call (cp = 0), allocate min *sz
133149 * - next calls double current size
134150 * - Until current size is maxinc * sz, then increment by maxinc*sz everytime
136152 void *
137153 allocmem
138154 (
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 */
144160 )
145161 {
146 int inc;
162 int inc;
147163
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;
164191 }
3838 #include <stdio.h>
3939 #endif
4040
41 extern int h2toi (const char *);
41 extern int h2toi(const char *);
4242
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 *);
4545
4646 /* Help managing a growing contiguous array */
4747 extern void *
4848 allocmem
4949 (
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) */
5555 );
5656
5757 #endif /* _UTIL_H_INCLUDED_ */
4242 * 21 Apr 01, tuorfa@yahoo.com: fix for words getting lost after \par
4343 * 24 Jul 01, tuorfa@yahoo.com: moved conversion code to convert.c
4444 * 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
4646 * 29 Mar 05, daved@physiol.usyd.edu.au: changes requested by ZT Smith
4747 * 16 Dec 07, daved@physiol.usyd.edu.au: updated to GPL v3
4848 *--------------------------------------------------------------------*/
7777
7878
7979 /* For word_dump */
80 static int indent_level=0;
80 static int indent_level = 0;
8181
8282
8383 /*========================================================================
8989 *=======================================================================*/
9090
9191 const char *
92 word_string (Word *w) {
92 word_string(Word *w)
93 {
9394 CHECK_PARAM_NOT_NULL(w);
9495 return w->str;
9596 }
103104 * Returns: Word*.
104105 *=======================================================================*/
105106
106 Word *
107 word_new (char *str) {
108 Word * w;
107 Word *
108 word_new(char *str)
109 {
110 Word *w;
109111
110112 w = (Word *) my_malloc(sizeof(Word));
111113 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 }
117127
118128 return w;
119129 }
126136 * Returns: None.
127137 *=======================================================================*/
128138
129 void word_free (Word *w) {
139 void word_free(Word *w)
140 {
130141 Word *prev;
131142 Word *w2;
132143
133144 CHECK_PARAM_NOT_NULL(w);
134145
135 while (w) {
146 while (w)
147 {
136148 w2 = w->child;
137149 if (w2)
150 {
138151 word_free(w2);
152 }
139153
140154 prev = w;
141155 w = w->next;
142 my_free((char*) prev);
156 my_free((char *) prev);
143157 }
144158 }
145159
155169 *=======================================================================*/
156170
157171 static void
158 print_indentation (int level)
172 print_indentation(int level)
159173 {
160174 int i;
161175
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");
167186 }
168187 }
169188
178197 *=======================================================================*/
179198
180199 void
181 word_dump (Word *w)
200 word_dump(Word *w)
182201 {
183202 const char *s;
184203
185204 CHECK_PARAM_NOT_NULL(w);
186205
187 printf ("\n");
206 printf("\n");
188207 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);
200224 }
201225 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 }
203229 }
204230 w = w->next;
205231 }
209235
210236 /*========================================================================
211237 * 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.
213240 * Args: Word to optimize.
214241 * Returns: Optimized word.
215242 *=======================================================================*/
222249 Tag tags_to_opt[] = OPT_ARRAY;
223250 Word *root = w, *w2 = 0;
224251
225 if (depth > MAX_GROUP_DEPTH) {
252 if (depth > MAX_GROUP_DEPTH)
253 {
226254 /* Have to be reasonable at some point */
227 warning_handler ("Max group depth reached");
255 warning_handler("Max group depth reached");
228256 return w;
229 }
257 }
230258 for (; w != NULL; w = w->next)
231259 {
232260
238266 {
239267 len = strlen(tags_to_opt[i].name);
240268 if (!strncmp(tags_to_opt[i].name, s, len) && (isdigit(s[len]) || s[len] == '-'))
269 {
241270 break;
271 }
242272 }
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 }
246277 }
247278
248279 if (tags_to_opt[i].name[0] != '\0')
256287 w = w2;
257288 }
258289 else
290 {
259291 c = add_to_collection(c, i, s);
292 }
260293 }
261294 }
262295
263296 if (w->child != NULL)
264 w->child = optimize_word(w->child, depth+1);
297 {
298 w->child = optimize_word(w->child, depth + 1);
299 }
265300
266301 w2 = w;
267302 }
3535 * 25 Sep 11, jf@dockes.org: reposition top #ifndef
3636 *--------------------------------------------------------------------*/
3737
38 typedef struct _w {
38 typedef struct _w
39 {
3940 const char *str;
40 struct _w * next;
41 struct _w * child;
41 struct _w *next;
42 struct _w *child;
4243 } Word;
4344
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 *);
5051
5152 #ifndef MAX_GROUP_DEPTH
5253 #define MAX_GROUP_DEPTH 1000
5354 #endif
54
55 extern Word* optimize_word(Word*, int depth);
5655
57 typedef struct _t {
56 extern Word *optimize_word(Word *, int depth);
57
58 typedef struct _t
59 {
5860 char *name;
5961 int has_param;
6062 } 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.
11 # @configure_input@
22
3 # Copyright (C) 1994-2013 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2017 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
1313
1414 @SET_MAKE@
1515 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 }
1727 am__make_running_with_option = \
1828 case $${target_option-} in \
1929 ?) ;; \
7787 build_triplet = @build@
7888 host_triplet = @host@
7989 subdir = tests
80 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
81 $(top_srcdir)/config/test-driver
8290 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
8391 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
8492 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
8593 $(ACLOCAL_M4)
94 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
8695 mkinstalldirs = $(install_sh) -d
8796 CONFIG_HEADER = $(top_builddir)/config.h
8897 CONFIG_CLEAN_FILES =
311320 TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/config/test-driver
312321 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
313322 $(TEST_LOG_FLAGS)
323 am__DIST_COMMON = $(srcdir)/Makefile.in \
324 $(top_srcdir)/config/test-driver
314325 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
315326 ACLOCAL = @ACLOCAL@
316327 AMTAR = @AMTAR@
566577 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
567578 $(am__cd) $(top_srcdir) && \
568579 $(AUTOMAKE) --gnu tests/Makefile
569 .PRECIOUS: Makefile
570580 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
571581 @case '$?' in \
572582 *config.status*) \
621631 if test -n "$$am__remaking_logs"; then \
622632 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
623633 "recursion detected" >&2; \
624 else \
634 elif test -n "$$redo_logs"; then \
625635 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
626636 fi; \
627637 if $(am__make_dryrun); then :; else \
920930 mostlyclean-generic pdf pdf-am ps ps-am recheck tags-am \
921931 uninstall uninstall-am
922932
933 .PRECIOUS: Makefile
934
923935
924936 # ensure that the distributed scripts are executable before distribution.
925937 # Could be necessary if checking out CVS.
3636 \par }{\impr\cf8\insrsid4857473 This text is formatted with engrave.
3737 \par }{\scaps\insrsid4857473 This text is formatted with small caps.
3838 \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.
4040 \par }{\v\insrsid4857473 This text is formatted as hidden.}{\insrsid4857473
4141 \par
4242 \par Character spacing is 100%