mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 21:56:57 +00:00
Merge branch 'obsd-master'
This commit is contained in:
42
format.c
42
format.c
@ -1984,7 +1984,17 @@ format_replace_expression(struct format_modifier *mexp,
|
|||||||
int use_fp = 0;
|
int use_fp = 0;
|
||||||
u_int prec = 0;
|
u_int prec = 0;
|
||||||
double mleft, mright, result;
|
double mleft, mright, result;
|
||||||
enum { ADD, SUBTRACT, MULTIPLY, DIVIDE, MODULUS } operator;
|
enum { ADD,
|
||||||
|
SUBTRACT,
|
||||||
|
MULTIPLY,
|
||||||
|
DIVIDE,
|
||||||
|
MODULUS,
|
||||||
|
EQUAL,
|
||||||
|
NOT_EQUAL,
|
||||||
|
GREATER_THAN,
|
||||||
|
GREATER_THAN_EQUAL,
|
||||||
|
LESS_THAN,
|
||||||
|
LESS_THAN_EQUAL } operator;
|
||||||
|
|
||||||
if (strcmp(mexp->argv[0], "+") == 0)
|
if (strcmp(mexp->argv[0], "+") == 0)
|
||||||
operator = ADD;
|
operator = ADD;
|
||||||
@ -1997,6 +2007,18 @@ format_replace_expression(struct format_modifier *mexp,
|
|||||||
else if (strcmp(mexp->argv[0], "%") == 0 ||
|
else if (strcmp(mexp->argv[0], "%") == 0 ||
|
||||||
strcmp(mexp->argv[0], "m") == 0)
|
strcmp(mexp->argv[0], "m") == 0)
|
||||||
operator = MODULUS;
|
operator = MODULUS;
|
||||||
|
else if (strcmp(mexp->argv[0], "==") == 0)
|
||||||
|
operator = EQUAL;
|
||||||
|
else if (strcmp(mexp->argv[0], "!=") == 0)
|
||||||
|
operator = NOT_EQUAL;
|
||||||
|
else if (strcmp(mexp->argv[0], ">") == 0)
|
||||||
|
operator = GREATER_THAN;
|
||||||
|
else if (strcmp(mexp->argv[0], "<") == 0)
|
||||||
|
operator = LESS_THAN;
|
||||||
|
else if (strcmp(mexp->argv[0], ">=") == 0)
|
||||||
|
operator = GREATER_THAN_EQUAL;
|
||||||
|
else if (strcmp(mexp->argv[0], "<=") == 0)
|
||||||
|
operator = LESS_THAN_EQUAL;
|
||||||
else {
|
else {
|
||||||
format_log(es, "expression has no valid operator: '%s'",
|
format_log(es, "expression has no valid operator: '%s'",
|
||||||
mexp->argv[0]);
|
mexp->argv[0]);
|
||||||
@ -2059,6 +2081,24 @@ format_replace_expression(struct format_modifier *mexp,
|
|||||||
case MODULUS:
|
case MODULUS:
|
||||||
result = fmod(mleft, mright);
|
result = fmod(mleft, mright);
|
||||||
break;
|
break;
|
||||||
|
case EQUAL:
|
||||||
|
result = fabs(mleft - mright) < 1e-9;
|
||||||
|
break;
|
||||||
|
case NOT_EQUAL:
|
||||||
|
result = fabs(mleft - mright) > 1e-9;
|
||||||
|
break;
|
||||||
|
case GREATER_THAN:
|
||||||
|
result = (mleft > mright);
|
||||||
|
break;
|
||||||
|
case GREATER_THAN_EQUAL:
|
||||||
|
result = (mleft >= mright);
|
||||||
|
break;
|
||||||
|
case LESS_THAN:
|
||||||
|
result = (mleft < mright);
|
||||||
|
break;
|
||||||
|
case LESS_THAN_EQUAL:
|
||||||
|
result = (mleft > mright);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (use_fp)
|
if (use_fp)
|
||||||
xasprintf(&value, "%.*f", prec, result);
|
xasprintf(&value, "%.*f", prec, result);
|
||||||
|
12
tmux.1
12
tmux.1
@ -4544,7 +4544,7 @@ multiplication
|
|||||||
.Ql * ,
|
.Ql * ,
|
||||||
division
|
division
|
||||||
.Ql / ,
|
.Ql / ,
|
||||||
and modulus
|
modulus
|
||||||
.Ql m
|
.Ql m
|
||||||
or
|
or
|
||||||
.Ql %
|
.Ql %
|
||||||
@ -4553,7 +4553,15 @@ or
|
|||||||
must be escaped as
|
must be escaped as
|
||||||
.Ql %%
|
.Ql %%
|
||||||
in formats which are also expanded by
|
in formats which are also expanded by
|
||||||
.Xr strftime 3 ) .
|
.Xr strftime 3 )
|
||||||
|
and numeric comparison operators
|
||||||
|
.Ql == ,
|
||||||
|
.Ql != ,
|
||||||
|
.Ql < ,
|
||||||
|
.Ql <= ,
|
||||||
|
.Ql >
|
||||||
|
and
|
||||||
|
.Ql >= .
|
||||||
For example,
|
For example,
|
||||||
.Ql #{e|*|f|4:5.5,3}
|
.Ql #{e|*|f|4:5.5,3}
|
||||||
multiplies 5.5 by 3 for a result with four decimal places and
|
multiplies 5.5 by 3 for a result with four decimal places and
|
||||||
|
Reference in New Issue
Block a user