update copyright dates
[deliverable/binutils-gdb.git] / bfd / doc / chew.c
index 42ab3993b0e02e1c651ab9fdbf7eca130e42cfbe..172bc581c7c77316ab072b92169d3b6c011ad82f 100644 (file)
@@ -1,23 +1,25 @@
 /* chew
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001,
+   2002, 2003, 2005, 2007, 2009
    Free Software Foundation, Inc.
    Contributed by steve chamberlain @cygnus
 
-This file is part of BFD, the Binary File Descriptor library.
+   This file is part of BFD, the Binary File Descriptor library.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
 /* Yet another way of extracting documentation from source.
    No, I haven't finished it yet, but I hope you people like it better
@@ -81,11 +83,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
    Foo.  */
 
-#include <ansidecl.h>
-#include "sysdep.h"
+#include "ansidecl.h"
 #include <assert.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 
 #define DEF_SIZE 5000
 #define STACK 50
@@ -117,6 +120,7 @@ static void overwrite_string (string_type *, string_type *);
 static void catbuf (string_type *, char *, unsigned int);
 static void cattext (string_type *, char *);
 static void catstr (string_type *, string_type *);
+static void die (char *);
 #endif
 
 static void
@@ -159,7 +163,9 @@ write_buffer (buffer, f)
      string_type *buffer;
      FILE *f;
 {
-  fwrite (buffer->ptr, buffer->write_idx, 1, f);
+  if (buffer->write_idx != 0
+      && fwrite (buffer->ptr, buffer->write_idx, 1, f) != 1)
+    die ("cannot write output");
 }
 
 static void
@@ -289,8 +295,6 @@ struct dict_struct
 
 typedef struct dict_struct dict_type;
 
-#define WORD(x) static void x()
-
 static void
 die (msg)
      char *msg;
@@ -362,7 +366,8 @@ exec (word)
     (*pc) ();
 }
 
-WORD (call)
+static void
+call ()
 {
   stinst_type *oldpc = pc;
   dict_type *e;
@@ -371,7 +376,8 @@ WORD (call)
   pc = oldpc + 2;
 }
 
-WORD (remchar)
+static void
+remchar ()
 {
   if (tos->write_idx)
     tos->write_idx--;
@@ -388,7 +394,8 @@ strip_trailing_newlines ()
   pc++;
 }
 
-WORD (push_number)
+static void
+push_number ()
 {
   isp++;
   icheck_range ();
@@ -397,7 +404,8 @@ WORD (push_number)
   pc++;
 }
 
