From b9b0b2b5e316a1fcae539390d66e1cac0e481fd9 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 30 May 2022 17:02:01 +0930 Subject: [PATCH] Reorganise bfd/doc/chew.c a little This also removes some unused variables, and deletes support for the "var" keyword which isn't used and was broken. (No means to set variables, and add_var used push_number inconsistent with its use elsewhere.) * doc/chew.c: Move typedefs before variables, variables before functions. (die): Move earlier. (word_type, sstack, ssp): Delete. (dict_type): Delete var field. (add_var): Delete. (compile): Remove "var" support. --- bfd/doc/chew.c | 102 ++++++++++++++++++------------------------------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c index 0c20acbc0be..2f987821bd9 100644 --- a/bfd/doc/chew.c +++ b/bfd/doc/chew.c @@ -91,11 +91,6 @@ #define DEF_SIZE 5000 #define STACK 50 -int internal_wanted; -int internal_mode; - -int warning; - /* Here is a string type ... */ typedef struct buffer @@ -105,6 +100,35 @@ typedef struct buffer unsigned long size; } string_type; +typedef void (*stinst_type)(); + +typedef struct dict_struct +{ + char *word; + struct dict_struct *next; + stinst_type *code; + int code_length; + int code_end; +} dict_type; + +int internal_wanted; +int internal_mode; + +int warning; + +string_type stack[STACK]; +string_type *tos; + +unsigned int idx = 0; /* Pos in input buffer */ +string_type *ptr; /* and the buffer */ + +long istack[STACK]; +long *isp = &istack[0]; + +dict_type *root; + +stinst_type *pc; + #ifdef __STDC__ static void init_string_with_size (string_type *, unsigned int); static void init_string (string_type *); @@ -121,6 +145,14 @@ static void catstr (string_type *, string_type *); static void die (char *); #endif +static void +die (msg) + char *msg; +{ + fprintf (stderr, "%s\n", msg); + exit (1); +} + static void init_string_with_size (buffer, size) string_type *buffer; @@ -279,42 +311,6 @@ skip_past_newline_1 (ptr, idx) return idx; } -/***********************************************************************/ - -string_type stack[STACK]; -string_type *tos; - -unsigned int idx = 0; /* Pos in input buffer */ -string_type *ptr; /* and the buffer */ -typedef void (*stinst_type)(); -stinst_type *pc; -stinst_type sstack[STACK]; -stinst_type *ssp = &sstack[0]; -long istack[STACK]; -long *isp = &istack[0]; - -typedef int *word_type; - -struct dict_struct -{ - char *word; - struct dict_struct *next; - stinst_type *code; - int code_length; - int code_end; - int var; -}; - -typedef struct dict_struct dict_type; - -static void -die (msg) - char *msg; -{ - fprintf (stderr, "%s\n", msg); - exit (1); -} - static void check_range () { @@ -356,7 +352,6 @@ static void perform (void); dict_type *newentry (char *); unsigned int add_to_definition (dict_type *, stinst_type); void add_intrinsic (char *, void (*)()); -void add_var (char *); void compile (char *); static void bang (void); static void atsign (void); @@ -1230,8 +1225,6 @@ nextword (string, word) return NULL; } -dict_type *root; - dict_type * lookup_word (word) char *word; @@ -1351,16 +1344,6 @@ add_intrinsic (name, func) add_to_definition (new_d, 0); } -void -add_var (name) - char *name; -{ - dict_type *new_d = newentry (name); - add_to_definition (new_d, push_number); - add_to_definition (new_d, (stinst_type) (&(new_d->var))); - add_to_definition (new_d, 0); -} - void compile (string) char *string; @@ -1371,16 +1354,7 @@ compile (string) string = nextword (string, &word); while (string && *string && word[0]) { - if (strcmp (word, "var") == 0) - { - free (word); - string = nextword (string, &word); - if (!string) - continue; - add_var (word); - string = nextword (string, &word); - } - else if (word[0] == ':') + if (word[0] == ':') { dict_type *ptr; -- 2.30.2