public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: Reorganise bfd/doc/chew.c a little
Date: Mon, 30 May 2022 19:03:04 +0930	[thread overview]
Message-ID: <YpSPUD+p3Kc+pxls@squeak.grove.modra.org> (raw)

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.

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;
 

-- 
Alan Modra
Australia Development Lab, IBM

             reply	other threads:[~2022-05-30  9:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-30  9:33 Alan Modra [this message]
2022-05-30  9:33 ` Update K&R functions in bfd/doc/chew.c Alan Modra
2022-05-30  9:34 ` use libiberty xmalloc " Alan Modra
2022-06-01  0:10   ` H.J. Lu
2022-06-01  1:27     ` Alan Modra
2022-05-30  9:35 ` Use a union to avoid casts " Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YpSPUD+p3Kc+pxls@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).