-WORD (push_text)
+static void
+push_text ()
 {
   tos++;
   check_range ();
@@ -482,7 +490,7 @@ print_stack_level ()
  */
 
 static void
-paramstuff (void)
+paramstuff ()
 {
   unsigned int openp;
   unsigned int fname;
@@ -491,8 +499,11 @@ paramstuff (void)
   string_type out;
   init_string (&out);
 
+#define NO_PARAMS 1
+
   /* Make sure that it's not already param'd or proto'd.  */
-  if (find (tos, "PARAMS") || find (tos, "PROTO") || !find (tos, "("))
+  if (NO_PARAMS
+      || find (tos, "PARAMS") || find (tos, "PROTO") || !find (tos, "("))
     {
       catstr (&out, tos);
     }
@@ -551,7 +562,8 @@ paramstuff (void)
 /* turn {*
    and *} into comments */
 
-WORD (translatecomments)
+static void
+translatecomments ()
 {
   unsigned int idx = 0;
   string_type out;
@@ -581,47 +593,9 @@ WORD (translatecomments)
   pc++;
 }
 
-#if 0
-
-/* This is not currently used.  */
-
-/* turn everything not starting with a . into a comment */
-
-WORD (manglecomments)
-{
-  unsigned int idx = 0;
-  string_type out;
-  init_string (&out);
-
-  while (at (tos, idx))
-    {
-      if (at (tos, idx) == '\n' && at (tos, idx + 1) == '*')
-       {
-         cattext (&out, "      /*");
-         idx += 2;
-       }
-      else if (at (tos, idx) == '*' && at (tos, idx + 1) == '}')
-       {
-         cattext (&out, "*/");
-         idx += 2;
-       }
-      else
-       {
-         catchar (&out, at (tos, idx));
-         idx++;
-       }
-    }
-
-  overwrite_string (tos, &out);
-
-  pc++;
-}
-
-#endif
-
 /* Mod tos so that only lines with leading dots remain */
 static void
-outputdots (void)
+outputdots ()
 {
   unsigned int idx = 0;
   string_type out;
@@ -665,7 +639,8 @@ outputdots (void)
 }
 
 /* Find lines starting with . and | and put example around them on tos */
-WORD (courierize)
+static void
+courierize ()
 {
   string_type out;
   unsigned int idx = 0;
@@ -751,7 +726,8 @@ WORD (courierize)
    on @itemize @bullet, and @items each of them. Then ends with @end
    itemize, inplace at TOS*/
 
-WORD (bulletize)
+static void
+bulletize ()
 {
   unsigned int idx = 0;
   int on = 0;
@@ -805,7 +781,8 @@ WORD (bulletize)
 
 /* Turn <<foo>> into @code{foo} in place at TOS*/
 
-WORD (do_fancy_stuff)
+static void
+do_fancy_stuff ()
 {
   unsigned int idx = 0;
   string_type out;
@@ -901,7 +878,8 @@ copy_past_newline (ptr, idx, dst)
 
 }
 
-WORD (icopy_past_newline)
+static void
+icopy_past_newline ()
 {
   tos++;
   check_range ();
@@ -913,7 +891,8 @@ WORD (icopy_past_newline)
 /* indent
    Take the string at the top of the stack, do some prettying.  */
 
-WORD (kill_bogus_lines)
+static void
+kill_bogus_lines ()
 {
   int sl;
 
@@ -999,7 +978,8 @@ WORD (kill_bogus_lines)
 
 }
 
-WORD (indent)
+static void
+indent ()
 {
   string_type out;
   int tab = 0;
@@ -1049,7 +1029,8 @@ WORD (indent)
 
 }
 
-WORD (get_stuff_in_command)
+static void
+get_stuff_in_command ()
 {
   tos++;
   check_range ();
@@ -1064,7 +1045,8 @@ WORD (get_stuff_in_command)
   pc++;
 }
 
-WORD (swap)
+static void
+swap ()
 {
   string_type t;
 
@@ -1074,7 +1056,8 @@ WORD (swap)
   pc++;
 }
 
-WORD (other_dup)
+static void
+other_dup ()
 {
   tos++;
   check_range ();
@@ -1083,21 +1066,24 @@ WORD (other_dup)
   pc++;
 }
 
-WORD (drop)
+static void
+drop ()
 {
   tos--;
   check_range ();
   pc++;
 }
 
-WORD (idrop)
+static void
+idrop ()
 {
   isp--;
   icheck_range ();
   pc++;
 }
 
-WORD (icatstr)
+static void
+icatstr ()
 {
   tos--;
   check_range ();
@@ -1106,7 +1092,8 @@ WORD (icatstr)
   pc++;
 }
 
-WORD (skip_past_newline)
+static void
+skip_past_newline ()
 {
   while (at (ptr, idx)
         && at (ptr, idx) != '\n')
@@ -1115,7 +1102,8 @@ WORD (skip_past_newline)
   pc++;
 }
 
-WORD (internalmode)
+static void
+internalmode ()
 {
   internal_mode = *(isp);
   isp--;
@@ -1123,7 +1111,8 @@ WORD (internalmode)
   pc++;
 }
 
-WORD (maybecatstr)
+static void
+maybecatstr ()
 {
   if (internal_wanted == internal_mode)
     {
@@ -1241,7 +1230,7 @@ lookup_word (word)
 }
 
 static void
-perform (void)
+perform ()
 {
   tos = stack;
 
@@ -1278,14 +1267,14 @@ dict_type *
 newentry (word)
      char *word;
 {
-  dict_type *new = (dict_type *) malloc (sizeof (dict_type));
-  new->word = word;
-  new->next = root;
-  root = new;
-  new->code = (stinst_type *) malloc (sizeof (stinst_type));
-  new->code_length = 1;
-  new->code_end = 0;
-  return new;
+  dict_type *new_d = (dict_type *) malloc (sizeof (dict_type));
+  new_d->word = word;
+  new_d->next = root;
+  root = new_d;
+  new_d->code = (stinst_type *) malloc (sizeof (stinst_type));
+  new_d->code_length = 1;
+  new_d->code_end = 0;
+  return new_d;
 }
 
 unsigned int
@@ -1310,19 +1299,19 @@ add_intrinsic (name, func)
      char *name;
      void (*func) ();
 {
-  dict_type *new = newentry (name);
-  add_to_definition (new, func);
-  add_to_definition (new, 0);
+  dict_type *new_d = newentry (name);
+  add_to_definition (new_d, func);
+  add_to_definition (new_d, 0);
 }
 
 void
 add_var (name)
      char *name;
 {
-  dict_type *new = newentry (name);
-  add_to_definition (new, push_number);
-  add_to_definition (new, (stinst_type) (&(new->var)));
-  add_to_definition (new, 0);
+  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
@@ -1392,7 +1381,7 @@ compile (string)
 }
 
 static void
-bang (void)
+bang ()
 {
   *(long *) ((isp[0])) = isp[-1];
   isp -= 2;
@@ -1400,19 +1389,22 @@ bang (void)
   pc++;
 }
 
-WORD (atsign)
+static void
+atsign ()
 {
   isp[0] = *(long *) (isp[0]);
   pc++;
 }
 
-WORD (hello)
+static void
+hello ()
 {
   printf ("hello\n");
   pc++;
 }
 
-WORD (stdout_)
+static void
+stdout_ ()
 {
   isp++;
   icheck_range ();
@@ -1420,7 +1412,8 @@ WORD (stdout_)
   pc++;
 }
 
-WORD (stderr_)
+static void
+stderr_ ()
 {
   isp++;
   icheck_range ();
@@ -1428,7 +1421,8 @@ WORD (stderr_)
   pc++;
 }
 
-WORD (print)
+static void
+print ()
 {
   if (*isp == 1)
     write_buffer (tos, stdout);
@@ -1462,7 +1456,7 @@ read_in (str, file)
 }
 
 static void
-usage (void)
+usage ()
 {
   fprintf (stderr, "usage: -[d|i|g] <file >file\n");
   exit (33);
This page took 0.042792 seconds and 4 git commands to generate.