mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Improve show config and help config order
This commit is contained in:
38
config.c
38
config.c
@@ -94,6 +94,7 @@ NAMETYPE configs[] = {
|
|||||||
{"redc2", CONFIG_REDC2},
|
{"redc2", CONFIG_REDC2},
|
||||||
{"tilde", CONFIG_TILDE},
|
{"tilde", CONFIG_TILDE},
|
||||||
{"tilde_space", CONFIG_TILDE_SPACE},
|
{"tilde_space", CONFIG_TILDE_SPACE},
|
||||||
|
{"fraction_space", CONFIG_FRACTION_SPACE},
|
||||||
{"tab", CONFIG_TAB},
|
{"tab", CONFIG_TAB},
|
||||||
{"quomod", CONFIG_QUOMOD},
|
{"quomod", CONFIG_QUOMOD},
|
||||||
{"quo", CONFIG_QUO},
|
{"quo", CONFIG_QUO},
|
||||||
@@ -132,7 +133,6 @@ NAMETYPE configs[] = {
|
|||||||
{"redecl_warn", CONFIG_REDECL_WARN},
|
{"redecl_warn", CONFIG_REDECL_WARN},
|
||||||
{"dupvar_warn", CONFIG_DUPVAR_WARN},
|
{"dupvar_warn", CONFIG_DUPVAR_WARN},
|
||||||
{"hz", CONFIG_HZ},
|
{"hz", CONFIG_HZ},
|
||||||
{"fraction_space", CONFIG_FRACTION_SPACE},
|
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -644,6 +644,20 @@ setconfig(int type, VALUE *vp)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CONFIG_FRACTION_SPACE:
|
||||||
|
if (vp->v_type == V_NUM) {
|
||||||
|
q = vp->v_num;
|
||||||
|
conf->fraction_space = !qiszero(q);
|
||||||
|
} else if (vp->v_type == V_STR) {
|
||||||
|
temp = lookup_long(truth, vp->v_str->s_str);
|
||||||
|
if (temp < 0) {
|
||||||
|
math_error("Illegal truth value for fraction_space");
|
||||||
|
not_reached();
|
||||||
|
}
|
||||||
|
conf->fraction_space = (int)temp;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case CONFIG_TAB:
|
case CONFIG_TAB:
|
||||||
if (vp->v_type == V_NUM) {
|
if (vp->v_type == V_NUM) {
|
||||||
q = vp->v_num;
|
q = vp->v_num;
|
||||||
@@ -1009,20 +1023,6 @@ setconfig(int type, VALUE *vp)
|
|||||||
not_reached();
|
not_reached();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_FRACTION_SPACE:
|
|
||||||
if (vp->v_type == V_NUM) {
|
|
||||||
q = vp->v_num;
|
|
||||||
conf->fraction_space = !qiszero(q);
|
|
||||||
} else if (vp->v_type == V_STR) {
|
|
||||||
temp = lookup_long(truth, vp->v_str->s_str);
|
|
||||||
if (temp < 0) {
|
|
||||||
math_error("Illegal truth value for fraction_space");
|
|
||||||
not_reached();
|
|
||||||
}
|
|
||||||
conf->fraction_space = (int)temp;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
math_error("Setting illegal config parameter");
|
math_error("Setting illegal config parameter");
|
||||||
not_reached();
|
not_reached();
|
||||||
@@ -1243,6 +1243,10 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
i = (cfg->tilde_space ? 1 : 0);
|
i = (cfg->tilde_space ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CONFIG_FRACTION_SPACE:
|
||||||
|
i = (cfg->fraction_space ? 1 : 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case CONFIG_TAB:
|
case CONFIG_TAB:
|
||||||
i = (cfg->tab_ok ? 1 : 0);
|
i = (cfg->tab_ok ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
@@ -1422,10 +1426,6 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
|||||||
i = CALC_HZ;
|
i = CALC_HZ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONFIG_FRACTION_SPACE:
|
|
||||||
i = (cfg->fraction_space ? 1 : 0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
math_error("Getting illegal CONFIG element");
|
math_error("Getting illegal CONFIG element");
|
||||||
not_reached();
|
not_reached();
|
||||||
|
34
help/config
34
help/config
@@ -372,7 +372,7 @@ DESCRIPTION
|
|||||||
|
|
||||||
If config("tilde") is false, then config("tilde_space") has no effect.
|
If config("tilde") is false, then config("tilde_space") has no effect.
|
||||||
|
|
||||||
The initial "tilde" value is 1.
|
The initial "tilde" value is 1 (on).
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
|
|
||||||
@@ -385,7 +385,22 @@ DESCRIPTION
|
|||||||
NOTE: Use of config("tilde_space", 1) can break printing and scanning
|
NOTE: Use of config("tilde_space", 1) can break printing and scanning
|
||||||
of complex values via "%c".
|
of complex values via "%c".
|
||||||
|
|
||||||
The initial "tilde_space" value is 0.
|
The initial "tilde_space" value is 0 (off)
|
||||||
|
|
||||||
|
=-=
|
||||||
|
|
||||||
|
config("fraction_space", boolean)
|
||||||
|
|
||||||
|
The "fraction_space" controls whether or not a space (' ') is
|
||||||
|
printed both before and after '/' when printing a fraction.
|
||||||
|
|
||||||
|
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".
|
||||||
|
|
||||||
|
The initial "fraction_space" value is 0 (off).
|
||||||
|
|
||||||
=-=
|
=-=
|
||||||
|
|
||||||
@@ -902,21 +917,6 @@ DESCRIPTION
|
|||||||
|
|
||||||
This config parameter is read-only and cannot be set.
|
This config parameter is read-only and cannot be set.
|
||||||
|
|
||||||
=-=
|
|
||||||
|
|
||||||
config("fraction_space", boolean)
|
|
||||||
|
|
||||||
The "fraction_space" controls whether or not a space (' ') is
|
|
||||||
printed both before and after '/' when printing a fraction.
|
|
||||||
|
|
||||||
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".
|
|
||||||
|
|
||||||
The initial "fraction_space" value is 0.
|
|
||||||
|
|
||||||
EXAMPLE
|
EXAMPLE
|
||||||
; current_cfg = config("all");
|
; current_cfg = config("all");
|
||||||
; config("tilde", off),;
|
; config("tilde", off),;
|
||||||
|
Reference in New Issue
Block a user