/[bison]/bison/lib/obstack.c
ViewVC logotype

Diff of /bison/lib/obstack.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by eggert, Mon Aug 12 14:12:57 2002 UTC revision 1.5 by eggert, Fri Dec 13 11:24:16 2002 UTC
# Line 1  Line 1 
1  /* obstack.c - subroutines used implicitly by object stack macros  /* obstack.c - subroutines used implicitly by object stack macros
2       Copyright (C) 1988-1994, 1996-1999, 2000-2002 Free Software Foundation, Inc.
    Copyright (C) 1988-1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002  
    Free Software Foundation, Inc.  
   
    This file is part of the GNU C Library.  Its master source is NOT part of  
    the C library, however.  The master source lives in /gd/gnu/lib.  
   
3     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation; either version 2, or (at your option)     the Free Software Foundation; either version 2, or (at your option)
# Line 16  Line 10 
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11     GNU General Public License for more details.     GNU General Public License for more details.
12    
13     You should have received a copy of the GNU General Public License     You should have received a copy of the GNU General Public License along
14     along with this program; if not, write to the Free Software Foundation,     with this program; if not, write to the Free Software Foundation,
15     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
16    
17  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
# Line 55  Line 49 
49  #ifndef ELIDE_CODE  #ifndef ELIDE_CODE
50    
51    
52  # ifdef __STDC__  # if defined __STDC__ && __STDC__
53  #  define POINTER void *  #  define POINTER void *
54  # else  # else
55  #  define POINTER char *  #  define POINTER char *
# Line 86  union fooround {long x; double d;}; Line 80  union fooround {long x; double d;};
80     abort gracefully or use longjump - but shouldn't return.  This     abort gracefully or use longjump - but shouldn't return.  This
81     variable by default points to the internal function     variable by default points to the internal function
82     `print_and_abort'.  */     `print_and_abort'.  */
83  # if PROTOTYPES || (defined __STDC__ && __STDC__)  # if defined __STDC__ && __STDC__
84  static void print_and_abort (void);  static void print_and_abort (void);
85  void (*obstack_alloc_failed_handler) (void) = print_and_abort;  void (*obstack_alloc_failed_handler) (void) = print_and_abort;
86  # else  # else
# Line 114  struct obstack *_obstack; Line 108  struct obstack *_obstack;
108     For free, do not use ?:, since some compilers, like the MIPS compilers,     For free, do not use ?:, since some compilers, like the MIPS compilers,
109     do not allow (expr) ? void : void.  */     do not allow (expr) ? void : void.  */
110    
111  # if PROTOTYPES || (defined __STDC__ && __STDC__)  # if defined __STDC__ && __STDC__
112  #  define CALL_CHUNKFUN(h, size) \  #  define CALL_CHUNKFUN(h, size) \
113    (((h) -> use_extra_arg) \    (((h) -> use_extra_arg) \
114     ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \     ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
# Line 156  _obstack_begin (h, size, alignment, chun Line 150  _obstack_begin (h, size, alignment, chun
150       struct obstack *h;       struct obstack *h;
151       int size;       int size;
152       int alignment;       int alignment;
153  # if PROTOTYPES || (defined __STDC__ && __STDC__)  # if defined __STDC__ && __STDC__
154       POINTER (*chunkfun) (long);       POINTER (*chunkfun) (long);
155       void (*freefun) (void *);       void (*freefun) (void *);
156  # else  # else
# Line 185  _obstack_begin (h, size, alignment, chun Line 179  _obstack_begin (h, size, alignment, chun
179        size = 4096 - extra;        size = 4096 - extra;
180      }      }
181    
182  # if PROTOTYPES || (defined __STDC__ && __STDC__)  # if defined __STDC__ && __STDC__
183    h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;    h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
184    h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;    h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
185  # else  # else
# Line 214  _obstack_begin_1 (h, size, alignment, ch Line 208  _obstack_begin_1 (h, size, alignment, ch
208       struct obstack *h;       struct obstack *h;
209       int size;       int size;
210       int alignment;       int alignment;
211  # if PROTOTYPES || (defined __STDC__ && __STDC__)  # if defined __STDC__ && __STDC__
212       POINTER (*chunkfun) (POINTER, long);       POINTER (*chunkfun) (POINTER, long);
213       void (*freefun) (POINTER, POINTER);       void (*freefun) (POINTER, POINTER);
214  # else  # else
# Line 244  _obstack_begin_1 (h, size, alignment, ch Line 238  _obstack_begin_1 (h, size, alignment, ch
238        size = 4096 - extra;        size = 4096 - extra;
239      }      }
240    
241  # if PROTOTYPES || (defined __STDC__ && __STDC__)  # if defined __STDC__ && __STDC__
242    h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;    h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
243    h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;    h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
244  # else  # else
# Line 345  _obstack_newchunk (h, length) Line 339  _obstack_newchunk (h, length)
339     This is here for debugging.     This is here for debugging.
340     If you use it in a program, you are probably losing.  */     If you use it in a program, you are probably losing.  */
341    
342  # if PROTOTYPES || (defined __STDC__ && __STDC__)  # if defined __STDC__ && __STDC__
343  /* Suppress -Wmissing-prototypes warning.  We don't want to declare this in  /* Suppress -Wmissing-prototypes warning.  We don't want to declare this in
344     obstack.h because it is just for debugging.  */     obstack.h because it is just for debugging.  */
345  int _obstack_allocated_p (struct obstack *h, POINTER obj);  int _obstack_allocated_p (struct obstack *h, POINTER obj);
# Line 460  _obstack_memory_used (h) Line 454  _obstack_memory_used (h)
454  }  }
455    
456  /* Define the error handler.  */  /* Define the error handler.  */
457  # ifndef _  # ifdef _LIBC
458  #  if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC  #  include <libintl.h>
459  #   include <libintl.h>  # else
460  #   ifndef _  #  include "gettext.h"
 #    define _(Str) gettext (Str)  
 #   endif  
 #  else  
 #   define _(Str) (Str)  
 #  endif  
461  # endif  # endif
462    # define _(msgid) gettext (msgid)
463    
464  # if defined _LIBC && defined USE_IN_LIBIO  # if defined _LIBC && defined USE_IN_LIBIO
465  #  include <libio/iolibio.h>  #  include <libio/iolibio.h>
466  #  define fputs(s, f) _IO_fputs (s, f)  #  define fputs(s, f) _IO_fputs (s, f)
# Line 507  print_and_abort () Line 498  print_and_abort ()
498  /* Now define the functional versions of the obstack macros.  /* Now define the functional versions of the obstack macros.
499     Define them to simply use the corresponding macros to do the job.  */     Define them to simply use the corresponding macros to do the job.  */
500    
501  #  if PROTOTYPES || (defined __STDC__ && __STDC__)  #  if defined __STDC__ && __STDC__
502  /* These function definitions do not work with non-ANSI preprocessors;  /* These function definitions do not work with non-ANSI preprocessors;
503     they won't pass through the macro names in parentheses.  */     they won't pass through the macro names in parentheses.  */
504    
# Line 618  POINTER (obstack_copy0) (obstack, addres Line 609  POINTER (obstack_copy0) (obstack, addres
609    return obstack_copy0 (obstack, address, length);    return obstack_copy0 (obstack, address, length);
610  }  }
611    
612  #  endif /* PROTOTYPES || (defined __STDC__ && __STDC__) */  #  endif /* __STDC__ */
613    
614  # endif /* 0 */  # endif /* 0 */
615    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26