From 261cb4bb750143d8078bb27a343e0d9560b884df Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 21 May 2012 08:36:54 -0700 Subject: [PATCH] Assume C89 or later. * configure.in (AC_C_PROTOTYPES, AC_C_VOLATILE, AC_C_CONST) (POINTER_TYPE, PROTOTYPES): Remove. * admin/CPP-DEFINES: Remove NULL, const. * lib-src/etags.c (static, const): Remove macros. (PTR): Remove; all uses replaced with void *. Omit needless casts. * src/alloc.c, src/buffer.c, lisp.h: Replace POINTER_TYPE with void. * alloc.c (overrun_check_malloc, overrun_check_realloc, xmalloc) (xrealloc): * buffer.c (mmap_free_1, mmap_enlarge): Omit needless casts. * editfns.c, fns.c, gmalloc.c, insdel.c, sysdep.c, termcap.c (NULL): * textprop.c, tparam.c (NULL): Remove. * ralloc.c, vm-limit.c (POINTER): Assume void * works. * regex.c (SIGN_EXTEND_CHAR): Assume signed char works. * regex.h (_RE_ARGS): Remove. All uses rewritten to use prototypes. * unexelf.c (ElfBitsW): Assume c89 preprocessor or better. * xterm.c (input_signal_count): Assume volatile works. --- ChangeLog | 14 +++++--- admin/CPP-DEFINES | 2 -- admin/ChangeLog | 3 ++ configure.in | 25 ------------- lib-src/ChangeLog | 6 ++++ lib-src/etags.c | 28 ++++----------- src/ChangeLog | 15 ++++++++ src/alloc.c | 56 ++++++++++++++--------------- src/buffer.c | 50 +++++++++++++------------- src/editfns.c | 4 --- src/fns.c | 4 --- src/gmalloc.c | 4 --- src/insdel.c | 4 --- src/lisp.h | 8 ++--- src/ralloc.c | 8 ++--- src/regex.c | 83 ++++++++++++++++-------------------------- src/regex.h | 91 ++++++++++++++++++++--------------------------- src/sysdep.c | 3 -- src/termcap.c | 8 ----- src/textprop.c | 4 --- src/tparam.c | 4 --- src/unexelf.c | 6 +--- src/vm-limit.c | 2 +- src/xterm.c | 4 --- 24 files changed, 169 insertions(+), 267 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9b2a917766..6f1c9254bd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,9 @@ -2012-05-21 Glenn Morris - - * configure.in (LEIM_INSTALLDIR): - Rename to leimdir, treat like lispdir. - 2012-05-21 Paul Eggert + Assume C89 or later. + * configure.in (AC_C_PROTOTYPES, AC_C_VOLATILE, AC_C_CONST) + (POINTER_TYPE, PROTOTYPES): Remove. + Make merging from gnulib a script, not a makefile action. Putting it in a makefile has some problems with reflection, as merging from gnulib updates 'configure', which can update the makefile. @@ -13,6 +12,11 @@ (GNULIB_MODULES, GNULIB_TOOL_FLAGS, sync-from-gnulib): Remove, moving the actions to the script admin/merge-gnulib. +2012-05-21 Glenn Morris + + * configure.in (LEIM_INSTALLDIR): + Rename to leimdir, treat like lispdir. + 2012-05-21 Glenn Morris * Makefile.in (install-arch-indep, install-doc, install-info) diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index 71ba4bf8ece..d736f2354f7 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -201,7 +201,6 @@ NO_MATHERR NO_TERMIO NSIG NSIG_MINIMUM -NULL NULL_DEVICE ORDINARY_LINK O_APPEND @@ -272,7 +271,6 @@ chdir chmod chown close -const creat ctime dup diff --git a/admin/ChangeLog b/admin/ChangeLog index 86069da7f0b..1da647a803d 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog @@ -1,5 +1,8 @@ 2012-05-21 Paul Eggert + Assume C89 or later. + * CPP-DEFINES: Remove NULL, const. + Make merging from gnulib a script, not a makefile action. * merge-gnulib: New script, with actions moved here from ../Makefile.in. diff --git a/configure.in b/configure.in index ab11b9d6431..eb5e8482e9b 100644 --- a/configure.in +++ b/configure.in @@ -1355,27 +1355,6 @@ AC_CHECK_MEMBERS([struct ifreq.ifr_flags, struct ifreq.ifr_hwaddr, #include #endif]) -dnl checks for compiler characteristics - -dnl Testing __STDC__ to determine prototype support isn't good enough. -dnl DEC C, for instance, doesn't define it with default options, and -dnl is used on 64-bit systems (OSF Alphas). Similarly for volatile -dnl and void *. -AC_C_PROTOTYPES -AC_C_VOLATILE -AC_C_CONST -AC_CACHE_CHECK([for void * support], emacs_cv_void_star, - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[void * foo;]])], - emacs_cv_void_star=yes, emacs_cv_void_star=no)]) -if test $emacs_cv_void_star = yes; then - AC_DEFINE(POINTER_TYPE, void) -else - AC_DEFINE(POINTER_TYPE, char) -fi -AH_TEMPLATE(POINTER_TYPE, - [Define as `void' if your compiler accepts `void *'; otherwise - define as `char'.])dnl - dnl Check for endianness. AC_C_BIGENDIAN @@ -3663,10 +3642,6 @@ AH_BOTTOM([ #define BITS_PER_LONG_LONG 64 #endif -/* Define if the compiler supports function prototypes. It may do so but - not define __STDC__ (e.g. DEC C by default) or may define it as zero. */ -#undef PROTOTYPES - #include #include diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 1b4cd548a99..c3ddc9bfbab 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,9 @@ +2012-05-21 Paul Eggert + + Assume C89 or later. + * etags.c (static, const): Remove macros. + (PTR): Remove; all uses replaced with void *. Omit needless casts. + 2012-05-21 Glenn Morris * Makefile.in (insrcdir, $(DESTDIR)${archlibdir}): diff --git a/lib-src/etags.c b/lib-src/etags.c index ccf97a8357f..7d2a5a90999 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -93,22 +93,6 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; #ifdef HAVE_CONFIG_H # include - /* This is probably not necessary any more. On some systems, config.h - used to define static as nothing for the sake of unexec. We don't - want that here since we don't use unexec. None of these systems - are supported any more, but the idea is still mentioned in - etc/PROBLEMS. */ -# undef static -# ifndef PTR /* for XEmacs */ -# define PTR void * -# endif -#else /* no config.h */ -# if defined (__STDC__) && (__STDC__ || defined (__SUNPRO_C)) -# define PTR void * /* for generic pointers */ -# else /* not standard C */ -# define const /* remove const for old compilers' sake */ -# define PTR long * /* don't use void* */ -# endif #endif /* !HAVE_CONFIG_H */ #ifndef _GNU_SOURCE @@ -415,8 +399,8 @@ static bool filename_is_absolute (char *f); static void canonicalize_filename (char *); static void linebuffer_init (linebuffer *); static void linebuffer_setlen (linebuffer *, int); -static PTR xmalloc (size_t); -static PTR xrealloc (char *, size_t); +static void *xmalloc (size_t); +static void *xrealloc (char *, size_t); static char searchar = '/'; /* use /.../ searches */ @@ -6686,19 +6670,19 @@ linebuffer_setlen (linebuffer *lbp, int toksize) } /* Like malloc but get fatal error if memory is exhausted. */ -static PTR +static void * xmalloc (size_t size) { - PTR result = (PTR) malloc (size); + void *result = malloc (size); if (result == NULL) fatal ("virtual memory exhausted", (char *)NULL); return result; } -static PTR +static void * xrealloc (char *ptr, size_t size) { - PTR result = (PTR) realloc (ptr, size); + void *result = realloc (ptr, size); if (result == NULL) fatal ("virtual memory exhausted", (char *)NULL); return result; diff --git a/src/ChangeLog b/src/ChangeLog index b9e91d308cc..3054f4a284f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2012-05-21 Paul Eggert + + Assume C89 or later. + * alloc.c, buffer.c, lisp.h: Replace POINTER_TYPE with void. + * alloc.c (overrun_check_malloc, overrun_check_realloc, xmalloc) + (xrealloc): + * buffer.c (mmap_free_1, mmap_enlarge): Omit needless casts. + * editfns.c, fns.c, gmalloc.c, insdel.c, sysdep.c, termcap.c (NULL): + * textprop.c, tparam.c (NULL): Remove. + * ralloc.c, vm-limit.c (POINTER): Assume void * works. + * regex.c (SIGN_EXTEND_CHAR): Assume signed char works. + * regex.h (_RE_ARGS): Remove. All uses rewritten to use prototypes. + * unexelf.c (ElfBitsW): Assume c89 preprocessor or better. + * xterm.c (input_signal_count): Assume volatile works. + 2012-05-21 Ken Brown * xgselect.c (xg_select): Fix first argument in call to 'select' diff --git a/src/alloc.c b/src/alloc.c index a120ce9b61f..3601c256c41 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -66,7 +66,7 @@ along with GNU Emacs. If not, see . */ #include #ifndef HAVE_UNISTD_H -extern POINTER_TYPE *sbrk (); +extern void *sbrk (); #endif #include @@ -306,7 +306,7 @@ enum mem_type MEM_TYPE_VECTORLIKE }; -static POINTER_TYPE *lisp_malloc (size_t, enum mem_type); +static void *lisp_malloc (size_t, enum mem_type); #if GC_MARK_STACK || defined GC_MALLOC_CHECK @@ -388,7 +388,7 @@ static struct mem_node mem_z; #define MEM_NIL &mem_z static struct Lisp_Vector *allocate_vectorlike (EMACS_INT); -static void lisp_free (POINTER_TYPE *); +static void lisp_free (void *); static void mark_stack (void); static int live_vector_p (struct mem_node *, void *); static int live_buffer_p (struct mem_node *, void *); @@ -435,15 +435,15 @@ static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag}; static int staticidx = 0; -static POINTER_TYPE *pure_alloc (size_t, int); +static void *pure_alloc (size_t, int); /* Value is SZ rounded up to the next multiple of ALIGNMENT. ALIGNMENT must be a power of 2. */ #define ALIGN(ptr, ALIGNMENT) \ - ((POINTER_TYPE *) ((((uintptr_t) (ptr)) + (ALIGNMENT) - 1) \ - & ~((ALIGNMENT) - 1))) + ((void *) (((uintptr_t) (ptr) + (ALIGNMENT) - 1) \ + & ~ ((ALIGNMENT) - 1))) @@ -604,7 +604,7 @@ static ptrdiff_t check_depth; /* Like malloc, but wraps allocated block with header and trailer. */ -static POINTER_TYPE * +static void * overrun_check_malloc (size_t size) { register unsigned char *val; @@ -622,15 +622,15 @@ overrun_check_malloc (size_t size) XMALLOC_OVERRUN_CHECK_SIZE); } --check_depth; - return (POINTER_TYPE *)val; + return val; } /* Like realloc, but checks old block for overrun, and wraps new block with header and trailer. */ -static POINTER_TYPE * -overrun_check_realloc (POINTER_TYPE *block, size_t size) +static void * +overrun_check_realloc (void *block, size_t size) { register unsigned char *val = (unsigned char *) block; int overhead = ++check_depth == 1 ? XMALLOC_OVERRUN_CHECK_OVERHEAD : 0; @@ -652,7 +652,7 @@ overrun_check_realloc (POINTER_TYPE *block, size_t size) memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE); } - val = (unsigned char *) realloc ((POINTER_TYPE *)val, size + overhead); + val = realloc (val, size + overhead); if (val && check_depth == 1) { @@ -663,13 +663,13 @@ overrun_check_realloc (POINTER_TYPE *block, size_t size) XMALLOC_OVERRUN_CHECK_SIZE); } --check_depth; - return (POINTER_TYPE *)val; + return val; } /* Like free, but checks block for overrun. */ static void -overrun_check_free (POINTER_TYPE *block) +overrun_check_free (void *block) { unsigned char *val = (unsigned char *) block; @@ -718,13 +718,13 @@ overrun_check_free (POINTER_TYPE *block) /* Like malloc but check for no memory and block interrupt input.. */ -POINTER_TYPE * +void * xmalloc (size_t size) { - register POINTER_TYPE *val; + void *val; MALLOC_BLOCK_INPUT; - val = (POINTER_TYPE *) malloc (size); + val = malloc (size); MALLOC_UNBLOCK_INPUT; if (!val && size) @@ -735,18 +735,18 @@ xmalloc (size_t size) /* Like realloc but check for no memory and block interrupt input.. */ -POINTER_TYPE * -xrealloc (POINTER_TYPE *block, size_t size) +void * +xrealloc (void *block, size_t size) { - register POINTER_TYPE *val; + void *val; MALLOC_BLOCK_INPUT; /* We must call malloc explicitly when BLOCK is 0, since some reallocs don't do this. */ if (! block) - val = (POINTER_TYPE *) malloc (size); + val = malloc (size); else - val = (POINTER_TYPE *) realloc (block, size); + val = realloc (block, size); MALLOC_UNBLOCK_INPUT; if (!val && size) @@ -758,7 +758,7 @@ xrealloc (POINTER_TYPE *block, size_t size) /* Like free but block interrupt input. */ void -xfree (POINTER_TYPE *block) +xfree (void *block) { if (!block) return; @@ -893,7 +893,7 @@ safe_alloca_unwind (Lisp_Object arg) static void *lisp_malloc_loser; #endif -static POINTER_TYPE * +static void * lisp_malloc (size_t nbytes, enum mem_type type) { register void *val; @@ -938,7 +938,7 @@ lisp_malloc (size_t nbytes, enum mem_type type) call to lisp_malloc. */ static void -lisp_free (POINTER_TYPE *block) +lisp_free (void *block) { MALLOC_BLOCK_INPUT; free (block); @@ -1034,7 +1034,7 @@ static struct ablock *free_ablock; /* Allocate an aligned block of nbytes. Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be smaller or equal to BLOCK_BYTES. */ -static POINTER_TYPE * +static void * lisp_align_malloc (size_t nbytes, enum mem_type type) { void *base, *val; @@ -1141,7 +1141,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type) } static void -lisp_align_free (POINTER_TYPE *block) +lisp_align_free (void *block) { struct ablock *ablock = block; struct ablocks *abase = ABLOCK_ABASE (ablock); @@ -4722,10 +4722,10 @@ valid_lisp_object_p (Lisp_Object obj) pointer to it. TYPE is the Lisp type for which the memory is allocated. TYPE < 0 means it's not used for a Lisp object. */ -static POINTER_TYPE * +static void * pure_alloc (size_t size, int type) { - POINTER_TYPE *result; + void *result; #ifdef USE_LSB_TAG size_t alignment = (1 << GCTYPEBITS); #else diff --git a/src/buffer.c b/src/buffer.c index 2ddbc699481..4dcdf7bae69 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2051,10 +2051,10 @@ DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text, eassert (current_buffer->text == ¤t_buffer->own_text); eassert (other_buffer->text == &other_buffer->own_text); #ifdef REL_ALLOC - r_alloc_reset_variable ((POINTER_TYPE **) ¤t_buffer->own_text.beg, - (POINTER_TYPE **) &other_buffer->own_text.beg); - r_alloc_reset_variable ((POINTER_TYPE **) &other_buffer->own_text.beg, - (POINTER_TYPE **) ¤t_buffer->own_text.beg); + r_alloc_reset_variable ((void **) ¤t_buffer->own_text.beg, + (void **) &other_buffer->own_text.beg); + r_alloc_reset_variable ((void **) &other_buffer->own_text.beg, + (void **) ¤t_buffer->own_text.beg); #endif /* REL_ALLOC */ swapfield (pt, EMACS_INT); @@ -4383,7 +4383,7 @@ struct mmap_region /* Pointer to the location holding the address of the memory allocated with the mmap'd block. The variable actually points after this structure. */ - POINTER_TYPE **var; + void **var; /* Next and previous in list of all mmap'd regions. */ struct mmap_region *next, *prev; @@ -4430,7 +4430,7 @@ static int mmap_initialized_p; to the start of the user-visible part of the region. */ #define MMAP_USER_AREA(P) \ - ((POINTER_TYPE *) ((char *) (P) + MMAP_REGION_STRUCT_SIZE)) + ((void *) ((char *) (P) + MMAP_REGION_STRUCT_SIZE)) #define MEM_ALIGN sizeof (double) @@ -4479,7 +4479,7 @@ mmap_init (void) is at END - 1. */ static struct mmap_region * -mmap_find (POINTER_TYPE *start, POINTER_TYPE *end) +mmap_find (void *start, void *end) { struct mmap_region *r; char *s = (char *) start, *e = (char *) end; @@ -4517,7 +4517,7 @@ mmap_free_1 (struct mmap_region *r) else mmap_regions = r->next; - if (munmap ((POINTER_TYPE *) r, r->nbytes_mapped) == -1) + if (munmap (r, r->nbytes_mapped) == -1) { fprintf (stderr, "munmap: %s\n", emacs_strerror (errno)); return 0; @@ -4559,13 +4559,13 @@ mmap_enlarge (struct mmap_region *r, int npages) I'm not sure this is worth doing, let's see. */ if (!MMAP_ALLOCATED_P (region_end, region_end + nbytes)) { - POINTER_TYPE *p; + void *p; p = mmap (region_end, nbytes, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, mmap_fd, 0); if (p == MAP_FAILED) ; /* fprintf (stderr, "mmap: %s\n", emacs_strerror (errno)); */ - else if (p != (POINTER_TYPE *) region_end) + else if (p != region_end) { /* Kernels are free to choose a different address. In that case, unmap what we've mapped above; we have @@ -4627,8 +4627,8 @@ mmap_set_vars (int restore_p) If we can't allocate the necessary memory, set *VAR to null, and return null. */ -static POINTER_TYPE * -mmap_alloc (POINTER_TYPE **var, size_t nbytes) +static void * +mmap_alloc (void **var, size_t nbytes) { void *p; size_t map; @@ -4669,7 +4669,7 @@ mmap_alloc (POINTER_TYPE **var, size_t nbytes) PTR. Store 0 in *PTR to show there's no block allocated. */ static void -mmap_free (POINTER_TYPE **var) +mmap_free (void **var) { mmap_init (); @@ -4686,10 +4686,10 @@ mmap_free (POINTER_TYPE **var) and return this value. If more memory cannot be allocated, then leave *VAR unchanged, and return null. */ -static POINTER_TYPE * -mmap_realloc (POINTER_TYPE **var, size_t nbytes) +static void * +mmap_realloc (void **var, size_t nbytes) { - POINTER_TYPE *result; + void *result; mmap_init (); @@ -4708,7 +4708,7 @@ mmap_realloc (POINTER_TYPE **var, size_t nbytes) if (room < nbytes) { /* Must enlarge. */ - POINTER_TYPE *old_ptr = *var; + void *old_ptr = *var; /* Try to map additional pages at the end of the region. If that fails, allocate a new region, copy data @@ -4770,13 +4770,13 @@ mmap_realloc (POINTER_TYPE **var, size_t nbytes) static void alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) { - POINTER_TYPE *p; + void *p; BLOCK_INPUT; #if defined USE_MMAP_FOR_BUFFERS - p = mmap_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); + p = mmap_alloc ((void **) &b->text->beg, nbytes); #elif defined REL_ALLOC - p = r_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); + p = r_alloc ((void **) &b->text->beg, nbytes); #else p = xmalloc (nbytes); #endif @@ -4797,14 +4797,14 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) void enlarge_buffer_text (struct buffer *b, EMACS_INT delta) { - POINTER_TYPE *p; + void *p; ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 + delta); BLOCK_INPUT; #if defined USE_MMAP_FOR_BUFFERS - p = mmap_realloc ((POINTER_TYPE **) &b->text->beg, nbytes); + p = mmap_realloc ((void **) &b->text->beg, nbytes); #elif defined REL_ALLOC - p = r_re_alloc ((POINTER_TYPE **) &b->text->beg, nbytes); + p = r_re_alloc ((void **) &b->text->beg, nbytes); #else p = xrealloc (b->text->beg, nbytes); #endif @@ -4828,9 +4828,9 @@ free_buffer_text (struct buffer *b) BLOCK_INPUT; #if defined USE_MMAP_FOR_BUFFERS - mmap_free ((POINTER_TYPE **) &b->text->beg); + mmap_free ((void **) &b->text->beg); #elif defined REL_ALLOC - r_alloc_free ((POINTER_TYPE **) &b->text->beg); + r_alloc_free ((void **) &b->text->beg); #else xfree (b->text->beg); #endif diff --git a/src/editfns.c b/src/editfns.c index d266ca9951d..c5ba280c178 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -59,10 +59,6 @@ along with GNU Emacs. If not, see . */ #include "window.h" #include "blockinput.h" -#ifndef NULL -#define NULL 0 -#endif - #ifndef USER_FULL_NAME #define USER_FULL_NAME pw->pw_gecos #endif diff --git a/src/fns.c b/src/fns.c index a92a1c882fd..aa7284f7ce0 100644 --- a/src/fns.c +++ b/src/fns.c @@ -42,10 +42,6 @@ along with GNU Emacs. If not, see . */ #endif #endif /* HAVE_MENUS */ -#ifndef NULL -#define NULL ((POINTER_TYPE *)0) -#endif - Lisp_Object Qstring_lessp; static Lisp_Object Qprovide, Qrequire; static Lisp_Object Qyes_or_no_p_history; diff --git a/src/gmalloc.c b/src/gmalloc.c index b53199e7312..0df050e127a 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -1531,10 +1531,6 @@ MA 02110-1301, USA. */ extern void *__sbrk (ptrdiff_t increment); #endif /* __GNU_LIBRARY__ && ! defined (__UCLIBC__) */ -#ifndef NULL -#define NULL 0 -#endif - /* Allocate INCREMENT more bytes of data space, and return the start of data space, or NULL on errors. If INCREMENT is negative, shrink data space. */ diff --git a/src/insdel.c b/src/insdel.c index 34d82fa017d..373b3848f05 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -31,10 +31,6 @@ along with GNU Emacs. If not, see . */ #include "blockinput.h" #include "region-cache.h" -#ifndef NULL -#define NULL 0 -#endif - static void insert_from_string_1 (Lisp_Object string, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT nchars, EMACS_INT nbytes, diff --git a/src/lisp.h b/src/lisp.h index 6376862949a..fd5219adf4c 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2780,7 +2780,7 @@ extern int pos_visible_p (struct window *, EMACS_INT, int *, extern void syms_of_xsettings (void); /* Defined in vm-limit.c. */ -extern void memory_warnings (POINTER_TYPE *, void (*warnfun) (const char *)); +extern void memory_warnings (void *, void (*warnfun) (const char *)); /* Defined in alloc.c */ extern void check_pure_size (void); @@ -3597,9 +3597,9 @@ extern int initialized; extern int immediate_quit; /* Nonzero means ^G can quit instantly */ -extern POINTER_TYPE *xmalloc (size_t); -extern POINTER_TYPE *xrealloc (POINTER_TYPE *, size_t); -extern void xfree (POINTER_TYPE *); +extern void *xmalloc (size_t); +extern void *xrealloc (void *, size_t); +extern void xfree (void *); extern void *xnmalloc (ptrdiff_t, ptrdiff_t); extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t); extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t); diff --git a/src/ralloc.c b/src/ralloc.c index 4bb2f240438..d736e279520 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -31,9 +31,6 @@ along with GNU Emacs. If not, see . */ #include -typedef POINTER_TYPE *POINTER; -typedef size_t SIZE; - #ifdef DOUG_LEA_MALLOC #define M_TOP_PAD -2 extern int mallopt (int, int); @@ -47,9 +44,6 @@ extern size_t __malloc_extra_blocks; #include -typedef size_t SIZE; -typedef void *POINTER; - #include #include @@ -58,6 +52,8 @@ typedef void *POINTER; #include "getpagesize.h" +typedef size_t SIZE; +typedef void *POINTER; #define NIL ((POINTER) 0) /* A flag to indicate whether we have initialized ralloc yet. For diff --git a/src/regex.c b/src/regex.c index d16a5148054..f9a12a3c2dc 100644 --- a/src/regex.c +++ b/src/regex.c @@ -434,17 +434,7 @@ init_syntax_once (void) #endif /* not emacs */ -/* We remove any previous definition of `SIGN_EXTEND_CHAR', - since ours (we hope) works properly with all combinations of - machines, compilers, `char' and `unsigned char' argument types. - (Per Bothner suggested the basic approach.) */ -#undef SIGN_EXTEND_CHAR -#if __STDC__ -# define SIGN_EXTEND_CHAR(c) ((signed char) (c)) -#else /* not __STDC__ */ -/* As in Harbison and Steele. */ -# define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) -#endif +#define SIGN_EXTEND_CHAR(c) ((signed char) (c)) /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we use `alloca' instead of `malloc'. This is because using malloc in @@ -553,12 +543,12 @@ typedef char boolean; #define false 0 #define true 1 -static regoff_t re_match_2_internal _RE_ARGS ((struct re_pattern_buffer *bufp, - re_char *string1, size_t size1, - re_char *string2, size_t size2, - ssize_t pos, - struct re_registers *regs, - ssize_t stop)); +static regoff_t re_match_2_internal (struct re_pattern_buffer *bufp, + re_char *string1, size_t size1, + re_char *string2, size_t size2, + ssize_t pos, + struct re_registers *regs, + ssize_t stop); /* These are the command codes that appear in compiled regular expressions. Some opcodes are followed by argument bytes. A @@ -735,11 +725,8 @@ typedef enum } while (0) #ifdef DEBUG -static void extract_number _RE_ARGS ((int *dest, re_char *source)); static void -extract_number (dest, source) - int *dest; - re_char *source; +extract_number (int *dest, re_char *source) { int temp = SIGN_EXTEND_CHAR (*(source + 1)); *dest = *source & 0377; @@ -763,12 +750,8 @@ extract_number (dest, source) } while (0) #ifdef DEBUG -static void extract_number_and_incr _RE_ARGS ((int *destination, - re_char **source)); static void -extract_number_and_incr (destination, source) - int *destination; - re_char **source; +extract_number_and_incr (int *destination, re_char **source) { extract_number (destination, *source); *source += 2; @@ -1672,25 +1655,22 @@ do { \ /* Subroutine declarations and macros for regex_compile. */ -static reg_errcode_t regex_compile _RE_ARGS ((re_char *pattern, size_t size, - reg_syntax_t syntax, - struct re_pattern_buffer *bufp)); -static void store_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg)); -static void store_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, - int arg1, int arg2)); -static void insert_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, - int arg, unsigned char *end)); -static void insert_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, - int arg1, int arg2, unsigned char *end)); -static boolean at_begline_loc_p _RE_ARGS ((re_char *pattern, - re_char *p, - reg_syntax_t syntax)); -static boolean at_endline_loc_p _RE_ARGS ((re_char *p, - re_char *pend, - reg_syntax_t syntax)); -static re_char *skip_one_char _RE_ARGS ((re_char *p)); -static int analyse_first _RE_ARGS ((re_char *p, re_char *pend, - char *fastmap, const int multibyte)); +static reg_errcode_t regex_compile (re_char *pattern, size_t size, + reg_syntax_t syntax, + struct re_pattern_buffer *bufp); +static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); +static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); +static void insert_op1 (re_opcode_t op, unsigned char *loc, + int arg, unsigned char *end); +static void insert_op2 (re_opcode_t op, unsigned char *loc, + int arg1, int arg2, unsigned char *end); +static boolean at_begline_loc_p (re_char *pattern, re_char *p, + reg_syntax_t syntax); +static boolean at_endline_loc_p (re_char *p, re_char *pend, + reg_syntax_t syntax); +static re_char *skip_one_char (re_char *p); +static int analyse_first (re_char *p, re_char *pend, + char *fastmap, const int multibyte); /* Fetch the next character in the uncompiled pattern, with no translation. */ @@ -2442,9 +2422,8 @@ regex_grow_registers (int num_regs) #endif /* not MATCH_MAY_ALLOCATE */ -static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type - compile_stack, - regnum_t regnum)); +static boolean group_in_compile_stack (compile_stack_type compile_stack, + regnum_t regnum); /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. Returns one of error codes defined in `regex.h', or zero for success. @@ -4554,10 +4533,10 @@ WEAK_ALIAS (__re_search_2, re_search_2) /* Declarations and macros for re_match_2. */ -static int bcmp_translate _RE_ARGS ((re_char *s1, re_char *s2, - register ssize_t len, - RE_TRANSLATE_TYPE translate, - const int multibyte)); +static int bcmp_translate (re_char *s1, re_char *s2, + register ssize_t len, + RE_TRANSLATE_TYPE translate, + const int multibyte); /* This converts PTR, a pointer into one of the search strings `string1' and `string2' into an offset from the beginning of that string. */ diff --git a/src/regex.h b/src/regex.h index 643d0b7b5ab..e0ede012b20 100644 --- a/src/regex.h +++ b/src/regex.h @@ -451,38 +451,21 @@ typedef struct /* Declarations for routines. */ -/* To avoid duplicating every routine declaration -- once with a - prototype (if we are ANSI), and once without (if we aren't) -- we - use the following macro to declare argument types. This - unfortunately clutters up the declarations a bit, but I think it's - worth it. */ - -#if defined __STDC__ || defined PROTOTYPES - -# define _RE_ARGS(args) args - -#else /* not __STDC__ || PROTOTYPES */ - -# define _RE_ARGS(args) () - -#endif /* not __STDC__ || PROTOTYPES */ - /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); +extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern - _RE_ARGS ((const char *pattern, size_t length, - struct re_pattern_buffer *buffer)); +extern const char *re_compile_pattern (const char *__pattern, size_t __length, + struct re_pattern_buffer *__buffer); /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ -extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); +extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); /* Search in the string STRING (with length LENGTH) for the pattern @@ -490,33 +473,35 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern regoff_t re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - size_t length, ssize_t start, ssize_t range, - struct re_registers *regs)); +extern regoff_t re_search (struct re_pattern_buffer *__buffer, + const char *__string, size_t __length, + ssize_t __start, ssize_t __range, + struct re_registers *__regs); /* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ -extern regoff_t re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - size_t length1, const char *string2, size_t length2, - ssize_t start, ssize_t range, struct re_registers *regs, - ssize_t stop)); +extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, + const char *__string1, size_t __length1, + const char *__string2, size_t __length2, + ssize_t __start, ssize_t __range, + struct re_registers *__regs, + ssize_t __stop); /* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ -extern regoff_t re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - size_t length, ssize_t start, struct re_registers *regs)); +extern regoff_t re_match (struct re_pattern_buffer *__buffer, + const char *__string, size_t __length, + ssize_t __start, struct re_registers *__regs); /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern regoff_t re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - size_t length1, const char *string2, size_t length2, - ssize_t start, struct re_registers *regs, ssize_t stop)); +extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, + const char *__string1, size_t __length1, + const char *__string2, size_t __length2, + ssize_t __start, struct re_registers *__regs, + ssize_t __stop); /* Set REGS to hold NUM_REGS registers, storing them in STARTS and @@ -531,15 +516,16 @@ extern regoff_t re_match_2 Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ -extern void re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); +extern void re_set_registers (struct re_pattern_buffer *__buffer, + struct re_registers *__regs, + unsigned __num_regs, + regoff_t *__starts, regoff_t *__ends); #if defined _REGEX_RE_COMP || defined _LIBC # ifndef _CRAY /* 4.2 bsd compatibility. */ -extern char *re_comp _RE_ARGS ((const char *)); -extern int re_exec _RE_ARGS ((const char *)); +extern char *re_comp (const char *); +extern int re_exec (const char *); # endif #endif @@ -562,20 +548,19 @@ extern int re_exec _RE_ARGS ((const char *)); #endif /* POSIX compatibility. */ -extern reg_errcode_t regcomp _RE_ARGS ((regex_t *__restrict __preg, - const char *__restrict __pattern, - int __cflags)); +extern reg_errcode_t regcomp (regex_t *__restrict __preg, + const char *__restrict __pattern, + int __cflags); -extern reg_errcode_t regexec _RE_ARGS ((const regex_t *__restrict __preg, - const char *__restrict __string, - size_t __nmatch, - regmatch_t __pmatch[__restrict_arr], - int __eflags)); +extern reg_errcode_t regexec (const regex_t *__restrict __preg, + const char *__restrict __string, size_t __nmatch, + regmatch_t __pmatch[__restrict_arr], + int __eflags); -extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg, - char *__errbuf, size_t __errbuf_size)); +extern size_t regerror (int __errcode, const regex_t * __preg, + char *__errbuf, size_t __errbuf_size); -extern void regfree _RE_ARGS ((regex_t *__preg)); +extern void regfree (regex_t *__preg); #ifdef __cplusplus diff --git a/src/sysdep.c b/src/sysdep.c index 81529fc7d9b..6d1ed3aeb86 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -52,9 +52,6 @@ along with GNU Emacs. If not, see . */ #define read sys_read #define write sys_write #include -#ifndef NULL -#define NULL 0 -#endif #endif /* not WINDOWSNT */ #include diff --git a/src/termcap.c b/src/termcap.c index 10c195eebe2..61f9d9a31ea 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -30,10 +30,6 @@ Boston, MA 02110-1301, USA. */ #include "msdos.h" #endif -#ifndef NULL -#define NULL (char *) 0 -#endif - /* BUFSIZE is the initial size allocated for the buffer for reading the termcap file. It is not a limit. @@ -661,10 +657,6 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) #ifdef TEST -#ifdef NULL -#undef NULL -#endif - #include static void diff --git a/src/textprop.c b/src/textprop.c index 688b32eb4ec..1e5e4577a00 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -23,10 +23,6 @@ along with GNU Emacs. If not, see . */ #include "buffer.h" #include "window.h" -#ifndef NULL -#define NULL (void *)0 -#endif - /* Test for membership, allowing for t (actually any non-cons) to mean the universal set. */ diff --git a/src/tparam.c b/src/tparam.c index ac21667d65b..4d26ef524fb 100644 --- a/src/tparam.c +++ b/src/tparam.c @@ -22,10 +22,6 @@ Boston, MA 02110-1301, USA. */ #include #include "lisp.h" /* for xmalloc */ #include "tparam.h" - -#ifndef NULL -#define NULL (char *) 0 -#endif /* Assuming STRING is the value of a termcap string entry containing `%' constructs to expand parameters, diff --git a/src/unexelf.c b/src/unexelf.c index ac9c9e75764..f35b53aeab3 100644 --- a/src/unexelf.c +++ b/src/unexelf.c @@ -506,11 +506,7 @@ typedef struct { #endif #ifndef ElfW -# ifdef __STDC__ -# define ElfBitsW(bits, type) Elf##bits##_##type -# else -# define ElfBitsW(bits, type) Elf/**/bits/**/_/**/type -# endif +# define ElfBitsW(bits, type) Elf##bits##_##type # ifdef _LP64 # define ELFSIZE 64 # else diff --git a/src/vm-limit.c b/src/vm-limit.c index 94725044048..c313a900f2c 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -31,7 +31,7 @@ along with GNU Emacs. If not, see . */ enum warnlevel { not_warned, warned_75, warned_85, warned_95 }; static enum warnlevel warnlevel; -typedef POINTER_TYPE *POINTER; +typedef void *POINTER; /* Function to call to issue a warning; 0 means don't issue them. */ diff --git a/src/xterm.c b/src/xterm.c index 02fa137d6a7..d030df55748 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -256,11 +256,7 @@ static Time last_user_time; /* Incremented by XTread_socket whenever it really tries to read events. */ -#ifdef __STDC__ static int volatile input_signal_count; -#else -static int input_signal_count; -#endif /* Used locally within XTread_socket. */ -- 2.39.2