From cbeb0b26e4c7caa8d1b47de791a7418dc20a4567 Mon Sep 17 00:00:00 2001 From: rsc Date: Sat, 1 Apr 2006 19:24:03 +0000 Subject: Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms. --- include/html.h | 496 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 248 insertions(+), 248 deletions(-) (limited to 'include/html.h') diff --git a/include/html.h b/include/html.h index 23b9c591..5d4b5012 100644 --- a/include/html.h +++ b/include/html.h @@ -10,13 +10,13 @@ AUTOLIB(html) #pragma src "/sys/src/libhtml" */ -// UTILS +/* UTILS */ extern uchar* fromStr(Rune* buf, int n, int chset); extern Rune* toStr(uchar* buf, int n, int chset); -// Common LEX and BUILD enums +/* Common LEX and BUILD enums */ -// Media types +/* Media types */ enum { ApplMsword, @@ -58,14 +58,14 @@ enum NMEDIATYPES }; -// HTTP methods +/* HTTP methods */ enum { HGet, HPost }; -// Charsets +/* Charsets */ enum { UnknownCharset, @@ -76,7 +76,7 @@ enum NCHARSETS }; -// Frame Target IDs +/* Frame Target IDs */ enum { FTtop, FTself, @@ -84,11 +84,11 @@ enum { FTblank }; -// LEX +/* LEX */ typedef struct Token Token; typedef struct Attr Attr; -// BUILD +/* BUILD */ typedef struct Item Item; typedef struct Itext Itext; @@ -119,9 +119,9 @@ typedef struct Docinfo Docinfo; typedef struct Stack Stack; typedef struct Pstate Pstate; typedef struct ItemSource ItemSource; -typedef struct Lay Lay; // defined in Layout module +typedef struct Lay Lay; /* defined in Layout module */ -// Alignment types +/* Alignment types */ enum { ALnone = 0, ALleft, ALcenter, ALright, ALjustify, ALchar, ALtop, ALmiddle, ALbottom, ALbaseline @@ -129,16 +129,16 @@ enum { struct Align { - uchar halign; // one of ALnone, ALleft, etc. - uchar valign; // one of ALnone, ALtop, etc. + uchar halign; /* one of ALnone, ALleft, etc. */ + uchar valign; /* one of ALnone, ALtop, etc. */ }; -// A Dimen holds a dimension specification, especially for those -// cases when a number can be followed by a % or a * to indicate -// percentage of total or relative weight. -// Dnone means no dimension was specified +/* A Dimen holds a dimension specification, especially for those */ +/* cases when a number can be followed by a % or a * to indicate */ +/* percentage of total or relative weight. */ +/* Dnone means no dimension was specified */ -// To fit in a word, use top bits to identify kind, rest for value +/* To fit in a word, use top bits to identify kind, rest for value */ enum { Dnone = 0, Dpixels = (1<<29), @@ -150,36 +150,36 @@ enum { struct Dimen { - int kindspec; // kind | spec + int kindspec; /* kind | spec */ }; -// Background is either an image or a color. -// If both are set, the image has precedence. +/* Background is either an image or a color. */ +/* If both are set, the image has precedence. */ struct Background { - Rune* image; // url + Rune* image; /* url */ int color; }; -// There are about a half dozen Item variants. -// The all look like this at the start (using Plan 9 C's -// anonymous structure member mechanism), -// and then the tag field dictates what extra fields there are. +/* There are about a half dozen Item variants. */ +/* The all look like this at the start (using Plan 9 C's */ +/* anonymous structure member mechanism), */ +/* and then the tag field dictates what extra fields there are. */ struct Item { - Item* next; // successor in list of items - int width; // width in pixels (0 for floating items) - int height; // height in pixels + Item* next; /* successor in list of items */ + int width; /* width in pixels (0 for floating items) */ + int height; /* height in pixels */ Rectangle r; - int ascent; // ascent (from top to baseline) in pixels - int anchorid; // if nonzero, which anchor we're in - int state; // flags and values (see below) - Genattr* genattr; // generic attributes and events - int tag; // variant discriminator: Itexttag, etc. + int ascent; /* ascent (from top to baseline) in pixels */ + int anchorid; /* if nonzero, which anchor we're in */ + int state; /* flags and values (see below) */ + Genattr* genattr; /* generic attributes and events */ + int tag; /* variant discriminator: Itexttag, etc. */ }; -// Item variant tags +/* Item variant tags */ enum { Itexttag, Iruletag, @@ -192,45 +192,45 @@ enum { struct Itext { - Item item; // (with tag ==Itexttag) - Rune* s; // the characters - int fnt; // style*NumSize+size (see font stuff, below) - int fg; // Pixel (color) for text - uchar voff; // Voffbias+vertical offset from baseline, in pixels (+ve == down) - uchar ul; // ULnone, ULunder, or ULmid + Item item; /* (with tag ==Itexttag) */ + Rune* s; /* the characters */ + int fnt; /* style*NumSize+size (see font stuff, below) */ + int fg; /* Pixel (color) for text */ + uchar voff; /* Voffbias+vertical offset from baseline, in pixels (+ve == down) */ + uchar ul; /* ULnone, ULunder, or ULmid */ }; struct Irule { - Item item; // (with tag ==Iruletag) - uchar align; // alignment spec - uchar noshade; // if true, don't shade - int size; // size attr (rule height) - Dimen wspec; // width spec + Item item; /* (with tag ==Iruletag) */ + uchar align; /* alignment spec */ + uchar noshade; /* if true, don't shade */ + int size; /* size attr (rule height) */ + Dimen wspec; /* width spec */ }; struct Iimage { - Item item; // (with tag ==Iimagetag) - Rune* imsrc; // image src url - int imwidth; // spec width (actual, if no spec) - int imheight; // spec height (actual, if no spec) - Rune* altrep; // alternate representation, in absence of image - Map* map; // if non-nil, client side map - int ctlid; // if animated - uchar align; // vertical alignment - uchar hspace; // in pixels; buffer space on each side - uchar vspace; // in pixels; buffer space on top and bottom - uchar border; // in pixels: border width to draw around image - Iimage* nextimage; // next in list of document's images + Item item; /* (with tag ==Iimagetag) */ + Rune* imsrc; /* image src url */ + int imwidth; /* spec width (actual, if no spec) */ + int imheight; /* spec height (actual, if no spec) */ + Rune* altrep; /* alternate representation, in absence of image */ + Map* map; /* if non-nil, client side map */ + int ctlid; /* if animated */ + uchar align; /* vertical alignment */ + uchar hspace; /* in pixels; buffer space on each side */ + uchar vspace; /* in pixels; buffer space on top and bottom */ + uchar border; /* in pixels: border width to draw around image */ + Iimage* nextimage; /* next in list of document's images */ void *aux; }; struct Iformfield { - Item item; // (with tag ==Iformfieldtag) + Item item; /* (with tag ==Iformfieldtag) */ Formfield* formfield; void *aux; }; @@ -238,59 +238,59 @@ struct Iformfield struct Itable { - Item item; // (with tag ==Itabletag) + Item item; /* (with tag ==Itabletag) */ Table* table; }; struct Ifloat { - Item _item; // (with tag ==Ifloattag) - Item* item; // table or image item that floats - int x; // x coord of top (from right, if ALright) - int y; // y coord of top - uchar side; // margin it floats to: ALleft or ALright - uchar infloats; // true if this has been added to a lay.floats - Ifloat* nextfloat; // in list of floats + Item _item; /* (with tag ==Ifloattag) */ + Item* item; /* table or image item that floats */ + int x; /* x coord of top (from right, if ALright) */ + int y; /* y coord of top */ + uchar side; /* margin it floats to: ALleft or ALright */ + uchar infloats; /* true if this has been added to a lay.floats */ + Ifloat* nextfloat; /* in list of floats */ }; struct Ispacer { - Item item; // (with tag ==Ispacertag) - int spkind; // ISPnull, etc. + Item item; /* (with tag ==Ispacertag) */ + int spkind; /* ISPnull, etc. */ }; -// Item state flags and value fields +/* Item state flags and value fields */ enum { -// IFbrk = 0x80000000, // forced break before this item +/* IFbrk = 0x80000000, // forced break before this item */ #define IFbrk 0x80000000 /* too big for sun */ - IFbrksp = 0x40000000, // add 1 line space to break (IFbrk set too) - IFnobrk = 0x20000000, // break not allowed before this item - IFcleft = 0x10000000, // clear left floats (IFbrk set too) - IFcright = 0x08000000, // clear right floats (IFbrk set too) - IFwrap = 0x04000000, // in a wrapping (non-pre) line - IFhang = 0x02000000, // in a hanging (into left indent) item - IFrjust = 0x01000000, // right justify current line - IFcjust = 0x00800000, // center justify current line - IFsmap = 0x00400000, // image is server-side map + IFbrksp = 0x40000000, /* add 1 line space to break (IFbrk set too) */ + IFnobrk = 0x20000000, /* break not allowed before this item */ + IFcleft = 0x10000000, /* clear left floats (IFbrk set too) */ + IFcright = 0x08000000, /* clear right floats (IFbrk set too) */ + IFwrap = 0x04000000, /* in a wrapping (non-pre) line */ + IFhang = 0x02000000, /* in a hanging (into left indent) item */ + IFrjust = 0x01000000, /* right justify current line */ + IFcjust = 0x00800000, /* center justify current line */ + IFsmap = 0x00400000, /* image is server-side map */ IFindentshift = 8, - IFindentmask = (255<events of containing item + Formfield* next; /* in list of fields for a form */ + int ftype; /* Ftext, Fpassword, etc. */ + int fieldid; /* serial no. of field within its form */ + Form* form; /* containing form */ + Rune* name; /* name attr */ + Rune* value; /* value attr */ + int size; /* size attr */ + int maxlength; /* maxlength attr */ + int rows; /* rows attr */ + int cols; /* cols attr */ + uchar flags; /* FFchecked, etc. */ + Option* options; /* for Fselect fields */ + Item* image; /* image item, for Fimage fields */ + int ctlid; /* identifies control for this field in layout */ + SEvent* events; /* same as genattr->events of containing item */ }; enum { @@ -357,29 +357,29 @@ enum { FFmultiple = (1<<6) }; -// Option holds info about an option in a "select" form field +/* Option holds info about an option in a "select" form field */ struct Option { - Option* next; // next in list of options for a field - int selected; // true if selected initially - Rune* value; // value attr - Rune* display; // display string + Option* next; /* next in list of options for a field */ + int selected; /* true if selected initially */ + Rune* value; /* value attr */ + Rune* display; /* display string */ }; -// Form holds info about a form +/* Form holds info about a form */ struct Form { - Form* next; // in list of forms for document - int formid; // serial no. of form within its doc - Rune* name; // name or id attr (netscape uses name, HTML 4.0 uses id) - Rune* action; // action attr - int target; // target attr as targetid - int method; // HGet or HPost - int nfields; // number of fields - Formfield* fields; // field's forms, in input order + Form* next; /* in list of forms for document */ + int formid; /* serial no. of form within its doc */ + Rune* name; /* name or id attr (netscape uses name, HTML 4.0 uses id) */ + Rune* action; /* action attr */ + int target; /* target attr as targetid */ + int method; /* HGet or HPost */ + int nfields; /* number of fields */ + Formfield* fields; /* field's forms, in input order */ }; -// Flags used in various table structures +/* Flags used in various table structures */ enum { TFparsing = (1<<7), TFnowrap = (1<<6), @@ -387,33 +387,33 @@ enum { }; -// Information about a table +/* Information about a table */ struct Table { - Table* next; // next in list of document's tables - int tableid; // serial no. of table within its doc - Tablerow* rows; // array of row specs (list during parsing) - int nrow; // total number of rows - Tablecol* cols; // array of column specs - int ncol; // total number of columns - Tablecell* cells; // list of unique cells - int ncell; // total number of cells - Tablecell*** grid; // 2-D array of cells - Align align; // alignment spec for whole table - Dimen width; // width spec for whole table - int border; // border attr - int cellspacing; // cellspacing attr - int cellpadding; // cellpadding attr - Background background; // table background - Item* caption; // linked list of Items, giving caption - uchar caption_place; // ALtop or ALbottom - Lay* caption_lay; // layout of caption - int totw; // total width - int toth; // total height - int caph; // caption height - int availw; // used for previous 3 sizes - Token* tabletok; // token that started the table - uchar flags; // Lchanged, perhaps + Table* next; /* next in list of document's tables */ + int tableid; /* serial no. of table within its doc */ + Tablerow* rows; /* array of row specs (list during parsing) */ + int nrow; /* total number of rows */ + Tablecol* cols; /* array of column specs */ + int ncol; /* total number of columns */ + Tablecell* cells; /* list of unique cells */ + int ncell; /* total number of cells */ + Tablecell*** grid; /* 2-D array of cells */ + Align align; /* alignment spec for whole table */ + Dimen width; /* width spec for whole table */ + int border; /* border attr */ + int cellspacing; /* cellspacing attr */ + int cellpadding; /* cellpadding attr */ + Background background; /* table background */ + Item* caption; /* linked list of Items, giving caption */ + uchar caption_place; /* ALtop or ALbottom */ + Lay* caption_lay; /* layout of caption */ + int totw; /* total width */ + int toth; /* total height */ + int caph; /* caption height */ + int availw; /* used for previous 3 sizes */ + Token* tabletok; /* token that started the table */ + uchar flags; /* Lchanged, perhaps */ }; @@ -427,101 +427,101 @@ struct Tablecol struct Tablerow { - Tablerow* next; // Next in list of rows, during parsing - Tablecell* cells; // Cells in row, linked through nextinrow + Tablerow* next; /* Next in list of rows, during parsing */ + Tablecell* cells; /* Cells in row, linked through nextinrow */ int height; int ascent; Align align; Background background; Point pos; - uchar flags; // 0 or TFparsing + uchar flags; /* 0 or TFparsing */ }; -// A Tablecell is one cell of a table. -// It may span multiple rows and multiple columns. -// Cells are linked on two lists: the list for all the cells of -// a document (the next pointers), and the list of all the -// cells that start in a given row (the nextinrow pointers) +/* A Tablecell is one cell of a table. */ +/* It may span multiple rows and multiple columns. */ +/* Cells are linked on two lists: the list for all the cells of */ +/* a document (the next pointers), and the list of all the */ +/* cells that start in a given row (the nextinrow pointers) */ struct Tablecell { - Tablecell* next; // next in list of table's cells - Tablecell* nextinrow; // next in list of row's cells - int cellid; // serial no. of cell within table - Item* content; // contents before layout - Lay* lay; // layout of cell - int rowspan; // number of rows spanned by this cell - int colspan; // number of cols spanned by this cell - Align align; // alignment spec - uchar flags; // TFparsing, TFnowrap, TFisth - Dimen wspec; // suggested width - int hspec; // suggested height - Background background; // cell background - int minw; // minimum possible width - int maxw; // maximum width - int ascent; // cell's ascent - int row; // row of upper left corner - int col; // col of upper left corner - Point pos; // nw corner of cell contents, in cell -}; - -// Anchor is for info about hyperlinks that go somewhere + Tablecell* next; /* next in list of table's cells */ + Tablecell* nextinrow; /* next in list of row's cells */ + int cellid; /* serial no. of cell within table */ + Item* content; /* contents before layout */ + Lay* lay; /* layout of cell */ + int rowspan; /* number of rows spanned by this cell */ + int colspan; /* number of cols spanned by this cell */ + Align align; /* alignment spec */ + uchar flags; /* TFparsing, TFnowrap, TFisth */ + Dimen wspec; /* suggested width */ + int hspec; /* suggested height */ + Background background; /* cell background */ + int minw; /* minimum possible width */ + int maxw; /* maximum width */ + int ascent; /* cell's ascent */ + int row; /* row of upper left corner */ + int col; /* col of upper left corner */ + Point pos; /* nw corner of cell contents, in cell */ +}; + +/* Anchor is for info about hyperlinks that go somewhere */ struct Anchor { - Anchor* next; // next in list of document's anchors - int index; // serial no. of anchor within its doc - Rune* name; // name attr - Rune* href; // href attr - int target; // target attr as targetid + Anchor* next; /* next in list of document's anchors */ + int index; /* serial no. of anchor within its doc */ + Rune* name; /* name attr */ + Rune* href; /* href attr */ + int target; /* target attr as targetid */ }; -// DestAnchor is for info about hyperlinks that are destinations +/* DestAnchor is for info about hyperlinks that are destinations */ struct DestAnchor { - DestAnchor* next; // next in list of document's destanchors - int index; // serial no. of anchor within its doc - Rune* name; // name attr - Item* item; // the destination + DestAnchor* next; /* next in list of document's destanchors */ + int index; /* serial no. of anchor within its doc */ + Rune* name; /* name attr */ + Item* item; /* the destination */ }; -// Maps (client side) +/* Maps (client side) */ struct Map { - Map* next; // next in list of document's maps - Rune* name; // map name - Area* areas; // list of map areas + Map* next; /* next in list of document's maps */ + Rune* name; /* map name */ + Area* areas; /* list of map areas */ }; struct Area { - Area* next; // next in list of a map's areas - int shape; // SHrect, etc. - Rune* href; // associated hypertext link - int target; // associated target frame - Dimen* coords; // array of coords for shape - int ncoords; // size of coords array + Area* next; /* next in list of a map's areas */ + int shape; /* SHrect, etc. */ + Rune* href; /* associated hypertext link */ + int target; /* associated target frame */ + Dimen* coords; /* array of coords for shape */ + int ncoords; /* size of coords array */ }; -// Area shapes +/* Area shapes */ enum { SHrect, SHcircle, SHpoly }; -// Fonts are represented by integers: style*NumSize + size +/* Fonts are represented by integers: style*NumSize + size */ -// Font styles +/* Font styles */ enum { - FntR, // roman - FntI, // italic - FntB, // bold - FntT, // typewriter + FntR, /* roman */ + FntI, /* italic */ + FntB, /* bold */ + FntT, /* typewriter */ NumStyle }; -// Font sizes +/* Font sizes */ enum { Tiny, Small, @@ -536,12 +536,12 @@ enum { DefFnt = (FntR*NumSize+Normal) }; -// Lines are needed through some text items, for underlining or strikethrough +/* Lines are needed through some text items, for underlining or strikethrough */ enum { ULnone, ULunder, ULmid }; -// Kidinfo flags +/* Kidinfo flags */ enum { FRnoresize = (1<<0), FRnoscroll = (1<<1), @@ -551,59 +551,59 @@ enum { FRvscrollauto = (1<<5) }; -// Information about child frame or frameset +/* Information about child frame or frameset */ struct Kidinfo { - Kidinfo* next; // in list of kidinfos for a frameset + Kidinfo* next; /* in list of kidinfos for a frameset */ int isframeset; - // fields for "frame" - Rune* src; // only nil if a "dummy" frame or this is frameset - Rune* name; // always non-empty if this isn't frameset + /* fields for "frame" */ + Rune* src; /* only nil if a "dummy" frame or this is frameset */ + Rune* name; /* always non-empty if this isn't frameset */ int marginw; int marginh; int framebd; int flags; - // fields for "frameset" - Dimen* rows; // array of row dimensions - int nrows; // length of rows - Dimen* cols; // array of col dimensions - int ncols; // length of cols + /* fields for "frameset" */ + Dimen* rows; /* array of row dimensions */ + int nrows; /* length of rows */ + Dimen* cols; /* array of col dimensions */ + int ncols; /* length of cols */ Kidinfo* kidinfos; - Kidinfo* nextframeset; // parsing stack + Kidinfo* nextframeset; /* parsing stack */ }; -// Document info (global information about HTML page) +/* Document info (global information about HTML page) */ struct Docinfo { - // stuff from HTTP headers, doc head, and body tag - Rune* src; // original source of doc - Rune* base; // base URL of doc - Rune* doctitle; // from element - Background background; // background specification - Iimage* backgrounditem; // Image Item for doc background image, or nil - int text; // doc foreground (text) color - int link; // unvisited hyperlink color - int vlink; // visited hyperlink color - int alink; // highlighting hyperlink color - int target; // target frame default - int chset; // ISO_8859, etc. - int mediatype; // TextHtml, etc. - int scripttype; // TextJavascript, etc. - int hasscripts; // true if scripts used - Rune* refresh; // content of <http-equiv=Refresh ...> - Kidinfo* kidinfo; // if a frameset - int frameid; // id of document frame - - // info needed to respond to user actions - Anchor* anchors; // list of href anchors - DestAnchor* dests; // list of destination anchors - Form* forms; // list of forms - Table* tables; // list of tables - Map* maps; // list of maps - Iimage* images; // list of image items (through nextimage links) + /* stuff from HTTP headers, doc head, and body tag */ + Rune* src; /* original source of doc */ + Rune* base; /* base URL of doc */ + Rune* doctitle; /* from <title> element */ + Background background; /* background specification */ + Iimage* backgrounditem; /* Image Item for doc background image, or nil */ + int text; /* doc foreground (text) color */ + int link; /* unvisited hyperlink color */ + int vlink; /* visited hyperlink color */ + int alink; /* highlighting hyperlink color */ + int target; /* target frame default */ + int chset; /* ISO_8859, etc. */ + int mediatype; /* TextHtml, etc. */ + int scripttype; /* TextJavascript, etc. */ + int hasscripts; /* true if scripts used */ + Rune* refresh; /* content of <http-equiv=Refresh ...> */ + Kidinfo* kidinfo; /* if a frameset */ + int frameid; /* id of document frame */ + + /* info needed to respond to user actions */ + Anchor* anchors; /* list of href anchors */ + DestAnchor* dests; /* list of destination anchors */ + Form* forms; /* list of forms */ + Table* tables; /* list of tables */ + Map* maps; /* list of maps */ + Iimage* images; /* list of image items (through nextimage links) */ }; extern int dimenkind(Dimen d); @@ -618,14 +618,14 @@ extern int validitems(Item* i); /* #pragma varargck type "I" Item* */ -// Control print output +/* Control print output */ extern int warn; extern int dbglex; extern int dbgbuild; -// To be provided by caller -// emalloc and erealloc should not return if can't get memory. -// emalloc should zero its memory. +/* To be provided by caller */ +/* emalloc and erealloc should not return if can't get memory. */ +/* emalloc should zero its memory. */ extern void* emalloc(ulong); extern void* erealloc(void* p, ulong size); #ifdef __cpluspplus -- cgit v1.2.3