awk: reduce ifdef forest

Signed-off-by: Rob Landley <rob@landley.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Rob Landley 2010-10-24 03:27:22 +02:00 committed by Denys Vlasenko
parent 738e4de013
commit d8205b39ab

View File

@ -524,9 +524,7 @@ static const char EMSG_TOO_FEW_ARGS[] ALIGN1 = "Too few arguments for builtin";
static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array"; static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array";
static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error"; static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error";
static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function"; static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function";
#if !ENABLE_FEATURE_AWK_LIBM
static const char EMSG_NO_MATH[] ALIGN1 = "Math support is not compiled in"; static const char EMSG_NO_MATH[] ALIGN1 = "Math support is not compiled in";
#endif
static void zero_out_var(var *vp) static void zero_out_var(var *vp)
{ {
@ -700,8 +698,7 @@ static ALWAYS_INLINE int isalnum_(int c)
static double my_strtod(char **pp) static double my_strtod(char **pp)
{ {
char *cp = *pp; char *cp = *pp;
#if ENABLE_DESKTOP if (ENABLE_DESKTOP && cp[0] == '0') {
if (cp[0] == '0') {
/* Might be hex or octal integer: 0x123abc or 07777 */ /* Might be hex or octal integer: 0x123abc or 07777 */
char c = (cp[1] | 0x20); char c = (cp[1] | 0x20);
if (c == 'x' || isdigit(cp[1])) { if (c == 'x' || isdigit(cp[1])) {
@ -718,7 +715,6 @@ static double my_strtod(char **pp)
*/ */
} }
} }
#endif
return strtod(cp, pp); return strtod(cp, pp);
} }
@ -2168,11 +2164,10 @@ static NOINLINE var *exec_builtin(node *op, var *res)
switch (info) { switch (info) {
case B_a2: case B_a2:
#if ENABLE_FEATURE_AWK_LIBM if (ENABLE_FEATURE_AWK_LIBM)
setvar_i(res, atan2(getvar_i(av[0]), getvar_i(av[1]))); setvar_i(res, atan2(getvar_i(av[0]), getvar_i(av[1])));
#else else
syntax_error(EMSG_NO_MATH); syntax_error(EMSG_NO_MATH);
#endif
break; break;
case B_sp: { case B_sp: {
@ -2655,35 +2650,40 @@ static var *evaluate(node *op, var *res)
case F_rn: case F_rn:
R_d = (double)rand() / (double)RAND_MAX; R_d = (double)rand() / (double)RAND_MAX;
break; break;
#if ENABLE_FEATURE_AWK_LIBM
case F_co: case F_co:
if (ENABLE_FEATURE_AWK_LIBM) {
R_d = cos(L_d); R_d = cos(L_d);
break; break;
}
case F_ex: case F_ex:
if (ENABLE_FEATURE_AWK_LIBM) {
R_d = exp(L_d); R_d = exp(L_d);
break; break;
}
case F_lg: case F_lg:
if (ENABLE_FEATURE_AWK_LIBM) {
R_d = log(L_d); R_d = log(L_d);
break; break;
}
case F_si: case F_si:
if (ENABLE_FEATURE_AWK_LIBM) {
R_d = sin(L_d); R_d = sin(L_d);
break; break;
}
case F_sq: case F_sq:
if (ENABLE_FEATURE_AWK_LIBM) {
R_d = sqrt(L_d); R_d = sqrt(L_d);
break; break;
#else }
case F_co:
case F_ex:
case F_lg:
case F_si:
case F_sq:
syntax_error(EMSG_NO_MATH); syntax_error(EMSG_NO_MATH);
break; break;
#endif
case F_sr: case F_sr:
R_d = (double)seed; R_d = (double)seed;
seed = op1 ? (unsigned)L_d : (unsigned)time(NULL); seed = op1 ? (unsigned)L_d : (unsigned)time(NULL);
@ -2834,11 +2834,10 @@ static var *evaluate(node *op, var *res)
L_d /= R_d; L_d /= R_d;
break; break;
case '&': case '&':
#if ENABLE_FEATURE_AWK_LIBM if (ENABLE_FEATURE_AWK_LIBM)
L_d = pow(L_d, R_d); L_d = pow(L_d, R_d);
#else else
syntax_error(EMSG_NO_MATH); syntax_error(EMSG_NO_MATH);
#endif
break; break;
case '%': case '%':
if (R_d == 0) if (R_d == 0)