[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] C++ solution of the char length problem

From: Bernd Warken
Subject: [Groff] C++ solution of the char length problem
Date: Sun, 30 Mar 2003 23:01:36 +0200
User-agent: Mutt/1.2.5i tests=SPAM_PHRASE_01_02,USER_AGENT,USER_AGENT_MUTT version=2.41

We had already some discussions on the bad handling of the length of
character variables in groff.  The C solution uses a cumbersome
preprocessor construct.  Fortunately, there is a possibility to handle
the variable length with an excellent C++ solution, that is even
available in all versions of C++, but not in plain C.

The member in a `struct' or `class' can be enhanced by a so-called
"bit-field", a `:' separated length argument appended to the variable
name.  For example, a 8 bits integer could be defined as

struct Int8 {
  int data: 8;


class Int8 {
  int data: 8;

Usually, groff uses positive values for normal characters, and
negative values for special groff properties.  So groff uses signed
variables for representing characters.  This doubles the necessary

When we are using a `struct' or `class' anyway, this can be optimized
by an additional Boolean member.  For example, a groff Unicode
character type could be defined as

class GroffChar {
  unsigned int data: 16;
  bool special;

This will be especially helpful for the increasing number of handheld
computers with small standard space.

I will not have the time to do this for groff, so feel free to use
this as you like.

Bernd Warken

reply via email to

[Prev in Thread] Current Thread [Next in Thread]