diff options
author | wlemb <wlemb> | 2004-08-05 16:38:22 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2004-08-05 16:38:22 +0000 |
commit | 8437acbc786b4b3ffc6814453d3b2d4d680ece38 (patch) | |
tree | ea38b061998727f788cfa6f6d56a3ad0769f1944 /src/utils | |
parent | 18188931386228763f4870449b0937b32af6a0ac (diff) | |
download | groff-8437acbc786b4b3ffc6814453d3b2d4d680ece38.tar.gz |
* doc/meref.me: Document `_M' register.
Make hpftodit work correctly on big-endian systems.
* src/utils/hpftodit/hpftodit.cpp (File): New method
`get_uint32(char *)'.
(entry): New member `orig_value'.
(read_tags): Use new method.
(output_font_name, read_and_output_pcltypeface, dump_ascii):
Updated.
* tmac/s.tmac: Undo change 2003-06-29. The proper macro definitions
are already in X11's `macros.t' file.
* src/utils/hpftodit/hfptodit.cpp (output_font_name, dump_ascii):
Fix casting bug.
(read_and_output_pcltypeface): Handle strings with length <= 4.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/hpftodit/hpftodit.cpp | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/utils/hpftodit/hpftodit.cpp b/src/utils/hpftodit/hpftodit.cpp index 3315cf78..5756ae92 100644 --- a/src/utils/hpftodit/hpftodit.cpp +++ b/src/utils/hpftodit/hpftodit.cpp @@ -145,6 +145,7 @@ public: byte get_byte(); uint16 get_uint16(); uint32 get_uint32(); + uint32 get_uint32(char *orig); void seek(uint32 n); private: unsigned char *buf_; @@ -157,6 +158,7 @@ struct entry { uint16 type; uint32 count; uint32 value; + char orig_value[4]; entry() : present(0) { } }; @@ -463,6 +465,22 @@ File::get_uint32() return n; } +uint32 +File::get_uint32(char *orig) +{ + if (end_ - ptr_ < 4) + fatal("unexpected end of file"); + unsigned char v = *ptr_++; + uint32 n = v; + orig[0] = v; + for (int i = 1; i < 4; i++) { + v = *ptr_++; + orig[i] = v; + n += v << i*8; + } + return n; +} + static void read_tags(File &f) { @@ -481,7 +499,7 @@ read_tags(File &f) p->present = 1; p->type = f.get_uint16(); p->count = f.get_uint32(); - p->value = f.get_uint32(); + p->value = f.get_uint32(p->orig_value); } } @@ -547,8 +565,9 @@ output_font_name(File &f) while (--n) *p++ = f.get_byte(); } - else // value contains the string - sprintf(font_name, "%.*s", count, (char*)(tag_info(font_name_tag).value)); + else // orig_value contains the string + sprintf(font_name, "%.*s", + count, tag_info(font_name_tag).orig_value); // remove any trailing space p = font_name + count - 1; @@ -717,13 +736,17 @@ read_and_output_pcltypeface(File &f) { printf("pcltypeface "); require_tag(typeface_tag); - f.seek(tag_info(typeface_tag).value); - for (uint32 i = 0; i < tag_info(typeface_tag).count; i++) { - unsigned char c = f.get_byte(); - if (c == '\0') - break; - putchar(c); + if (tag_info(typeface_tag).count > 4) { + f.seek(tag_info(typeface_tag).value); + for (uint32 i = 0; i < tag_info(typeface_tag).count; i++) { + unsigned char c = f.get_byte(); + if (c == '\0') + break; + putchar(c); + } } + else + printf("%.4s", tag_info(typeface_tag).orig_value); printf("\n"); } @@ -1168,7 +1191,7 @@ dump_ascii(File &f, tag_type t) printf("%c", f.get_byte()); } else - printf("%.4s", (char*)(tag_info(t).value)); + printf("%.4s", tag_info(t).orig_value); putchar('"'); } |