This repository has been archived by the owner on Sep 4, 2021. It is now read-only.
/
groff_1.18.1-15.diff
20101 lines (19800 loc) · 409 KB
/
groff_1.18.1-15.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--- groff-1.18.1.orig/src/include/config.hin
+++ groff-1.18.1/src/include/config.hin
@@ -1,84 +1,96 @@
-/* src/include/config.hin. Generated automatically from configure.ac by autoheader. */
+/* src/include/config.hin. Generated from configure.ac by autoheader. */
/* Define if your C++ doesn't understand `delete []'. */
#undef ARRAY_DELETE_NEEDS_SIZE
+/* Define if you want to use multibyte extension. */
+#undef ENABLE_MULTIBYTE
+
/* Define if you have a C++ <limits.h>. */
#undef HAVE_CC_LIMITS_H
/* Define if you have a C++ <osfcn.h>. */
#undef HAVE_CC_OSFCN_H
-/* Define if you have the <dirent.h> header file. */
+/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
-/* Define if you have the `fmod' function. */
+/* Define to 1 if you have the `fmod' function. */
#undef HAVE_FMOD
-/* Define if you have the `getcwd' function. */
+/* Define to 1 if you have the `getcwd' function. */
#undef HAVE_GETCWD
-/* Define if you have the `getpagesize' function. */
+/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
-/* Define if you have the `gettimeofday' function. */
+/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
-/* Define if you have the <limits.h> header file. */
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `isatty' function. */
+#undef HAVE_ISATTY
+
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#undef HAVE_LANGINFO_CODESET
+
+/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
-/* Define if you have the <math.h> header file. */
+/* Define to 1 if you have the <math.h> header file. */
#undef HAVE_MATH_H
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
/* Define if you have mkstemp(). */
#undef HAVE_MKSTEMP
-/* Define if you have a working `mmap' system call. */
+/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
-/* Define if you have the `putenv' function. */
+/* Define to 1 if you have the `putenv' function. */
#undef HAVE_PUTENV
-/* Define if you have the `rename' function. */
+/* Define to 1 if you have the `rename' function. */
#undef HAVE_RENAME
-/* Define if you have the `snprintf' function. */
+/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
-/* Define if you have the `isatty' function. */
-#undef HAVE_ISATTY
-
-/* Define if you have the <stdint.h> header file. */
+/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
-/* Define if you have the <stdlib.h> header file. */
+/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
-/* Define if you have the `strcasecmp' function. */
+/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
-/* Define if you have the `strerror' function. */
+/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
-/* Define if you have the <strings.h> header file. */
+/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
-/* Define if you have the <string.h> header file. */
+/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
-/* Define if you have the `strncasecmp' function. */
+/* Define to 1 if you have the `strncasecmp' function. */
#undef HAVE_STRNCASECMP
-/* Define if you have the `strsep' function. */
+/* Define to 1 if you have the `strsep' function. */
#undef HAVE_STRSEP
-/* Define if you have the `strtol' function. */
+/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
/* Define if <math.h> defines struct exception. */
#undef HAVE_STRUCT_EXCEPTION
-/* Define if you have the <sys/dir.h> header file. */
+/* Define to 1 if you have the <sys/dir.h> header file. */
#undef HAVE_SYS_DIR_H
/* Define if you have sys_errlist in <errno.h> or in <stdio.h>. */
@@ -87,10 +99,16 @@
/* Define if you have sysnerr in <errno.h> or <stdio.h>. */
#undef HAVE_SYS_NERR
-/* Define if you have the <sys/time.h> header file. */
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
-/* Define if you have the <unistd.h> header file. */
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if the host's encoding is EBCDIC. */
@@ -120,6 +138,21 @@
/* Define if your C++ doesn't declare strncasecmp(). */
#undef NEED_DECLARATION_STRNCASECMP
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
/* Define if the printer's page size is A4. */
#undef PAGEA4
@@ -129,7 +162,10 @@
/* Define if srand() returns void not int. */
#undef RET_TYPE_SRAND_IS_VOID
-/* Define if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
#undef SYS_SIGLIST_DECLARED
/* Define if your C++ compiler uses a traditional (Reiser) preprocessor. */
--- groff-1.18.1.orig/src/include/device.h
+++ groff-1.18.1/src/include/device.h
@@ -18,4 +18,9 @@
with groff; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#ifndef _DEVICE_H
+#define _DEVICE_H
+
extern const char *device;
+
+#endif /* _DEVICE_H */
--- groff-1.18.1.orig/src/include/driver.h
+++ groff-1.18.1/src/include/driver.h
@@ -27,6 +27,7 @@
#include <errno.h>
#include <assert.h>
#include <math.h>
+#include "encoding.h" // XXX: ukai
#include "errarg.h"
#include "error.h"
#include "font.h"
--- groff-1.18.1.orig/src/include/font.h
+++ groff-1.18.1/src/include/font.h
@@ -18,11 +18,17 @@
with groff; see the file COPYING. If not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+#include "encoding.h"
+
typedef void (*FONT_COMMAND_HANDLER)(const char *, const char *,
const char *, int);
struct font_kern_list;
struct font_char_metric;
+#ifdef ENABLE_MULTIBYTE
+struct fontset_list;
+struct font_wchar_metric;
+#endif
struct font_widths_cache;
class font {
@@ -53,6 +59,9 @@
const char *get_special_device_encoding(int index);
const char *get_name();
const char *get_internal_name();
+#ifdef ENABLE_MULTIBYTE
+ const char *get_subfont_name(int index);
+#endif
static int scan_papersize(const char *, const char **, double *, double *);
@@ -62,6 +71,9 @@
static int load_desc();
static int name_to_index(const char *);
static int number_to_index(int);
+#ifdef ENABLE_MULTIBYTE
+ static int wchar_index(wchar);
+#endif
static FONT_COMMAND_HANDLER
set_unknown_desc_command_handler(FONT_COMMAND_HANDLER);
@@ -76,6 +88,11 @@
static int spare2;
static int sizescale;
static int tcommand;
+#ifdef ENABLE_MULTIBYTE
+ // XXX: should be in charinfo or font_wchar_metric?
+ static int lowerwchar;
+ static int wcharkern;
+#endif
static int pass_filenames;
static int use_charnames_in_special;
@@ -83,13 +100,27 @@
static const char **style_table;
static const char *family;
static int *sizes;
+#ifdef ENABLE_MULTIBYTE
+ // fontsets - sub font list
+ static fontset_list *fontsets;
+ // get fontset for `wc' in current font `fname'
+ static int get_fontset_font(const char *fname, wchar wc);
+ // is the fontno's font load on demand?
+ static int is_on_demand(int fontno);
+#endif
private:
unsigned ligatures;
font_kern_list **kern_hash_table;
int space_width;
- short *ch_index;
+ short *ch_index; /* XXX: this is used unless font_wchar_metric. */
int nindices;
font_char_metric *ch;
+#ifdef ENABLE_MULTIBYTE
+ // font metric for wchar
+ font_wchar_metric *wch;
+ // get font metric for wchar indexed by c
+ font_wchar_metric *get_font_wchar_metric(int c);
+#endif
int ch_used;
int ch_size;
int special;
--- groff-1.18.1.orig/src/include/lib.h
+++ groff-1.18.1/src/include/lib.h
@@ -88,8 +88,15 @@
extern char invalid_char_table[];
+#include "encoding.h" /* XXX: ukai */
+
inline int invalid_input_char(int c)
{
+#ifdef ENABLE_MULTIBYTE
+ if (input_encoding->is_wchar_byte(c))
+ return 0;
+ else
+#endif
return c >= 0 && invalid_char_table[c];
}
--- groff-1.18.1.orig/src/include/printer.h
+++ groff-1.18.1/src/include/printer.h
@@ -38,6 +38,8 @@
#include "color.h"
+#include "encoding.h"
+
struct environment {
int fontno;
int size;
@@ -63,6 +65,9 @@
printer();
virtual ~printer();
void load_font(int i, const char *name);
+#ifdef ENABLE_MULTIBYTE
+ void set_wchar_char(wchar c, char *s, int i0, int len, const environment *env, int *widthp = 0);
+#endif
void set_ascii_char(unsigned char c, const environment *env,
int *widthp = 0);
void set_special_char(const char *nm, const environment *env,
--- groff-1.18.1.orig/src/include/encoding.h
+++ groff-1.18.1/src/include/encoding.h
@@ -0,0 +1,175 @@
+// -*- C++ -*-
+/* Copyright (c) 2001 Fumitoshi UKAI <ukai@debian.or.jp>
+
+This file is part of groff.
+
+groff is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+groff is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef ENCODING_H
+#define ENCODING_H
+
+#include <config.h>
+
+#ifdef ENABLE_MULTIBYTE
+typedef int wchar; // negative is used for charcode & index
+#else
+typedef char wchar;
+#endif
+
+#include <stdio.h>
+
+#ifdef __cplusplus
+class encoding_istream {
+public:
+ encoding_istream() {};
+ virtual ~encoding_istream() {};
+ virtual int getbyte() = 0;
+ virtual int peekbyte() = 0;
+ virtual void ungetbyte(int ch) = 0;
+};
+
+class encoding_istream_str: public encoding_istream {
+private:
+ const unsigned char *s;
+ int *i;
+ encoding_istream_str() {};
+public:
+ encoding_istream_str(const unsigned char *s0, int *i0) : s(s0), i(i0) {};
+ ~encoding_istream_str() {};
+ inline int getbyte() { return s[(*i)++]; };
+ inline int peekbyte() { return s[(*i)]; };
+ inline void ungetbyte(int ch) { --(*i); };
+};
+
+class encoding_istream_fp: public encoding_istream {
+private:
+ FILE *fp;
+public:
+ encoding_istream_fp(FILE *fp0) : fp(fp0) {};
+ ~encoding_istream_fp() {};
+ inline int getbyte() { return fgetc(fp); };
+ inline int peekbyte() { int ch = fgetc(fp); ungetc(ch, fp); return ch; };
+ inline void ungetbyte(int ch) { ungetc(ch, fp); };
+};
+
+class encoding_ostream {
+public:
+ encoding_ostream() {};
+ virtual ~encoding_ostream() {};
+ virtual void putbyte(unsigned char ch) = 0;
+};
+
+class encoding_ostream_str: public encoding_ostream {
+private:
+ unsigned char *s;
+ int *i;
+ int len;
+ encoding_ostream_str() {};
+public:
+ encoding_ostream_str(unsigned char *s0, int *i0, int max) : s(s0), i(i0), len(max) {};
+ ~encoding_ostream_str() {};
+ inline void putbyte(unsigned char ch) {
+ if (*i < len)
+ s[(*i)++] = ch;
+ }
+};
+
+class encoding_ostream_fp: public encoding_ostream {
+private:
+ FILE *fp;
+ const char *format;
+public:
+ encoding_ostream_fp(FILE *ofp, const char *fmt = "%c") : fp(ofp), format(fmt) {};
+ ~encoding_ostream_fp() {};
+ inline void putbyte(unsigned char ch) {
+ fprintf(fp, format, ch);
+ }
+};
+
+class encoding_handler {
+public:
+ encoding_handler() {};
+ virtual ~encoding_handler() {};
+
+ // name of this encoding_handler
+ virtual const char *name() { return ""; };
+
+ // check if this byte is byte in multibyte character in this encoding?
+ virtual int is_wchar_byte(unsigned char c) { return 0; };
+
+ // make new wchar from c0 (beginning of multibytes) and rest from `in'
+ virtual wchar make_wchar(unsigned char c0, encoding_istream& in) {
+ return wchar(c0);
+ }
+ // make new wchar from c0 (beginning of multibytes) and rest from `fp'
+ virtual wchar make_wchar(unsigned char c0, FILE *fp) {
+ encoding_istream_fp in(fp);
+ return make_wchar(c0, in);
+ }
+ // make new wchar from c0 (beginning of multibtyes) and rest from
+ // s[*i], *i will be changed to point the byte of next character.
+ virtual wchar make_wchar(unsigned char c0, const unsigned char *s, int *i) {
+ encoding_istream_str in(s, i);
+ return make_wchar(c0, in);
+ }
+
+ // put wchar to outputstream
+ // returns number of bytes written
+ virtual int put_wchar(wchar wc, encoding_ostream& eos) {
+ eos.putbyte((unsigned char)wc);
+ return 1;
+ }
+ // put wchar to `fp' using `fmt'
+ // returns number of bytes written
+ virtual int put_wchar(wchar wc, FILE *fp, const char *fmt = "%c") {
+ encoding_ostream_fp out(fp, fmt);
+ return put_wchar(wc, out);
+ }
+ // put wchar to s[*i] (until maxlen)
+ // *i will be changed to point the byte of next character.
+ virtual int put_wchar(wchar wc, unsigned char *s, int *i, int maxlen) {
+ encoding_ostream_str out(s, i, maxlen);
+ return put_wchar(wc, out);
+ }
+
+ // maximum number of bytes of multibyte character in this encoding
+ virtual int max_wchar_len() { return 1; };
+
+};
+
+encoding_handler* select_input_encoding_handler(const char* encoding_name);
+encoding_handler* select_output_encoding_handler(const char* encoding_name);
+extern encoding_handler* input_encoding;
+extern encoding_handler* output_encoding;
+void init_encoding_handler();
+
+// check if wc is wchar?
+int is_wchar_code(wchar wc);
+
+// check if wc is wchar & can be represented in single byte?
+int is_wchar_singlebyte(wchar wc);
+
+// get singlebyte representation of wchar (if is_wchar_singlebyte(wc))
+unsigned char wchar_singlebyte(wchar wc);
+
+// get actual wide character code
+int wchar_code(wchar wc);
+
+// make wchar from wide character code
+int make_wchar(int w);
+
+#endif
+
+#endif /* ENCODING_H */
--- groff-1.18.1.orig/src/include/config.h
+++ groff-1.18.1/src/include/config.h
@@ -0,0 +1,187 @@
+/* src/include/config.h. Generated by configure. */
+/* src/include/config.hin. Generated from configure.ac by autoheader. */
+
+/* Define if your C++ doesn't understand `delete []'. */
+/* #undef ARRAY_DELETE_NEEDS_SIZE */
+
+/* Define if you want to use multibyte extension. */
+#define ENABLE_MULTIBYTE 1
+
+/* Define if you have a C++ <limits.h>. */
+#define HAVE_CC_LIMITS_H 1
+
+/* Define if you have a C++ <osfcn.h>. */
+/* #undef HAVE_CC_OSFCN_H */
+
+/* Define to 1 if you have the <dirent.h> header file. */
+#define HAVE_DIRENT_H 1
+
+/* Define to 1 if you have the `fmod' function. */
+#define HAVE_FMOD 1
+
+/* Define to 1 if you have the `getcwd' function. */
+#define HAVE_GETCWD 1
+
+/* Define to 1 if you have the `getpagesize' function. */
+#define HAVE_GETPAGESIZE 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the `isatty' function. */
+#define HAVE_ISATTY 1
+
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#define HAVE_LANGINFO_CODESET 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <math.h> header file. */
+#define HAVE_MATH_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define if you have mkstemp(). */
+#define HAVE_MKSTEMP 1
+
+/* Define to 1 if you have a working `mmap' system call. */
+#define HAVE_MMAP 1
+
+/* Define to 1 if you have the `putenv' function. */
+#define HAVE_PUTENV 1
+
+/* Define to 1 if you have the `rename' function. */
+#define HAVE_RENAME 1
+
+/* Define to 1 if you have the `snprintf' function. */
+#define HAVE_SNPRINTF 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#define HAVE_STRCASECMP 1
+
+/* Define to 1 if you have the `strerror' function. */
+#define HAVE_STRERROR 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#define HAVE_STRNCASECMP 1
+
+/* Define to 1 if you have the `strsep' function. */
+#define HAVE_STRSEP 1
+
+/* Define to 1 if you have the `strtol' function. */
+#define HAVE_STRTOL 1
+
+/* Define if <math.h> defines struct exception. */
+#define HAVE_STRUCT_EXCEPTION 1
+
+/* Define to 1 if you have the <sys/dir.h> header file. */
+#define HAVE_SYS_DIR_H 1
+
+/* Define if you have sys_errlist in <errno.h> or in <stdio.h>. */
+#define HAVE_SYS_ERRLIST 1
+
+/* Define if you have sysnerr in <errno.h> or <stdio.h>. */
+#define HAVE_SYS_NERR 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define if the host's encoding is EBCDIC. */
+/* #undef IS_EBCDIC_HOST */
+
+/* Define if localtime() takes a long * not a time_t *. */
+/* #undef LONG_FOR_TIME_T */
+
+/* Define if your C++ doesn't declare gettimeofday(). */
+/* #undef NEED_DECLARATION_GETTIMEOFDAY */
+
+/* Define if your C++ doesn't declare hypot(). */
+/* #undef NEED_DECLARATION_HYPOT */
+
+/* Define if your C++ doesn't declare pclose(). */
+/* #undef NEED_DECLARATION_PCLOSE */
+
+/* Define if your C++ doesn't declare popen(). */
+/* #undef NEED_DECLARATION_POPEN */
+
+/* Define if your C++ doesn't declare putenv(). */
+/* #undef NEED_DECLARATION_PUTENV */
+
+/* Define if your C++ doesn't declare strcasecmp(). */
+/* #undef NEED_DECLARATION_STRCASECMP */
+
+/* Define if your C++ doesn't declare strncasecmp(). */
+/* #undef NEED_DECLARATION_STRNCASECMP */
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME ""
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING ""
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION ""
+
+/* Define if the printer's page size is A4. */
+#define PAGEA4 1
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#define RETSIGTYPE void
+
+/* Define if srand() returns void not int. */
+#define RET_TYPE_SRAND_IS_VOID 1
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if `sys_siglist' is declared by <signal.h> or <unistd.h>. */
+#define SYS_SIGLIST_DECLARED 1
+
+/* Define if your C++ compiler uses a traditional (Reiser) preprocessor. */
+/* #undef TRADITIONAL_CPP */
+
+/* Define if the 0200 bit of the status returned by wait() indicates whether a
+ core image was produced for a process that was terminated by a signal. */
+/* #undef WCOREFLAG */
+
+/* Define if -D_POSIX_SOURCE is necessary. */
+/* #undef _POSIX_SOURCE */
+
+/* Define if you have ISC 3.x or 4.x. */
+/* #undef _SYSV3 */
+
+/* Define uintmax_t to `unsigned long' or `unsigned long long' if <inttypes.h>
+ does not exist. */
+/* #undef uintmax_t */
--- groff-1.18.1.orig/src/libs/libgroff/Makefile.sub
+++ groff-1.18.1/src/libs/libgroff/Makefile.sub
@@ -6,6 +6,7 @@
color.$(OBJEXT) \
cset.$(OBJEXT) \
device.$(OBJEXT) \
+ encoding.$(OBJEXT) \
errarg.$(OBJEXT) \
error.$(OBJEXT) \
fatal.$(OBJEXT) \
@@ -45,6 +46,7 @@
$(srcdir)/color.cc \
$(srcdir)/cset.cc \
$(srcdir)/device.cc \
+ $(srcdir)/encoding.cc \
$(srcdir)/errarg.cc \
$(srcdir)/error.cc \
$(srcdir)/fatal.cc \
--- groff-1.18.1.orig/src/libs/libgroff/font.cc
+++ groff-1.18.1/src/libs/libgroff/font.cc
@@ -25,6 +25,7 @@
#include <assert.h>
#include <math.h>
#include <stdlib.h>
+#include "encoding.h" // XXX: ukai
#include "errarg.h"
#include "error.h"
#include "cset.h"
@@ -43,8 +44,39 @@
int italic_correction;
int subscript_correction;
char *special_device_coding;
+#ifdef ENABLE_MULTIBYTE
+ char *subfont_name;
+#endif
};
+#ifdef ENABLE_MULTIBYTE
+struct fontset_list {
+ struct fontset_list *next;
+ char *primary_font_name;
+ int fontset_font;
+ wchar start_code;
+ wchar end_code;
+ int on_demand;
+};
+
+fontset_list *font::fontsets = NULL;
+
+struct font_wchar_metric {
+ struct font_wchar_metric *next;
+ char type;
+ int start_code;
+ int end_code;
+ int width;
+ int height;
+ int depth;
+ int pre_math_space;
+ int italic_correction;
+ int subscript_correction;
+ char *special_device_coding;
+ char *subfont_name;
+};
+#endif
+
struct font_kern_list {
int i1;
int i2;
@@ -149,7 +181,11 @@
font::font(const char *s)
: ligatures(0), kern_hash_table(0), space_width(0), ch_index(0), nindices(0),
- ch(0), ch_used(0), ch_size(0), special(0), widths_cache(0)
+ ch(0),
+#ifdef ENABLE_MULTIBYTE
+ wch(0),
+#endif
+ ch_used(0), ch_size(0), special(0), widths_cache(0)
{
name = new char[strlen(s) + 1];
strcpy(name, s);
@@ -183,6 +219,17 @@
widths_cache = widths_cache->next;
delete tem;
}
+#ifdef ENABLE_MULTIBYTE
+ struct font_wchar_metric *wcp, *nwcp;
+ for (wcp = wch; wcp != NULL; wcp = nwcp) {
+ nwcp = wcp->next;
+ if (wcp->special_device_coding)
+ delete [] wcp->special_device_coding;
+ if (wcp->subfont_name)
+ delete [] wcp->subfont_name;
+ delete wcp;
+ }
+#endif
}
static int scale_round(int n, int x, int y)
@@ -244,6 +291,11 @@
int font::contains(int c)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL)
+ return 1;
+#endif
return c >= 0 && c < nindices && ch_index[c] >= 0;
}
@@ -266,8 +318,31 @@
a_delete width;
}
+#ifdef ENABLE_MULTIBYTE
+struct font_wchar_metric *
+font::get_font_wchar_metric(int c)
+{
+ /* XXX: c is font index, not char code... */
+ /* XXX: we assume wchar_code == font index code for wchars */
+ /* XXX: does really code conflicts with index? */
+ struct font_wchar_metric *wcp;
+ for (wcp = wch; wcp != NULL; wcp = wcp->next) {
+ if (wcp->start_code <= wchar_code(c) && wchar_code(c) <= wcp->end_code) {
+ return wcp;
+ }
+ }
+ return NULL;
+}
+#endif
+
int font::get_width(int c, int point_size)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL) {
+ return scale(wcp->width, point_size);
+ }
+#endif
assert(c >= 0 && c < nindices);
int i = ch_index[c];
assert(i >= 0);
@@ -299,30 +374,60 @@
int font::get_height(int c, int point_size)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL) {
+ return scale(wcp->height, point_size);
+ }
+#endif
assert(c >= 0 && c < nindices && ch_index[c] >= 0);
return scale(ch[ch_index[c]].height, point_size);
}
int font::get_depth(int c, int point_size)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL) {
+ return scale(wcp->depth, point_size);
+ }
+#endif
assert(c >= 0 && c < nindices && ch_index[c] >= 0);
return scale(ch[ch_index[c]].depth, point_size);
}
int font::get_italic_correction(int c, int point_size)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL) {
+ return scale(wcp->italic_correction, point_size);
+ }
+#endif
assert(c >= 0 && c < nindices && ch_index[c] >= 0);
return scale(ch[ch_index[c]].italic_correction, point_size);
}
int font::get_left_italic_correction(int c, int point_size)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL) {
+ return scale(wcp->pre_math_space, point_size);
+ }
+#endif
assert(c >= 0 && c < nindices && ch_index[c] >= 0);
return scale(ch[ch_index[c]].pre_math_space, point_size);
}
int font::get_subscript_correction(int c, int point_size)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL) {
+ return scale(wcp->subscript_correction, point_size);
+ }
+#endif
assert(c >= 0 && c < nindices && ch_index[c] >= 0);
return scale(ch[ch_index[c]].subscript_correction, point_size);
}
@@ -371,12 +476,24 @@
int font::get_character_type(int c)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL) {
+ return wcp->type;
+ }
+#endif
assert(c >= 0 && c < nindices && ch_index[c] >= 0);
return ch[ch_index[c]].type;
}
int font::get_code(int c)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL) {
+ return c;
+ }
+#endif
assert(c >= 0 && c < nindices && ch_index[c] >= 0);
return ch[ch_index[c]].code;
}
@@ -393,10 +510,26 @@
const char *font::get_special_device_encoding(int c)
{
+#ifdef ENABLE_MULTIBYTE
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL)
+ return wcp->special_device_coding;
+#endif
assert(c >= 0 && c < nindices && ch_index[c] >= 0);
return( ch[ch_index[c]].special_device_coding );
}
+#ifdef ENABLE_MULTIBYTE
+const char *font::get_subfont_name(int c)
+{
+ font_wchar_metric *wcp = get_font_wchar_metric(c);
+ if (wcp != NULL)
+ return wcp->subfont_name;
+ assert(c >= 0 && c < nindices && ch_index[c] >= 0);
+ return ch[ch_index[c]].subfont_name;
+}
+#endif
+
void font::alloc_ch_index(int index)
{
if (nindices == 0) {
@@ -554,9 +687,11 @@
return 0;
}
+
// If the font can't be found, then if not_found is non-NULL, it will be set
// to 1 otherwise a message will be printed.
+
int font::load(int *not_found)
{
char *path;
@@ -570,7 +705,7 @@
}
text_file t(fp, path);
t.skip_comments = 1;
- char *p;
+ char *p = NULL;
for (;;) {
if (!t.next()) {
t.error("missing charset command");
@@ -681,6 +816,9 @@
}
else if (strcmp(command, "charset") == 0) {
had_charset = 1;
+#ifdef ENABLE_MULTIBYTE
+ int had_range = 0;
+#endif
int last_index = -1;
for (;;) {
if (!t.next()) {
@@ -695,6 +833,11 @@
command = nm;
break;
}
+#ifdef ENABLE_MULTIBYTE
+ int start_code = 0;
+ int end_code = 0;
+ int nrange = sscanf(nm, "u%X..u%X", &start_code, &end_code);
+#endif
if (p[0] == '"') {
if (last_index == -1) {
t.error("first charset entry is duplicate");
@@ -711,7 +854,64 @@
}
copy_entry(index, last_index);
}
+#ifdef ENABLE_MULTIBYTE
+ else if (nrange == 2) {
+ had_range = 1;
+ font_wchar_metric *wcp = new font_wchar_metric;
+ wcp->start_code = start_code;
+ wcp->end_code = end_code;
+ wcp->height = 0;
+ wcp->depth = 0;
+ wcp->pre_math_space = 0;
+ wcp->italic_correction = 0;