diff options
author | wl <wl> | 2006-02-17 16:23:21 +0000 |
---|---|---|
committer | wl <wl> | 2006-02-17 16:23:21 +0000 |
commit | 2d8ea136167d1a4c79fcc2eafe62f892f31a0e90 (patch) | |
tree | 542b1405b001e0641586f616d773926ff1674043 /src/roff/troff | |
parent | 9f9f4b09af5eb0bb1dc390d3edf5ba4423013890 (diff) | |
download | groff-2d8ea136167d1a4c79fcc2eafe62f892f31a0e90.tar.gz |
* src/include/font.h (struct glyphinfo): New class.
(struct glyph): Change internal representation.
Change constructor signature.
New method glyph::glyph_number().
(glyph::glyph, glyph glyph::undefined_glyph, glyph::glyph_index,
glyph::operator==, glyph::operator!=): Update.
(font::index_to_name, font::index_to_number): New functions.
* src/include/itable.h: New file, based on src/include/ptable.h.
* src/libs/libgroff/nametoindex.cpp: Include itable.h.
(class charinfo): New class.
(class character_indexer): Change table result type from `int' to
`class charinfo'.
Add table with integer key.
(character_indexer::character_indexer): Update.
(character_indexer::ascii_char_index): Update.
(character_indexer::numbered_char_index): Use NULL as name, not a
string starting with a space.
(character_indexer::named_char_index): Update.
(font::number_to_index, font::name_to_index): Remove no-op cast.
(glyph::glyph_name): New method.
* src/roff/troff/charinfo.h (class charinfo): Inherit from class
glyphinfo.
(NUMBERED): Remove flag bit.
(charinfo::numbered, charinfo::get_index): Update.
* src/roff/troff/input.cpp (charinfo::charinfo): Update.
(charinfo::set_number, charinfo::get_number): Update.
(glyph::glyph_name): New method.
Diffstat (limited to 'src/roff/troff')
-rw-r--r-- | src/roff/troff/charinfo.h | 14 | ||||
-rw-r--r-- | src/roff/troff/input.cpp | 13 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h index ad78beeb..0ac19cc3 100644 --- a/src/roff/troff/charinfo.h +++ b/src/roff/troff/charinfo.h @@ -21,11 +21,9 @@ Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ class macro; -class charinfo { +class charinfo : glyphinfo { static int next_index; charinfo *translation; - glyph index; - int number; macro *mac; unsigned char special_translation; unsigned char hyphenation_code; @@ -39,14 +37,14 @@ class charinfo { // active for .asciify (set by .trin) char_mode mode; public: - enum { + enum { // Values for the flags bitmask. See groff + // manual, description of the `.cflags' request. ENDS_SENTENCE = 1, BREAK_BEFORE = 2, BREAK_AFTER = 4, OVERLAPS_HORIZONTALLY = 8, OVERLAPS_VERTICALLY = 16, - TRANSPARENT = 32, - NUMBERED = 64 + TRANSPARENT = 32 }; enum { TRANSLATE_NONE, @@ -126,7 +124,7 @@ inline int charinfo::transparent() inline int charinfo::numbered() { - return flags & NUMBERED; + return number >= 0; } inline int charinfo::is_normal() @@ -173,7 +171,7 @@ inline void charinfo::set_flags(unsigned char c) inline glyph charinfo::get_index() { - return index; + return glyph(this); } inline void charinfo::set_translation_input() diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index 51d4beb8..f7f7e66f 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -8094,7 +8094,8 @@ charinfo::charinfo(symbol s) not_found(0), transparent_translate(1), translate_input(0), mode(CHAR_NORMAL), nm(s) { - index = glyph(next_index++, s.contents()); + index = next_index++; + number = -1; } void charinfo::set_hyphenation_code(unsigned char c) @@ -8152,13 +8153,13 @@ macro *charinfo::setx_macro(macro *m, char_mode cm) void charinfo::set_number(int n) { + assert(n >= 0); number = n; - flags |= NUMBERED; } int charinfo::get_number() { - assert(flags & NUMBERED); + assert(number >= 0); return number; } @@ -8213,3 +8214,9 @@ glyph font::number_to_index(int n) { return get_charinfo_by_number(n)->get_index(); } + +const char *glyph::glyph_name() +{ + charinfo *ci = (charinfo *)ptr; // Every glyphinfo is actually a charinfo. + return (ci->nm != UNNAMED_SYMBOL ? ci->nm.contents() : NULL); +} |