Debian Codegraph @

texk/tex4htk/t4ht.c

raw ◀ ▶
1 Debian patch touch this file
1
2 #line 145 "./tex4ht-t4ht.tex"
3
4 /* t4ht.c (2018-07-04-14:25), generated from tex4ht-t4ht.tex
5 Copyright (C) 2009-2018 TeX Users Group
6 Copyright (C) 1998-2009 Eitan M. Gurari
7
8 #line 1 "./tex4ht-t4ht.tex"
9
10 %
11 % This work may be distributed and/or modified under the
12 % conditions of the LaTeX Project Public License, either
13 % version 1.3c of this license or (at your option) any
14 % later version. The latest version of this license is in
15 % http://www.latex-project.org/lppl.txt
16 % and version 1.3c or later is part of all distributions
17 % of LaTeX version 2005/12/01 or later.
18 %
19 % This work has the LPPL maintenance status "maintained".
20 %
21 % The Current Maintainer of this work
22 % is the TeX4ht Project <http://tug.org/tex4ht>.
23 %
24 % If you modify this program, changing the
25 % version identification would be appreciated.
26
27 */
28
29 #line 334 "./tex4ht-t4ht.tex"
30
31 /* **********************************************
32 Compiler options *
33 (uncommented | command line) *
34 ------------------------------------------------*
35 Classic C (CC) default
36 #define ANSI ansi-c, c++
37 #define DOS_C
38 #define HAVE_STRING_H <string.h>
39 #define HAVE_DIRENT_H <dirent.h>
40 #define HAVE_SYS_NDIR_H <sys/ndir.h>
41 #define HAVE_SYS_DIR_H <sys/dir.h>
42 #define HAVE_NDIR_H <ndir.h>
43 #define HAVE_IO_H <io.h>
44 #define HAVE_UNISTD_H <unistd.h>
45 #define WIN32
46 #define KPATHSEA
47 #define SYSTEM_FUNCTION_OK
48 #define CDECL ..........
49 #define BCC32 bordland c++
50
51 *************************************************
52 Tex4ht variables *
53 (uncommented | command line) *
54 ----------------------------------------------- */
55
56 #line 3237 "./tex4ht-t4ht.tex"
57
58 #ifndef ENVFILE
59
60 #endif
61
62
63 /* ******************************************** */
64
65
66 #line 384 "./tex4ht-t4ht.tex"
67
68 #ifdef BCC32
69 #define WIN32
70 #define ANSI
71 #define HAVE_IO_H
72 #define HAVE_STRING_H
73 #define PLATFORM "ms-win32"
74 #endif
75
76
77
78 #line 396 "./tex4ht-t4ht.tex"
79
80 #ifdef BCC
81 #define DOS_C
82 #define ANSI
83 #define HAVE_IO_H
84 #define PLATFORM "ms-dos"
85 #endif
86
87
88
89 #line 758 "./tex4ht-t4ht.tex"
90
91 #ifdef __DJGPP__
92 #define DOS_WIN32
93 #define ANSI
94 #endif
95
96
97 #ifdef DOS_C
98 #define DOS
99 #endif
100 #ifdef DOS
101 #define DOS_WIN32
102 #ifndef HAVE_STRING_H
103 #define HAVE_STRING_H
104 #endif
105 #endif
106 #ifdef WIN32
107 #define DOS_WIN32
108 #endif
109
110 #line 436 "./tex4ht-t4ht.tex"
111
112 #ifdef DOS_WIN32
113 #define STRUCT_DIRENT
114 #endif
115
116
117
118 #line 579 "./tex4ht-t4ht.tex"
119
120 #ifdef KPATHSEA
121 #ifdef WIN32
122 #define KWIN32
123 #endif
124 #endif
125
126
127
128 #line 406 "./tex4ht-t4ht.tex"
129
130 #ifdef KPATHSEA
131 #include <kpathsea/config.h>
132 #endif
133 #include <stdio.h>
134 #include <stdlib.h>
135
136
137 #line 427 "./tex4ht-t4ht.tex"
138
139 #ifdef HAVE_STRING_H
140 #include <string.h>
141 #endif
142
143
144 #line 443 "./tex4ht-t4ht.tex"
145
146 #ifdef HAVE_DIRENT_H
147
148 #line 456 "./tex4ht-t4ht.tex"
149
150 #include <dirent.h>
151
152
153 #else
154 #ifndef STRUCT_DIRENT
155 #define STRUCT_DIRECT
156 #endif
157
158 #line 461 "./tex4ht-t4ht.tex"
159
160 #ifdef HAVE_SYS_NDIR_H
161 #include <sys/ndir.h>
162 #endif
163 #ifdef HAVE_SYS_DIR_H
164 #include <sys/dir.h>
165 #endif
166 #ifdef HAVE_NDIR_H
167 #include <ndir.h>
168 #endif
169
170
171 #endif
172
173
174 #line 3978 "./tex4ht-t4ht.tex"
175
176 #include <signal.h>
177
178
179
180 #line 542 "./tex4ht-t4ht.tex"
181
182
183 #line 3500 "./tex4ht-t4ht.tex"
184
185 #ifndef __DJGPP__
186
187 #line 3534 "./tex4ht-t4ht.tex"
188
189 #ifndef F_OK
190 #ifdef DOS_WIN32
191 #define F_OK 0
192 #endif
193 #ifndef KPATHSEA
194 #ifndef DOS_WIN32
195 #define HAVE_UNISTD_H
196 #endif
197 #endif
198 #endif
199 #ifdef HAVE_IO_H
200 #include <io.h>
201 #endif
202 #ifndef KPATHSEA
203 #ifdef HAVE_UNISTD_H
204 #include <unistd.h>
205 #endif
206 #endif
207
208
209 #endif
210
211
212 #ifdef KPATHSEA
213 #include <kpathsea/c-errno.h>
214 #include <kpathsea/c-ctype.h>
215 #include <kpathsea/c-fopen.h>
216 #include <kpathsea/c-pathmx.h>
217 #include <kpathsea/proginit.h>
218 #include <kpathsea/tex-file.h>
219 #include <kpathsea/tex-make.h>
220 #include <kpathsea/variable.h>
221 #include <signal.h>
222 #if !defined(_AMIGA) && !defined(WIN32)
223 #include <sys/time.h>
224 #endif
225 #include <fcntl.h>
226 #include <setjmp.h>
227 #endif
228
229 #line 3511 "./tex4ht-t4ht.tex"
230
231 #ifdef __DJGPP__
232
233 #line 3534 "./tex4ht-t4ht.tex"
234
235 #ifndef F_OK
236 #ifdef DOS_WIN32
237 #define F_OK 0
238 #endif
239 #ifndef KPATHSEA
240 #ifndef DOS_WIN32
241 #define HAVE_UNISTD_H
242 #endif
243 #endif
244 #endif
245 #ifdef HAVE_IO_H
246 #include <io.h>
247 #endif
248 #ifndef KPATHSEA
249 #ifdef HAVE_UNISTD_H
250 #include <unistd.h>
251 #endif
252 #endif
253
254
255 #endif
256
257
258
259
260
261
262 #line 479 "./tex4ht-t4ht.tex"
263
264 #ifdef DOS
265 #define PROTOTYP
266 #endif
267 #ifdef ANSI
268 #define PROTOTYP
269 #endif
270 #ifdef KWIN32
271 #define PROTOTYP
272 #endif
273
274
275 #line 568 "./tex4ht-t4ht.tex"
276
277 #ifdef KPATHSEA
278 #ifdef WIN32
279 #undef CDECL
280 #define CDECL __cdecl
281 #else
282 #define CDECL
283 #endif
284 #endif
285
286
287 #line 3793 "./tex4ht-t4ht.tex"
288
289 #if defined(DOS_WIN32) || defined(__MSDOS__)
290 #define READ_BIN_FLAGS "rb"
291 #define READ_TEXT_FLAGS "r"
292 #define WRITE_BIN_FLAGS "wb"
293 #ifdef WIN32
294 #define WRITE_TEXT_FLAGS "wb"
295 #else
296 #define WRITE_TEXT_FLAGS "w"
297 #endif
298 #else
299 #define READ_BIN_FLAGS "r"
300 #define READ_TEXT_FLAGS "r"
301 #define WRITE_BIN_FLAGS "w"
302 #define WRITE_TEXT_FLAGS "w"
303 #endif
304
305
306
307 #line 234 "./tex4ht-t4ht.tex"
308
309 #define Q_CHAR char
310 #define U_CHAR char
311 #define C_CHAR char
312 #define Q_NULL (Q_CHAR *) 0
313 #define U_NULL (U_CHAR *) 0
314 #define C_NULL (C_CHAR *) 0
315
316
317 #line 328 "./tex4ht-t4ht.tex"
318
319 #define IGNORED void
320
321
322 #line 421 "./tex4ht-t4ht.tex"
323
324 #ifndef EXIT_FAILURE
325 #define EXIT_FAILURE 1
326 #endif
327
328
329 #line 491 "./tex4ht-t4ht.tex"
330
331 #ifdef PROTOTYP
332 #define MYVOID void
333 #define ARG_I(x) x
334 #define ARG_II(x,y) x,y
335 #define ARG_III(x,y,z) x,y,z
336 #define ARG_IV(x,y,z,w) x,y,z,w
337 #define ARG_V(x,y,z,w,u) x,y,z,w,u
338 #else
339 #define MYVOID
340 #define ARG_I(x)
341 #define ARG_II(x,y)
342 #define ARG_III(x,y,z)
343 #define ARG_IV(x,y,z,w)
344 #define ARG_V(x,y,z,w,u)
345 #endif
346
347
348 #line 783 "./tex4ht-t4ht.tex"
349
350 #if defined(DOS_WIN32) || defined(__DJGPP__)
351 #define dir_path_slash(str) (is_forward_slash(str)? '/' : '\\')
352 #else
353 #define dir_path_slash(str) '/'
354 #endif
355
356
357 #line 1158 "./tex4ht-t4ht.tex"
358
359 struct empty_pic_struct{
360 long int n;
361 struct empty_pic_struct *next;
362 };
363
364
365 #line 1501 "./tex4ht-t4ht.tex"
366
367 #ifndef HTFDIR
368 #define HTFDIR ""
369 #endif
370
371
372 #line 2039 "./tex4ht-t4ht.tex"
373
374 struct files_rec{
375 FILE* file;
376 char *name, *group, op;
377 Q_CHAR file_mode[5];
378 int loc, label;
379 struct files_rec *from_rec, *right, *left, *down, *up;
380 };
381 #define No_op 0
382 #define From_op 1
383 #define Until_op 2
384 #define Skip_op 3
385 #define Cont_op 4
386 #define Addr_op 5
387 #define Set_op 6
388
389
390 #line 2181 "./tex4ht-t4ht.tex"
391
392 struct env_c_rec{
393 Q_CHAR *option;
394 struct env_c_rec *next;
395 };
396
397
398 #line 2311 "./tex4ht-t4ht.tex"
399
400 struct sys_call_rec{
401 Q_CHAR * filter;
402 struct sys_call_rec *next;
403 };
404
405
406 #line 2361 "./tex4ht-t4ht.tex"
407
408 struct htf_struct{
409 Q_CHAR *key, *body, *media;
410 struct htf_struct *next;
411 };
412
413
414 #line 3092 "./tex4ht-t4ht.tex"
415
416 struct script_struct{
417 Q_CHAR *command;
418 struct script_struct *next;
419 };
420
421
422 #line 3111 "./tex4ht-t4ht.tex"
423
424 #define NULL_SCRIPT (struct script_struct *) 0
425
426
427 #line 3722 "./tex4ht-t4ht.tex"
428
429 #define LG_EXT ".lg"
430
431
432 #line 3854 "./tex4ht-t4ht.tex"
433
434 #define bad_arg err_arg(0)
435 #define bad_mem err_i(1)
436
437
438 #line 4205 "./tex4ht-t4ht.tex"
439
440 #define eq_str(x,y) (!strcmp(x,y))
441
442
443 #line 4259 "./tex4ht-t4ht.tex"
444
445 #define m_alloc(typ,n) (typ *) malloc_chk((int) ((n) * sizeof(typ)))
446
447
448 #line 4494 "./tex4ht-t4ht.tex"
449
450 #ifndef TRUE
451 #define TRUE 1
452 #endif
453 #ifndef FALSE
454 #define FALSE 0
455 #endif
456 #ifndef BOOL
457 #define BOOL int
458 #endif
459
460
461 #line 4508 "./tex4ht-t4ht.tex"
462
463 #define eq_str(x,y) (!strcmp(x,y))
464
465
466
467 #line 246 "./tex4ht-t4ht.tex"
468
469 static int eoln_ch;
470
471
472 #line 292 "./tex4ht-t4ht.tex"
473
474 static BOOL check_tex4ht_c_err = FALSE;
475
476
477 #line 878 "./tex4ht-t4ht.tex"
478
479 static Q_CHAR *ch_mod = Q_NULL;
480 static Q_CHAR *debug = Q_NULL;
481 static Q_CHAR *Xfield = Q_NULL;
482 static Q_CHAR *Dotfield = Q_NULL;
483 static Q_CHAR *dir = Q_NULL;
484 static Q_CHAR *lg_name = Q_NULL, tmp_name[255], job_name[255];
485 static Q_CHAR *nopict = Q_NULL;
486 static Q_CHAR *bitmaps_no_dm = Q_NULL;
487 static BOOL newchmod = FALSE;
488 static Q_CHAR *noreuse = Q_NULL;
489
490
491 #line 1100 "./tex4ht-t4ht.tex"
492
493 U_CHAR *HOME_DIR;
494
495
496 #line 2188 "./tex4ht-t4ht.tex"
497
498 static struct env_c_rec *envChoice
499 = (struct env_c_rec*) 0;
500
501
502 #line 2319 "./tex4ht-t4ht.tex"
503
504 static BOOL system_yes;
505 static struct sys_call_rec *system_calls = (struct sys_call_rec *) 0;
506
507
508 #line 2356 "./tex4ht-t4ht.tex"
509
510 static struct htf_struct *htf_rec = (struct htf_struct *) 0;
511
512
513 #line 2605 "./tex4ht-t4ht.tex"
514
515 static BOOL status;
516
517
518 #line 2819 "./tex4ht-t4ht.tex"
519
520 static char *Font_css_base = NULL,
521 *Font_css_mag = NULL;
522 static int base_font_size = 10;
523
524
525 #line 3099 "./tex4ht-t4ht.tex"
526
527 static struct script_struct
528 * dvigif_script = NULL_SCRIPT,
529 * dvigif_glyp_script = NULL_SCRIPT,
530 * move_script = NULL_SCRIPT,
531 * empty_fig_script = NULL_SCRIPT,
532 * copy_script = NULL_SCRIPT,
533 *
534 #line 2239 "./tex4ht-t4ht.tex"
535
536 file_script
537
538 = NULL_SCRIPT,
539 *
540 #line 2175 "./tex4ht-t4ht.tex"
541
542 ext_script
543
544 = NULL_SCRIPT,
545 * chmod_script = NULL_SCRIPT;
546
547
548 #line 3773 "./tex4ht-t4ht.tex"
549
550 static FILE* lg_file;
551 static long begin_lg_file;
552
553
554 #line 3923 "./tex4ht-t4ht.tex"
555
556 static const C_CHAR *warn_err_mssg[]={
557 #line 3845 "./tex4ht-t4ht.tex"
558
559
560 #line 843 "./tex4ht-t4ht.tex"
561
562 "\n--------------------------------------------------------------------\n"
563 "t4ht [-f<dir char>]filename ...\n"
564 " -b ignore -d -m -M for bitmaps\n"
565 " -c... choose named segment in env file\n"
566 " -d... directory for output files (default: current)\n"
567 " -e... location of tex4ht.env\n"
568 " -i debugging info\n"
569 " -g ignore errors in system calls\n"
570 " -m... chmod ... of new output files (reused bitmaps excluded)\n"
571 " -p don't convert pictures (default: convert)\n"
572 " -r replace bitmaps of all glyphs (default: reuse old ones)\n"
573 " -M... chmod ... of all output files\n"
574 " -Q quit, if tex4ht.c had problems\n"
575 " -S... permission for system calls: *-always, filter\n"
576 " -X... content for field %%3 in X scripts\n"
577 " -.... content for field %%2 in . scripts\n\n"
578 "Example: \n"
579 " t4ht name -d/WWW/temp/ -etex4ht-32.env -m644\n"
580 "--------------------------------------------------------------------\n"
581
582 ,
583 "Insufficient memory\n",
584
585 #line 3839 "./tex4ht-t4ht.tex"
586
587 "Illegal storage address\n",
588 "Floating-point\n",
589 "Interrupt with Cntr-C\n",
590
591
592 "Can't find/open file `%s'\n",
593
594 "" };
595
596
597 #line 4131 "./tex4ht-t4ht.tex"
598
599 static Q_CHAR command[255];
600 static int system_return;
601
602
603 #line 4142 "./tex4ht-t4ht.tex"
604
605 static BOOL system_yes;
606
607
608 #line 4195 "./tex4ht-t4ht.tex"
609
610 static BOOL always_call_sys = FALSE;
611
612
613 #line 4380 "./tex4ht-t4ht.tex"
614
615 static Q_CHAR* match[10];
616 static int max_match[10];
617
618
619
620 #line 793 "./tex4ht-t4ht.tex"
621
622 #if defined(DOS_WIN32) || defined(__DJGPP__)
623 static BOOL is_forward_slash( ARG_I(Q_CHAR *) );
624 #endif
625
626
627 #line 1069 "./tex4ht-t4ht.tex"
628
629 static char * abs_addr( ARG_II( U_CHAR *, U_CHAR *) );
630
631
632 #line 1379 "./tex4ht-t4ht.tex"
633
634 static void execute_script(
635 ARG_V(struct script_struct*,const Q_CHAR *,const Q_CHAR *,const Q_CHAR *,const Q_CHAR *) );
636
637
638 #line 1535 "./tex4ht-t4ht.tex"
639
640 static struct script_struct * filterGifScript(
641 ARG_II( struct script_struct *, Q_CHAR *) );
642
643
644 #line 1609 "./tex4ht-t4ht.tex"
645
646 void free_script(
647 ARG_I( struct script_struct *) );
648
649
650 #line 2156 "./tex4ht-t4ht.tex"
651
652 static BOOL strpre( ARG_II(char *,char *) );
653
654
655 #line 3055 "./tex4ht-t4ht.tex"
656
657 static struct script_struct * add_script( ARG_I(struct script_struct *) );
658
659
660 #line 3631 "./tex4ht-t4ht.tex"
661
662 static FILE* f_open( ARG_II(const char*,const char*) );
663
664
665 #line 3652 "./tex4ht-t4ht.tex"
666
667 static FILE* f_home_open( ARG_II(const char*,const char*) );
668
669
670 #line 3682 "./tex4ht-t4ht.tex"
671
672 static FILE* open_file( ARG_II(const C_CHAR *, const C_CHAR *) );
673
674
675 #line 3864 "./tex4ht-t4ht.tex"
676
677 static void err_i( ARG_I(int) );
678
679
680 #line 3880 "./tex4ht-t4ht.tex"
681
682 static void err_arg( ARG_I(int) );
683
684
685 #line 3898 "./tex4ht-t4ht.tex"
686
687 static void warn_i_str( ARG_II(int,const Q_CHAR *) );
688
689
690 #line 3982 "./tex4ht-t4ht.tex"
691
692 static void
693
694 #line 4023 "./tex4ht-t4ht.tex"
695
696 #ifdef CDECL
697 CDECL
698 #endif
699
700
701 sig_err(ARG_I(int));
702
703
704 #line 4109 "./tex4ht-t4ht.tex"
705
706 #ifdef KWIN32
707 static BOOL sigint_handler(ARG_I(DWORD));
708 #endif
709
710
711 #line 4173 "./tex4ht-t4ht.tex"
712
713 static void call_sys(ARG_I(Q_CHAR *));
714
715
716 #line 4216 "./tex4ht-t4ht.tex"
717
718 static void strct( ARG_II(C_CHAR *, const C_CHAR *) );
719
720
721 #line 4236 "./tex4ht-t4ht.tex"
722
723 static long int get_long_int( ARG_I(Q_CHAR *) );
724
725
726 #line 4265 "./tex4ht-t4ht.tex"
727
728 static void* malloc_chk(ARG_I(int));
729
730
731 #line 4282 "./tex4ht-t4ht.tex"
732
733 static void* r_alloc(ARG_II(void *, size_t));
734
735
736 #line 4346 "./tex4ht-t4ht.tex"
737
738 static BOOL scan_until_end_str( ARG_IV(const C_CHAR *, int, BOOL, FILE *) );
739
740
741 #line 4396 "./tex4ht-t4ht.tex"
742
743 static BOOL scan_until_str( ARG_IV(const C_CHAR *, int, BOOL, FILE *) );
744
745
746 #line 4434 "./tex4ht-t4ht.tex"
747
748 static BOOL scan_str( ARG_III(const C_CHAR *, BOOL, FILE *) );
749
750
751
752 #line 799 "./tex4ht-t4ht.tex"
753
754 #if defined(DOS_WIN32) || defined(__DJGPP__)
755
756 static BOOL is_forward_slash
757 #ifdef ANSI
758 #define SEP ,
759 (
760 Q_CHAR * str
761 )
762 #undef SEP
763 #else
764 #define SEP ;
765 (str)
766 Q_CHAR * str
767 ;
768 #undef SEP
769 #endif
770 {
771 while( *str ){ if( *(str++) == '/' ) { return TRUE; } }
772 return FALSE;
773 }
774 #endif
775
776
777 #line 1073 "./tex4ht-t4ht.tex"
778
779
780 static char * abs_addr
781 #ifdef ANSI
782 #define SEP ,
783 (
784 U_CHAR *dir SEP
785 U_CHAR *base
786
787 )
788 #undef SEP
789 #else
790 #define SEP ;
791 ( dir, base)
792 U_CHAR *dir SEP
793 U_CHAR *base
794
795 ;
796 #undef SEP
797 #endif
798 { U_CHAR *p;
799 p = m_alloc(char, (int) strlen((char *) dir ) +
800 (base? (int) strlen((char *) base ):0) +
801 (int) strlen((char *) HOME_DIR ));
802 *p = '\0';
803 if( (*(dir+1) == '~') && base ){
804 if( *base == '~' ){
805 (IGNORED) strct(p, HOME_DIR);
806 (IGNORED) strct(p, base+1);
807 } else {
808 (IGNORED) strct(p, base);
809 }
810 (IGNORED) strct(p, dir+2);
811 } else {
812 (IGNORED) strct(p, HOME_DIR);
813 (IGNORED) strct(p, dir+1);
814 }
815 return p;
816 }
817
818
819 #line 1384 "./tex4ht-t4ht.tex"
820
821
822 static void execute_script
823 #ifdef ANSI
824 #define SEP ,
825 (
826 struct script_struct* script SEP
827 const Q_CHAR * match_1 SEP
828 const Q_CHAR * match_2 SEP
829 const Q_CHAR * match_3 SEP
830 const Q_CHAR * match_4
831
832 )
833 #undef SEP
834 #else
835 #define SEP ;
836 (script,match_1,match_2,match_3,match_4)
837 struct script_struct* script SEP
838 const Q_CHAR * match_1 SEP
839 const Q_CHAR * match_2 SEP
840 const Q_CHAR * match_3 SEP
841 const Q_CHAR * match_4
842
843 ;
844 #undef SEP
845 #endif
846 { struct script_struct* temp;
847 Q_CHAR *p, *q;
848 const Q_CHAR *t;
849
850 #line 1462 "./tex4ht-t4ht.tex"
851
852 #ifdef KPATHSEA
•853 const char * texmf = "/usr/share/texlive";
854 #endif
855
856
857 temp = script; system_return = 0;
858 while( temp ){
859
860 #line 1424 "./tex4ht-t4ht.tex"
861
862 p = temp->command;
863 q = command;
864 while( *p != '\0' ){
865 *q = *(p++);
866 if( (*q == '%') && (*p == '%')
867 && ( (*(p+1) == '%')
868 || (*(p+1) == '~')
869 || ( (*(p+1) >= '0') && (*(p+1) < '5') ) )
870 ){ p++;
871 switch( *(p++) ){
872 case '%':{ q++; break; }
873 case '0':{ t = job_name;
874 while( *t != '\0' ){ *(q++) = *(t++); } break; }
875 case '1':{ t = match_1;
876 while( *t != '\0' ){ *(q++) = *(t++); } break; }
877 case '2':{ t = match_2;
878 while( *t != '\0' ){ *(q++) = *(t++); } break; }
879 case '3':{ t = match_3;
880 while( *t != '\0' ){ *(q++) = *(t++); } break; }
881 case '4':{ t = match_4;
882 while( *t != '\0' ){ *(q++) = *(t++); } break; }
883 case '~':{
884 #line 1468 "./tex4ht-t4ht.tex"
885
886 #ifdef KPATHSEA
887 if( texmf ){
888 t = texmf;
889 while( *t != '\0' ){ *(q++) = *(t++); }
890 } else {
891 *(q++) = '~';
892 }
893 #else
894 *(q++) = '~';
895 #endif
896
897 break; }
898 default: { }
899 }} else { q++; }
900 }
901 *q = '\0';
902
903
904 if( (command[0] != '\0') && !system_return ){
905
906 #line 4166 "./tex4ht-t4ht.tex"
907
908 (IGNORED) call_sys(command);
909
910 }
911 temp = temp->next;
912 } }
913
914
915 #line 1540 "./tex4ht-t4ht.tex"
916
917
918 static struct script_struct * filterGifScript
919 #ifdef ANSI
920 #define SEP ,
921 (
922 struct script_struct *script SEP
923 Q_CHAR *file
924 )
925 #undef SEP
926 #else
927 #define SEP ;
928 ( script, file)
929 struct script_struct *script SEP
930 Q_CHAR *file
931 ;
932 #undef SEP
933 #endif
934 {
935 struct script_struct *filtered_script, *scr,
936 *old_script,
937 *new_script;
938 Q_CHAR *command, *ext;
939 filtered_script = NULL_SCRIPT;
940 if( script == NULL_SCRIPT )
941 return filtered_script;
942 old_script = script;
943 command = old_script->command;
944 if( *command != '.' ){
945
946 #line 1563 "./tex4ht-t4ht.tex"
947
948 new_script = NULL_SCRIPT;
949 while( old_script != NULL_SCRIPT ){
950 command = old_script->command;
951 if( *command == '.' ){ return filtered_script; }
952 scr = (struct script_struct *)
953 m_alloc(struct script_struct, (int) 1);
954 scr->command = old_script->command;
955 scr->next = NULL_SCRIPT;
956 if( new_script == NULL_SCRIPT ){
957 filtered_script = new_script = scr;
958 } else {
959 new_script = new_script->next = scr;
960 }
961 old_script = old_script->next;
962 }
963 return filtered_script;
964
965
966 } else {
967
968 #line 1582 "./tex4ht-t4ht.tex"
969
970
971 #line 1602 "./tex4ht-t4ht.tex"
972
973 ext = file;
974 while( *ext != '\0' ){ ext++; }
975 while( (*ext != '.') && (ext != file) ){ ext--; }
976
977
978 while( TRUE ){
979 if( old_script == NULL_SCRIPT ){
980 return NULL_SCRIPT;
981 }
982 command = old_script->command;
983 if(*command != '.') {
984 old_script = old_script->next;
985 continue;
986 }
987 old_script = old_script->next;
988 if( (*(command+1) == '\0') || eq_str(ext,command) ){
989 break;
990 }
991 }
992
993 #line 1563 "./tex4ht-t4ht.tex"
994
995 new_script = NULL_SCRIPT;
996 while( old_script != NULL_SCRIPT ){
997 command = old_script->command;
998 if( *command == '.' ){ return filtered_script; }
999 scr = (struct script_struct *)
1000 m_alloc(struct script_struct, (int) 1);
1001 scr->command = old_script->command;
1002 scr->next = NULL_SCRIPT;
1003 if( new_script == NULL_SCRIPT ){
1004 filtered_script = new_script = scr;
1005 } else {
1006 new_script = new_script->next = scr;
1007 }
1008 old_script = old_script->next;
1009 }
1010 return filtered_script;
1011
1012
1013
1014
1015 }
1016 }
1017
1018
1019 #line 1614 "./tex4ht-t4ht.tex"
1020
1021
1022 void free_script
1023 #ifdef ANSI
1024 #define SEP ,
1025 (
1026 struct script_struct *script
1027 )
1028 #undef SEP
1029 #else
1030 #define SEP ;
1031 (script)
1032 struct script_struct *script
1033 ;
1034 #undef SEP
1035 #endif
1036 {
1037 struct script_struct *temp;
1038 while( script != NULL_SCRIPT ){
1039 temp = script;
1040 script = script->next;
1041 free( temp );
1042 }
1043 }
1044
1045
1046 #line 2160 "./tex4ht-t4ht.tex"
1047
1048
1049 static BOOL strpre
1050 #ifdef ANSI
1051 #define SEP ,
1052 (
1053 char * s1 SEP
1054 char * s2
1055 )
1056 #undef SEP
1057 #else
1058 #define SEP ;
1059 (s1,s2)
1060 char * s1 SEP
1061 char * s2
1062 ;
1063 #undef SEP
1064 #endif
1065 { int i;
1066 for( i=0; i < (int) strlen((char *) s1); i++){
1067 if( *(s1+i) != *(s2+i) ){ return FALSE; }
1068 }
1069 return TRUE;
1070 }
1071
1072
1073 #line 3059 "./tex4ht-t4ht.tex"
1074
1075
1076 static struct script_struct * add_script
1077 #ifdef ANSI
1078 #define SEP ,
1079 (
1080 struct script_struct * script
1081 )
1082 #undef SEP
1083 #else
1084 #define SEP ;
1085 (script)
1086 struct script_struct * script
1087 ;
1088 #undef SEP
1089 #endif
1090 {
1091 struct script_struct* temp, * q;
1092 temp = (struct script_struct *)
1093 m_alloc(struct script_struct, (int) 1);
1094 temp->command = match[1];
1095 if( debug ){
1096 (IGNORED) printf("....... %s\n", temp->command); }
1097 temp->next = NULL_SCRIPT;
1098 match[1] = (Q_CHAR *) malloc(70);
1099 max_match[1] = 70;
1100 if( script ){
1101 q = script;
1102 while( q->next ){ q = q->next; }
1103 q->next = temp;
1104 } else {
1105 script = temp;
1106 }
1107 return script;
1108 }
1109
1110
1111 #line 3580 "./tex4ht-t4ht.tex"
1112
1113 #if defined(__MSDOS__)
1114
1115 #line 3586 "./tex4ht-t4ht.tex"
1116
1117
1118 static char *get_env_dir
1119 #ifdef ANSI
1120 #define SEP ,
1121 (
1122 Q_CHAR *progname
1123
1124 )
1125 #undef SEP
1126 #else
1127 #define SEP ;
1128 (progname)
1129 Q_CHAR *progname
1130
1131 ;
1132 #undef SEP
1133 #endif
1134 { int i;
1135 Q_CHAR *p;
1136 if(! progname || ! *progname) return NULL;
1137 i = (int) strlen((char *) progname);
1138 while( (progname[--i] != (int) dir_path_slash(progname) )
1139 && i > 0) ;
1140 if(i == 0) return NULL;
1141 p = (Q_CHAR *) malloc(i+12);
1142 if(p == NULL) return NULL;
1143 strncpy(p, progname, i+1);
1144 (IGNORED) strcpy((char *) &p[i+1],
1145 "tex4ht.env");
1146 return p;
1147 }
1148
1149
1150 #endif
1151
1152
1153 #line 3635 "./tex4ht-t4ht.tex"
1154
1155
1156 static FILE* f_open
1157 #ifdef ANSI
1158 #define SEP ,
1159 (
1160 const char* name SEP
1161 const char* flags
1162 )
1163 #undef SEP
1164 #else
1165 #define SEP ;
1166 ( name, flags )
1167 const char* name SEP
1168 const char* flags
1169 ;
1170 #undef SEP
1171 #endif
1172 { FILE* file;
1173 if( (file = fopen(name,flags) ) != NULL ) {
1174 (IGNORED) printf("(%s)\n",name);
1175 }
1176 return file;
1177 }
1178
1179
1180 #line 3656 "./tex4ht-t4ht.tex"
1181
1182
1183 static FILE* f_home_open
1184 #ifdef ANSI
1185 #define SEP ,
1186 (
1187 const char* name SEP
1188 const char* flags
1189 )
1190 #undef SEP
1191 #else
1192 #define SEP ;
1193 ( name, flags )
1194 const char* name SEP
1195 const char* flags
1196 ;
1197 #undef SEP
1198 #endif
1199 { FILE* file;
1200 U_CHAR *str;
1201 if( *name == '~' ){
1202 if( HOME_DIR ){
1203 str = m_alloc(char, strlen((char *) HOME_DIR)+strlen(name));
1204 (IGNORED) sprintf(str,"%s%s", HOME_DIR, name+1);
1205 file = f_open(str,flags);
1206 free((void *) str);
1207 return file;
1208 } else { return NULL; }
1209 } else { return f_open( name, flags ); }
1210 }
1211
1212
1213 #line 3686 "./tex4ht-t4ht.tex"
1214
1215
1216 static FILE* open_file
1217 #ifdef ANSI
1218 #define SEP ,
1219 (
1220 const C_CHAR *name SEP const C_CHAR *ext
1221 )
1222 #undef SEP
1223 #else
1224 #define SEP ;
1225 (name,ext)
1226 const C_CHAR *name SEP const C_CHAR *ext
1227 ;
1228 #undef SEP
1229 #endif
1230 { FILE* file;
1231 C_CHAR filename[255], *p;
1232 if( eq_str( ext,LG_EXT ) ) {
1233 (IGNORED) strcpy((char *) filename, (char *) job_name);
1234 (IGNORED) strct(filename, ext);
1235 } else {
1236 (IGNORED) strcpy((char *) filename, name );
1237 p = filename;
1238 while( TRUE ){
1239 if( *p == '.' ){ break; }
1240 if( *p == '\0' ){ (IGNORED) strcpy((char *) p, ext); break; }
1241 p++;
1242 }
1243 }
1244 file = fopen(filename, READ_TEXT_FLAGS);
1245 if( !file ) {
1246 (IGNORED) warn_i_str(5,filename);
1247 } else { (IGNORED) printf ("Entering %s\n", filename); }
1248
1249 return file;
1250 }
1251
1252
1253 #line 3868 "./tex4ht-t4ht.tex"
1254
1255
1256 static void err_i
1257 #ifdef ANSI
1258 #define SEP ,
1259 ( int n
1260
1261 )
1262 #undef SEP
1263 #else
1264 #define SEP ;
1265 (n) int n
1266
1267 ;
1268 #undef SEP
1269 #endif
1270 { (IGNORED) fprintf(stderr,"--- error --- ");
1271 (IGNORED) fprintf(stderr, "%s", warn_err_mssg[n]);
1272 exit(EXIT_FAILURE);
1273 }
1274
1275
1276 #line 3884 "./tex4ht-t4ht.tex"
1277
1278
1279 static void err_arg
1280 #ifdef ANSI
1281 #define SEP ,
1282 ( int n
1283
1284 )
1285 #undef SEP
1286 #else
1287 #define SEP ;
1288 (n) int n
1289
1290 ;
1291 #undef SEP
1292 #endif
1293 { (IGNORED) fprintf(stderr,"--- error --- ");
1294 (IGNORED) fprintf(stderr, "%s", warn_err_mssg[n]);
1295 exit(EXIT_FAILURE);
1296 }
1297
1298
1299 #line 3902 "./tex4ht-t4ht.tex"
1300
1301
1302 static void warn_i_str
1303 #ifdef ANSI
1304 #define SEP ,
1305 (
1306 int n SEP
1307 const Q_CHAR *str
1308
1309 )
1310 #undef SEP
1311 #else
1312 #define SEP ;
1313 (n,str)
1314 int n SEP
1315 const Q_CHAR *str
1316
1317 ;
1318 #undef SEP
1319 #endif
1320 { (IGNORED) fprintf(stderr,"--- warning --- ");
1321 (IGNORED) fprintf(stderr,warn_err_mssg[n], str);
1322 }
1323
1324
1325 #line 3991 "./tex4ht-t4ht.tex"
1326
1327
1328 static void
1329
1330 #line 4023 "./tex4ht-t4ht.tex"
1331
1332 #ifdef CDECL
1333 CDECL
1334 #endif
1335
1336
1337 sig_err
1338 #ifdef ANSI
1339 #define SEP ,
1340 ( int s
1341 )
1342 #undef SEP
1343 #else
1344 #define SEP ;
1345 (s) int s
1346 ;
1347 #undef SEP
1348 #endif
1349 {
1350 (void) signal(s,SIG_IGN);
1351 switch( s ){
1352 #ifdef SIGSEGV
1353 case SIGSEGV: err_i(2);
1354 #endif
1355 case SIGFPE : err_i(3);
1356 #if defined(SIGINT) && !defined(WIN32)
1357 case SIGINT : err_i(4);
1358 #endif
1359 }
1360
1361 #line 768 "./tex4ht-t4ht.tex"
1362
1363 #ifdef __DJGPP__
1364 if (s != SIGINT && s != SIGQUIT)
1365 exit(EXIT_FAILURE);
1366 #endif
1367
1368
1369 }
1370
1371
1372 #line 4115 "./tex4ht-t4ht.tex"
1373
1374 #ifdef KWIN32
1375
1376 static BOOL sigint_handler
1377 #ifdef ANSI
1378 #define SEP ,
1379 ( DWORD dwCtrlType
1380 )
1381 #undef SEP
1382 #else
1383 #define SEP ;
1384 (dwCtrlType) DWORD dwCtrlType
1385 ;
1386 #undef SEP
1387 #endif
1388 {
1389 err_i(32);
1390 return FALSE;
1391 }
1392 #endif
1393
1394
1395 #line 4180 "./tex4ht-t4ht.tex"
1396
1397
1398 static void call_sys
1399 #ifdef ANSI
1400 #define SEP ,
1401 ( Q_CHAR * command
1402 )
1403 #undef SEP
1404 #else
1405 #define SEP ;
1406 (command) Q_CHAR * command
1407 ;
1408 #undef SEP
1409 #endif
1410 {
1411 if( *command ){
1412 (IGNORED) printf("System call: %s\n", command);
1413 system_return = system_yes? (int) system(command) : -1;
1414 (IGNORED) printf("%sSystem return: %d\n",
1415 system_return? "--- Warning --- " : "", system_return );
1416 if( always_call_sys ){ system_return = 0; }
1417 }
1418 }
1419
1420
1421 #line 4220 "./tex4ht-t4ht.tex"
1422
1423
1424 static void strct
1425 #ifdef ANSI
1426 #define SEP ,
1427 (
1428 C_CHAR * str1 SEP
1429 const C_CHAR * str2
1430
1431 )
1432 #undef SEP
1433 #else
1434 #define SEP ;
1435 ( str1, str2 )
1436 C_CHAR * str1 SEP
1437 const C_CHAR * str2
1438
1439 ;
1440 #undef SEP
1441 #endif
1442 { Q_CHAR * ch;
1443 ch = str1 + (int) strlen((char *) str1);
1444 (IGNORED) strcpy((char *) ch, str2 );
1445 }
1446
1447
1448 #line 4240 "./tex4ht-t4ht.tex"
1449
1450
1451 static long int get_long_int
1452 #ifdef ANSI
1453 #define SEP ,
1454 (
1455 Q_CHAR *str
1456 )
1457 #undef SEP
1458 #else
1459 #define SEP ;
1460 (str)
1461 Q_CHAR *str
1462 ;
1463 #undef SEP
1464 #endif
1465 { long int i;
1466 Q_CHAR *ch;
1467 ch = str; i = 0;
1468 while( (*ch>= '0') && (*ch <='9') ){
1469 i = 10*i + *(ch++) - '0';
1470 }
1471 return i;
1472 }
1473
1474
1475 #line 4269 "./tex4ht-t4ht.tex"
1476
1477
1478 static void* malloc_chk
1479 #ifdef ANSI
1480 #define SEP ,
1481 ( int n
1482 )
1483 #undef SEP
1484 #else
1485 #define SEP ;
1486 ( n ) int n
1487 ;
1488 #undef SEP
1489 #endif
1490 { void* p;
1491 if((p = (void *) malloc( (size_t) n)) == NULL ) bad_mem;
1492 return p;
1493 }
1494
1495
1496 #line 4286 "./tex4ht-t4ht.tex"
1497
1498
1499 static void* r_alloc
1500 #ifdef ANSI
1501 #define SEP ,
1502 (
1503 void *q SEP
1504 size_t n
1505 )
1506 #undef SEP
1507 #else
1508 #define SEP ;
1509 ( q, n )
1510 void *q SEP
1511 size_t n
1512 ;
1513 #undef SEP
1514 #endif
1515 { void* p;
1516 if((p = (void *) realloc( q, (size_t) n)) == NULL) bad_mem;
1517 return p;
1518 }
1519
1520
1521 #line 4350 "./tex4ht-t4ht.tex"
1522
1523
1524 static BOOL scan_until_end_str
1525 #ifdef ANSI
1526 #define SEP ,
1527 (
1528 const C_CHAR *str SEP
1529 int n SEP
1530 BOOL flag SEP
1531 FILE* file
1532 )
1533 #undef SEP
1534 #else
1535 #define SEP ;
1536 (str,n,flag,file)
1537 const C_CHAR *str SEP
1538 int n SEP
1539 BOOL flag SEP
1540 FILE* file
1541 ;
1542 #undef SEP
1543 #endif
1544 { Q_CHAR *p;
1545 int i;
1546 if( !flag ) { return flag; }
1547 p = match[n]; i = 0;
1548 while( TRUE ){
1549 if( (i+1) >= max_match[n] ){
1550 max_match[n] += 10;
1551 p = match[n] = (Q_CHAR *)
1552 r_alloc((void *) match[n], (size_t) max_match[n]);
1553 }
1554 p[i] = (char) (eoln_ch = getc(file));
1555 if( (eoln_ch == (int) '\n') || (eoln_ch == EOF) ){ break; }
1556 i++;
1557 }
1558 p[i] = '\0';
1559 i -= (int) strlen(str);
1560 if( i>= 0 ){ return eq_str(p+i,str); }
1561 return FALSE;
1562 }
1563
1564
1565 #line 4400 "./tex4ht-t4ht.tex"
1566
1567
1568 static BOOL scan_until_str
1569 #ifdef ANSI
1570 #define SEP ,
1571 (
1572 const C_CHAR *str SEP
1573 int n SEP
1574 BOOL flag SEP
1575 FILE* file
1576 )
1577 #undef SEP
1578 #else
1579 #define SEP ;
1580 (str,n,flag,file)
1581 const C_CHAR *str SEP
1582 int n SEP
1583 BOOL flag SEP
1584 FILE* file
1585 ;
1586 #undef SEP
1587 #endif
1588 { Q_CHAR *p, ch;
1589 int i, j;
1590 if( !flag ) { return flag; }
1591 p = match[n]; i = 0;
1592 while( TRUE ){
1593 ch = (char) (eoln_ch = getc(file));
1594 if( (eoln_ch == (int) '\n') || (eoln_ch == EOF) ){ return FALSE; }
1595 if( (i+1) >= max_match[n] ){
1596 max_match[n] += 10;
1597 p = match[n] = (Q_CHAR *)
1598 r_alloc((void *) match[n], (size_t) max_match[n]);
1599 }
1600 p[i++] = ch;
1601 j = i - (int) strlen(str);
1602 if( j>= 0 ){
1603 p[i] = '\0';
1604 if( eq_str(p+j,str) ) { return TRUE; }
1605 }
1606 }
1607 }
1608
1609
1610 #line 4438 "./tex4ht-t4ht.tex"
1611
1612
1613 static BOOL scan_str
1614 #ifdef ANSI
1615 #define SEP ,
1616 (
1617 const C_CHAR *str SEP
1618 BOOL flag SEP
1619 FILE* file
1620 )
1621 #undef SEP
1622 #else
1623 #define SEP ;
1624 (str,flag,file)
1625 const C_CHAR *str SEP
1626 BOOL flag SEP
1627 FILE* file
1628 ;
1629 #undef SEP
1630 #endif
1631 { const Q_CHAR *p;
1632 int temp_eoln_ch;
1633 if( !flag ) { return flag; }
1634 p = str;
1635 while( *p != '\0' ){
1636 if( *(p++) != (temp_eoln_ch = getc(file)) ) {
1637 while( (temp_eoln_ch != (int) '\n')
1638 && (temp_eoln_ch != EOF) ){ temp_eoln_ch = getc(file); }
1639 eoln_ch = temp_eoln_ch; return FALSE;
1640 }
1641 }
1642 return TRUE;
1643 }
1644
1645
1646
1647 int
1648 #line 4023 "./tex4ht-t4ht.tex"
1649
1650 #ifdef CDECL
1651 CDECL
1652 #endif
1653
1654 main
1655 #ifdef ANSI
1656 #define SEP ,
1657 (
1658 int argc SEP
1659 Q_CHAR **argv
1660 )
1661 #undef SEP
1662 #else
1663 #define SEP ;
1664 (argc, argv)
1665 int argc SEP
1666 Q_CHAR **argv
1667 ;
1668 #undef SEP
1669 #endif
1670 {
1671 #line 1154 "./tex4ht-t4ht.tex"
1672
1673 struct empty_pic_struct *empty_pic;
1674
1675
1676 #line 3559 "./tex4ht-t4ht.tex"
1677
1678 Q_CHAR * tex4ht_env_file = (Q_CHAR *) 0;
1679 Q_CHAR * dos_env_file =
1680 #if defined(__MSDOS__)
1681
1682 #line 3576 "./tex4ht-t4ht.tex"
1683
1684 get_env_dir(argv[0])
1685
1686 ;
1687 #endif
1688 #if !defined(__MSDOS__)
1689 (Q_CHAR *) 0;
1690 #endif
1691
1692
1693
1694
1695 #line 3927 "./tex4ht-t4ht.tex"
1696
1697 #ifdef WIN32
1698 /* See comments in tex4ht */
1699 if (argc > 2) {
1700 int i, nargc;
1701 char **nargv, **pnargv, **pargv;
1702
1703 nargv = (char **) xmalloc (2 * argc * sizeof (char *));
1704 pnargv = nargv;
1705 pargv = argv;
1706 *pnargv++ = xstrdup (*pargv++);
1707 *pnargv++ = xstrdup (*pargv++);
1708 nargc = 2;
1709
1710 for (i=2; i < argc; i++) {
1711 char *p, *q, *r;
1712 p = q = *pargv++;
1713 while (*p == ' ' || *p == '\t') {
1714 p++;
1715 q++;
1716 }
1717 while (*p != ' ' && *p != '\t' && *p) {
1718 p++;
1719 if (*p == '\0') {
1720 *pnargv++ = xstrdup(q);
1721 nargc++;
1722 } else if (*p == ' ' || *p == '\t') {
1723 r = p;
1724 while (*p == ' ' || *p == '\t')
1725 p++;
1726 if (*p == '-' || *p == '\0') {
1727 *r = '\0';
1728 *pnargv++ = xstrdup(q);
1729 nargc++;
1730 q = p;
1731 }
1732 }
1733 }
1734 }
1735
1736 nargv[nargc] = NULL;
1737 argv = nargv;
1738 argc = nargc;
1739 }
1740 #endif
1741
1742
1743
1744 #line 4032 "./tex4ht-t4ht.tex"
1745
1746
1747 #ifdef SIGSEGV
1748 (void) signal(SIGSEGV,sig_err);
1749 #endif
1750 (void) signal(SIGFPE,sig_err);
1751 #ifdef KWIN32
1752
1753 #line 4055 "./tex4ht-t4ht.tex"
1754
1755 SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigint_handler, TRUE);
1756
1757
1758 #else
1759 #ifdef SIGINT
1760 (void) signal(SIGINT,sig_err);
1761 #endif
1762 #endif
1763
1764
1765
1766 #line 173 "./tex4ht-t4ht.tex"
1767
1768 (IGNORED) printf("----------------------------\n");
1769 #ifndef KPATHSEA
1770 #ifdef PLATFORM
1771 (IGNORED) printf("t4ht.c (2018-07-04-14:25 %s)\n",PLATFORM);
1772 #else
1773 (IGNORED) printf("t4ht.c (2018-07-04-14:25)\n");
1774 #endif
1775 #else
1776 #ifdef PLATFORM
1777 (IGNORED) printf("t4ht.c (2018-07-04-14:25 %s kpathsea)\n",PLATFORM);
1778 #else
1779 (IGNORED) printf("t4ht.c (2018-07-04-14:25 kpathsea)\n");
1780 #endif
1781 #endif
1782
1783
1784 #line 910 "./tex4ht-t4ht.tex"
1785
1786 { int i, count = 0;
1787 for(i=0; i<argc; i++){
1788 Q_CHAR *p = argv[i];
1789 count++;
1790 if( (*p == '\'') || (*p == '\"') ){
1791 int cnt;
1792 int len = 0;
1793 for( cnt=i; cnt < argc; cnt++ ){
1794 len += (int) strlen((char *) argv[cnt]);
1795 if( *(argv[cnt] + (int) strlen((char *) argv[cnt]) -1) == *p ){
1796 Q_CHAR * arg = m_alloc(char, len + cnt - i + 1);
1797 Q_CHAR * toArg = arg;
1798 Q_CHAR *pp;
1799 i--;
1800 do {
1801 pp = argv[++i];
1802 while( *pp != '\0' ){
1803 if( *pp != *p ){ *(toArg++) = *pp; }
1804 pp++;
1805 }
1806 *(toArg++) = ' ';
1807 } while ( i != cnt );
1808 *(toArg-1) = '\0';
1809 argv[count-1] = arg;
1810 break;
1811 } } } }
1812 argc = count;
1813 }
1814
1815
1816 { int i;
1817 for(i=0; i<argc; i++){
1818 (IGNORED) printf("%s%s ", (i>1)?"\n " : "", argv[i]); }
1819 (IGNORED) printf("\n");
1820 }
1821
1822
1823
1824 #line 1104 "./tex4ht-t4ht.tex"
1825
1826 HOME_DIR = getenv("HOME");
1827
1828
1829 #line 4146 "./tex4ht-t4ht.tex"
1830
1831 { C_CHAR *yes = NULL;
1832 system_yes = (
1833 #line 4158 "./tex4ht-t4ht.tex"
1834
1835 #ifdef SYSTEM_FUNCTION_OK
1836 0
1837 #else
1838 system( yes ) != 0
1839 #endif
1840
1841 );
1842 }
1843
1844
1845 #line 4386 "./tex4ht-t4ht.tex"
1846
1847 { int i;
1848 for( i=0; i<=9; i++){
1849 match[i] = (Q_CHAR *) malloc(70);
1850 max_match[i] = 70;
1851 }
1852 }
1853
1854
1855
1856
1857 #line 892 "./tex4ht-t4ht.tex"
1858
1859 { int i;
1860 Q_CHAR *p, *q;
1861
1862 #line 1002 "./tex4ht-t4ht.tex"
1863
1864 #ifdef KPATHSEA
1865 kpse_set_program_name (argv[0], "tex4ht");
1866 #endif
1867
1868
1869
1870 if( argc == 1 ){ bad_arg; }
1871 for(i=1; i<argc; i++){
1872 if( *( p=argv[i] ) == '-' ){
1873 #line 1014 "./tex4ht-t4ht.tex"
1874
1875 if( (int) strlen((char *) argv[i] ) == 2 ){
1876 if(
1877 #line 1041 "./tex4ht-t4ht.tex"
1878
1879 (*(p+1) != 'i')
1880 && (*(p+1) != 'p')
1881 && (*(p+1) != 'r')
1882 && (*(p+1) != 'b')
1883 && (*(p+1) != 'g')
1884 && (*(p+1) != 'Q')
1885
1886 )
1887 { if( ++i == argc ) bad_arg; }
1888 q = argv[i];
1889 } else q = p+2;
1890 switch( *(p+1) ){
1891 case 'M':{ ch_mod = q; newchmod = TRUE; break; }
1892 case 'S':{
1893 #line 2283 "./tex4ht-t4ht.tex"
1894
1895 { struct sys_call_rec *q;
1896 q = m_alloc(struct sys_call_rec, 1);
1897 q->next = system_calls;
1898 q->filter = p + 2;
1899 system_calls = q;
1900 }
1901
1902 break; }
1903 case 'X':{ Xfield = q; break;}
1904 case 'b':{ bitmaps_no_dm = q-1; break;}
1905 case 'c':{
1906 #line 2194 "./tex4ht-t4ht.tex"
1907
1908 struct env_c_rec *temp = (struct env_c_rec*)
1909 m_alloc(struct env_c_rec, (int) 1);
1910 temp->option = q;
1911 temp->next = envChoice;
1912 envChoice = temp;
1913
1914 break;}
1915 case 'd':{ dir = (*q=='~')? abs_addr(q,NULL) : q; break; }
1916 case 'e':{
1917 #line 3486 "./tex4ht-t4ht.tex"
1918
1919 tex4ht_env_file = q;
1920
1921 break; }
1922 case 'f':{
1923 #line 1058 "./tex4ht-t4ht.tex"
1924
1925 p = p + 2;
1926 lg_name = p + (int) strlen((char *) p );
1927 while( *lg_name != *p ){ lg_name--; }
1928 lg_name++;
1929
1930 break; }
1931 case 'i':{ debug = q-1; break;}
1932 case 'g':{ always_call_sys = TRUE; break;}
1933 case 'm':{ ch_mod = q; break; }
1934 case 'p':{ nopict = q-1; break;}
1935 case 'Q':{ check_tex4ht_c_err = TRUE; break;}
1936 case 'r':{ noreuse = q-1; break;}
1937 case '.':{ Dotfield = q; break;}
1938 default:{ bad_arg; }
1939 }
1940
1941 }
1942 else
1943 { lg_name = argv[i]; }
1944 }
1945 if( lg_name == NULL ){ bad_arg; }
1946
1947 #line 944 "./tex4ht-t4ht.tex"
1948
1949 { Q_CHAR *p, *q;
1950 FILE* file;
1951 (IGNORED) strcpy((char *) (char *) tmp_name, (char *) (char *) lg_name);
1952 p = q = tmp_name + strlen((char *) tmp_name );
1953 while( p != tmp_name ){
1954 if( *p == '.' ){
1955 if( eq_str( p+1,LG_EXT ) ) { *p = '\0'; }
1956 else {
1957 (IGNORED) strct( tmp_name, LG_EXT);
1958 file = fopen( tmp_name, READ_TEXT_FLAGS );
1959 if( file ){
1960 (IGNORED) fclose(file); *q = '\0';
1961 } else { *p = '\0'; }
1962 }
1963 break;
1964 }
1965 p--;
1966 }
1967 (IGNORED) strct(tmp_name, ".tmp");
1968 }
1969
1970
1971
1972 #line 968 "./tex4ht-t4ht.tex"
1973
1974 (IGNORED) strcpy((char *) job_name, (char *) tmp_name);
1975 *(job_name + strlen((char *) job_name) - 4) = '\0';
1976
1977
1978 }
1979
1980
1981
1982 #line 92 "./tex4ht-t4ht.tex"
1983
1984
1985 #line 2914 "./tex4ht-t4ht.tex"
1986
1987 { FILE* file;
1988 U_CHAR env_loc[512];
1989 env_loc[0] = '\0';
1990
1991 #line 3168 "./tex4ht-t4ht.tex"
1992
1993 { Q_CHAR str[512],
1994 *TEX4HTENV;
1995
1996 #line 3453 "./tex4ht-t4ht.tex"
1997
1998 if( tex4ht_env_file ){
1999 if( debug ){
2000 (IGNORED) printf("%s?\n", tex4ht_env_file);
2001 }
2002 file = f_home_open( tex4ht_env_file, READ_TEXT_FLAGS );
2003 } else {
2004 file = NULL;
2005 }
2006 if( tex4ht_env_file ){
2007 (IGNORED) strcpy((char *) &env_loc[0], (char *) tex4ht_env_file);
2008 }
2009 if( debug && file ){
2010 (IGNORED) printf(".......Open: %s\n", tex4ht_env_file); }
2011
2012
2013
2014 #line 3156 "./tex4ht-t4ht.tex"
2015
2016 if( !file ) {
2017 if( debug ){
2018 (IGNORED) printf("tex4ht.env?\n");
2019 }
2020 file = f_open("tex4ht.env", READ_TEXT_FLAGS);
2021 (IGNORED) strcpy((char *) &env_loc[0], "tex4ht.env");
2022 if( debug && file ){
2023 (IGNORED) printf(".......Open: ./tex4ht.env\n"); }
2024 }
2025
2026
2027
2028 #line 3207 "./tex4ht-t4ht.tex"
2029
2030 #ifndef DOS_WIN32
2031 if( !file ) {
2032 if( debug ){
2033 (IGNORED) printf(".tex4ht?\n");
2034 }
2035 file = f_open(".tex4ht", READ_TEXT_FLAGS);
2036 (IGNORED) strcpy((char *) &env_loc[0], ".tex4ht");
2037 if( debug && file ){
2038 (IGNORED) printf(".......Open: ./.tex4ht\n"); }
2039 }
2040 #endif
2041
2042
2043
2044 #line 3190 "./tex4ht-t4ht.tex"
2045
2046 if( !file ){
2047 TEX4HTENV = getenv("TEX4HTENV");
2048 if( TEX4HTENV ){
2049 if( debug ){
2050 (IGNORED) printf("%s?\n", TEX4HTENV);
2051 }
2052 file = f_home_open(TEX4HTENV,READ_TEXT_FLAGS);
2053 }
2054 }
2055
2056
2057
2058 #line 3394 "./tex4ht-t4ht.tex"
2059
2060 if( !file ){
2061 if( HOME_DIR ){ (IGNORED) sprintf(str,
2062 #line 3433 "./tex4ht-t4ht.tex"
2063
2064 #if defined(DOS_WIN32) || defined(__DJGPP__)
2065 is_forward_slash(HOME_DIR)? "%s/tex4ht.env" : "%s\\tex4ht.env"
2066 #else
2067 "%s/tex4ht.env"
2068 #endif
2069
2070 , HOME_DIR);
2071 if( debug ){
2072 (IGNORED) printf("%s?\n", str);
2073 }
2074 file = f_open(str,READ_TEXT_FLAGS);
2075 (IGNORED) strcpy((char *) &env_loc[0], (char *) str);
2076 if( debug && file ){
2077 (IGNORED) printf(".......Open: %s\n", str); }
2078 }
2079 }
2080 #ifndef DOS_WIN32
2081 if( !file ){
2082 if( HOME_DIR ){
2083 (IGNORED) sprintf(str,"%s/.tex4ht", HOME_DIR);
2084 if( debug ){
2085 (IGNORED) printf("%s?\n", str);
2086 }
2087 file = f_open(str,READ_TEXT_FLAGS);
2088 (IGNORED) strcpy((char *) &env_loc[0], (char *) str);
2089 if( debug && file ){
2090 (IGNORED) printf(".......Open: %s\n", str); }
2091 }
2092 }
2093 #endif
2094 #if defined(DOS_WIN32) || defined(__MSDOS__)
2095 if( !file ){
2096 if( debug ){
2097 (IGNORED) printf("C:/tex4ht.env?\n");
2098 }
2099 file = f_open("C:/tex4ht.env",READ_TEXT_FLAGS);
2100 (IGNORED) strcpy((char *) &env_loc[0], "C:/tex4ht.env");
2101 if( debug && file ){
2102 (IGNORED) printf(".......Open: C:/tex4ht.env\n"); }
2103 }
2104 #endif
2105
2106
2107
2108 #line 3221 "./tex4ht-t4ht.tex"
2109
2110 #ifdef ENVFILE
2111 if( !file ) {
2112 if( debug ){
2113 (IGNORED) printf("%s?\n", ENVFILE);
2114 }
2115 file = f_home_open( ENVFILE,READ_TEXT_FLAGS);
2116 (IGNORED) strcpy((char *) &env_loc[0], (char *) ENVFILE);
2117 if( debug && file ){
2118 (IGNORED) printf(".......Open: %s\n", ENVFILE); }
2119 }
2120 #endif
2121
2122
2123 if( !file ) {
2124 #line 3469 "./tex4ht-t4ht.tex"
2125
2126 if( dos_env_file ){
2127 if( debug ){
2128 (IGNORED) printf("%s?\n", dos_env_file);
2129 }
2130 file = f_open( dos_env_file, READ_TEXT_FLAGS ) ;
2131 (IGNORED) strcpy((char *) &env_loc[0], (char *) dos_env_file);
2132 if( debug && file ){
2133 (IGNORED) printf(".......Open: %s\n", dos_env_file); }
2134 }
2135
2136 }
2137
2138 #line 3257 "./tex4ht-t4ht.tex"
2139
2140
2141 #ifdef KPATHSEA
2142 if( !file ) { U_CHAR * envfile;
2143 char *arch, *p, str[256];
2144
2145 #line 3284 "./tex4ht-t4ht.tex"
2146
2147 p = arch = (char *) kpse_var_value( "SELFAUTOLOC" );
2148 while( *p != '\0' ){
2149 if( (*p == '/') || (*p == '\\') ){
2150 arch = p;
2151 }
2152 p++;
2153 }
2154
2155
2156 envfile = (char *) 0;
2157
2158 #line 3295 "./tex4ht-t4ht.tex"
2159
2160 if( arch ){
2161 (IGNORED) sprintf(str,"%s%ctex4ht.env", arch+1, *arch);
2162 if( debug ){
2163 (IGNORED) printf(
2164 "kpse_open_file (\"%s\", kpse_program_text_format)?\n", str );
2165 }
2166 envfile= kpse_find_file (str, kpse_program_text_format, 0);
2167 }
2168
2169
2170 if ( !envfile ){
2171 #line 3307 "./tex4ht-t4ht.tex"
2172
2173 if( debug ){
2174 (IGNORED) printf(
2175 "kpse_open_file (\"tex4ht.env\", kpse_program_text_format)?\n");
2176 }
2177 envfile= kpse_find_file ("tex4ht.env", kpse_program_text_format, 0);
2178
2179 }
2180 if ( !envfile ){
2181 #line 3361 "./tex4ht-t4ht.tex"
2182
2183 if( system("kpsewhich --progname=tex4ht tex4ht.env > tex4ht.tmp") == 0 ){
2184
2185 #line 3374 "./tex4ht-t4ht.tex"
2186
2187 char fileaddr [256];
2188 int loc = 0;
2189 FILE* file = f_open("tex4ht.tmp", READ_TEXT_FLAGS);
2190 if( file ){
2191 while( (fileaddr[loc] = getc(file)) >=0 ){
2192 if( fileaddr[loc] == '\n' ){ fileaddr[loc] = '\0'; break; }
2193 loc++;
2194 }
2195 (IGNORED) fclose(file);
2196 }
2197
2198
2199 envfile= kpse_find_file (fileaddr, kpse_program_text_format, 0);
2200 }
2201
2202 }
2203 if ( envfile ){
2204 file = kpse_open_file (envfile, kpse_program_text_format);
2205 (IGNORED) printf("(%s)\n", envfile);
2206 }
2207 if( debug && file ){
2208 (IGNORED) printf(".......Open kpathsea %s\n", envfile);
2209 }
2210 }
2211 if( debug ){
2212 U_CHAR *p, *q;
2213
2214 #line 3326 "./tex4ht-t4ht.tex"
2215
2216 p = (U_CHAR *) kpse_var_value( "T4HTINPUTS" );
2217 if( p ){
2218 (IGNORED) printf("T4HTINPUTS = %s\n", p);
2219 }
2220 q = getenv("T4HTINPUTS");
2221 if( q ){ (IGNORED) printf(
2222 "Environmet var T4HTINPUTS: %s\n", q);
2223 }
2224 if( !p && !q ){
2225 (IGNORED) printf( "Missing T4HTINPUTS for kpathsea\n" );
2226 }
2227
2228
2229 }
2230 #endif
2231
2232
2233 if( !file ) warn_i_str( 5,
2234 #line 3245 "./tex4ht-t4ht.tex"
2235
2236 #ifdef DOS_WIN32
2237 "tex4ht.env"
2238 #endif
2239 #ifndef DOS_WIN32
2240 "tex4ht.env | .tex4ht"
2241 #endif
2242
2243 );
2244 }
2245
2246
2247 if( file ){
2248
2249 #line 2931 "./tex4ht-t4ht.tex"
2250
2251 eoln_ch = (int) 'x';
2252 while( eoln_ch != EOF ) { Q_CHAR ch;
2253 ch = (char) (eoln_ch = getc(file));
2254 if( eoln_ch != (int) '\n' ){
2255 status = scan_until_end_str("", 1, TRUE, file);
2256 if( status ){
2257 switch( ch ){
2258 case 'A':{
2259 #line 2996 "./tex4ht-t4ht.tex"
2260
2261 if( debug ){
2262 (IGNORED) printf(".......'A' script\n"); }
2263 chmod_script = add_script(chmod_script);
2264
2265 break;}
2266 case 'C':{
2267 #line 2971 "./tex4ht-t4ht.tex"
2268
2269 if( debug ){
2270 (IGNORED) printf(".......'C' script\n"); }
2271 copy_script = add_script(copy_script);
2272
2273 break;}
2274 case 'E':{
2275 #line 3002 "./tex4ht-t4ht.tex"
2276
2277 if( debug ){
2278 (IGNORED) printf(".......'E' script\n"); }
2279 empty_fig_script = add_script(empty_fig_script);
2280
2281 break;}
2282 case 'F':{
2283 #line 2957 "./tex4ht-t4ht.tex"
2284
2285 if( debug ){
2286 (IGNORED) printf(".......'F' script\n"); }
2287 dvigif_glyp_script = add_script(dvigif_glyp_script);
2288
2289 break;}
2290 case 'G':{
2291 #line 1179 "./tex4ht-t4ht.tex"
2292
2293 if( debug ){ (IGNORED) printf(".......'G' script\n"); }
2294 dvigif_script = add_script(dvigif_script);
2295
2296 break;}
2297 case 'M':{
2298 #line 2964 "./tex4ht-t4ht.tex"
2299
2300 if( debug ){
2301 (IGNORED) printf(".......'M' script\n"); }
2302 move_script = add_script(move_script);
2303
2304 break;}
2305 case 'S':{
2306 #line 2270 "./tex4ht-t4ht.tex"
2307
2308 { struct sys_call_rec *q;
2309 q = m_alloc(struct sys_call_rec, 1);
2310 q->next = system_calls;
2311 q->filter = match[1];
2312 match[1] = (Q_CHAR *) malloc(70); max_match[1] = 70;
2313 system_calls = q;
2314 if( debug ){
2315 (IGNORED) printf(".......'S' script: '%s'\n",
2316 q->filter); }
2317 }
2318
2319 break;}
2320 case 'X':{
2321 #line 2981 "./tex4ht-t4ht.tex"
2322
2323 if( debug ){
2324 (IGNORED) printf(".......'X' script\n"); }
2325
2326 #line 2239 "./tex4ht-t4ht.tex"
2327
2328 file_script
2329
2330 = add_script(
2331 #line 2239 "./tex4ht-t4ht.tex"
2332
2333 file_script
2334
2335 );
2336
2337 break;}
2338 case '.':{
2339 #line 2987 "./tex4ht-t4ht.tex"
2340
2341 if( debug ){
2342 (IGNORED) printf(".......'.' script\n"); }
2343
2344 #line 2175 "./tex4ht-t4ht.tex"
2345
2346 ext_script
2347
2348 = add_script(
2349 #line 2175 "./tex4ht-t4ht.tex"
2350
2351 ext_script
2352
2353 );
2354
2355 break;}
2356 case '<':{
2357 #line 3013 "./tex4ht-t4ht.tex"
2358
2359 if( *(match[1]) != '/' ){
2360 U_CHAR *p;
2361 BOOL env_skip;
2362 for( p = match[1];
2363 (*p != '>') && (*p != '\n') && (*p != EOF ) ;
2364 p++ ){}
2365 if( *p == '>' ){ *p = '\0'; }
2366
2367 #line 2202 "./tex4ht-t4ht.tex"
2368
2369 if( envChoice == (struct env_c_rec*) 0 ){
2370 env_skip = !eq_str(match[1], "default" );
2371 } else {
2372 struct env_c_rec *p;
2373 env_skip = TRUE;
2374 for( p=envChoice; p!=(struct env_c_rec*) 0 ; p = p->next ){
2375 if( eq_str(match[1], p->option ) ){ env_skip = FALSE; }
2376 } }
2377
2378
2379 if( env_skip ){
2380
2381 #line 3034 "./tex4ht-t4ht.tex"
2382
2383 U_CHAR cur_block[90];
2384 if( debug ){
2385 (IGNORED) printf("....... <%s> skipping ...\n", match[1]);
2386 }
2387 (IGNORED) strcpy((char *) cur_block, (char *) match[1]);
2388 status = FALSE;
2389 while( !status && (eoln_ch != EOF) ){
2390 status = scan_str("</", TRUE, file);
2391 status = scan_until_str(">", 1, status, file);
2392 status = scan_until_end_str("", 2, status, file);
2393 if( status ){
2394 *(match[1] + strlen((char *) match[1]) - 1) = '\0';
2395 status = eq_str(match[1], cur_block);
2396 if( debug ){
2397 (IGNORED) printf("....... </%s>\n", match[1]);
2398 } } }
2399
2400
2401 } else {
2402 if( debug ){
2403 (IGNORED) printf("....... <%s>\n", match[1]);
2404 }
2405 }
2406 } else if( debug ){
2407 (IGNORED) printf("....... <%s\n", match[1]);
2408 }
2409
2410 break;}
2411 default:{ }
2412 } } } }
2413
2414
2415 (IGNORED) fclose(file);
2416 } }
2417
2418
2419 lg_file = open_file(lg_name,LG_EXT);
2420 if( lg_file ) {
2421
2422 #line 3759 "./tex4ht-t4ht.tex"
2423
2424 begin_lg_file = ftell(lg_file);
2425
2426
2427
2428 #line 3763 "./tex4ht-t4ht.tex"
2429
2430 (IGNORED) fseek(lg_file, begin_lg_file,
2431 #line 3767 "./tex4ht-t4ht.tex"
2432
2433 0
2434 );
2435
2436
2437 #line 274 "./tex4ht-t4ht.tex"
2438
2439 if( check_tex4ht_c_err ){
2440 eoln_ch = (int) 'x';
2441 while( eoln_ch != EOF ) {
2442 status = scan_str("tex4ht.c error: ", TRUE, lg_file);
2443 if( status ){
2444 (IGNORED) fprintf(stderr,
2445 "--- Error --- tex4ht.c ran into problems\n"
2446 );
2447 exit(EXIT_FAILURE);
2448 }
2449 status = scan_until_end_str("", 1, status, lg_file);
2450 } }
2451
2452
2453
2454 #line 3763 "./tex4ht-t4ht.tex"
2455
2456 (IGNORED) fseek(lg_file, begin_lg_file,
2457 #line 3767 "./tex4ht-t4ht.tex"
2458
2459 0
2460 );
2461
2462
2463 #line 1704 "./tex4ht-t4ht.tex"
2464
2465 {
2466 #line 2056 "./tex4ht-t4ht.tex"
2467
2468 Q_CHAR *file_name, file_mode[5];
2469 int i, start_loc, end_loc, addr = 0;
2470 char rec_op, *ch;
2471 static struct files_rec *to_rec, *from_rec,
2472 *opened_files = (struct files_rec *) 0,
2473 *p, *p1, *p2, *p3, *p4, *from_op;
2474 FILE *in_file, *out_file;
2475 BOOL write_on;
2476
2477
2478 eoln_ch = (int) 'x';
2479 while( eoln_ch != EOF ) {
2480 status = scan_str("CopyTo: ", TRUE, lg_file);
2481 status = scan_until_str(" ", 1, status, lg_file);
2482 status = scan_until_str(" ", 2, status, lg_file);
2483 status = scan_until_str(" ", 3, status, lg_file);
2484 status = scan_until_str(" ", 4, status, lg_file);
2485 status = scan_until_end_str("", 5, status, lg_file);
2486 if( status ){
2487 if( debug ){
2488 (IGNORED) printf("...CopyTo: %s%s%s%s%s...\n",
2489 match[1], match[2], match[3], match[4], match[5]);
2490 }
2491 rec_op = eq_str(match[2],"From ")? From_op :
2492 ( eq_str(match[2],"Until ")? Until_op :
2493 ( eq_str(match[2],"Skip ")? Skip_op :
2494 ( eq_str(match[2],"Cont ")? Cont_op : No_op )));
2495 if( rec_op == No_op ){
2496 #line 1740 "./tex4ht-t4ht.tex"
2497
2498 ch = match[2];
2499 if( (ch[0]=='S') && (ch[1]=='e') && (ch[2]=='t') ){
2500 ch += 3; rec_op = Set_op;
2501 } else if( (ch[0]=='A') && (ch[1]=='d') && (ch[2]=='d') && (ch[3]=='r') ){
2502 ch += 4; rec_op = Addr_op;
2503 }
2504 if( rec_op != No_op ){
2505 addr = 0; while( (*ch>='0') && (*ch<='9') ){
2506 addr = addr*10 + *ch - '0'; ch++;
2507 } }
2508
2509 }
2510 if( rec_op == No_op ){
2511 (IGNORED) fprintf(stderr,"--- warning --- ");
2512 (IGNORED) fprintf(stderr,"CopyTo: %s%s%s%s%s?\n",
2513 match[1], match[2], match[3], match[4], match[5]);
2514 } else {
2515
2516 #line 2002 "./tex4ht-t4ht.tex"
2517
2518 file_name = match[1];
2519 *(file_name + (int) strlen((char *) file_name) - 1) = '\0';
2520 strcpy((char *) file_mode, WRITE_TEXT_FLAGS);
2521 for(i=1; i<=2; i++){
2522
2523 #line 2021 "./tex4ht-t4ht.tex"
2524
2525 for( p = opened_files; p != (struct files_rec*) 0; p = p->right ){
2526 if( eq_str(file_name,p->name) ) { break; }
2527 }
2528 if( p == (struct files_rec*) 0 ){
2529 p = m_alloc(struct files_rec, 1);
2530 p->right = opened_files; opened_files = p;
2531 p->down = (struct files_rec*) 0;
2532 strcpy((char *) p->file_mode, (char *) file_mode);
2533 p->name = m_alloc(char, (int) strlen((char *) file_name) + 1);
2534 (IGNORED) strcpy((char *) p->name, (char *) file_name );
2535 if( (p->file = fopen(file_name, file_mode)) == NULL )
2536 { (IGNORED) warn_i_str(5,file_name); }
2537 }
2538 to_rec = from_rec; from_rec = p;
2539
2540
2541 file_name = match[5];
2542 strcpy((char *) file_mode,
2543 #line 4309 "./tex4ht-t4ht.tex"
2544
2545 READ_BIN_FLAGS
2546
2547 );
2548 }
2549
2550
2551
2552 #line 1963 "./tex4ht-t4ht.tex"
2553
2554 if( to_rec->down == (struct files_rec*) 0 ){
2555
2556 #line 1977 "./tex4ht-t4ht.tex"
2557
2558 to_rec->down = p = m_alloc(struct files_rec, 1);
2559 p->up = to_rec;
2560 p->right = p->left = p->down = (struct files_rec*) 0;
2561 p->name = to_rec->name;
2562 p->file = to_rec->file;
2563 p->from_rec = from_rec;
2564 p->loc = -1;
2565 p->op = No_op;
2566 to_rec = p;
2567
2568
2569 } else {
2570 to_rec = to_rec->down;
2571 for( p = to_rec->right; p != (struct files_rec*) 0; p = p->right ){
2572 if( to_rec->from_rec == from_rec ){ break; }
2573 to_rec = p;
2574 }
2575 if( to_rec->from_rec != from_rec ){
2576
2577 #line 1989 "./tex4ht-t4ht.tex"
2578
2579 to_rec->right = p = m_alloc(struct files_rec, 1);
2580 p->left = to_rec;
2581 p->right = p->down = (struct files_rec*) 0;
2582 p->up = to_rec->up;
2583 p->name = to_rec->name;
2584 p->file = to_rec->file;
2585 p->from_rec = from_rec;
2586 p->loc = -1;
2587 to_rec = p;
2588
2589
2590 } }
2591
2592
2593
2594 #line 1917 "./tex4ht-t4ht.tex"
2595
2596 if( to_rec->down == (struct files_rec*) 0 ){
2597
2598 #line 1933 "./tex4ht-t4ht.tex"
2599
2600 to_rec->down = p = m_alloc(struct files_rec, 1);
2601 p->up = to_rec;
2602 p->right = p->left = p->down = (struct files_rec*) 0;
2603 p->name = to_rec->name;
2604 p->file = to_rec->file;
2605 p->from_rec = from_rec;
2606 p->loc = -1;
2607 p->op = No_op;
2608 p->group = m_alloc(char, (int) strlen((char *) match[3]) + 1);
2609 (IGNORED) strcpy((char *) p->group, (char *) match[3] );
2610 to_rec = p;
2611
2612
2613 } else {
2614 to_rec = to_rec->down;
2615 for( p = to_rec->right; p != (struct files_rec*) 0; p = p->right ){
2616 if( eq_str(to_rec->group,match[3]) ){ break; }
2617 to_rec = p;
2618 }
2619 if( !eq_str(to_rec->group,match[3]) ){
2620
2621 #line 1947 "./tex4ht-t4ht.tex"
2622
2623 to_rec->right = p = m_alloc(struct files_rec, 1);
2624 p->left = to_rec;
2625 p->right = p->down = (struct files_rec*) 0;
2626 p->up = to_rec->up;
2627 p->name = to_rec->name;
2628 p->file = to_rec->file;
2629 p->from_rec = from_rec;
2630 p->loc = -1;
2631 p->group = m_alloc(char, (int) strlen((char *) match[3]) + 1);
2632 (IGNORED) strcpy((char *) p->group, (char *) match[3] );
2633 to_rec = p;
2634
2635
2636 } }
2637
2638
2639
2640 #line 1904 "./tex4ht-t4ht.tex"
2641
2642 p = m_alloc(struct files_rec, 1);
2643 p->down = to_rec->down; to_rec->down = p;
2644 p->up = to_rec;
2645 if( p->down != (struct files_rec*) 0 ){
2646 (p->down)->up = p;
2647 }
2648 *(match[4] + (int) strlen((char *) match[4]) - 1) = '\0';
2649 p->loc = (int) get_long_int(match[4]);
2650 p->op = rec_op;
2651 p->label = addr;
2652
2653
2654
2655 #line 1786 "./tex4ht-t4ht.tex"
2656
2657 if( rec_op == Until_op ){
2658 for( p = to_rec->down;
2659 p != (struct files_rec*) 0; p = p->down ){
2660 if( p->op == From_op ){ from_op = p; break; }
2661 }
2662 if( p == (struct files_rec*) 0 ){
2663
2664 #line 1886 "./tex4ht-t4ht.tex"
2665
2666 (IGNORED) fprintf(stderr,"%sMissing `CopyTo From':\n", "--- warning --- ");
2667 for( p = to_rec->down; p != (struct files_rec*) 0; p = p->down ){
2668 (IGNORED) fprintf(stderr," %s %s%d %s\n", to_rec->name,
2669 p->op == From_op ? "From " :
2670 ( p->op == Until_op ? "Until " :
2671 ( p->op == Skip_op ? "Skip " :
2672 ( p->op == Cont_op? "Cont " :
2673 ( p->op == Addr_op? "Addr " :
2674 ( p->op == Set_op? "Set " : "No_op " ))))),
2675 p->loc, from_rec->name
2676 );
2677 }
2678
2679
2680 } else {
2681
2682 #line 1804 "./tex4ht-t4ht.tex"
2683
2684 in_file = from_rec->file;
2685 out_file = to_rec->file;
2686 start_loc = from_op->loc;
2687 write_on = TRUE;
2688 (IGNORED) fseek(in_file, (long) start_loc,
2689 #line 3767 "./tex4ht-t4ht.tex"
2690
2691 0
2692 );
2693 for( p= from_op; p != to_rec; p = p->up ){
2694 switch( p->op ){
2695 case Until_op:{
2696 #line 1821 "./tex4ht-t4ht.tex"
2697
2698 if( write_on ){
2699 end_loc = p->loc;
2700 for(; start_loc<end_loc; start_loc++) {
2701 (IGNORED) putc( getc(in_file), out_file );
2702 } }
2703
2704 break; }
2705 case Skip_op:{
2706 #line 1830 "./tex4ht-t4ht.tex"
2707
2708 if( write_on ){
2709 end_loc = p->loc;
2710 for(; start_loc<end_loc; start_loc++) {
2711 (IGNORED) putc( getc(in_file), out_file );
2712 }
2713 }
2714 write_on = FALSE;
2715
2716 break; }
2717 case Cont_op:{
2718 #line 1841 "./tex4ht-t4ht.tex"
2719
2720 end_loc = p->loc;
2721 if( write_on ){
2722 for(; start_loc<end_loc; start_loc++) {
2723 (IGNORED) putc( getc(in_file), out_file );
2724 }
2725 } else {
2726 start_loc = end_loc;
2727 (IGNORED) fseek(in_file, (long) end_loc,
2728 #line 3767 "./tex4ht-t4ht.tex"
2729
2730 0
2731 );
2732 }
2733 write_on = TRUE;
2734
2735 break; }
2736 case Set_op:{
2737 #line 1855 "./tex4ht-t4ht.tex"
2738
2739 addr = -1;
2740 for( p1 = from_op->up; p1 != to_rec; p1 = p1->up ){
2741 if( (p1->op == Addr_op) && (p1->label == p->label) ){
2742 addr = p1->loc; break;
2743 } }
2744 if( addr != -1 ){ (p->up)->loc = addr; }
2745
2746 break; }
2747 default: { }
2748 } }
2749
2750
2751
2752 #line 1865 "./tex4ht-t4ht.tex"
2753
2754 to_rec->down = from_op->down;
2755 if( from_op->down != (struct files_rec*) 0){
2756 (from_op->down)->up = to_rec;
2757 }
2758 for( p = from_op; p != to_rec; ){
2759 p1 = p; p = p->up; free((void *) p1);
2760 }
2761 if( to_rec->down == (struct files_rec*) 0){
2762 if( to_rec->left == (struct files_rec*) 0 ){
2763 (to_rec->up)->down = to_rec->right;
2764 } else {
2765 (to_rec->left)->right = to_rec->right;
2766 }
2767 if( to_rec->right != (struct files_rec*) 0 ){
2768 (to_rec->right)->left = to_rec->left;
2769 }
2770 p1 = to_rec; to_rec = to_rec->up; free((void *) p1);
2771 }
2772
2773
2774 }
2775 }
2776
2777
2778 } } }
2779
2780 #line 1753 "./tex4ht-t4ht.tex"
2781
2782 for( p = opened_files; p != (struct files_rec*) 0; ){
2783 (IGNORED) fclose(p->file);
2784 free((void *) p->name);
2785
2786 #line 1762 "./tex4ht-t4ht.tex"
2787
2788 for( p1 = p->down; p1 != (struct files_rec*) 0; ){
2789
2790 #line 1769 "./tex4ht-t4ht.tex"
2791
2792 for( p2 = p1->down; p2 != (struct files_rec*) 0; ){
2793
2794 #line 1776 "./tex4ht-t4ht.tex"
2795
2796 for( p3 = p2->down; p3 != (struct files_rec*) 0; ){
2797 p4 = p3; p3 = p3->down; free((void *) p4);
2798 }
2799
2800
2801 p3 = p2; p2 = p2->right; free((void *) p3);
2802 }
2803
2804
2805 p2 = p1; p1 = p1->right; free((void *) p2);
2806 }
2807
2808
2809 p1= p; p = p->right; free((void *) p1);
2810 }
2811
2812
2813 }
2814
2815
2816
2817 #line 3763 "./tex4ht-t4ht.tex"
2818
2819 (IGNORED) fseek(lg_file, begin_lg_file,
2820 #line 3767 "./tex4ht-t4ht.tex"
2821
2822 0
2823 );
2824
2825
2826 #line 2372 "./tex4ht-t4ht.tex"
2827
2828 { struct htf_struct *last_rec, *p;
2829 last_rec = (struct htf_struct *) 0;
2830 eoln_ch = (int) 'x';
2831 while( eoln_ch != EOF ) {
2832 status = scan_str("htfcss: ", TRUE, lg_file);
2833 status = scan_until_end_str("", 1, status, lg_file);
2834
2835 #line 2387 "./tex4ht-t4ht.tex"
2836
2837 if( status ){
2838 Q_CHAR *s, *t;
2839 int i;
2840 s = t = match[1];
2841 for( i=0; *s == ' '; s++ ) { i++; }
2842 if( i>0 ){
2843 while( *s != 0 ){
2844 *(t++) = *(s++);
2845 }
2846 *t = 0;
2847 } }
2848
2849
2850 if( status ){ Q_CHAR *key, *body, *media;
2851 media = body = key = match[1];
2852
2853 #line 2404 "./tex4ht-t4ht.tex"
2854
2855 while( *body && (*body != ' ') ){ body++; }
2856 if( *body == ' ' ){ media = body; *(body++) = '\0'; }
2857
2858 #line 2416 "./tex4ht-t4ht.tex"
2859
2860 if( (int) strlen((char *) body) > 6 ){
2861 if( (*(body) == '@')
2862 && (*(body+1) == 'm')
2863 && (*(body+2) == 'e')
2864 && (*(body+3) == 'd')
2865 && (*(body+4) == 'i')
2866 && (*(body+5) == 'a') )
2867 {
2868 body += 6;
2869 while( *body == ' ' ){ body++; }
2870 media = body;
2871 while( (*body != ' ') && (*body != '\0') ){ body++; }
2872 if( *body == ' ' ){ *(body++) = '\0'; }
2873 while( *body == ' ' ){ body++; }
2874 } }
2875
2876
2877 if( *body ){
2878 if( *key ){
2879 #line 2434 "./tex4ht-t4ht.tex"
2880
2881 p = m_alloc(struct htf_struct, 1);
2882 p->next = (struct htf_struct *) 0;
2883 p->key = m_alloc(char, (int) strlen((char *) key) + 1);
2884 (IGNORED) strcpy((char *) p->key, (char *) key );
2885 p->media = m_alloc(char, (int) strlen((char *) media) + 1);
2886 (IGNORED) strcpy((char *) p->media, (char *) media );
2887 p->body = m_alloc(char, (int) strlen((char *) body) + 1);
2888 (IGNORED) strcpy((char *) p->body, (char *) body );
2889 if( last_rec ){
2890 last_rec->next = p; last_rec = p;
2891 } else {
2892 htf_rec = last_rec = p;
2893 }
2894 if( debug ){
2895 (IGNORED) printf(".......%s...%s...%s\n", key, media, body);
2896 }
2897
2898 }
2899 #if 0 /* unreachable */
2900 else if( last_rec ){
2901 #line 2453 "./tex4ht-t4ht.tex"
2902
2903 last_rec->body = (Q_CHAR *) r_alloc((void *) last_rec->body,
2904 (size_t) strlen((char *) last_rec->body)
2905 + (size_t) strlen((char *) body)
2906 + 2);
2907 (IGNORED) strct(last_rec->body,"\n");
2908 (IGNORED) strct(last_rec->body,body);
2909 if( debug ){
2910 (IGNORED) printf(".......%s\n", body);
2911 }
2912
2913 }
2914 #endif /* 0, unreachable */
2915 }
2916
2917
2918 } }
2919 }
2920
2921
2922
2923 #line 3763 "./tex4ht-t4ht.tex"
2924
2925 (IGNORED) fseek(lg_file, begin_lg_file,
2926 #line 3767 "./tex4ht-t4ht.tex"
2927
2928 0
2929 );
2930
2931
2932 #line 2475 "./tex4ht-t4ht.tex"
2933
2934 eoln_ch = (int) 'x';
2935 while( eoln_ch != EOF ) {
2936 status = scan_str("Font_Css_Plus ", TRUE, lg_file);
2937 status = scan_until_str(" ", 1, status, lg_file);
2938 status = scan_until_end_str("", 2, status, lg_file);
2939 if( status ){ Q_CHAR *key;
2940 key = match[1];
2941 *(key + (int) strlen((char *) key) - 1) = '\0';
2942
2943 #line 2490 "./tex4ht-t4ht.tex"
2944
2945 if( (*key != '\0') && (*key != '\n') ) {
2946 struct htf_struct *p;
2947 p = m_alloc(struct htf_struct, 1);
2948 p->next = htf_rec;
2949 htf_rec = p;
2950 p->key = m_alloc(char, (int) strlen((char *) key) + 1);
2951 (IGNORED) strcpy((char *) p->key, (char *) key );
2952 p->body = m_alloc(char, (int) strlen((char *) match[2]) + 1);
2953 (IGNORED) strcpy((char *) p->body, (char *) match[2] );
2954 if( debug ){
2955 (IGNORED) printf(".......%s...%s\n", key, match[2]);
2956 } }
2957
2958
2959 } }
2960
2961
2962
2963 #line 3763 "./tex4ht-t4ht.tex"
2964
2965 (IGNORED) fseek(lg_file, begin_lg_file,
2966 #line 3767 "./tex4ht-t4ht.tex"
2967
2968 0
2969 );
2970
2971
2972 #line 1124 "./tex4ht-t4ht.tex"
2973
2974 { struct empty_pic_struct *last;
2975 last = empty_pic = (struct empty_pic_struct *) 0;
2976 while( TRUE ) {
2977 status = scan_str("--- empty picture --- ", TRUE, lg_file);
2978 status = scan_until_str( ".idv[" , 1, status, lg_file);
2979 status = scan_until_end_str("] ---", 1, status, lg_file);
2980 if( status ){
2981 #line 1141 "./tex4ht-t4ht.tex"
2982
2983 if( last == (struct empty_pic_struct *) 0 ){
2984 last = empty_pic = (struct empty_pic_struct *)
2985 m_alloc(struct empty_pic_struct, (int) 1);
2986 } else {
2987 last = last->next = (struct empty_pic_struct *)
2988 m_alloc(struct empty_pic_struct, (int) 1);
2989 }
2990 last->next = (struct empty_pic_struct *) 0;
2991 last->n = get_long_int(match[1]);
2992
2993 }
2994 if ( eoln_ch == EOF ){ break; }
2995 }
2996
2997 #line 1141 "./tex4ht-t4ht.tex"
2998
2999 if( last == (struct empty_pic_struct *) 0 ){
3000 last = empty_pic = (struct empty_pic_struct *)
3001 m_alloc(struct empty_pic_struct, (int) 1);
3002 } else {
3003 last = last->next = (struct empty_pic_struct *)
3004 m_alloc(struct empty_pic_struct, (int) 1);
3005 }
3006 last->next = (struct empty_pic_struct *) 0;
3007 last->n = get_long_int(match[1]);
3008
3009
3010 last->next = (struct empty_pic_struct *) 0;
3011 last->n = 100000;
3012 }
3013
3014
3015
3016 #line 3763 "./tex4ht-t4ht.tex"
3017
3018 (IGNORED) fseek(lg_file, begin_lg_file,
3019 #line 3767 "./tex4ht-t4ht.tex"
3020
3021 0
3022 );
3023
3024
3025 #line 1192 "./tex4ht-t4ht.tex"
3026
3027 { BOOL characters, skip;
3028 characters = skip = FALSE;
3029 while( TRUE ) {
3030 status = scan_until_str("--- ", 1, TRUE, lg_file);
3031 status = scan_until_str( " ---" , 2, status, lg_file);
3032 if( status ) {
3033 if( eq_str(match[1],"--- ") ){
3034 if( eq_str(match[2],"needs ---") ){
3035
3036 #line 1231 "./tex4ht-t4ht.tex"
3037
3038 status = scan_until_str(" ", 1, status, lg_file);
3039 status = scan_until_str(".idv", 1, status, lg_file);
3040 status = scan_until_str("[", 2, status, lg_file);
3041 status = scan_until_str("] ==> ", 2, status, lg_file);
3042 status = scan_until_str(" ", 3, status, lg_file);
3043 *(match[3] + (int) strlen((char *) match[3]) - 1) = '\0';
3044 status = scan_until_end_str("---", 4, status, lg_file);
3045 if( status ) {
3046
3047 #line 1353 "./tex4ht-t4ht.tex"
3048
3049 struct script_struct
3050 * filtered_dvigif_script = NULL_SCRIPT;
3051
3052
3053 long int gif_i;
3054 Q_CHAR *p;
3055 gif_i = get_long_int(match[2]);
3056 p = match[2];
3057 *(p + (int) strlen((char *) p) - 6) = '\0';
3058 if( characters ){
3059
3060 #line 1295 "./tex4ht-t4ht.tex"
3061
3062 Q_CHAR filename[255];
3063 FILE* file;
3064 (IGNORED) strcpy((char *) filename, "");
3065 if( dir && !bitmaps_no_dm ){ (IGNORED) strct(filename, dir); }
3066 (IGNORED) strct(filename, match[3]);
3067 file = fopen(filename, READ_TEXT_FLAGS);
3068 if( !file || noreuse ){
3069
3070 #line 1332 "./tex4ht-t4ht.tex"
3071
3072 filtered_dvigif_script = dvigif_glyp_script?
3073 filterGifScript(dvigif_glyp_script, match[3]):
3074 filterGifScript(dvigif_script, match[3]);
3075 (void) execute_script(
3076 filtered_dvigif_script,match[1],match[2],match[3],job_name);
3077 (void) free_script( filtered_dvigif_script );
3078 if( dir && !bitmaps_no_dm && !system_return ){
3079 (void) execute_script(move_script,match[3],dir,".","");
3080
3081 #line 1346 "./tex4ht-t4ht.tex"
3082
3083 if( ch_mod && !bitmaps_no_dm && !system_return ){
3084 (void) execute_script(chmod_script, ch_mod, dir?dir:"",match[3], "");
3085 }
3086
3087
3088 }
3089
3090
3091 } else {
3092 (IGNORED) fclose(file);
3093 if( newchmod )
3094 {
3095 #line 1346 "./tex4ht-t4ht.tex"
3096
3097 if( ch_mod && !bitmaps_no_dm && !system_return ){
3098 (void) execute_script(chmod_script, ch_mod, dir?dir:"",match[3], "");
3099 }
3100
3101 }
3102 (IGNORED) printf("%s already in %s\n", match[3],
3103 dir? dir : "current directory" );
3104 }
3105
3106
3107 } else {
3108 #line 1258 "./tex4ht-t4ht.tex"
3109
3110 if( gif_i ==
3111 #line 1286 "./tex4ht-t4ht.tex"
3112
3113 empty_pic->n
3114
3115 ) {
3116
3117 #line 1272 "./tex4ht-t4ht.tex"
3118
3119 if( !skip ){
3120 (void) execute_script(empty_fig_script,
3121 (dir && !bitmaps_no_dm )? dir :"", match[3],"","");
3122 if( ch_mod && !bitmaps_no_dm && !system_return ){
3123 (void) execute_script(chmod_script, ch_mod,
3124 dir?dir:"",match[3], "");
3125 }
3126 }
3127 empty_pic = empty_pic->next;
3128
3129
3130 } else {
3131 #line 1265 "./tex4ht-t4ht.tex"
3132
3133 if( !nopict && !skip ){
3134
3135 #line 1319 "./tex4ht-t4ht.tex"
3136
3137 filtered_dvigif_script = filterGifScript(dvigif_script, match[3]);
3138 (void) execute_script(
3139 filtered_dvigif_script,match[1],match[2],match[3],job_name);
3140 (void) free_script( filtered_dvigif_script );
3141 if( dir && !bitmaps_no_dm && !system_return ){
3142 (void) execute_script(move_script,match[3],dir,".","");
3143 }
3144 if( ch_mod && !bitmaps_no_dm && !system_return ){
3145 (void) execute_script(chmod_script, ch_mod, dir?dir:"",match[3], "");
3146 }
3147
3148
3149 }
3150
3151 }
3152
3153 }
3154 }
3155
3156
3157 } else if( eq_str(match[2],"characters ---") ){
3158
3159 #line 1221 "./tex4ht-t4ht.tex"
3160
3161 status = scan_until_end_str("", 1, status, lg_file);
3162 characters = eq_str(match[1],"");
3163
3164
3165 } else {
3166 #line 1212 "./tex4ht-t4ht.tex"
3167
3168 status = scan_until_end_str("", 1, status, lg_file);
3169
3170 }
3171 } else {
3172 #line 1647 "./tex4ht-t4ht.tex"
3173
3174 status = scan_until_end_str(" ignore ---", 2, status, lg_file);
3175 if( status ){
3176 skip = eq_str(match[2]," ignore ---") ? TRUE :
3177 ( eq_str(match[2]," end ignore ---") ? FALSE : skip );
3178 }
3179
3180 }
3181 }
3182 if ( eoln_ch == EOF ){ break; }
3183 } }
3184
3185
3186
3187 #line 3763 "./tex4ht-t4ht.tex"
3188
3189 (IGNORED) fseek(lg_file, begin_lg_file,
3190 #line 3767 "./tex4ht-t4ht.tex"
3191
3192 0
3193 );
3194
3195
3196 #line 2538 "./tex4ht-t4ht.tex"
3197
3198 {
3199 Q_CHAR css_name[255];
3200 FILE *css_file, *tmp_file;
3201 BOOL css_sty;
3202
3203 #line 2582 "./tex4ht-t4ht.tex"
3204
3205 (IGNORED) strcpy((char *) css_name, (char *) job_name);
3206 (IGNORED) strct(css_name, ".css");
3207 css_file = fopen(css_name, READ_TEXT_FLAGS);
3208
3209
3210 if( css_file ){
3211 (IGNORED) printf ("Entering %s\n", css_name);
3212 tmp_file = fopen(tmp_name, WRITE_TEXT_FLAGS);
3213 if( !tmp_file ) {
3214 (IGNORED) warn_i_str(5,tmp_name);
3215 } else {
3216 #line 2572 "./tex4ht-t4ht.tex"
3217
3218 int ch;
3219 while( (ch = getc(css_file)) != EOF ) {
3220 (IGNORED) putc( ch, tmp_file );
3221 }
3222 (IGNORED) fclose(tmp_file);
3223 (IGNORED) fclose(css_file);
3224
3225 }
3226 tmp_file = open_file(tmp_name, ".tmp");
3227 css_file = fopen(css_name, WRITE_TEXT_FLAGS);
3228 if( !tmp_file ) {
3229 (IGNORED) warn_i_str(5,tmp_name);
3230 } else if( !css_file ) {
3231 (IGNORED) warn_i_str(5,css_name);
3232 } else {
3233
3234 #line 2594 "./tex4ht-t4ht.tex"
3235
3236 css_sty = FALSE;
3237 eoln_ch = (int) 'x';
3238 while( eoln_ch != EOF ) {
3239 status = scan_until_end_str("", 1, TRUE, tmp_file);
3240
3241 #line 2611 "./tex4ht-t4ht.tex"
3242
3243 { Q_CHAR *p, *q;
3244 int n;
3245 n = 0; p = match[1]; q = match[2];
3246 while ( (*p != '\0') ){
3247 if (n == 13) { *(q-10) = '\0'; break;}
3248 if( *p != ' ' ){ *(q++) = *p; n++; }
3249 p++;
3250 }
3251 *q = '\0';
3252 }
3253
3254
3255 if( eq_str(match[2], "/*css.sty*/") ){ css_sty = TRUE; break; }
3256 (IGNORED) fprintf(css_file, "%s\n", match[1]);
3257 }
3258
3259
3260 if( css_sty ){
3261
3262 #line 2628 "./tex4ht-t4ht.tex"
3263
3264 (IGNORED) fprintf(css_file, "/* start css.sty */\n");
3265
3266 #line 3763 "./tex4ht-t4ht.tex"
3267
3268 (IGNORED) fseek(lg_file, begin_lg_file,
3269 #line 3767 "./tex4ht-t4ht.tex"
3270
3271 0
3272 );
3273
3274
3275 #line 2801 "./tex4ht-t4ht.tex"
3276
3277 eoln_ch = (int) 'x';
3278 while( eoln_ch != EOF ) {
3279 status = scan_str("Font_css_base: ", TRUE, lg_file);
3280 status = scan_until_str("Font_css_mag: ", 1, status, lg_file);
3281 status = scan_until_end_str("", 2, status, lg_file);
3282 if( status ){
3283 Font_css_base = match[1];
3284 *(Font_css_base + (int) strlen((char *) Font_css_base) - 14) = '\0';
3285 match[1] = (Q_CHAR *) malloc(70); max_match[1] = 70;
3286 Font_css_mag = match[2];
3287 match[2] = (Q_CHAR *) malloc(70); max_match[2] = 70;
3288 } }
3289
3290
3291
3292 #line 3763 "./tex4ht-t4ht.tex"
3293
3294 (IGNORED) fseek(lg_file, begin_lg_file,
3295 #line 3767 "./tex4ht-t4ht.tex"
3296
3297 0
3298 );
3299
3300
3301 #line 2686 "./tex4ht-t4ht.tex"
3302
3303 eoln_ch = (int) 'x';
3304 while( eoln_ch != EOF ) {
3305 status = scan_str("Font_Size: ", TRUE, lg_file);
3306 status = scan_until_end_str("", 1, status, lg_file);
3307 if( status ){
3308 base_font_size = (int) get_long_int(match[1]);
3309 } }
3310
3311
3312
3313 #line 3763 "./tex4ht-t4ht.tex"
3314
3315 (IGNORED) fseek(lg_file, begin_lg_file,
3316 #line 3767 "./tex4ht-t4ht.tex"
3317
3318 0
3319 );
3320
3321
3322 #line 2715 "./tex4ht-t4ht.tex"
3323
3324 eoln_ch = (int) 'x';
3325 while( eoln_ch != EOF ) {
3326 status = scan_str("Font(\"", TRUE, lg_file);
3327 status = scan_until_str("\",\"", 1, status, lg_file);
3328 status = scan_until_str("\",\"", 2, status, lg_file);
3329 status = scan_until_str("\",\"", 3, status, lg_file);
3330 status = scan_until_end_str("\")", 4, status, lg_file);
3331 if( status ){
3332 Q_CHAR *p;
3333 struct htf_struct *font_sty;
3334 int second;
3335 p = match[1];
3336 *(p + (int) strlen((char *) p) - 3) = '\0';
3337 p = match[2];
3338 *(p + (int) strlen((char *) p) - 3) = '\0';
3339 p = match[3];
3340 *(p + (int) strlen((char *) p) - 3) = '\0';
3341 p = match[4];
3342 *(p + (int) strlen((char *) p) - 2) = '\0';
3343
3344 #line 2763 "./tex4ht-t4ht.tex"
3345
3346 { Q_CHAR *p;
3347 second = (int)
3348 ( (int) get_long_int(match[3])
3349 * (int) get_long_int(match[4])
3350 / base_font_size
3351 );
3352 while( second > 700 ){ second /= 10; }
3353 p = match[3];
3354 while( *p != '\0' ){
3355 if( (*p < '0') || (*p > '9') ){ second = 100; break; }
3356 p++;
3357 }
3358
3359 #line 2783 "./tex4ht-t4ht.tex"
3360
3361 if( (int) ( (double) get_long_int(match[2])
3362 / (int) get_long_int(match[4])
3363 + 0.5
3364 )
3365 == base_font_size
3366 ){
3367 second = 100;
3368 };
3369
3370
3371 }
3372
3373
3374
3375 #line 2744 "./tex4ht-t4ht.tex"
3376
3377 font_sty = htf_rec;
3378 while ( font_sty ) {
3379 if( eq_str(font_sty->key,match[1]) ){
3380 if( *(font_sty->media) == '\0' ){
3381
3382 #line 2827 "./tex4ht-t4ht.tex"
3383
3384 (IGNORED) fprintf(css_file,
3385 (Font_css_base == NULL)? ".%s-%s" : Font_css_base,
3386 match[1], match[2]);
3387 if( !eq_str(match[4],"100") ){
3388 (IGNORED) fprintf(css_file,
3389 (Font_css_mag == NULL)? "x-x-%s" : Font_css_mag,
3390 match[4]);
3391 }
3392 (IGNORED) fprintf(css_file, "{");
3393 if( (second < 98) || (second > 102) ){
3394 (IGNORED) fprintf(css_file, "font-size:%d%c;", second, '%');
3395 }
3396 if( font_sty ) {
3397 (IGNORED) fprintf(css_file, "%s", font_sty->body);
3398 }
3399 (IGNORED) fprintf(css_file, "}\n");
3400
3401
3402 second = 100;
3403 } else {
3404
3405 #line 2847 "./tex4ht-t4ht.tex"
3406
3407 (IGNORED) fprintf(css_file, "@media %s{", font_sty->media);
3408 (IGNORED) fprintf(css_file,
3409 (Font_css_base == NULL)? ".%s-%s" : Font_css_base,
3410 match[1], match[2]);
3411 if( !eq_str(match[4],"100") ){
3412 (IGNORED) fprintf(css_file,
3413 (Font_css_mag == NULL)? "x-x-%s" : Font_css_mag,
3414 match[4]);
3415 }
3416 (IGNORED) fprintf(css_file, "{");
3417 if( font_sty ) {
3418 (IGNORED) fprintf(css_file, "%s", font_sty->body);
3419 }
3420 (IGNORED) fprintf(css_file, "}}\n");
3421
3422
3423 }
3424 }
3425 font_sty = font_sty->next;
3426 }
3427 if( second != 100 ){
3428 #line 2827 "./tex4ht-t4ht.tex"
3429
3430 (IGNORED) fprintf(css_file,
3431 (Font_css_base == NULL)? ".%s-%s" : Font_css_base,
3432 match[1], match[2]);
3433 if( !eq_str(match[4],"100") ){
3434 (IGNORED) fprintf(css_file,
3435 (Font_css_mag == NULL)? "x-x-%s" : Font_css_mag,
3436 match[4]);
3437 }
3438 (IGNORED) fprintf(css_file, "{");
3439 if( (second < 98) || (second > 102) ){
3440 (IGNORED) fprintf(css_file, "font-size:%d%c;", second, '%');
3441 }
3442 if( font_sty ) {
3443 (IGNORED) fprintf(css_file, "%s", font_sty->body);
3444 }
3445 (IGNORED) fprintf(css_file, "}\n");
3446
3447 }
3448
3449
3450 } }
3451
3452
3453
3454 #line 3763 "./tex4ht-t4ht.tex"
3455
3456 (IGNORED) fseek(lg_file, begin_lg_file,
3457 #line 3767 "./tex4ht-t4ht.tex"
3458
3459 0
3460 );
3461
3462
3463 #line 2871 "./tex4ht-t4ht.tex"
3464
3465 { char *font_class [256];
3466 int last_class;
3467
3468 #line 2890 "./tex4ht-t4ht.tex"
3469
3470 last_class = 0;
3471 eoln_ch = (int) 'x';
3472 while( eoln_ch != EOF ) {
3473 status = scan_str("Font_Class(", TRUE, lg_file);
3474 status = scan_until_str(",\"", 1, status, lg_file);
3475 status = scan_until_str("\"): ", 1, status, lg_file);
3476 status = scan_until_end_str("", 2, status, lg_file);
3477 if( status ){
3478 font_class[last_class++] = match[1];
3479 match[1] = (Q_CHAR *) malloc(7); max_match[1] = 7;
3480 } }
3481
3482 #line 3763 "./tex4ht-t4ht.tex"
3483
3484 (IGNORED) fseek(lg_file, begin_lg_file,
3485 #line 3767 "./tex4ht-t4ht.tex"
3486
3487 0
3488 );
3489
3490
3491
3492
3493 eoln_ch = (int) 'x';
3494 while( eoln_ch != EOF ) {
3495 status = scan_str("Font_Css(\"", TRUE, lg_file);
3496 status = scan_until_str("\"): ", 1, status, lg_file);
3497 status = scan_until_end_str("", 2, status, lg_file);
3498 if( status ){ int i;
3499 for(i=0; i<last_class; i++){
3500 if( eq_str(match[1],font_class[i]) ){
3501 (IGNORED) fprintf(css_file, "%s\n", match[2]);
3502 break;
3503 } } } } }
3504
3505
3506
3507 #line 3763 "./tex4ht-t4ht.tex"
3508
3509 (IGNORED) fseek(lg_file, begin_lg_file,
3510 #line 3767 "./tex4ht-t4ht.tex"
3511
3512 0
3513 );
3514
3515
3516 #line 2667 "./tex4ht-t4ht.tex"
3517
3518 eoln_ch = (int) 'x';
3519 while( eoln_ch != EOF ) {
3520 status = scan_str("Css: ", TRUE, lg_file);
3521 status = scan_until_end_str("", 1, status, lg_file);
3522 if( status ){
3523 (IGNORED) fprintf(css_file, "%s\n", match[1]);
3524 } }
3525
3526
3527 (IGNORED) fprintf(css_file, "/* end css.sty */\n");
3528
3529
3530
3531 #line 2649 "./tex4ht-t4ht.tex"
3532
3533 eoln_ch = (int) 'x';
3534 while( eoln_ch != EOF ) {
3535 status = scan_until_end_str("", 1, TRUE, tmp_file);
3536
3537 #line 2611 "./tex4ht-t4ht.tex"
3538
3539 { Q_CHAR *p, *q;
3540 int n;
3541 n = 0; p = match[1]; q = match[2];
3542 while ( (*p != '\0') ){
3543 if (n == 13) { *(q-10) = '\0'; break;}
3544 if( *p != ' ' ){ *(q++) = *p; n++; }
3545 p++;
3546 }
3547 *q = '\0';
3548 }
3549
3550
3551 if( !eq_str(match[2], "/*css.sty*/") ){
3552 (IGNORED) fprintf(css_file, "%s\n", match[1]);
3553 }
3554 }
3555
3556
3557 }
3558 }
3559 (IGNORED) fclose(tmp_file);
3560 (IGNORED) fclose(css_file);
3561 } }
3562
3563
3564
3565 #line 3763 "./tex4ht-t4ht.tex"
3566
3567 (IGNORED) fseek(lg_file, begin_lg_file,
3568 #line 3767 "./tex4ht-t4ht.tex"
3569
3570 0
3571 );
3572
3573
3574 #line 2086 "./tex4ht-t4ht.tex"
3575
3576 if(
3577 #line 2175 "./tex4ht-t4ht.tex"
3578
3579 ext_script
3580
3581 ){
3582 eoln_ch = (int) 'x';
3583 while( eoln_ch != EOF ) {
3584 status = scan_str("File: ", TRUE, lg_file);
3585 status = scan_until_str(".", 1, status, lg_file);
3586 status = scan_until_end_str("", 2, status, lg_file);
3587 if( status ){ Q_CHAR *ext;
3588 struct script_struct *cur_script;
3589 ext = match[1];
3590 (IGNORED) strct( ext, match[2] );
3591 ext += strlen((char *) ext);
3592 while( *(--ext) != '.' ){ ; }
3593 *ext = '\0'; ext++;
3594
3595 #line 2108 "./tex4ht-t4ht.tex"
3596
3597 {
3598 struct script_struct *cur, *add, *temp;
3599 Q_CHAR extPlus[256];
3600 cur =
3601 #line 2175 "./tex4ht-t4ht.tex"
3602
3603 ext_script
3604
3605 ;
3606 add = cur_script = NULL_SCRIPT;
3607 while( cur ){
3608
3609 #line 2129 "./tex4ht-t4ht.tex"
3610
3611 (IGNORED) strcpy((char *) extPlus, (char *) ext);
3612 /*
3613 if ( envChoice ) {
3614 (IGNORED) strct ( extPlus, envChoice );
3615 }
3616 */
3617 (IGNORED) strct ( extPlus, " " );
3618
3619
3620 if( strpre(extPlus, cur->command) ){
3621
3622 #line 2139 "./tex4ht-t4ht.tex"
3623
3624 temp = (struct script_struct *)
3625 m_alloc(struct script_struct, (int) 1);
3626 temp->command = m_alloc(char, (int) strlen((char *) cur->command) + 1);
3627 temp->next = NULL_SCRIPT;
3628 (IGNORED) strcpy((char *) temp->command,
3629 (char *) cur->command + (int) strlen((char *) extPlus) );
3630
3631
3632 if( cur_script == NULL_SCRIPT ){
3633 cur_script = add = temp;
3634 } else {
3635 add = add->next = temp;
3636 } }
3637 cur = cur->next;
3638 } }
3639
3640
3641 (void) execute_script(cur_script,
3642 match[1], Dotfield? Dotfield : "", "", "");
3643
3644 #line 2148 "./tex4ht-t4ht.tex"
3645
3646 while( cur_script != (struct script_struct*) 0 ){
3647 struct script_struct *temp;
3648 temp = cur_script; cur_script = cur_script->next; free((void *) temp);
3649 }
3650
3651
3652 } } }
3653
3654
3655
3656 #line 3763 "./tex4ht-t4ht.tex"
3657
3658 (IGNORED) fseek(lg_file, begin_lg_file,
3659 #line 3767 "./tex4ht-t4ht.tex"
3660
3661 0
3662 );
3663
3664
3665 #line 2221 "./tex4ht-t4ht.tex"
3666
3667 if(
3668 #line 2239 "./tex4ht-t4ht.tex"
3669
3670 file_script
3671
3672 ){
3673 eoln_ch = (int) 'x';
3674 while( eoln_ch != EOF ) {
3675 status = scan_str("File: ", TRUE, lg_file);
3676 status = scan_until_str(".", 1, status, lg_file);
3677 status = scan_until_end_str("", 2, status, lg_file);
3678 if( status ){ Q_CHAR *p;
3679 p = match[1];
3680 (IGNORED) strct( p, match[2] );
3681 p += strlen((char *) p);
3682 while( *(--p) != '.' ){ ; }
3683 *p = '\0'; p++;
3684 (void) execute_script(file_script, match[1],
3685 p, Xfield? Xfield : "", "");
3686 } } }
3687
3688
3689
3690 #line 3763 "./tex4ht-t4ht.tex"
3691
3692 (IGNORED) fseek(lg_file, begin_lg_file,
3693 #line 3767 "./tex4ht-t4ht.tex"
3694
3695 0
3696 );
3697
3698
3699 #line 112 "./tex4ht-t4ht.tex"
3700
3701 eoln_ch = (int) 'x';
3702 while( eoln_ch != EOF ) {
3703 status = scan_str("File: ", TRUE, lg_file);
3704 status = scan_until_end_str("", 1, status, lg_file);
3705 status = status && !eq_str(match[1],tmp_name);
3706 if( status ){
3707 FILE* file;
3708 file = fopen(match[1], READ_TEXT_FLAGS);
3709 if( file ){
3710 (IGNORED) fclose(file);
3711 } else { status = FALSE; }
3712 }
3713 if( status ){
3714 if( dir ){
3715 (void) execute_script(copy_script, match[1],
3716 dir? dir :"",".","");
3717 }
3718 if( ch_mod ){
3719 (void) execute_script(chmod_script, ch_mod,
3720 dir? dir:"",match[1], "");
3721 }
3722 } }
3723
3724
3725
3726 #line 3763 "./tex4ht-t4ht.tex"
3727
3728 (IGNORED) fseek(lg_file, begin_lg_file,
3729 #line 3767 "./tex4ht-t4ht.tex"
3730
3731 0
3732 );
3733
3734
3735 #line 2249 "./tex4ht-t4ht.tex"
3736
3737 eoln_ch = (int) 'x';
3738 while( eoln_ch != EOF ) { Q_CHAR *command, ch;
3739 int n;
3740 struct sys_call_rec *p;
3741 BOOL flag;
3742 status = scan_str("l. ", TRUE, lg_file);
3743 status = scan_until_str(" --- needs --- \"", 1, status, lg_file);
3744 status = scan_until_str("\" ---", 2, status, lg_file);
3745 if( status ){
3746 command = match[2];
3747 *(command + (int) strlen((char *) command) - 5) = '\0';
3748
3749 #line 2293 "./tex4ht-t4ht.tex"
3750
3751 flag = FALSE;
3752 p = system_calls;
3753 while( p ){
3754 if( (n = (int) strlen((char *) p->filter)) == 1 ) {
3755 if( *(p->filter) == '*' ){
3756 flag = TRUE; break;
3757 }
3758 }
3759 if( strlen((char *) command) >= (unsigned int) n ) {
3760 ch = command[n]; command[n] = '\0';
3761 flag = flag || eq_str(p->filter,command);
3762 command[n] = ch;
3763 }
3764 p = p->next;
3765 }
3766
3767
3768 if( flag ){
3769
3770 #line 4166 "./tex4ht-t4ht.tex"
3771
3772 (IGNORED) call_sys(command);
3773
3774
3775 } else { (IGNORED) printf(
3776 "No permission for system call: %s\n", command); }
3777 } }
3778
3779
3780 (IGNORED) fclose(lg_file);
3781 }
3782
3783
3784 return 0;
3785 }
3786
3787