Add config("fraction_space") to control spaces around printing fractions

Added config("tilde_space", boolean) to help/config, along with
a few few minor text improvements.  Updated cal/regress to test
config("tilde_space").

Added config("fraction_space", boolean).  The "fraction_space" controls
whether or not a space (' ') is printed before and after fractions.
By default, config("fraction_space") is false.

For example, with the default, config("fraction_space", 0):

    ; base(1/3),
    ; 1/7
            1/7

With config("fraction_space", 1):

    ; base(1/3),
    ; 1/7
            1 / 7

NOTE: Use of config("fraction_space", 1) can break printing and scanning
      of fractional values via "%r".

NOTE: Use of config("fraction_space", 1) can break printing and scanning
      of complex values via "%c".

Added config("fraction_space", boolean) to help/config, along with
a few few minor text improvements.  Updated cal/regress to test
config("tilde_space").
This commit is contained in:
Landon Curt Noll
2022-12-03 14:39:25 -08:00
parent 7c6723db88
commit 17702a4799
8 changed files with 132 additions and 8 deletions

30
qio.c
View File

@@ -420,7 +420,13 @@ qprintfr(NUMBER *q, long width, BOOL force)
{
zprintval(q->num, 0L, width);
if (force || qisfrac(q)) {
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
zprintval(q->den, 0L, width);
}
}
@@ -454,7 +460,13 @@ qprintfx(NUMBER *q, long width)
{
zprintx(q->num, width);
if (qisfrac(q)) {
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
zprintx(q->den, 0L);
}
}
@@ -469,7 +481,13 @@ qprintfb(NUMBER *q, long width)
{
zprintb(q->num, width);
if (qisfrac(q)) {
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
zprintb(q->den, 0L);
}
}
@@ -484,7 +502,13 @@ qprintfo(NUMBER *q, long width)
{
zprinto(q->num, width);
if (qisfrac(q)) {
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
zprinto(q->den, 0L);
}
}
@@ -757,6 +781,12 @@ fitprint(NUMBER *q, long width)
width1 = width - width2;
}
fitzprint(q->num, numdigits, width1);
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
fitzprint(q->den, dendigits, width2);
}