Home | History | Annotate | Line # | Download | only in dist
      1 /*	$NetBSD: global.h,v 1.2 2021/04/12 08:54:11 mrg Exp $ */
      2 
      3 /*
      4  * Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
      5  * Copyright (C) 2016-2017 Philip A. Nelson.
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  *
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. The names Philip A. Nelson and Free Software Foundation may not be
     18  *    used to endorse or promote products derived from this software
     19  *    without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY PHILIP A. NELSON ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL PHILIP A. NELSON OR THE FREE SOFTWARE FOUNDATION BE
     25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     31  * THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /* global.h:  The global variables for bc.  */
     35 
     36 /* The current break level's label. */
     37 EXTERN int break_label;
     38 
     39 /* The current if statement's else label or label after else. */
     40 EXTERN int if_label;
     41 
     42 /* The current for statement label for continuing the loop. */
     43 EXTERN int continue_label;
     44 
     45 /* Next available label number. */
     46 EXTERN int next_label;
     47 
     48 /* Byte code character storage.  Used in many places for generation of code. */
     49 EXTERN char  *genstr  INIT(NULL);
     50 EXTERN int    genlen  INIT(0);
     51 
     52 /* Count of characters printed to the output in compile_only mode. */
     53 EXTERN int out_count;
     54 
     55 /* Have we generated any code since the last initialization of the code
     56    generator.  */
     57 EXTERN char did_gen;
     58 
     59 /* Is this run an interactive execution.  (Is stdin a terminal?) */
     60 EXTERN char interactive  INIT(FALSE);
     61 
     62 /* Just generate the byte code.  -c flag. */
     63 EXTERN int compile_only INIT(FALSE);
     64 
     65 /* Load the standard math functions.  -l flag. */
     66 EXTERN int use_math  INIT(FALSE);
     67 
     68 /* Give a warning on use of any non-standard feature (non-POSIX).  -w flag. */
     69 EXTERN int warn_not_std  INIT(FALSE);
     70 
     71 /* Accept POSIX bc only!  -s flag. */
     72 EXTERN int std_only  INIT(FALSE);
     73 
     74 /* Don't print the banner at start up.  -q flag. */
     75 EXTERN int quiet  INIT(FALSE);
     76 
     77 /* The list of file names to process. */
     78 EXTERN file_node *file_names  INIT(NULL);
     79 
     80 /* The name of the current file being processed. */
     81 EXTERN char *file_name;
     82 
     83 /* Is the current file a named file or standard input? */
     84 EXTERN char   is_std_in;
     85 
     86 /* global variables for the bc machine. All will be dynamic in size.*/
     87 /* Function storage. main is (0) and functions (1-f_count) */
     88 
     89 EXTERN bc_function *functions;
     90 EXTERN char **f_names;
     91 EXTERN int  f_count;
     92 
     93 /* Variable stoarge and reverse names. */
     94 
     95 EXTERN bc_var **variables;
     96 EXTERN char **v_names;
     97 EXTERN int  v_count;
     98 
     99 /* Array Variable storage and reverse names. */
    100 
    101 EXTERN bc_var_array **arrays;
    102 EXTERN char **a_names;
    103 EXTERN int  a_count;
    104 
    105 /* Execution stack. */
    106 EXTERN estack_rec *ex_stack;
    107 
    108 /* Function return stack. */
    109 EXTERN fstack_rec *fn_stack;
    110 
    111 /* Current ibase, obase, scale, and n_history (if needed). */
    112 EXTERN int i_base;
    113 EXTERN int o_base;
    114 EXTERN int scale;
    115 #if defined(READLINE) || defined(LIBEDIT)
    116 EXTERN int n_history;
    117 #endif
    118 
    119 #if defined(LIBEDIT)
    120 /* LIBEDIT data */
    121 EXTERN EditLine *edit INIT(NULL);
    122 EXTERN History  *hist;
    123 EXTERN HistEvent histev;
    124 #endif
    125 
    126 /* "Condition code" -- false (0) or true (1) */
    127 EXTERN char c_code;
    128 
    129 /* Records the number of the runtime error. */
    130 EXTERN char runtime_error;
    131 
    132 /* Holds the current location of execution. */
    133 EXTERN program_counter pc;
    134 
    135 /* For POSIX bc, this is just for number output, not strings. */
    136 EXTERN int out_col;
    137 
    138 /* Keeps track of the current number of characters per output line.
    139    This includes the \n at the end of the line. */
    140 EXTERN int line_size;
    141 
    142 /* Input Line numbers and other error information. */
    143 EXTERN int line_no;
    144 EXTERN int had_error;
    145 
    146 /* For larger identifiers, a tree, and how many "storage" locations
    147    have been allocated. */
    148 
    149 EXTERN int next_array;
    150 EXTERN int next_func;
    151 EXTERN int next_var;
    152 
    153 EXTERN id_rec *name_tree;
    154 
    155 /* For use with getopt.  Do not declare them here.*/
    156 extern int optind;
    157 
    158 /* Access to the yy input file.  Defined in scan.c. */
    159 extern FILE *yyin;
    160 
    161 /* Access to libmath */
    162 extern CONST char *libmath[];
    163