diff options
author | rgrimes <rgrimes@FreeBSD.org> | 1995-05-30 05:05:38 +0000 |
---|---|---|
committer | rgrimes <rgrimes@FreeBSD.org> | 1995-05-30 05:05:38 +0000 |
commit | 2ad6f3dee6bc54535003f4ab26bbc587b7efa38c (patch) | |
tree | a3959baf797787918878bec6d58d6a0fb743ad0a /gnu/usr.bin/bc | |
parent | 4f960dd75f181e9fa2edc44324f15f0ab5c64b37 (diff) | |
download | FreeBSD-src-2ad6f3dee6bc54535003f4ab26bbc587b7efa38c.zip FreeBSD-src-2ad6f3dee6bc54535003f4ab26bbc587b7efa38c.tar.gz |
Remove trailing whitespace.
Diffstat (limited to 'gnu/usr.bin/bc')
-rw-r--r-- | gnu/usr.bin/bc/bc.c | 18 | ||||
-rw-r--r-- | gnu/usr.bin/bc/bcdefs.h | 4 | ||||
-rw-r--r-- | gnu/usr.bin/bc/const.h | 2 | ||||
-rw-r--r-- | gnu/usr.bin/bc/execute.c | 36 | ||||
-rw-r--r-- | gnu/usr.bin/bc/global.c | 6 | ||||
-rw-r--r-- | gnu/usr.bin/bc/global.h | 2 | ||||
-rw-r--r-- | gnu/usr.bin/bc/load.c | 28 | ||||
-rw-r--r-- | gnu/usr.bin/bc/main.c | 16 | ||||
-rw-r--r-- | gnu/usr.bin/bc/number.c | 84 | ||||
-rw-r--r-- | gnu/usr.bin/bc/number.h | 4 | ||||
-rw-r--r-- | gnu/usr.bin/bc/proto.h | 4 | ||||
-rw-r--r-- | gnu/usr.bin/bc/scan.c | 20 | ||||
-rw-r--r-- | gnu/usr.bin/bc/storage.c | 48 | ||||
-rw-r--r-- | gnu/usr.bin/bc/util.c | 58 |
14 files changed, 165 insertions, 165 deletions
diff --git a/gnu/usr.bin/bc/bc.c b/gnu/usr.bin/bc/bc.c index 923215e..b6308d0 100644 --- a/gnu/usr.bin/bc/bc.c +++ b/gnu/usr.bin/bc/bc.c @@ -29,7 +29,7 @@ static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90"; Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ #include "bcdefs.h" @@ -736,7 +736,7 @@ case 20: warn ("comparison in expression"); if (yyvsp[0].i_value & 1) generate ("W"); - else + else generate ("p"); } break; @@ -793,7 +793,7 @@ break; case 28: #line 194 "bc.y" { - yyvsp[0].i_value = break_label; + yyvsp[0].i_value = break_label; break_label = next_label++; } break; @@ -857,7 +857,7 @@ break; case 34: #line 246 "bc.y" { - sprintf (genstr, "N%1d:", if_label); + sprintf (genstr, "N%1d:", if_label); generate (genstr); if_label = yyvsp[-4].i_value; } @@ -873,7 +873,7 @@ break; case 36: #line 258 "bc.y" { - yyvsp[0].i_value = break_label; + yyvsp[0].i_value = break_label; break_label = next_label++; sprintf (genstr, "Z%1d:", break_label); generate (genstr); @@ -912,7 +912,7 @@ case 46: { warn ("else clause in if statement"); yyvsp[0].i_value = next_label++; - sprintf (genstr, "J%d:N%1d:", yyvsp[0].i_value, if_label); + sprintf (genstr, "J%d:N%1d:", yyvsp[0].i_value, if_label); generate (genstr); if_label = yyvsp[0].i_value; } @@ -922,7 +922,7 @@ case 48: { /* Check auto list against parameter list? */ check_params (yyvsp[-4].a_value,yyvsp[0].a_value); - sprintf (genstr, "F%d,%s.%s[", lookup(yyvsp[-6].s_value,FUNCT), + sprintf (genstr, "F%d,%s.%s[", lookup(yyvsp[-6].s_value,FUNCT), arg_str (yyvsp[-4].a_value,TRUE), arg_str (yyvsp[0].a_value,TRUE)); generate (genstr); free_args (yyvsp[-4].a_value); @@ -1205,7 +1205,7 @@ case 85: { yyval.i_value = 1; if (yyvsp[-1].a_value != NULL) - { + { sprintf (genstr, "C%d,%s:", lookup (yyvsp[-3].s_value,FUNCT), arg_str (yyvsp[-1].a_value,FALSE)); @@ -1246,7 +1246,7 @@ case 87: if (yyvsp[-1].i_value < 0) { sprintf (genstr, "DL%d:x", -yyvsp[-1].i_value); - generate (genstr); + generate (genstr); if (yyvsp[0].c_value == '+') sprintf (genstr, "A%d:", -yyvsp[-1].i_value); else diff --git a/gnu/usr.bin/bc/bcdefs.h b/gnu/usr.bin/bc/bcdefs.h index a9d2176..0f2c5e1 100644 --- a/gnu/usr.bin/bc/bcdefs.h +++ b/gnu/usr.bin/bc/bcdefs.h @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ /* Include the configuration file. */ @@ -74,7 +74,7 @@ typedef struct arg_list struct arg_list *next; } arg_list; -typedef struct +typedef struct { char f_defined; /* Is this function defined yet. */ char *f_body[BC_MAX_SEGS]; diff --git a/gnu/usr.bin/bc/const.h b/gnu/usr.bin/bc/const.h index ea91eaf..a4ab2ac 100644 --- a/gnu/usr.bin/bc/const.h +++ b/gnu/usr.bin/bc/const.h @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ diff --git a/gnu/usr.bin/bc/execute.c b/gnu/usr.bin/bc/execute.c index a7bc9c7..a2f0e00 100644 --- a/gnu/usr.bin/bc/execute.c +++ b/gnu/usr.bin/bc/execute.c @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ #include "bcdefs.h" @@ -53,7 +53,7 @@ byte (pc) program_counter *pc; { int seg, offset; - + seg = pc->pc_addr >> BC_SEG_LOG; offset = pc->pc_addr++ % BC_SEG_SIZE; return (functions[pc->pc_func].f_body[seg][offset]); @@ -67,7 +67,7 @@ execute () { int label_num, l_gp, l_off; bc_label_group *gp; - + char inst, ch; int new_func; int var_name; @@ -89,7 +89,7 @@ execute () signal (SIGINT, stop_execution); had_sigint = FALSE; } - + while (pc.pc_addr < functions[pc.pc_func].f_code_size && !runtime_error) { inst = byte(&pc); @@ -97,7 +97,7 @@ execute () #if DEBUG > 3 { /* Print out address and the stack before each instruction.*/ int depth; estack_rec *temp = ex_stack; - + printf ("func=%d addr=%d inst=%c\n",pc.pc_func, pc.pc_addr, inst); if (temp == NULL) printf ("empty stack.\n", inst); else @@ -144,7 +144,7 @@ execute () case 'C' : /* Call a function. */ /* Get the function number. */ new_func = byte(&pc); - if ((new_func & 0x80) != 0) + if ((new_func & 0x80) != 0) new_func = ((new_func << 8) & 0x7f) + byte(&pc); /* Check to make sure it is defined. */ @@ -179,7 +179,7 @@ execute () case 'K' : /* Push a constant */ /* Get the input base and convert it to a bc number. */ - if (pc.pc_func == 0) + if (pc.pc_func == 0) const_base = i_base; else const_base = fn_stack->s_val; @@ -275,8 +275,8 @@ execute () int2num (&ex_stack->s_num, ex_stack->s_num->n_len + ex_stack->s_num->n_scale); break; - - case 'S': /* Scale function. */ + + case 'S': /* Scale function. */ int2num (&ex_stack->s_num, ex_stack->s_num->n_scale); break; @@ -297,7 +297,7 @@ execute () var_name = ((var_name << 8) & 0x7f) + byte(&pc); decr_var (var_name); break; - + case 'h' : /* Halt the machine. */ exit (0); @@ -334,7 +334,7 @@ execute () while ((ch = byte(&pc)) != '"') out_char (ch); if (interactive) fflush (stdout); break; - + case 'x' : /* Exchange Top of Stack with the one under the tos. */ if (check_stack(2)) { bc_num temp = ex_stack->s_num; @@ -532,7 +532,7 @@ execute () pc.pc_func = fpop (); } - /* Clean up the execution stack. */ + /* Clean up the execution stack. */ while (ex_stack != NULL) pop(); /* Clean up the interrupt stuff. */ @@ -562,7 +562,7 @@ char input_char () { char in_ch; - + /* Get a character from the standard input for the read function. */ in_ch = getchar(); @@ -585,7 +585,7 @@ input_char () return (in_ch); if (in_ch <= ' ') return (' '); - + return (':'); } @@ -613,7 +613,7 @@ push_constant (in_char, conv_base) /* The conversion base. */ int2num (&mult, conv_base); - + /* Get things ready. */ in_ch = in_char(); while (in_ch == ' ') @@ -669,7 +669,7 @@ push_constant (in_char, conv_base) bc_divide (result, divisor, &result, digits); bc_add (build, result, &build); } - + /* Final work. */ if (negative) bc_sub (_zero_, build, &build); @@ -695,7 +695,7 @@ push_b10_const (pc) int kdigits, kscale; char inchar; char *ptr; - + /* Count the digits and get things ready. */ look_pc = *pc; kdigits = 0; @@ -718,7 +718,7 @@ push_b10_const (pc) /* Get the first character again and move the pc. */ inchar = byte(pc); - + /* Secial cases of 0, 1, and A-F single inputs. */ if (kdigits == 1 && kscale == 0) { diff --git a/gnu/usr.bin/bc/global.c b/gnu/usr.bin/bc/global.c index 1e7dc1c..b00a989 100644 --- a/gnu/usr.bin/bc/global.c +++ b/gnu/usr.bin/bc/global.c @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ #include "bcdefs.h" @@ -36,7 +36,7 @@ #include "global.h" #ifndef BC_MATH_FILE -CONST char libmath[] = +CONST char libmath[] = #include "math.h" ; -#endif +#endif diff --git a/gnu/usr.bin/bc/global.h b/gnu/usr.bin/bc/global.h index e2b6007..550afb1 100644 --- a/gnu/usr.bin/bc/global.h +++ b/gnu/usr.bin/bc/global.h @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ diff --git a/gnu/usr.bin/bc/load.c b/gnu/usr.bin/bc/load.c index be4ab3a..144ae0e 100644 --- a/gnu/usr.bin/bc/load.c +++ b/gnu/usr.bin/bc/load.c @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ #include "bcdefs.h" @@ -85,16 +85,16 @@ def_label (lab) { bc_label_group *temp; int group, offset, func; - + /* Get things ready. */ group = lab >> BC_LABEL_LOG; offset = lab % BC_LABEL_GROUP; func = load_adr.pc_func; - + /* Make sure there is at least one label group. */ if (functions[func].f_label == NULL) { - functions[func].f_label = + functions[func].f_label = (bc_label_group *) bc_malloc (sizeof(bc_label_group)); functions[func].f_label->l_next = NULL; } @@ -132,7 +132,7 @@ long_val (str) neg = TRUE; (*str)++; } - while (isdigit(**str)) + while (isdigit(**str)) val = val*10 + *(*str)++ - '0'; if (neg) @@ -157,7 +157,7 @@ load_code (code) /* Initialize. */ str = code; - + /* Scan the code. */ while (*str != 0) { @@ -172,7 +172,7 @@ load_code (code) else if (load_const) { - if (*str == '\n') + if (*str == '\n') str++; else { @@ -239,7 +239,7 @@ load_code (code) #if DEBUG > 2 printf ("parameter number %d\n", ap_name); #endif - functions[(int)func].f_params = + functions[(int)func].f_params = nextarg (functions[(int)func].f_params, ap_name); } @@ -251,14 +251,14 @@ load_code (code) #if DEBUG > 2 printf ("auto number %d\n", ap_name); #endif - functions[(int)func].f_autos = + functions[(int)func].f_autos = nextarg (functions[(int)func].f_autos, ap_name); } save_adr = load_adr; load_adr.pc_func = func; load_adr.pc_addr = 0; break; - + case ']': /* A function end */ functions[load_adr.pc_func].f_defined = TRUE; load_adr = save_adr; @@ -279,7 +279,7 @@ load_code (code) addbyte (*str++); addbyte (':'); break; - + case 'c': /* Call a special function. */ addbyte (*str++); addbyte (*str); @@ -318,14 +318,14 @@ load_code (code) case 'r': execute (); break; - } + } break; case '\n': /* Ignore the newlines */ break; - + default: /* Anything else */ - addbyte (*str); + addbyte (*str); } str++; } diff --git a/gnu/usr.bin/bc/main.c b/gnu/usr.bin/bc/main.c index 33827cc..ed8643a 100644 --- a/gnu/usr.bin/bc/main.c +++ b/gnu/usr.bin/bc/main.c @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ #include "bcdefs.h" @@ -42,14 +42,14 @@ main (argc, argv) int argc; char *argv[]; { - int ch; - + int ch; + /* Initialize many variables. */ compile_only = FALSE; use_math = FALSE; warn_not_std = FALSE; std_only = FALSE; - if (isatty(0) && isatty(1)) + if (isatty(0) && isatty(1)) interactive = TRUE; else interactive = FALSE; @@ -111,7 +111,7 @@ main (argc, argv) } -/* This is the function that opens all the files. +/* This is the function that opens all the files. It returns TRUE if the file was opened, otherwise it returns FALSE. */ @@ -137,7 +137,7 @@ open_new_file () { new_yy_file (new_file); return TRUE; - } + } else { fprintf (stderr, "Math Library unavailable.\n"); @@ -159,7 +159,7 @@ open_new_file () load_code (libmath); #endif } - + /* One of the argv values. */ while (optind < g_argc) { @@ -173,7 +173,7 @@ open_new_file () fprintf (stderr, "File %s is unavailable.\n", g_argv[optind++]); exit (1); } - + /* If we fall through to here, we should return stdin. */ new_yy_file (stdin); is_std_in = TRUE; diff --git a/gnu/usr.bin/bc/number.c b/gnu/usr.bin/bc/number.c index 346b44a..336ad11 100644 --- a/gnu/usr.bin/bc/number.c +++ b/gnu/usr.bin/bc/number.c @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ #include "bcdefs.h" @@ -43,7 +43,7 @@ free_num (num) bc_num *num; { if (*num == NULL) return; - (*num)->n_refs--; + (*num)->n_refs--; if ((*num)->n_refs == 0) free(*num); *num = NULL; } @@ -113,19 +113,19 @@ int2num (num, val) char *bptr, *vptr; int ix = 1; char neg = 0; - + /* Sign. */ if (val < 0) { neg = 1; val = -val; } - + /* Get things going. */ bptr = buffer; *bptr++ = val % 10; val = val / 10; - + /* Extract remaining digits. */ while (val != 0) { @@ -133,12 +133,12 @@ int2num (num, val) val = val / 10; ix++; /* Count the digits. */ } - + /* Make the number. */ free_num (num); *num = new_num (ix, 0); if (neg) (*num)->n_sign = MINUS; - + /* Assign the digits. */ vptr = (*num)->n_value; while (ix-- > 0) @@ -146,7 +146,7 @@ int2num (num, val) } -/* Convert a number NUM to a long. The function returns only the integer +/* Convert a number NUM to a long. The function returns only the integer part of the number. For numbers that are too large to represent as a long, this function returns a zero. This can be detected by checking the NUM for zero after having a zero returned. */ @@ -164,11 +164,11 @@ num2long (num) nptr = num->n_value; for (index=num->n_len; (index>0) && (val<=(LONG_MAX/10)); index--) val = val*10 + *nptr++; - + /* Check for overflow. If overflow, return zero. */ if (index>0) val = 0; if (val < 0) val = 0; - + /* Return the value. */ if (num->n_sign == PLUS) return (val); @@ -200,7 +200,7 @@ _do_compare (n1, n2, use_sign, ignore_last) { char *n1ptr, *n2ptr; int count; - + /* First, compare signs. */ if (use_sign && n1->n_sign != n2->n_sign) { @@ -209,7 +209,7 @@ _do_compare (n1, n2, use_sign, ignore_last) else return (-1); /* Negative N1 < Positive N1 */ } - + /* Now compare the magnitude. */ if (n1->n_len != n2->n_len) { @@ -266,7 +266,7 @@ _do_compare (n1, n2, use_sign, ignore_last) } /* They are equal up to the last part of the equal part of the fraction. */ - if (n1->n_scale != n2->n_scale) + if (n1->n_scale != n2->n_scale) if (n1->n_scale > n2->n_scale) { for (count = n1->n_scale-n2->n_scale; count>0; count--) @@ -291,7 +291,7 @@ _do_compare (n1, n2, use_sign, ignore_last) return (1); } } - + /* They must be equal! */ return (0); } @@ -328,7 +328,7 @@ is_zero (num) if (count != 0) return FALSE; - else + else return TRUE; } @@ -366,7 +366,7 @@ _rm_leading_zeros (num) bytes += num->n_scale; dst = num->n_value; while (bytes-- > 0) *dst++ = *src++; - + } @@ -443,10 +443,10 @@ _do_add (n1, n2) /* Set final carry. */ if (carry == 1) *sumptr += 1; - + /* Adjust sum and return. */ _rm_leading_zeros (sum); - return sum; + return sum; } @@ -478,7 +478,7 @@ _do_sub (n1, n2) /* Subtract the numbers. */ borrow = 0; - + /* Take care of the longer scaled number. */ if (n1->n_scale != min_scale) { @@ -502,9 +502,9 @@ _do_sub (n1, n2) *diffptr-- = val; } } - + /* Now do the equal length scale and integer parts. */ - + for (count = 0; count < min_len + min_scale; count++) { val = *n1ptr-- - *n2ptr-- - borrow; @@ -569,7 +569,7 @@ bc_add ( n1, n2, result) break; case 0: /* They are equal! return zero! */ - sum = copy_num (_zero_); + sum = copy_num (_zero_); break; case 1: /* n2 is less than n1, subtract n2 from n1. */ @@ -612,7 +612,7 @@ bc_sub ( n1, n2, result) break; case 0: /* They are equal! return zero! */ - diff = copy_num (_zero_); + diff = copy_num (_zero_); break; case 1: /* n2 is less than n1, subtract n2 from n1. */ @@ -621,7 +621,7 @@ bc_sub ( n1, n2, result) break; } } - + /* Clean up and return. */ free_num (result); *result = diff; @@ -685,7 +685,7 @@ bc_multiply (n1, n2, prod, scale) free_num (prod); *prod = pval; _rm_leading_zeros (*prod); - if (is_zero (*prod)) + if (is_zero (*prod)) (*prod)->n_sign = PLUS; } @@ -723,7 +723,7 @@ _one_mult (num, size, digit, result) *rptr-- = value % 10; carry = value / 10; } - + if (carry != 0) *rptr = carry; } } @@ -739,7 +739,7 @@ int bc_divide (n1, n2, quot, scale) bc_num n1, n2, *quot; int scale; -{ +{ bc_num qval; unsigned char *num1, *num2; unsigned char *ptr1, *ptr2, *n2ptr, *qptr; @@ -767,7 +767,7 @@ bc_divide (n1, n2, quot, scale) *quot = qval; } } - + /* Set up the divide. Move the decimal point on n1 by n2's scale. Remember, zeros on the end of num2 are wasted effort for dividing. */ scale2 = n2->n_scale; @@ -859,7 +859,7 @@ bc_divide (n1, n2, quot, scale) + num1[qdig+2]) qguess--; } - + /* Multiply and subtract. */ borrow = 0; if (qguess != 0) @@ -903,7 +903,7 @@ bc_divide (n1, n2, quot, scale) } if (carry == 1) *ptr1 = (*ptr1 + 1) % 10; } - + /* We now know the quotient digit. */ *qptr++ = qguess; qdig++; @@ -943,7 +943,7 @@ bc_modulo (num1, num2, result, scale) /* Calculate final scale. */ rscale = MAX (num1->n_scale, num2->n_scale+scale); init_num (&temp); - + /* Calculate it. */ bc_divide (num1, num2, &temp, scale); bc_multiply (temp, num2, &temp, rscale); @@ -1001,12 +1001,12 @@ bc_raise (num1, num2, result, scale) /* Do the calculation. */ while (exponent != 0) { - if (exponent & 1 != 0) + if (exponent & 1 != 0) bc_multiply (temp, power, &temp, rscale); bc_multiply (power, power, &power, rscale); exponent = exponent >> 1; } - + /* Assign the value. */ if (neg) { @@ -1025,7 +1025,7 @@ bc_raise (num1, num2, result, scale) /* Take the square root NUM and return it in NUM with SCALE digits after the decimal place. */ -int +int bc_sqrt (num, scale) bc_num *num; int scale; @@ -1062,8 +1062,8 @@ bc_sqrt (num, scale) init_num (&guess1); point5 = new_num (1,1); point5->n_value[1] = 5; - - + + /* Calculate the initial guess. */ if (cmp_res < 0) /* The number is between 0 and 1. Guess should start at 1. */ @@ -1078,7 +1078,7 @@ bc_sqrt (num, scale) bc_raise (guess, guess1, &guess, rscale); free_num (&guess1); } - + /* Find the square root using Newton's algorithm. */ done = FALSE; while (!done) @@ -1091,7 +1091,7 @@ bc_sqrt (num, scale) cmp_res = _do_compare (guess,guess1,FALSE,TRUE); if (cmp_res == 0) done = TRUE; } - + /* Assign the number and clean up. */ free_num (num); bc_divide (guess,_one_,num,rscale); @@ -1179,7 +1179,7 @@ out_num (num, o_base, out_char) (*out_char) (BCD_CHAR(*nptr++)); else nptr++; - + /* Now the fraction. */ if (num->n_scale > 0) { @@ -1223,7 +1223,7 @@ out_num (num, o_base, out_char) { temp = digits; digits = digits->next; - if (o_base <= 16) + if (o_base <= 16) (*out_char) (ref_str[ (int) temp->digit]); else out_long (temp->digit, max_o_digit->n_len, 1, out_char); @@ -1251,7 +1251,7 @@ out_num (num, o_base, out_char) bc_multiply (t_num, base, &t_num, 0); } } - + /* Clean up. */ free_num (&int_part); free_num (&frac_part); @@ -1353,7 +1353,7 @@ str2num (num, str, scale) for (;digits > 0; digits--) *nptr++ = CH_VAL(*ptr++); - + /* Build the fractional part. */ if (strscale > 0) { diff --git a/gnu/usr.bin/bc/number.h b/gnu/usr.bin/bc/number.h index 9938515..79a340f 100644 --- a/gnu/usr.bin/bc/number.h +++ b/gnu/usr.bin/bc/number.h @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ @@ -35,7 +35,7 @@ typedef struct int n_len; /* The number of digits before the decimal point. */ int n_scale; /* The number of digits after the decimal point. */ int n_refs; /* The number of pointers to this number. */ - char n_value[1]; /* The storage. Not zero char terminated. It is + char n_value[1]; /* The storage. Not zero char terminated. It is allocated with all other fields. */ } bc_struct; diff --git a/gnu/usr.bin/bc/proto.h b/gnu/usr.bin/bc/proto.h index fea9405..f2aa490 100644 --- a/gnu/usr.bin/bc/proto.h +++ b/gnu/usr.bin/bc/proto.h @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ /* For the pc version using k&r ACK. (minix1.5 and earlier.) */ @@ -158,7 +158,7 @@ _PROTOTYPE(void process_params, (program_counter *pc, int func )); /* For the scanner and parser.... */ _PROTOTYPE(int yyparse, (void)); -_PROTOTYPE(int yylex, (void)); +_PROTOTYPE(int yylex, (void)); /* Other things... */ _PROTOTYPE (int getopt, (int, char *[], CONST char *)); diff --git a/gnu/usr.bin/bc/scan.c b/gnu/usr.bin/bc/scan.c index 59aa6e5..6bff451 100644 --- a/gnu/usr.bin/bc/scan.c +++ b/gnu/usr.bin/bc/scan.c @@ -1,7 +1,7 @@ /* A lexical scanner generated by flex */ /* scanner skeleton version: - * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $ + * $Header: /home/ncvs/src/gnu/usr.bin/bc/scan.c,v 1.1.1.1 1993/06/19 00:26:18 paul Exp $ */ #define FLEX_SCANNER @@ -150,7 +150,7 @@ int read(); /* default declaration of generated scanner - a define so the user can * easily add parameters */ -#define YY_DECL int yylex YY_PROTO(( void )) +#define YY_DECL int yylex YY_PROTO(( void )) /* code executed at the end of each rule */ #define YY_BREAK break; @@ -192,7 +192,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ #include "bcdefs.h" @@ -260,7 +260,7 @@ struct yy_buffer_state YY_CHAR *yy_buf_pos; /* current position in input buffer */ /* size of input buffer in bytes, not including room for EOB characters*/ - int yy_buf_size; + int yy_buf_size; /* number of characters read into yy_ch_buf, not including EOB characters */ int yy_n_chars; @@ -683,7 +683,7 @@ return(Limits); YY_BREAK case 22: # line 82 "scan.l" -{ yylval.c_value = yytext[0]; +{ yylval.c_value = yytext[0]; return((int)yytext[0]); } YY_BREAK case 23: @@ -708,7 +708,7 @@ case 27: YY_BREAK case 28: # line 89 "scan.l" -{ +{ #ifdef OLD_EQ_OP char warn_save; warn_save = warn_not_std; @@ -750,7 +750,7 @@ case 34: for (;;) { - while ( ((c=input()) != '*') && (c != EOF)) + while ( ((c=input()) != '*') && (c != EOF)) /* eat it */ if (c == '\n') line_no++; if (c == '*') @@ -812,7 +812,7 @@ case 37: *dst++ = *src++; } *dst = 0; - yylval.s_value = strcopyof(yytext); + yylval.s_value = strcopyof(yytext); return(NUMBER); } YY_BREAK @@ -952,9 +952,9 @@ case YY_STATE_EOF(INITIAL): * * synopsis * int yy_get_next_buffer(); - * + * * returns a code representing an action - * EOB_ACT_LAST_MATCH - + * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ diff --git a/gnu/usr.bin/bc/storage.c b/gnu/usr.bin/bc/storage.c index 1edd6e2..18ddb93 100644 --- a/gnu/usr.bin/bc/storage.c +++ b/gnu/usr.bin/bc/storage.c @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ #include "bcdefs.h" @@ -45,7 +45,7 @@ init_storage () /* Variables. */ v_count = 0; more_variables (); - + /* Arrays. */ a_count = 0; more_arrays (); @@ -231,7 +231,7 @@ fpop() { fstack_rec *temp; int retval; - + if (fn_stack != NULL) { temp = fn_stack; @@ -250,7 +250,7 @@ fpush (val) int val; { fstack_rec *temp; - + temp = (fstack_rec *) bc_malloc (sizeof (fstack_rec)); temp->s_next = fn_stack; temp->s_val = val; @@ -264,7 +264,7 @@ void pop () { estack_rec *temp; - + if (ex_stack != NULL) { temp = ex_stack; @@ -397,7 +397,7 @@ get_array_num (var_index, index) ix >>= NODE_SHIFT; log++; } - + /* Build any tree that is necessary. */ while (log > a_var->a_depth) { @@ -416,7 +416,7 @@ get_array_num (var_index, index) a_var->a_tree = temp; a_var->a_depth++; } - + /* Find the indexed variable. */ temp = a_var->a_tree; while ( log-- > 1) @@ -437,13 +437,13 @@ get_array_num (var_index, index) else temp = temp->n_items.n_down[ix1]; } - + /* Return the address of the indexed variable. */ return &(temp->n_items.n_num[sub[0]]); } -/* Store the top of the execution stack into VAR_NAME. +/* Store the top of the execution stack into VAR_NAME. This includes the special variables ibase, obase, and scale. */ void @@ -541,7 +541,7 @@ store_var (var_name) } -/* Store the top of the execution stack into array VAR_NAME. +/* Store the top of the execution stack into array VAR_NAME. VAR_NAME is the name of an array, and the next to the top of stack for the index into the array. */ @@ -555,7 +555,7 @@ store_array (var_name) if (!check_stack(2)) return; index = num2long (ex_stack->s_next->s_num); if (index < 0 || index > BC_DIM_MAX || - (index == 0 && !is_zero(ex_stack->s_next->s_num))) + (index == 0 && !is_zero(ex_stack->s_next->s_num))) rt_error ("Array %s subscript out of bounds.", a_names[var_name]); else { @@ -627,7 +627,7 @@ load_array (var_name) if (!check_stack(1)) return; index = num2long (ex_stack->s_num); if (index < 0 || index > BC_DIM_MAX || - (index == 0 && !is_zero(ex_stack->s_num))) + (index == 0 && !is_zero(ex_stack->s_num))) rt_error ("Array %s subscript out of bounds.", a_names[var_name]); else { @@ -659,7 +659,7 @@ decr_var (var_name) else rt_warn ("ibase too small in --"); break; - + case 1: /* obase */ if (o_base > 2) o_base--; @@ -696,7 +696,7 @@ decr_array (var_name) if (!check_stack (1)) return; index = num2long (ex_stack->s_num); if (index < 0 || index > BC_DIM_MAX || - (index == 0 && !is_zero (ex_stack->s_num))) + (index == 0 && !is_zero (ex_stack->s_num))) rt_error ("Array %s subscript out of bounds.", a_names[var_name]); else { @@ -765,7 +765,7 @@ incr_array (var_name) if (!check_stack (1)) return; index = num2long (ex_stack->s_num); if (index < 0 || index > BC_DIM_MAX || - (index == 0 && !is_zero (ex_stack->s_num))) + (index == 0 && !is_zero (ex_stack->s_num))) rt_error ("Array %s subscript out of bounds.", a_names[var_name]); else { @@ -809,7 +809,7 @@ auto_var (name) a_temp->a_value = NULL; a_temp->a_param = FALSE; arrays[ix] = a_temp; - } + } } @@ -877,7 +877,7 @@ pop_vars (list) } free (a_temp); } - } + } list = list->next; } } @@ -900,7 +900,7 @@ process_params (pc, func) bc_var *v_temp; bc_var_array *a_src, *a_dest; bc_num *n_temp; - + /* Get the parameter names from the function. */ params = functions[func].f_params; @@ -922,17 +922,17 @@ process_params (pc, func) if ((ch == '1') && (params->av_name < 0)) { /* The variables is an array variable. */ - + /* Compute source index and make sure some structure exists. */ ix = (int) num2long (ex_stack->s_num); - n_temp = get_array_num (ix, 0); - + n_temp = get_array_num (ix, 0); + /* Push a new array and Compute Destination index */ - auto_var (params->av_name); + auto_var (params->av_name); ix1 = -params->av_name; /* Set up the correct pointers in the structure. */ - if (ix == ix1) + if (ix == ix1) a_src = arrays[ix]->a_next; else a_src = arrays[ix]; @@ -962,6 +962,6 @@ process_params (pc, func) } params = params->next; } - if (params != NULL) + if (params != NULL) rt_error ("Parameter number mismatch"); } diff --git a/gnu/usr.bin/bc/util.c b/gnu/usr.bin/bc/util.c index 954c719..5a01803 100644 --- a/gnu/usr.bin/bc/util.c +++ b/gnu/usr.bin/bc/util.c @@ -23,7 +23,7 @@ Computer Science Department, 9062 Western Washington University Bellingham, WA 98226-9062 - + *************************************************************************/ @@ -62,7 +62,7 @@ nextarg (args, val) temp = (arg_list *) bc_malloc (sizeof (arg_list)); temp->av_name = val; temp->next = args; - + return (temp); } @@ -102,7 +102,7 @@ make_arg_str (args, len, commas) } /* Add the current number to the end of the string. */ - if (len != 1 && commas) + if (len != 1 && commas) sprintf (sval, "%d,", args->av_name); else sprintf (sval, "%d", args->av_name); @@ -115,7 +115,7 @@ arg_str (args, commas) arg_list *args; int commas; { - if (arglist2 != NULL) + if (arglist2 != NULL) free (arglist2); arglist2 = arglist1; arglist1 = make_arg_str (args, 1, commas); @@ -128,9 +128,9 @@ arg_str (args, commas) void free_args (args) arg_list *args; -{ +{ arg_list *temp; - + temp = args; while (temp != NULL) { @@ -160,7 +160,7 @@ check_params ( params, autos ) tmp2 = tmp1->next; while (tmp2 != NULL) { - if (tmp2->av_name == tmp1->av_name) + if (tmp2->av_name == tmp1->av_name) yyerror ("duplicate parameter names"); tmp2 = tmp2->next; } @@ -179,7 +179,7 @@ check_params ( params, autos ) tmp2 = tmp1->next; while (tmp2 != NULL) { - if (tmp2->av_name == tmp1->av_name) + if (tmp2->av_name == tmp1->av_name) yyerror ("duplicate auto variable names"); tmp2 = tmp2->next; } @@ -196,7 +196,7 @@ check_params ( params, autos ) tmp2 = autos; while (tmp2 != NULL) { - if (tmp2->av_name == tmp1->av_name) + if (tmp2->av_name == tmp1->av_name) yyerror ("variable in both parameter and auto lists"); tmp2 = tmp2->next; } @@ -216,7 +216,7 @@ init_gen () continue_label = 0; next_label = 1; out_count = 2; - if (compile_only) + if (compile_only) printf ("@i"); else init_load (); @@ -257,7 +257,7 @@ run_code() { if (compile_only) { - printf ("@r\n"); + printf ("@r\n"); out_count = 0; } else @@ -310,7 +310,7 @@ find_id (tree, id) char *id; { int cmp_result; - + /* Check for an empty tree. */ if (tree == NULL) return NULL; @@ -322,7 +322,7 @@ find_id (tree, id) else if (cmp_result < 0) return find_id (tree->left, id); else - return find_id (tree->right, id); + return find_id (tree->right, id); } @@ -355,7 +355,7 @@ int insert_id_rec (root, new_id) { /* The height increased. */ (*root)->balance --; - + switch ((*root)->balance) { case 0: /* no height increase. */ @@ -399,8 +399,8 @@ int insert_id_rec (root, new_id) } (*root)->balance = 0; } - } - } + } + } } else { @@ -452,10 +452,10 @@ int insert_id_rec (root, new_id) } (*root)->balance = 0; } - } - } + } + } } - + /* If we fall through to here, the tree did not grow in height. */ return (FALSE); } @@ -502,7 +502,7 @@ lookup (name, namekind) /* Return the correct value. */ switch (namekind) { - + case ARRAY: /* ARRAY variable numbers are returned as negative numbers. */ if (id->a_name != 0) @@ -560,7 +560,7 @@ lookup (name, namekind) /* Print the welcome banner. */ -void +void welcome() { printf ("This is free software with ABSOLUTELY NO WARRANTY.\n"); @@ -570,7 +570,7 @@ welcome() /* Print out the warranty information. */ -void +void warranty(prefix) char *prefix; { @@ -604,7 +604,7 @@ limits() printf ("Number of vars = %ld\n", (long) MAX_STORE); #ifdef OLD_EQ_OP printf ("Old assignment operatiors are valid. (=-, =+, ...)\n"); -#endif +#endif } /* bc_malloc will check the return value so all other places do not @@ -657,7 +657,7 @@ yyerror (str, va_alist) char *name; va_list args; -#ifndef VARARGS +#ifndef VARARGS va_start (args, str); #else va_start (args); @@ -679,7 +679,7 @@ yyerror (str, va_alist) #ifndef VARARGS #ifdef __STDC__ -void +void warn (char *mesg, ...) #else void @@ -695,7 +695,7 @@ warn (mesg, va_alist) char *name; va_list args; -#ifndef VARARGS +#ifndef VARARGS va_start (args, mesg); #else va_start (args); @@ -745,14 +745,14 @@ rt_error (mesg, va_alist) va_list args; char error_mesg [255]; -#ifndef VARARGS +#ifndef VARARGS va_start (args, mesg); #else va_start (args); #endif vsprintf (error_mesg, mesg, args); va_end (args); - + fprintf (stderr, "Runtime error (func=%s, adr=%d): %s\n", f_names[pc.pc_func], pc.pc_addr, error_mesg); runtime_error = TRUE; @@ -781,7 +781,7 @@ rt_warn (mesg, va_alist) va_list args; char error_mesg [255]; -#ifndef VARARGS +#ifndef VARARGS va_start (args, mesg); #else va_start (args); |