aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2010-10-24 03:27:22 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-10-24 03:27:22 +0200
commitd8205b39abb9971bc6aeff4a21c22b3f5f575e49 (patch)
tree4a3bac3be00ed044339ea277d6e91aae7fad6b69
parent738e4de01332a10edd30149aa998f8ed403c12ed (diff)
downloadbusybox-w32-d8205b39abb9971bc6aeff4a21c22b3f5f575e49.tar.gz
busybox-w32-d8205b39abb9971bc6aeff4a21c22b3f5f575e49.tar.bz2
busybox-w32-d8205b39abb9971bc6aeff4a21c22b3f5f575e49.zip
awk: reduce ifdef forest
Signed-off-by: Rob Landley <rob@landley.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/awk.c65
1 files changed, 32 insertions, 33 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 9646cedd6..8bc56756c 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -524,9 +524,7 @@ static const char EMSG_TOO_FEW_ARGS[] ALIGN1 = "Too few arguments for builtin";
524static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array"; 524static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array";
525static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error"; 525static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error";
526static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function"; 526static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function";
527#if !ENABLE_FEATURE_AWK_LIBM
528static const char EMSG_NO_MATH[] ALIGN1 = "Math support is not compiled in"; 527static const char EMSG_NO_MATH[] ALIGN1 = "Math support is not compiled in";
529#endif
530 528
531static void zero_out_var(var *vp) 529static void zero_out_var(var *vp)
532{ 530{
@@ -700,8 +698,7 @@ static ALWAYS_INLINE int isalnum_(int c)
700static double my_strtod(char **pp) 698static double my_strtod(char **pp)
701{ 699{
702 char *cp = *pp; 700 char *cp = *pp;
703#if ENABLE_DESKTOP 701 if (ENABLE_DESKTOP && cp[0] == '0') {
704 if (cp[0] == '0') {
705 /* Might be hex or octal integer: 0x123abc or 07777 */ 702 /* Might be hex or octal integer: 0x123abc or 07777 */
706 char c = (cp[1] | 0x20); 703 char c = (cp[1] | 0x20);
707 if (c == 'x' || isdigit(cp[1])) { 704 if (c == 'x' || isdigit(cp[1])) {
@@ -718,7 +715,6 @@ static double my_strtod(char **pp)
718 */ 715 */
719 } 716 }
720 } 717 }
721#endif
722 return strtod(cp, pp); 718 return strtod(cp, pp);
723} 719}
724 720
@@ -2168,11 +2164,10 @@ static NOINLINE var *exec_builtin(node *op, var *res)
2168 switch (info) { 2164 switch (info) {
2169 2165
2170 case B_a2: 2166 case B_a2:
2171#if ENABLE_FEATURE_AWK_LIBM 2167 if (ENABLE_FEATURE_AWK_LIBM)
2172 setvar_i(res, atan2(getvar_i(av[0]), getvar_i(av[1]))); 2168 setvar_i(res, atan2(getvar_i(av[0]), getvar_i(av[1])));
2173#else 2169 else
2174 syntax_error(EMSG_NO_MATH); 2170 syntax_error(EMSG_NO_MATH);
2175#endif
2176 break; 2171 break;
2177 2172
2178 case B_sp: { 2173 case B_sp: {
@@ -2655,35 +2650,40 @@ static var *evaluate(node *op, var *res)
2655 case F_rn: 2650 case F_rn:
2656 R_d = (double)rand() / (double)RAND_MAX; 2651 R_d = (double)rand() / (double)RAND_MAX;
2657 break; 2652 break;
2658#if ENABLE_FEATURE_AWK_LIBM 2653
2659 case F_co: 2654 case F_co:
2660 R_d = cos(L_d); 2655 if (ENABLE_FEATURE_AWK_LIBM) {
2661 break; 2656 R_d = cos(L_d);
2657 break;
2658 }
2662 2659
2663 case F_ex: 2660 case F_ex:
2664 R_d = exp(L_d); 2661 if (ENABLE_FEATURE_AWK_LIBM) {
2665 break; 2662 R_d = exp(L_d);
2663 break;
2664 }
2666 2665
2667 case F_lg: 2666 case F_lg:
2668 R_d = log(L_d); 2667 if (ENABLE_FEATURE_AWK_LIBM) {
2669 break; 2668 R_d = log(L_d);
2669 break;
2670 }
2670 2671
2671 case F_si: 2672 case F_si:
2672 R_d = sin(L_d); 2673 if (ENABLE_FEATURE_AWK_LIBM) {
2673 break; 2674 R_d = sin(L_d);
2675 break;
2676 }
2674 2677
2675 case F_sq: 2678 case F_sq:
2676 R_d = sqrt(L_d); 2679 if (ENABLE_FEATURE_AWK_LIBM) {
2677 break; 2680 R_d = sqrt(L_d);
2678#else 2681 break;
2679 case F_co: 2682 }
2680 case F_ex: 2683
2681 case F_lg:
2682 case F_si:
2683 case F_sq:
2684 syntax_error(EMSG_NO_MATH); 2684 syntax_error(EMSG_NO_MATH);
2685 break; 2685 break;
2686#endif 2686
2687 case F_sr: 2687 case F_sr:
2688 R_d = (double)seed; 2688 R_d = (double)seed;
2689 seed = op1 ? (unsigned)L_d : (unsigned)time(NULL); 2689 seed = op1 ? (unsigned)L_d : (unsigned)time(NULL);
@@ -2834,11 +2834,10 @@ static var *evaluate(node *op, var *res)
2834 L_d /= R_d; 2834 L_d /= R_d;
2835 break; 2835 break;
2836 case '&': 2836 case '&':
2837#if ENABLE_FEATURE_AWK_LIBM 2837 if (ENABLE_FEATURE_AWK_LIBM)
2838 L_d = pow(L_d, R_d); 2838 L_d = pow(L_d, R_d);
2839#else 2839 else
2840 syntax_error(EMSG_NO_MATH); 2840 syntax_error(EMSG_NO_MATH);
2841#endif
2842 break; 2841 break;
2843 case '%': 2842 case '%':
2844 if (R_d == 0) 2843 if (R_d == 0)