1
/* util.c: Utility routines for bc. */
3
1
/* This file is part of GNU bc.
4
Copyright (C) 1991-1994, 1997, 2000 Free Software Foundation, Inc.
3
Copyright (C) 1991-1994, 1997, 2006 Free Software Foundation, Inc.
6
5
This program is free software; you can redistribute it and/or modify
7
6
it under the terms of the GNU General Public License as published by
14
13
GNU General Public License for more details.
16
15
You should have received a copy of the GNU General Public License
17
along with this program; see the file COPYING. If not, write to
16
along with this program; see the file COPYING. If not, write to:
18
17
The Free Software Foundation, Inc.
19
59 Temple Place, Suite 330
18
Foundation, Inc. 51 Franklin Street, Fifth Floor,
19
Boston, MA 02110-1301 USA
22
21
You may contact the author by:
23
22
e-mail: philnelson@acm.org
423
436
/* The height increased. */
424
437
(*root)->balance --;
426
switch ((*root)->balance)
428
case 0: /* no height increase. */
430
case -1: /* height increase. */
432
case -2: /* we need to do a rebalancing act. */
448
B->right = (*root)->left;
449
A->left = (*root)->right;
452
switch ((*root)->balance)
467
(*root)->balance = 0;
439
switch ((*root)->balance)
441
case 0: /* no height increase. */
443
case -1: /* height increase. */
445
case -2: /* we need to do a rebalancing act. */
461
B->right = (*root)->left;
462
A->left = (*root)->right;
465
switch ((*root)->balance)
480
(*root)->balance = 0;
477
490
/* The height increased. */
478
491
(*root)->balance ++;
479
493
switch ((*root)->balance)
481
495
case 0: /* no height increase. */
483
497
case 1: /* height increase. */
485
499
case 2: /* we need to do a rebalancing act. */
487
501
B = (*root)->right;
579
593
return (-id->a_name);
581
595
id->a_name = next_array++;
582
a_names[id->a_name] = name;
583
596
if (id->a_name < MAX_STORE)
585
598
if (id->a_name >= a_count)
600
a_names[id->a_name] = name;
587
601
return (-id->a_name);
589
603
yyerror ("Too many array variables");
600
614
return (id->f_name);
602
616
id->f_name = next_func++;
603
f_names[id->f_name] = name;
604
617
if (id->f_name < MAX_STORE)
606
619
if (id->f_name >= f_count)
607
620
more_functions ();
621
f_names[id->f_name] = name;
608
622
return (id->f_name);
610
624
yyerror ("Too many functions");
617
631
return (id->v_name);
619
633
id->v_name = next_var++;
620
v_names[id->v_name - 1] = name;
621
634
if (id->v_name <= MAX_STORE)
623
636
if (id->v_name >= v_count)
624
637
more_variables ();
638
v_names[id->v_name - 1] = name;
625
639
return (id->v_name);
627
641
yyerror ("Too many variables");
633
647
/* not reached */
637
/* Print the welcome banner. */
642
printf ("This is free software with ABSOLUTELY NO WARRANTY.\n");
643
printf ("For details type `warranty'. \n");
644
checkferror_output(stdout);
647
/* Print out the version information. */
651
printf("%s %s\n%s\n", PACKAGE, VERSION, BC_COPYRIGHT);
652
checkferror_output(stdout);
656
/* Print out the warranty information. */
662
printf ("\n%s", prefix);
665
" This program is free software; you can redistribute it and/or modify\n"
666
" it under the terms of the GNU General Public License as published by\n"
667
" the Free Software Foundation; either version 2 of the License , or\n"
668
" (at your option) any later version.\n\n"
669
" This program is distributed in the hope that it will be useful,\n"
670
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
671
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
672
" GNU General Public License for more details.\n\n"
673
" You should have received a copy of the GNU General Public License\n"
674
" along with this program. If not, write to\n\n"
675
" The Free Software Foundation, Inc.\n"
676
" 59 Temple Place, Suite 330\n"
677
" Boston, MA 02111, USA.\n\n");
678
checkferror_output(stdout);
681
650
/* Print out the limits of this program. */
795
764
name = "(standard_in)";
797
766
name = file_name;
798
fprintf (stderr,"%s %d: ",name,line_no);
767
fprintf (stderr,"%s %d: Error: ",name,line_no);
799
768
vfprintf (stderr, mesg, args);
800
769
fprintf (stderr, "\n");
801
770
checkferror_output(stderr);