-
Notifications
You must be signed in to change notification settings - Fork 1
/
output.c
3579 lines (3135 loc) · 110 KB
/
output.c
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
#ifdef RCSID
static char RCSid[] =
"$Header: d:/cvsroot/tads/TADS2/Output.c,v 1.2 1999/05/17 02:52:12 MJRoberts Exp $";
#endif
/*
* Copyright (c) 1987, 1988 by Michael J. Roberts. All Rights Reserved.
*
* Please see the accompanying license file, LICENSE.TXT, for information
* on using and copying this software.
*/
/*
Name
output - TADS Interpreter and Compiler formatted Output routines
Function
Provides formatted output support. Text that is sent through outformat()
is displayed with word-wrap so that words fill the line but are not broken
across lines. Other routines allow flushing the output buffer, displaying
blank lines, and logging output to a file as well as to the display.
Notes
We use the global variables G_os_pagelength and G_os_linewidth, defined
in the OS code, to determine the size of the display area and to determine
the number of lines to display between page pauses (MORE prompts). Line
breaking and MORE prompting can be handled by the OS code if desired;
the USE_MORE macro controls this setting.
Returns
None
Modified
04/05/92 MJRoberts - TADS 2.0 changes
03/29/92 MJRoberts - fix unfound formatstring handling
08/01/91 MJRoberts - no more mode when debugger is running
07/18/91 MJRoberts - improve t_outline [more] behavior
07/01/91 MJRoberts - Mac porting changes
06/05/91 MJRoberts - add format string support
03/27/91 MJRoberts - debugger enhancements
03/10/91 MJRoberts - integrate John's qa-scripter mods
04/24/90 MJRoberts - add \^ (equivalent to calling "caps()" intrinsic)
04/16/89 MJRoberts - add outcformat for compressed strings
10/30/88 MJRoberts - add outhide() and outshow() functions
10/29/88 MJRoberts - break lines on hyphens
12/22/87 MJRoberts - created
*/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "os.h"
#include "std.h"
#include "run.h"
#include "voc.h"
#include "tio.h"
#include "mcm.h"
#include "dbg.h"
#include "cmap.h"
/*
* use our own isxxx - anything outside the US ASCII range is not reliably
* classifiable by the normal C isxxx routines
*/
#define outissp(c) (((uchar)(c)) <= 127 && isspace((uchar)(c)))
#define outisal(c) (((uchar)(c)) <= 127 && isalpha((uchar)(c)))
#define outisdg(c) (((uchar)(c)) <= 127 && isdigit((uchar)(c)))
#define outisup(c) (((uchar)(c)) <= 127 && isupper((uchar)(c)))
#define outislo(c) (((uchar)(c)) <= 127 && islower((uchar)(c)))
/*
* Turn on formatter-level MORE mode, EXCEPT under any of the following
* conditions:
*
* - this is a MAC OS port
*. - this is an HTML TADS interpreter
*. - USE_OS_LINEWRAP is defined
*
* Formatter-level MORE mode and formatter-level line wrapping go together;
* you can't have one without the other. So, if USE_OS_LINEWRAP is
* defined, we must also use OS-level MORE mode, which means we don't want
* formatter-level MORE mode.
*
* For historical reasons, we check specifically for MAC_OS. This was the
* first platform for which OS-level MORE mode and OS-level line wrapping
* were invented; at the time, we foolishly failed to anticipate that more
* platforms might eventually come along with the same needs, so we coded a
* test for MAC_OS rather than some more abstract marker. For
* compatibility, we retain this specific test.
*
* USE_OS_LINEWRAP is intended as the more abstract marker we should
* originally have used. A port should #define USE_OS_LINEWRAP in its
* system-specific os_xxx.h header to turn on OS-level line wrapping and
* OS-level MORE mode. Ports should avoid adding new #ifndef tests for
* specific platforms here; we've only retained the MAC_OS test because we
* don't want to break the existing MAC_OS port.
*/
#ifndef MAC_OS
# ifndef USE_HTML
# ifndef USE_OS_LINEWRAP
# define USE_MORE /* activate formatter-level more-mode */
# endif /* USE_OS_LINEWRAP */
# endif /* USE_HTML */
#endif /* MAC_OS */
/*
* In HTML mode, don't use MORE mode. Note that we explicitly turn MORE
* mode OFF, even though we won't have turned it on above, because it might
* have been turned on by an os_xxx.h header. This is here for historical
* reasons; in particular, some of the HTML interpreter builds include
* headers that were originally written for the normal builds for those
* same platforms, and those original headers explicitly #define USE_MORE
* somewhere. So, to be absolutely sure we get it right here, we have to
* explicitly turn off USE_MORE when compiling for HTML mode.
*/
#ifdef USE_HTML
# ifdef USE_MORE
# undef USE_MORE
# endif
#endif
/*
* QSPACE is the special character for a quoted space (internally, the
* sequence "\ " (backslash-space) is converted to QSPACE). It must not
* be any printable character. The value here may need to be changed in
* the extremely unlikely event that TADS is ever ported to an EBCDIC
* machine.
*/
#define QSPACE 26
/*
* QTAB is a special hard tab character indicator. We use this when we
* need to generate a hard tab to send to the underlying output layer
* (in particular, we use this to send hard tabs to the HTML formatter
* when we're in HTML mode).
*/
#define QTAB 25
/* maximum width of the display */
#define MAXWIDTH OS_MAXWIDTH
/* ------------------------------------------------------------------------ */
/*
* Globals and statics. These should really be moved into a context
* structure, so that the output formatter subsystem could be shared
* among multiple clients. For now, there's no practical problem using
* statics, because we only need a single output subsystem at one time.
*/
/* current script (command input) file */
extern osfildef *scrfp;
/*
* This should be TRUE if the output should have two spaces after a
* period (or other such punctuation. It should generally be TRUE for
* fixed-width fonts, and FALSE for proportional fonts.
*/
static int doublespace = 1;
/*
* Log file handle and name. If we're copying output to a log file,
* these will tell us about the file.
*/
osfildef *logfp;
static char logfname[OSFNMAX];
/* flag indicating whether output has occurred since last check */
static uchar outcnt;
/* flag indicating whether hidden output has occurred */
static uchar hidout;
/* flag indicating whether to show (TRUE) or hide (FALSE) output */
static uchar outflag;
/* flag indicating whether output is hidden for debugging purposes */
int dbghid;
/*
* Current recursion level in formatter invocation
*/
static int G_recurse = 0;
/* active stream in current recursion level */
static struct out_stream_info *G_cur_stream;
/* watchpoint mode flag */
static uchar outwxflag;
/*
* User filter function. When this function is set, we'll invoke this
* function for each string that's displayed through the output
* formatter.
*/
static objnum G_user_filter = MCMONINV;
/* ------------------------------------------------------------------------ */
/*
* Hack to run with TADS 2.0 with minimal reworking. Rather than using
* an allocated output layer context, store our subsystem context
* information in some statics. This is less clean than using a real
* context, but doesn't create any practical problems as we don't need
* to share the output formatter subsystem among multiple simultaneous
* callers.
*/
static runcxdef *runctx; /* execution context */
static uchar *fmsbase; /* format string area base */
static uchar *fmstop; /* format string area top */
static objnum cmdActor; /* current actor */
/* forward declarations of static functions */
static void outstring_stream(struct out_stream_info *stream, char *s);
static void outchar_noxlat_stream(struct out_stream_info *stream, char c);
static char out_parse_entity(char *outbuf, size_t outbuf_size,
char **sp, size_t *slenp);
/* ------------------------------------------------------------------------ */
/*
* HTML lexical analysis mode
*/
#define HTML_MODE_NORMAL 0 /* normal text, not in a tag */
#define HTML_MODE_TAG 1 /* parsing inside a tag */
#define HTML_MODE_SQUOTE 2 /* in a single-quoted string in a tag */
#define HTML_MODE_DQUOTE 3 /* in a double-quoted string in a tag */
/*
* HTML parsing mode flag for <BR> tags. We defer these until we've
* read the full tag in order to obey an HEIGHT attribute we find. When
* we encounter a <BR>, we figure out whether we think we'll need a
* flush or a blank line; if we find a HEIGHT attribute, we may change
* this opinion.
*/
#define HTML_DEFER_BR_NONE 0 /* no pending <BR> */
#define HTML_DEFER_BR_FLUSH 1 /* only need an outflush() */
#define HTML_DEFER_BR_BLANK 2 /* need an outblank() */
/*
* If we're compiling for an HTML-enabled underlying output subsystem,
* we want to call the underlying OS layer when switching in and out of
* HTML mode. If the underlying system doesn't process HTML, we don't
* need to let it know anything about HTML mode.
*/
#ifdef USE_HTML
# define out_start_html(stream) os_start_html()
# define out_end_html(stream) os_end_html()
#else
# define out_start_html(stream)
# define out_end_html(stream)
#endif
/* ------------------------------------------------------------------------ */
/*
* Output formatter stream state structure. This structure encapsulates
* the state of an individual output stream.
*/
typedef struct out_stream_info out_stream_info;
struct out_stream_info
{
/* low-level display routine (va_list version) */
void (*do_print)(out_stream_info *stream, const char *str);
/* current line position and output column */
uchar linepos;
uchar linecol;
/* number of lines on the screen (since last MORE prompt) */
int linecnt;
/* output buffer */
char linebuf[MAXWIDTH];
/*
* attribute buffer - we keep one attribute entry for each character in
* the line buffer
*/
int attrbuf[MAXWIDTH];
/* current attribute for text we're buffering into linebuf */
int cur_attr;
/* last attribute we wrote to the osifc layer */
int os_attr;
/* CAPS mode - next character output is converted to upper-case */
uchar capsflag;
/* NOCAPS mode - next character output is converted to lower-case */
uchar nocapsflag;
/* ALLCAPS mode - all characters output are converted to upper-case */
uchar allcapsflag;
/* capture information */
mcmcxdef *capture_ctx; /* memory context to use for capturing */
mcmon capture_obj; /* object holding captured output */
uint capture_ofs; /* write offset in capture object */
int capturing; /* true -> we are capturing output */
/* "preview" state for line flushing */
int preview;
/* flag indicating that we just flushed a new line */
int just_did_nl;
/* this output stream uses "MORE" mode */
int use_more_mode;
/*
* This output stream uses OS-level line wrapping - if this is set,
* the output formatter will not insert a newline at the end of a
* line that it's flushing for word wrapping, but will instead let
* the underlying OS display layer handle the wrapping.
*/
int os_line_wrap;
/*
* Flag indicating that the underlying output system wants to
* receive its output as HTML.
*
* If this is true, we'll pass through HTML to the underlying output
* system, and in addition generate HTML sequences for certain
* TADS-native escapes (for example, we'll convert the "\n" sequence
* to a <BR> sequence).
*
* If this is false, we'll do just the opposite: we'll remove HTML
* from the output stream and convert it into normal text sequences.
*/
int html_target;
/*
* Flag indicating that the target uses plain text. If this flag is
* set, we won't add the OS escape codes for highlighted characters.
*/
int plain_text_target;
/*
* Flag indicating that the caller is displaying HTML. We always
* start off in text mode; the client can switch to HTML mode by
* displaying a special escape sequence, and can switch back to text
* mode by displaying a separate special escape sequence.
*/
int html_mode;
/* current lexical analysis mode */
unsigned int html_mode_flag;
/* <BR> defer mode */
unsigned int html_defer_br;
/*
* HTML "ignore" mode - we suppress all output when parsing the
* contents of a <TITLE> or <ABOUTBOX> tag
*/
int html_in_ignore;
/*
* HTML <TITLE> mode - when we're in this mode, we're gathering the
* title (i.e., we're inside a <TITLE> tag's contents). We'll copy
* characters to the title buffer rather than the normal output
* buffer, and then call os_set_title() when we reach the </TITLE>
* tag.
*/
int html_in_title;
/* buffer for the title */
char html_title_buf[256];
/* pointer to next available character in title buffer */
char *html_title_ptr;
/* quoting level */
int html_quote_level;
/* PRE nesting level */
int html_pre_level;
/*
* Parsing mode flag for ALT attributes. If we're parsing a tag
* that allows ALT, such as IMG or SOUND, we'll set this flag, then
* insert the ALT text if we encounter it during parsing.
*/
int html_allow_alt;
};
/*
* Default output converter. This is the output converter for the
* standard display. Functions in the public interface that do not
* specify an output converter will use this converter by default.
*/
static out_stream_info G_std_disp;
/*
* Log file converter. This is the output converter for a log file.
* Whenever we open a log file, we'll initialize this converter; as we
* display text to the main display, we'll also copy it to the log file.
*
* We maintain an entire separate conversion context for the log file,
* so that we can perform a different set of conversions on it. We may
* want, for example, to pass HTML text through to the OS display
* subsystem (this is the case for the HTML-enabled interpreter), but
* we'll still want to convert log file output to text. By keeping a
* separate display context for the log file, we can format output to
* the log file using an entirely different style than we do for the
* display.
*/
static out_stream_info G_log_disp;
/* ------------------------------------------------------------------------ */
/*
* low-level output handlers for the standard display and log file
*/
/* standard display printer */
static void do_std_print(out_stream_info *stream, const char *str)
{
VARUSED(stream);
/* display the text through the OS layer */
os_printz(str);
}
/* log file printer */
static void do_log_print(out_stream_info *stream, const char *str)
{
VARUSED(stream);
/* display to the log file */
if (logfp != 0 && G_os_moremode)
{
os_fprintz(logfp, str);
osfflush(logfp);
}
}
/* ------------------------------------------------------------------------ */
/*
* initialize a generic output formatter state structure
*/
static void out_state_init(out_stream_info *stream)
{
/* start out at the first column */
stream->linepos = 0;
stream->linecol = 0;
stream->linebuf[0] = '\0';
/* set normal text attributes */
stream->cur_attr = 0;
stream->os_attr = 0;
/* start out at the first line */
stream->linecnt = 0;
/* we're not in either "caps", "nocaps", or "allcaps" mode yet */
stream->capsflag = stream->nocapsflag = stream->allcapsflag = FALSE;
/* we're not capturing yet */
stream->capturing = FALSE;
stream->capture_obj = MCMONINV;
/* we aren't previewing a line yet */
stream->preview = 0;
/* we haven't flushed a new line yet */
stream->just_did_nl = FALSE;
/* presume this stream does not use "MORE" mode */
stream->use_more_mode = FALSE;
/* presume this stream uses formatter-level line wrapping */
stream->os_line_wrap = FALSE;
/* assume that the underlying system is not HTML-enabled */
stream->html_target = FALSE;
/* presume this target accepts OS highlighting sequences */
stream->plain_text_target = FALSE;
/* start out in text mode */
stream->html_mode = FALSE;
/* start out in "normal" lexical state */
stream->html_mode_flag = HTML_MODE_NORMAL;
/* not in an ignored tag yet */
stream->html_in_ignore = FALSE;
/* not in title mode yet */
stream->html_in_title = FALSE;
/* not yet deferring line breaks */
stream->html_defer_br = HTML_DEFER_BR_NONE;
/* not yet in quotes */
stream->html_quote_level = 0;
/* not yet in a PRE block */
stream->html_pre_level = 0;
/* not in an ALT tag yet */
stream->html_allow_alt = FALSE;
}
/* ------------------------------------------------------------------------ */
/*
* initialize a standard display stream
*/
static void out_init_std(out_stream_info *stream)
{
/* there's no user output filter function yet */
out_set_filter(MCMONINV);
/* initialize the basic stream state */
out_state_init(stream);
/* set up the low-level output routine */
G_std_disp.do_print = do_std_print;
#ifdef USE_MORE
/*
* We're compiled for MORE mode, and we're not compiling for an
* underlying HTML formatting layer, so use MORE mode for the
* standard display stream.
*/
stream->use_more_mode = TRUE;
#else
/*
* We're compiled for OS-layer (or HTML-layer) MORE handling. For
* this case, use OS-layer (or HTML-layer) line wrapping as well.
*/
stream->os_line_wrap = TRUE;
#endif
#ifdef USE_HTML
/*
* if we're compiled for HTML mode, set the standard output stream
* so that it knows it has an HTML target - this will ensure that
* HTML tags are passed through to the underlying stream, and that
* we generate HTML equivalents for our own control sequences
*/
stream->html_target = TRUE;
#endif
}
/*
* initialize a standard log file stream
*/
static void out_init_log(out_stream_info *stream)
{
/* initialize the basic stream state */
out_state_init(stream);
/* set up the low-level output routine */
stream->do_print = do_log_print;
/* use plain text in the log file stream */
stream->plain_text_target = TRUE;
}
/* ------------------------------------------------------------------------ */
/*
* table of '&' character name sequences
*/
struct amp_tbl_t
{
/* entity name */
const char *cname;
/* HTML Unicode character value */
uint html_cval;
/* native character set expansion */
char *expan;
};
/*
* HTML entity mapping table. When we're in non-HTML mode, we keep our
* own expansion table so that we can map HTML entity names into the
* local character set.
*
* The entries in this table must be in sorted order (by HTML entity
* name), because we use a binary search to find an entity name in the
* table.
*/
static struct amp_tbl_t amp_tbl[] =
{
{ "AElig", 198, 0 },
{ "Aacute", 193, 0 },
{ "Abreve", 258, 0 },
{ "Acirc", 194, 0 },
{ "Agrave", 192, 0 },
{ "Alpha", 913, 0 },
{ "Aogon", 260, 0 },
{ "Aring", 197, 0 },
{ "Atilde", 195, 0 },
{ "Auml", 196, 0 },
{ "Beta", 914, 0 },
{ "Cacute", 262, 0 },
{ "Ccaron", 268, 0 },
{ "Ccedil", 199, 0 },
{ "Chi", 935, 0 },
{ "Dagger", 8225, 0 },
{ "Dcaron", 270, 0 },
{ "Delta", 916, 0 },
{ "Dstrok", 272, 0 },
{ "ETH", 208, 0 },
{ "Eacute", 201, 0 },
{ "Ecaron", 282, 0 },
{ "Ecirc", 202, 0 },
{ "Egrave", 200, 0 },
{ "Eogon", 280, 0 },
{ "Epsilon", 917, 0 },
{ "Eta", 919, 0 },
{ "Euml", 203, 0 },
{ "Gamma", 915, 0 },
{ "Iacute", 205, 0 },
{ "Icirc", 206, 0 },
{ "Igrave", 204, 0 },
{ "Iota", 921, 0 },
{ "Iuml", 207, 0 },
{ "Kappa", 922, 0 },
{ "Lacute", 313, 0 },
{ "Lambda", 923, 0 },
{ "Lcaron", 317, 0 },
{ "Lstrok", 321, 0 },
{ "Mu", 924, 0 },
{ "Nacute", 323, 0 },
{ "Ncaron", 327, 0 },
{ "Ntilde", 209, 0 },
{ "Nu", 925, 0 },
{ "OElig", 338, 0 },
{ "Oacute", 211, 0 },
{ "Ocirc", 212, 0 },
{ "Odblac", 336, 0 },
{ "Ograve", 210, 0 },
{ "Omega", 937, 0 },
{ "Omicron", 927, 0 },
{ "Oslash", 216, 0 },
{ "Otilde", 213, 0 },
{ "Ouml", 214, 0 },
{ "Phi", 934, 0 },
{ "Pi", 928, 0 },
{ "Prime", 8243, 0 },
{ "Psi", 936, 0 },
{ "Racute", 340, 0 },
{ "Rcaron", 344, 0 },
{ "Rho", 929, 0 },
{ "Sacute", 346, 0 },
{ "Scaron", 352, 0 },
{ "Scedil", 350, 0 },
{ "Sigma", 931, 0 },
{ "THORN", 222, 0 },
{ "Tau", 932, 0 },
{ "Tcaron", 356, 0 },
{ "Tcedil", 354, 0 },
{ "Theta", 920, 0 },
{ "Uacute", 218, 0 },
{ "Ucirc", 219, 0 },
{ "Udblac", 368, 0 },
{ "Ugrave", 217, 0 },
{ "Upsilon", 933, 0 },
{ "Uring", 366, 0 },
{ "Uuml", 220, 0 },
{ "Xi", 926, 0 },
{ "Yacute", 221, 0 },
{ "Yuml", 376, 0 },
{ "Zacute", 377, 0 },
{ "Zcaron", 381, 0 },
{ "Zdot", 379, 0 },
{ "Zeta", 918, 0 },
{ "aacute", 225, 0 },
{ "abreve", 259, 0 },
{ "acirc", 226, 0 },
{ "acute", 180, 0 },
{ "aelig", 230, 0 },
{ "agrave", 224, 0 },
{ "alefsym", 8501, 0 },
{ "alpha", 945, 0 },
{ "amp", '&', 0 },
{ "and", 8743, 0 },
{ "ang", 8736, 0 },
{ "aogon", 261, 0 },
{ "aring", 229, 0 },
{ "asymp", 8776, 0 },
{ "atilde", 227, 0 },
{ "auml", 228, 0 },
{ "bdquo", 8222, 0 },
{ "beta", 946, 0 },
{ "breve", 728, 0 },
{ "brvbar", 166, 0 },
{ "bull", 8226, 0 },
{ "cacute", 263, 0 },
{ "cap", 8745, 0 },
{ "caron", 711, 0 },
{ "ccaron", 269, 0 },
{ "ccedil", 231, 0 },
{ "cedil", 184, 0 },
{ "cent", 162, 0 },
{ "chi", 967, 0 },
{ "circ", 710, 0 },
{ "clubs", 9827, 0 },
{ "cong", 8773, 0 },
{ "copy", 169, 0 },
{ "crarr", 8629, 0 },
{ "cup", 8746, 0 },
{ "curren", 164, 0 },
{ "dArr", 8659, 0 },
{ "dagger", 8224, 0 },
{ "darr", 8595, 0 },
{ "dblac", 733, 0 },
{ "dcaron", 271, 0 },
{ "deg", 176, 0 },
{ "delta", 948, 0 },
{ "diams", 9830, 0 },
{ "divide", 247, 0 },
{ "dot", 729, 0 },
{ "dstrok", 273, 0 },
{ "eacute", 233, 0 },
{ "ecaron", 283, 0 },
{ "ecirc", 234, 0 },
{ "egrave", 232, 0 },
{ "emdash", 8212, 0 },
{ "empty", 8709, 0 },
{ "endash", 8211, 0 },
{ "eogon", 281, 0 },
{ "epsilon", 949, 0 },
{ "equiv", 8801, 0 },
{ "eta", 951, 0 },
{ "eth", 240, 0 },
{ "euml", 235, 0 },
{ "exist", 8707, 0 },
{ "fnof", 402, 0 },
{ "forall", 8704, 0 },
{ "frac12", 189, 0 },
{ "frac14", 188, 0 },
{ "frac34", 190, 0 },
{ "frasl", 8260, 0 },
{ "gamma", 947, 0 },
{ "ge", 8805, 0 },
{ "gt", '>', 0 },
{ "hArr", 8660, 0 },
{ "harr", 8596, 0 },
{ "hearts", 9829, 0 },
{ "hellip", 8230, 0 },
{ "iacute", 237, 0 },
{ "icirc", 238, 0 },
{ "iexcl", 161, 0 },
{ "igrave", 236, 0 },
{ "image", 8465, 0 },
{ "infin", 8734, 0 },
{ "int", 8747, 0 },
{ "iota", 953, 0 },
{ "iquest", 191, 0 },
{ "isin", 8712, 0 },
{ "iuml", 239, 0 },
{ "kappa", 954, 0 },
{ "lArr", 8656, 0 },
{ "lacute", 314, 0 },
{ "lambda", 955, 0 },
{ "lang", 9001, 0 },
{ "laquo", 171, 0 },
{ "larr", 8592, 0 },
{ "lcaron", 318, 0 },
{ "lceil", 8968, 0 },
{ "ldq", 8220, 0 },
{ "ldquo", 8220, 0 },
{ "le", 8804, 0 },
{ "lfloor", 8970, 0 },
{ "lowast", 8727, 0 },
{ "loz", 9674, 0 },
{ "lsaquo", 8249, 0 },
{ "lsq", 8216, 0 },
{ "lsquo", 8216, 0 },
{ "lstrok", 322, 0 },
{ "lt", '<', 0 },
{ "macr", 175, 0 },
{ "mdash", 8212, 0 },
{ "micro", 181, 0 },
{ "middot", 183, 0 },
{ "minus", 8722, 0 },
{ "mu", 956, 0 },
{ "nabla", 8711, 0 },
{ "nacute", 324, 0 },
{ "nbsp", QSPACE, 0 },
{ "ncaron", 328, 0 },
{ "ndash", 8211, 0 },
{ "ne", 8800, 0 },
{ "ni", 8715, 0 },
{ "not", 172, 0 },
{ "notin", 8713, 0 },
{ "nsub", 8836, 0 },
{ "ntilde", 241, 0 },
{ "nu", 957, 0 },
{ "oacute", 243, 0 },
{ "ocirc", 244, 0 },
{ "odblac", 337, 0 },
{ "oelig", 339, 0 },
{ "ogon", 731, 0 },
{ "ograve", 242, 0 },
{ "oline", 8254, 0 },
{ "omega", 969, 0 },
{ "omicron", 959, 0 },
{ "oplus", 8853, 0 },
{ "or", 8744, 0 },
{ "ordf", 170, 0 },
{ "ordm", 186, 0 },
{ "oslash", 248, 0 },
{ "otilde", 245, 0 },
{ "otimes", 8855, 0 },
{ "ouml", 246, 0 },
{ "para", 182, 0 },
{ "part", 8706, 0 },
{ "permil", 8240, 0 },
{ "perp", 8869, 0 },
{ "phi", 966, 0 },
{ "pi", 960, 0 },
{ "piv", 982, 0 },
{ "plusmn", 177, 0 },
{ "pound", 163, 0 },
{ "prime", 8242, 0 },
{ "prod", 8719, 0 },
{ "prop", 8733, 0 },
{ "psi", 968, 0 },
{ "quot", '"', 0 },
{ "rArr", 8658, 0 },
{ "racute", 341, 0 },
{ "radic", 8730, 0 },
{ "rang", 9002, 0 },
{ "raquo", 187, 0 },
{ "rarr", 8594, 0 },
{ "rcaron", 345, 0 },
{ "rceil", 8969, 0 },
{ "rdq", 8221, 0 },
{ "rdquo", 8221, 0 },
{ "real", 8476, 0 },
{ "reg", 174, 0 },
{ "rfloor", 8971, 0 },
{ "rho", 961, 0 },
{ "rsaquo", 8250, 0 },
{ "rsq", 8217, 0 },
{ "rsquo", 8217, 0 },
{ "sacute", 347, 0 },
{ "sbquo", 8218, 0 },
{ "scaron", 353, 0 },
{ "scedil", 351, 0 },
{ "sdot", 8901, 0 },
{ "sect", 167, 0 },
{ "shy", 173, 0 },
{ "sigma", 963, 0 },
{ "sigmaf", 962, 0 },
{ "sim", 8764, 0 },
{ "spades", 9824, 0 },
{ "sub", 8834, 0 },
{ "sube", 8838, 0 },
{ "sum", 8721, 0 },
{ "sup", 8835, 0 },
{ "sup1", 185, 0 },
{ "sup2", 178, 0 },
{ "sup3", 179, 0 },
{ "supe", 8839, 0 },
{ "szlig", 223, 0 },
{ "tau", 964, 0 },
{ "tcaron", 357, 0 },
{ "tcedil", 355, 0 },
{ "there4", 8756, 0 },
{ "theta", 952, 0 },
{ "thetasym", 977, 0 },
{ "thorn", 254, 0 },
{ "thorn", 254, 0 },
{ "tilde", 732, 0 },
{ "times", 215, 0 },
{ "trade", 8482, 0 },
{ "uArr", 8657, 0 },
{ "uacute", 250, 0 },
{ "uarr", 8593, 0 },
{ "ucirc", 251, 0 },
{ "udblac", 369, 0 },
{ "ugrave", 249, 0 },
{ "uml", 168, 0 },
{ "upsih", 978, 0 },
{ "upsilon", 965, 0 },
{ "uring", 367, 0 },
{ "uuml", 252, 0 },
{ "weierp", 8472, 0 },
{ "xi", 958, 0 },
{ "yacute", 253, 0 },
{ "yen", 165, 0 },
{ "yuml", 255, 0 },
{ "zacute", 378, 0 },
{ "zcaron", 382, 0 },
{ "zdot", 380, 0 },
{ "zeta", 950, 0 }
};
/* ------------------------------------------------------------------------ */
/*
* turn on CAPS mode for a stream
*/
static void outcaps_stream(out_stream_info *stream)
{
/* turn on CAPS mode */
stream->capsflag = TRUE;
/* turn off NOCAPS and ALLCAPS mode */
stream->nocapsflag = FALSE;
stream->allcapsflag = FALSE;
}
/*
* turn on NOCAPS mode for a stream
*/
static void outnocaps_stream(out_stream_info *stream)
{
/* turn on NOCAPS mode */
stream->nocapsflag = TRUE;
/* turn off CAPS and ALLCAPS mode */
stream->capsflag = FALSE;
stream->allcapsflag = FALSE;
}
/*
* turn on or off ALLCAPS mode for a stream
*/
static void outallcaps_stream(out_stream_info *stream, int all_caps)
{
/* set the ALLCAPS flag */
stream->allcapsflag = all_caps;
/* clear the CAPS and NOCAPS flags */
stream->capsflag = FALSE;
stream->nocapsflag = FALSE;
}
/* ------------------------------------------------------------------------ */
/*
* write a string to a stream
*/
static void stream_print(out_stream_info *stream, char *str)
{
/* call the stream's do_print method */
(*stream->do_print)(stream, str);
}
/*
* Write out a line
*/
static void t_outline(out_stream_info *stream, int nl,
const char *txt, const int *attr)
{
extern int scrquiet;
/*
* Check the "script quiet" mode - this indicates that we're reading
* a script and not echoing output to the display. If this mode is
* on, and we're writing to the display, suppress this write. If
* the mode is off, or we're writing to another stream (such as the
* log file), show the output as normal.
*/
if (!scrquiet || stream != &G_std_disp)
{
size_t i;
char buf[MAXWIDTH];
char *dst;
/*
* Check to see if we've reached the end of the screen, and if
* so run the MORE prompt. Note that we don't make this check
* at all if USE_MORE is undefined, since this means that the OS
* layer code is taking responsibility for pagination issues.
* We also don't display a MORE prompt when reading from a
* script file.
*
* Note that we suppress the MORE prompt if nl == 0, since this
* is used to flush a partial line of text without starting a
* new line (for example, when displaying a prompt where the
* input will appear on the same line following the prompt).
*
* Skip the MORE prompt if this stream doesn't use it.
*/
if (stream->use_more_mode
&& scrfp == 0
&& G_os_moremode
&& nl != 0 && nl != 4
&& stream->linecnt++ >= G_os_pagelength)
{
/* display the MORE prompt */
out_more_prompt();
}
/*