about summary refs log tree commit diff stats
path: root/src/DefaultStyle.c
blob: 3dc17f75b3e0e8fc717448cb07113d188b9f81f9 (plain) (blame)
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
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include <math.h>
#include <stdio.h>
#include "state.h"
#include "util.h"
#include <stdlib.h>
#include <string.h>
#include "cmds.h"
#include <err.h>
#include <errno.h>

#define BUF_SIZE 50

/* rpncalc: a simple reverse polish notation calculator */
int main() {
  /* initialize state struct and its values */
  state s;
  /* default input buffer is stdin */
  s.defbuf = stdin;
  /* default output buffer is stdout */
  s.defout = stdout;
  s.last_op = 0;
  /* set default interactive prompt */
  s.prompt = "[%d]> ";
  stack stack = {{0}, 0};
  /* initialize value stack */
  s.stk = stack;
  s.command_count = 0;
  init_state(&s);


  fprintf(s.defout,"welcome to rpncalc! type 'list' to see a list of commands, or 'quit' to leave.\n");
  
  
  /* start reading from defbuf */
  char buf[BUF_SIZE];
  while(1){
    fprintf(s.defout, s.prompt, s.command_count, s.last_op);
    s.last_op = 0;
    char *endptr = NULL;
    char *check = fgets(buf, BUF_SIZE, s.defbuf);
    if (check == NULL) exit(0);
    buf[strcspn(buf, "\n")] = 0;
    double interpreted = strtod(buf, &endptr);
    if (errno == ERANGE) {
      fprintf(s.defout,"sorry, this number is too big\n");
      continue;
    }
    if (interpreted == (double)0 && endptr == buf) { /* strtod returned the char it could not read */
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * $LynxId: DefaultStyle.c,v 1.20 2009/11/27 13:04:27 tom Exp $
 *
 *	A real style sheet for the Character Grid browser
 *
 *	The dimensions are all in characters!
 */

#include <HTUtils.h>
#include <HTFont.h>
#include <HTStyle.h>

#include <LYGlobalDefs.h>
#include <LYLeaks.h>

/*	Tab arrays:
*/
static const HTTabStop tabs_8[] =
{
    {0, 8},
    {0, 16},
    {0, 24},
    {0, 32},
    {0, 40},
    {0, 48},
    {0, 56},
    {0, 64},
    {0, 72},
    {0, 80},
    {0, 88},
    {0, 96},
    {0, 104},
    {0, 112},
    {0, 120},
    {0, 128},
    {0, 136},
    {0, 144},
    {0, 152},
    {0, 160},
    {0, 168},
    {0, 176},
    {0, 0}			/* Terminate */
};

/* Template:
 *	link to next, name, name id (enum), tag,
 *	font, size, colour, superscript, anchor id,
 *	indents: 1st, left, right, alignment	lineheight, descent,	tabs,
 *	word wrap, free format, space: before, after, flags.
 */

static HTStyle HTStyleNormal =
HTStyleInit(
	       0, Normal, "P",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 3, 6, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleDivCenter =
HTStyleInit(
	       &HTStyleNormal, DivCenter, "DCENTER",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 3, 6, HT_CENTER, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleDivLeft =
HTStyleInit(
	       &HTStyleDivCenter, DivLeft, "DLEFT",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 3, 6, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleDivRight =
HTStyleInit(
	       &HTStyleDivLeft, DivRight, "DRIGHT",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 3, 6, HT_RIGHT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleBanner =
HTStyleInit(
	       &HTStyleDivRight, Banner, "BANNER",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 3, 6, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleBlockquote =
HTStyleInit(
	       &HTStyleBanner, Blockquote, "BLOCKQUOTE",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       5, 5, 7, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleBq =
HTStyleInit(			/* HTML 3.0 BLOCKQUOTE - FM */
	       &HTStyleBlockquote, Bq, "BQ",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       5, 5, 7, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleFootnote =
HTStyleInit(			/* HTML 3.0 FN - FM */
	       &HTStyleBq, Footnote, "FN",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       5, 5, 7, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleList =
HTStyleInit(
	       &HTStyleFootnote, List, "UL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 7, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0);

static HTStyle HTStyleList1 =
HTStyleInit(
	       &HTStyleList, List1, "UL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       8, 12, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0);

static HTStyle HTStyleList2 =
HTStyleInit(
	       &HTStyleList1, List2, "UL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       13, 17, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0);

static HTStyle HTStyleList3 =
HTStyleInit(
	       &HTStyleList2, List3, "UL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       18, 22, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0);

static HTStyle HTStyleList4 =
HTStyleInit(
	       &HTStyleList3, List4, "UL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       23, 27, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0);

static HTStyle HTStyleList5 =
HTStyleInit(
	       &HTStyleList4, List5, "UL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       28, 32, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0);

static HTStyle HTStyleList6 =
HTStyleInit(
	       &HTStyleList5, List6, "UL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       33, 37, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0);

static HTStyle HTStyleMenu =
HTStyleInit(
	       &HTStyleList6, Menu, "MENU",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 7, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleMenu1 =
HTStyleInit(
	       &HTStyleMenu, Menu1, "MENU",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       8, 12, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleMenu2 =
HTStyleInit(
	       &HTStyleMenu1, Menu2, "MENU",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       13, 17, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleMenu3 =
HTStyleInit(
	       &HTStyleMenu2, Menu3, "MENU",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       18, 22, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleMenu4 =
HTStyleInit(
	       &HTStyleMenu3, Menu4, "MENU",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       23, 27, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleMenu5 =
HTStyleInit(
	       &HTStyleMenu4, Menu5, "MENU",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       28, 33, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleMenu6 =
HTStyleInit(
	       &HTStyleMenu5, Menu6, "MENU",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       33, 38, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleGlossary =
HTStyleInit(
	       &HTStyleMenu6, Glossary, "DL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 10, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 1, 0
);

static HTStyle HTStyleGlossary1 =
HTStyleInit(
	       &HTStyleGlossary, Glossary1, "DL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       8, 16, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 1, 0
);

static HTStyle HTStyleGlossary2 =
HTStyleInit(
	       &HTStyleGlossary1, Glossary2, "DL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       14, 22, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 1, 0
);

static HTStyle HTStyleGlossary3 =
HTStyleInit(
	       &HTStyleGlossary2, Glossary3, "DL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       20, 28, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 1, 0
);

static HTStyle HTStyleGlossary4 =
HTStyleInit(
	       &HTStyleGlossary3, Glossary4, "DL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       26, 34, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 1, 0
);

static HTStyle HTStyleGlossary5 =
HTStyleInit(
	       &HTStyleGlossary4, Glossary5, "DL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       32, 40, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 1, 0
);

static HTStyle HTStyleGlossary6 =
HTStyleInit(
	       &HTStyleGlossary5, Glossary6, "DL",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       38, 46, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 1, 0
);

static HTStyle HTStyleGlossaryCompact =
HTStyleInit(
	       &HTStyleGlossary6, GlossaryCompact, "DLC",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       3, 10, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleGlossaryCompact1 =
HTStyleInit(
	       &HTStyleGlossaryCompact,
	       GlossaryCompact1, "DLC",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       8, 15, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleGlossaryCompact2 =
HTStyleInit(
	       &HTStyleGlossaryCompact1,
	       GlossaryCompact2, "DLC",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       13, 20, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleGlossaryCompact3 =
HTStyleInit(
	       &HTStyleGlossaryCompact2,
	       GlossaryCompact3, "DLC",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       18, 25, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleGlossaryCompact4 =
HTStyleInit(
	       &HTStyleGlossaryCompact3,
	       GlossaryCompact4, "DLC",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       23, 30, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleGlossaryCompact5 =
HTStyleInit(
	       &HTStyleGlossaryCompact4,
	       GlossaryCompact5, "DLC",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       28, 35, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleGlossaryCompact6 =
HTStyleInit(
	       &HTStyleGlossaryCompact5,
	       GlossaryCompact6, "DLC",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       33, 40, 6, HT_LEFT, 1, 0, 0,
	       YES, YES, 0, 0, 0
);

static HTStyle HTStyleExample =
HTStyleInit(
	       &HTStyleGlossaryCompact6,
	       Example, "XMP",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       0, 0, 0, HT_LEFT, 1, 0, tabs_8,
	       NO, NO, 0, 0, 0
);

static HTStyle HTStylePreformatted =
HTStyleInit(
	       &HTStyleExample,
	       Preformatted, "PRE",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       0, 0, 0, HT_LEFT, 1, 0, tabs_8,
	       NO, NO, 0, 0, 0
);

static HTStyle HTStyleListing =
HTStyleInit(
	       &HTStylePreformatted, Listing, "LISTING",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       0, 0, 0, HT_LEFT, 1, 0, tabs_8,
	       NO, NO, 0, 0, 0);

static HTStyle HTStyleAddress =
HTStyleInit(
	       &HTStyleListing, Address, "ADDRESS",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       4, 4, 7, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 2, 0, 0);

static HTStyle HTStyleNote =
HTStyleInit(			/* HTML 3.0 NOTE - FM */
	       &HTStyleAddress, Note, "NOTE",
	       HT_FONT, 1, HT_BLACK, 0, 0,
	       5, 5, 7, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleHeading1 =
HTStyleInit(
	       &HTStyleNote, Heading1, "H1",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       0, 0, 0, HT_CENTER, 1, 0, 0,
	       YES, YES, 1, 1, 0);

static HTStyle HTStyleHeading2 =
HTStyleInit(
	       &HTStyleHeading1, Heading2, "H2",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       0, 0, 0, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 1, 0);

static HTStyle HTStyleHeading3 =
HTStyleInit(
	       &HTStyleHeading2, Heading3, "H3",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       2, 2, 0, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleHeading4 =
HTStyleInit(
	       &HTStyleHeading3, Heading4, "H4",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       4, 4, 0, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleHeading5 =
HTStyleInit(
	       &HTStyleHeading4, Heading5, "H5",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       6, 6, 0, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleHeading6 =
HTStyleInit(
	       &HTStyleHeading5, Heading6, "H6",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       8, 8, 0, HT_LEFT, 1, 0, 0,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleHeadingCenter =
HTStyleInit(
	       &HTStyleHeading6, HeadingCenter, "HCENTER",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       0, 0, 3, HT_CENTER, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleHeadingLeft =
HTStyleInit(
	       &HTStyleHeadingCenter, HeadingLeft, "HLEFT",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       0, 0, 3, HT_LEFT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

static HTStyle HTStyleHeadingRight =
HTStyleInit(
	       &HTStyleHeadingLeft, HeadingRight, "HRIGHT",
	       HT_FONT + HT_BOLD, 1, HT_BLACK, 0, 0,
	       0, 0, 3, HT_RIGHT, 1, 0, tabs_8,
	       YES, YES, 1, 0, 0);

/* Style sheet points to the last in the list:
*/
static HTStyleSheet sheet =
{"default.style",
 &HTStyleHeadingRight};		/* sheet */

static HTStyle *st_array[ST_HeadingRight + 1] =
{NULL};

static HTStyleSheet *result = NULL;

#ifdef LY_FIND_LEAKS
static void FreeDefaultStyle(void)
{
    HTStyle *style;

    while ((style = result->styles) != 0) {
	result->styles = style->next;
	FREE(style);
    }
    FREE(result);
}
#endif /* LY_FIND_LEAKS */

HTStyleSheet *DefaultStyle(HTStyle ***result_array)
{
    HTStyle *p, *q;

    /*
     * The first time we're called, allocate a copy of the 'sheet' linked
     * list.  Thereafter, simply copy the data from 'sheet' into our copy
     * (preserving the copy's linked-list pointers).  We do this to reset the
     * parameters of a style that might be altered while processing a page.
     */
    if (result == 0) {		/* allocate & copy */
	result = HTStyleSheetNew();
	*result = sheet;
	result->styles = 0;
#ifdef LY_FIND_LEAKS
	atexit(FreeDefaultStyle);
#endif
	for (p = sheet.styles; p != 0; p = p->next) {
	    q = HTStyleNew();
	    *q = *p;
	    if (no_margins) {
		q->indent1st = 0;
		q->leftIndent = 0;
		q->rightIndent = 0;
	    }
	    st_array[q->id] = q;
	    q->next = result->styles;
	    result->styles = q;
	}
    } else {			/* recopy the data */
	for (q = result->styles, p = sheet.styles;
	     p != 0 && q != 0;
	     p = p->next, q = q->next) {
	    HTStyle *r = q->next;

	    *q = *p;
	    if (no_margins) {
		q->indent1st = 0;
		q->leftIndent = 0;
		q->rightIndent = 0;
	    }
	    st_array[q->id] = q;
	    q->next = r;
	}
    }
    *result_array = st_array;
    return result;
}