From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id CB97F384B0CA for ; Mon, 30 May 2022 09:33:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB97F384B0CA Received: by mail-pg1-x52a.google.com with SMTP id 137so9668332pgb.5 for ; Mon, 30 May 2022 02:33:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=F9Z8z17XP94kGkeMHE/Fy2N/gOn3CjdtYSRJiEodDZQ=; b=l2Qx2IzVyOOL9Y6Y0B1PzhY/ejA8kAYzo27MSJQke8Jh3gmO76yDMP7ITr3buNoVzl tVkCyyVNk9uiRT86WEwj0qGh7GpKn59VtZATTrG122X4PdBAtYaLcax1dP9tZRn1Ircm KtFB+F6+QflPiWj2AE1bdAaBDqGlmjA9nFsKvRVKG7gs+5ax7DBTDfCpIff71ebC94pE 1zq01oEjdzFsAxQ8wXPC1zJVtbE6dmydCXYZwMSxa9PruyZ2uIm4Nrssmy+OvbtncEWE SMcYUCwKZLKNIECedlzU75MXQA9gDbNba2jpg6svfyOexkPKT4iMc01o2x7MXpFmCowV +uoA== X-Gm-Message-State: AOAM531pY/Prv4OO0h6UfaFGlXos14UykkSAdd9h2Iyr6kUBAE00Jh2Q XyvZsr9sv2LnA7ctlhuaEeYykzXxS8c= X-Google-Smtp-Source: ABdhPJwrfdJ59sVeeBevsMrw6DbQExgNFQD8m1WrQGAPytVFDZT69R1YUw7gCGj6e2ixYpP8DMmNnw== X-Received: by 2002:a63:2601:0:b0:3fa:3b85:11a6 with SMTP id m1-20020a632601000000b003fa3b8511a6mr33431801pgm.99.1653903188495; Mon, 30 May 2022 02:33:08 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id q5-20020a170902f78500b0015e8d4eb218sm8654617pln.98.2022.05.30.02.33.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 May 2022 02:33:07 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id B4CFD11404D5; Mon, 30 May 2022 19:03:04 +0930 (ACST) Date: Mon, 30 May 2022 19:03:04 +0930 From: Alan Modra To: binutils@sourceware.org Subject: Reorganise bfd/doc/chew.c a little Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3037.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 May 2022 09:33:11 -0000 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