groff
[Top][All Lists]
Advanced

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

Re: [groff] hyphenation issues


From: Ralph Corderoy
Subject: Re: [groff] hyphenation issues
Date: Sat, 05 May 2018 10:31:48 +0100

Hi Branden,

> +  static int n_max = (HYPHEN_NOT_LAST_LINE | HYPHEN_NOT_LAST_CHARS
> +    | HYPHEN_NOT_FIRST_CHARS | HYPHEN_LAST_CHAR
> +    | HYPHEN_FIRST_CHAR);

s/static int/int const/?

>    if (has_arg() && get_integer(&n)) {
> -    if (((n & HYPHEN_FIRST_CHAR) && (n & HYPHEN_NOT_FIRST_CHARS))
> +    if (n > n_max) {
> +      warning(WARN_RANGE, "hyphenation request value '%1' not "
> +     "supported (maximum %2); ignored", n, n_max);
> +    } else if (((n & HYPHEN_FIRST_CHAR) && (n & HYPHEN_NOT_FIRST_CHARS))
>       || ((n & HYPHEN_LAST_CHAR) && (n & HYPHEN_NOT_LAST_CHARS)))
>        warning(WARN_SYNTAX, "contradicting hyphenation flags, ignored");

19 of the 64 six-bit values for `.hy' seem valid.

Given the enum,

    enum {
      HYPHEN_NOT_LAST_LINE = 2,
      HYPHEN_NOT_LAST_CHARS = 4,
      HYPHEN_NOT_FIRST_CHARS = 8,
      HYPHEN_LAST_CHAR = 16,
      HYPHEN_FIRST_CHAR = 32
    };

I'd suggest adding

    HYPHEN_NONE = 0,
    HYPHEN_DEFAULT = 1,
    HYPHEN_MAX = 63 // Or whatever the local naming convention is.

Then test for

    n > HYPHEN_MAX
    n & HYPHEN_DEFAULT && n & ~HYPHEN_DEFAULT

in addition to the existing

    n & HYPHEN_FIRST_CHAR && n & HYPHEN_NOT_FIRST_CHARS
    n & HYPHEN_LAST_CHAR && n & HYPHEN_NOT_LAST_CHARS

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy



reply via email to

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