mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Change default to print space after the approximation tilde
Added config("tilde_space", boolean). The "tilde_space" controls whether or not a space (' ') is printed after leading tilde ('~'). By default, config("tilde_space") is true, which is a change from past behavior. For example, now: ; 1/3 ~ 0.33333333333333333333 With config("tilde_space", 0): ; 1/3 ~0.33333333333333333333 To disable "tilde_space", use config("tilde_space", 0) on the command line and/or use config("tilde_space", 0),; in your ~/.calcrc. Thanks goes to <GitHub use ljramalho> for this suggestion. Added config("tilde_space", boolean) to help/config, along with a few few minor text improvements. Updated cal/regress to test config("tilde_space") and to account for the new default.
This commit is contained in:
21
config.c
21
config.c
@@ -93,6 +93,7 @@ NAMETYPE configs[] = {
|
||||
{"pow2", CONFIG_POW2},
|
||||
{"redc2", CONFIG_REDC2},
|
||||
{"tilde", CONFIG_TILDE},
|
||||
{"tilde_space", CONFIG_TILDE_SPACE},
|
||||
{"tab", CONFIG_TAB},
|
||||
{"quomod", CONFIG_QUOMOD},
|
||||
{"quo", CONFIG_QUO},
|
||||
@@ -151,6 +152,7 @@ CONFIG oldstd = { /* backward compatible standard configuration */
|
||||
POW_ALG2, /* size of modulus to use REDC for powers */
|
||||
REDC_ALG2, /* size of modulus to use REDC algorithm 2 */
|
||||
TRUE, /* OK to print a tilde on approximations */
|
||||
FALSE, /* OK to print a space after tilde on approximations */
|
||||
TRUE, /* OK to print tab before numeric values */
|
||||
0, /* quomod() default rounding mode */
|
||||
2, /* quotient // default rounding mode */
|
||||
@@ -211,6 +213,7 @@ CONFIG newstd = { /* new non-backward compatible configuration */
|
||||
POW_ALG2, /* size of modulus to use REDC for powers */
|
||||
REDC_ALG2, /* size of modulus to use REDC algorithm 2 */
|
||||
TRUE, /* OK to print a tilde on approximations */
|
||||
TRUE, /* OK to print a space after tilde on approximations */
|
||||
TRUE, /* OK to print tab before numeric values */
|
||||
0, /* quomod() default rounding mode */
|
||||
2, /* quotient // default rounding mode */
|
||||
@@ -624,6 +627,20 @@ setconfig(int type, VALUE *vp)
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG_TILDE_SPACE:
|
||||
if (vp->v_type == V_NUM) {
|
||||
q = vp->v_num;
|
||||
conf->tilde_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 tilde_space");
|
||||
not_reached();
|
||||
}
|
||||
conf->tilde_space = (int)temp;
|
||||
}
|
||||
break;
|
||||
|
||||
case CONFIG_TAB:
|
||||
if (vp->v_type == V_NUM) {
|
||||
q = vp->v_num;
|
||||
@@ -1205,6 +1222,10 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
|
||||
i = (cfg->tilde_ok ? 1 : 0);
|
||||
break;
|
||||
|
||||
case CONFIG_TILDE_SPACE:
|
||||
i = (cfg->tilde_space ? 1 : 0);
|
||||
break;
|
||||
|
||||
case CONFIG_TAB:
|
||||
i = (cfg->tab_ok ? 1 : 0);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user