diff --git a/ChangeLog b/ChangeLog index d13832b9060..f833e736e02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-03-23 Paul Eggert + + Fix more problems found by GCC 4.5.2's static checks. + * Makefile.in (GNULIB_MODULES): Add socklen. + * configure.in: Do not check for sys/socket.h, since socklen does that. + * m4/socklen.m4: New automatically-generated file, from gnulib. + + fakemail: Remove dependency on ignore-value. + * Makefile.in (GNULIB_MODULES): Add stdio. + * lib/stdio.in.h, m4/stdio_h.m4: New files, automatically + imported from gnulib. + * .bzrignore: Add lib/stdio.h. + 2011-03-22 Glenn Morris * autogen/copy_autogen: Work from ./ or ../. diff --git a/Makefile.in b/Makefile.in index 19267f82121..4dd8cff1bbc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -332,7 +332,8 @@ DOS_gnulib_comp.m4 = gl-comp.m4 # as per $(gnulib_srcdir)/DEPENDENCIES. GNULIB_MODULES = \ crypto/md5 dtoastr filemode getloadavg getopt-gnu \ - ignore-value intprops lstat mktime readlink strftime symlink sys_stat + ignore-value intprops lstat mktime readlink \ + socklen stdio strftime symlink sys_stat GNULIB_TOOL_FLAGS = \ --import --no-changelog --no-vc-files --makefile-name=gnulib.mk sync-from-gnulib: $(gnulib_srcdir) diff --git a/configure.in b/configure.in index b38aa976259..faf14fc6bb3 100644 --- a/configure.in +++ b/configure.in @@ -1265,7 +1265,6 @@ if test $emacs_cv_struct_exception != yes; then AC_DEFINE(NO_MATHERR, 1, [Define to 1 if you don't have struct exception in math.h.]) fi -AC_CHECK_HEADERS(sys/socket.h) AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT #if HAVE_SYS_SOCKET_H #include diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index bd1a84cf0b9..3df2f6881db 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,33 @@ +2011-03-23 Paul Eggert + + * ebrowse.c: Use size_t, not int, for sizes. + This avoids a warning with gcc -Wstrict-overflow, and works + better for very large objects. + (inbuffer_size): Now size_t. All uses changed. + (xmalloc, xrealloc, operator_name, process_file): Use size_t for + sizes. Don't bother testing whether a size_t value can be negative. + + * etags.c (Ada_funcs): Redo slightly to avoid overflow warning. + + etags: In Prolog functions, don't assume int fits in size_t. + This avoids a warning with gcc -Wstrict-overflow. + * etags.c (Prolog_functions, prolog_pr, prolog_atom): Use size_t, + not int, to store sizes. + (prolog_atom): Return 0, not -1, on error. All callers changed. + + update-game-score: fix bug with -r + * update-game-score.c (main): Don't set 'scores' to garbage when + -r is specified and scorecount != MAX_SCORES (Bug#8310). This bug + was introduced in the 2002-04-10 change, and was found with gcc + -Wstrict-overflow (GCC 4.5.2, x86-64). + + fakemail: Remove dependency on ignore-value. + This undoes some of the recent fakemail-related changes. + It is made possible due to recent changes to gnulib's stdio module. + * Makefile.in (fakemail${EXEEXT}): Do not depend on ignore-value.h. + * fakemail.c: Do not include ignore-value.h. + (put_line): Do not use ignore_value. + 2011-03-03 Drake Wilson (tiny change) * emacsclient.c (longopts): Add quiet. diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in index d622233efb4..f671b0844ce 100644 --- a/lib-src/Makefile.in +++ b/lib-src/Makefile.in @@ -353,7 +353,7 @@ movemail.o: ${srcdir}/movemail.c ../src/config.h pop.o: ${srcdir}/pop.c ${srcdir}/../lib/min-max.h ../src/config.h $(CC) -c ${CPP_CFLAGS} ${MOVE_FLAGS} ${srcdir}/pop.c -fakemail${EXEEXT}: ${srcdir}/fakemail.c ${srcdir}/../lib/ignore-value.h ../src/config.h +fakemail${EXEEXT}: ${srcdir}/fakemail.c ../src/config.h $(CC) ${ALL_CFLAGS} ${srcdir}/fakemail.c $(LOADLIBES) -o fakemail emacsclient${EXEEXT}: ${srcdir}/emacsclient.c ../src/config.h diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index 113b6fdfe40..7871a804997 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c @@ -378,7 +378,7 @@ int max_regexp = 50; char *inbuffer; char *in; -int inbuffer_size; +size_t inbuffer_size; /* Return the current buffer position in the input file. */ @@ -492,7 +492,7 @@ yyerror (const char *format, const char *s) available. */ static void * -xmalloc (int nbytes) +xmalloc (size_t nbytes) { void *p = malloc (nbytes); if (p == NULL) @@ -507,7 +507,7 @@ xmalloc (int nbytes) /* Like realloc but print an error and exit if out of memory. */ static void * -xrealloc (void *p, int sz) +xrealloc (void *p, size_t sz) { p = realloc (p, sz); if (p == NULL) @@ -2792,10 +2792,10 @@ parse_classname (void) static char * operator_name (int *sc) { - static int id_size = 0; + static size_t id_size = 0; static char *id = NULL; const char *s; - int len; + size_t len; MATCH (); @@ -2811,7 +2811,7 @@ operator_name (int *sc) len = strlen (s) + 10; if (len > id_size) { - int new_size = max (len, 2 * id_size); + size_t new_size = max (len, 2 * id_size); id = (char *) xrealloc (id, new_size); id_size = new_size; } @@ -2832,7 +2832,7 @@ operator_name (int *sc) } else { - int tokens_matched = 0; + size_t tokens_matched = 0; len = 20; if (len > id_size) @@ -2853,7 +2853,7 @@ operator_name (int *sc) len += strlen (s) + 2; if (len > id_size) { - int new_size = max (len, 2 * id_size); + size_t new_size = max (len, 2 * id_size); id = (char *) xrealloc (id, new_size); id_size = new_size; } @@ -3550,7 +3550,7 @@ process_file (char *file) fp = open_file (file); if (fp) { - int nread, nbytes; + size_t nread, nbytes; /* Give a progress indication if needed. */ if (f_very_verbose) @@ -3574,12 +3574,10 @@ process_file (char *file) } nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp); - if (nbytes <= 0) + if (nbytes == 0) break; nread += nbytes; } - if (nread < 0) - nread = 0; inbuffer[nread] = '\0'; /* Reinitialize scanner and parser for the new input file. */ diff --git a/lib-src/etags.c b/lib-src/etags.c index 385e4cc9721..6cb321fe75e 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -4198,7 +4198,7 @@ Ada_funcs (FILE *inf) /* Skip a string i.e. "abcd". */ if (inquote || (*dbp == '"')) { - dbp = etags_strchr ((inquote) ? dbp : dbp+1, '"'); + dbp = etags_strchr (dbp + !inquote, '"'); if (dbp != NULL) { inquote = FALSE; @@ -5254,16 +5254,16 @@ HTML_labels (FILE *inf) * Original code by Sunichirou Sugou (1989) * Rewritten by Anders Lindgren (1996) */ -static int prolog_pr (char *, char *); +static size_t prolog_pr (char *, char *); static void prolog_skip_comment (linebuffer *, FILE *); -static int prolog_atom (char *, int); +static size_t prolog_atom (char *, size_t); static void Prolog_functions (FILE *inf) { char *cp, *last; - int len; - int allocated; + size_t len; + size_t allocated; allocated = 0; len = 0; @@ -5320,16 +5320,16 @@ prolog_skip_comment (linebuffer *plb, FILE *inf) * Return the size of the name of the predicate or rule, or 0 if no * header was found. */ -static int +static size_t prolog_pr (char *s, char *last) /* Name of last clause. */ { - int pos; - int len; + size_t pos; + size_t len; pos = prolog_atom (s, 0); - if (pos < 1) + if (! pos) return 0; len = pos; @@ -5339,7 +5339,7 @@ prolog_pr (char *s, char *last) || (s[pos] == '(' && (pos += 1)) || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) && (last == NULL /* save only the first clause */ - || len != (int)strlen (last) + || len != strlen (last) || !strneq (s, last, len))) { make_tag (s, len, TRUE, s, pos, lineno, linecharno); @@ -5351,17 +5351,17 @@ prolog_pr (char *s, char *last) /* * Consume a Prolog atom. - * Return the number of bytes consumed, or -1 if there was an error. + * Return the number of bytes consumed, or 0 if there was an error. * * A prolog atom, in this context, could be one of: * - An alphanumeric sequence, starting with a lower case letter. * - A quoted arbitrary string. Single quotes can escape themselves. * Backslash quotes everything. */ -static int -prolog_atom (char *s, int pos) +static size_t +prolog_atom (char *s, size_t pos) { - int origpos; + size_t origpos; origpos = pos; @@ -5390,11 +5390,11 @@ prolog_atom (char *s, int pos) } else if (s[pos] == '\0') /* Multiline quoted atoms are ignored. */ - return -1; + return 0; else if (s[pos] == '\\') { if (s[pos+1] == '\0') - return -1; + return 0; pos += 2; } else @@ -5403,7 +5403,7 @@ prolog_atom (char *s, int pos) return pos - origpos; } else - return -1; + return 0; } diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c index 780a104b405..940d6219425 100644 --- a/lib-src/fakemail.c +++ b/lib-src/fakemail.c @@ -62,8 +62,6 @@ main () /* This is to declare cuserid. */ #include - -#include /* Type definitions */ @@ -500,7 +498,7 @@ put_line (const char *string) } } /* Output that much, then break the line. */ - ignore_value (fwrite (s, 1, breakpos - s, rem->handle)); + fwrite (s, 1, breakpos - s, rem->handle); column = 8; /* Skip whitespace and prepare to print more addresses. */ diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index 70b79a64f91..e95e2ce259d 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c @@ -242,13 +242,15 @@ main (int argc, char **argv) push_score (&scores, &scorecount, newscore, user_id, newdata); sort_scores (scores, scorecount, reverse); /* Limit the number of scores. If we're using reverse sorting, then - we should increment the beginning of the array, to skip over the - *smallest* scores. Otherwise, we just decrement the number of - scores, since the smallest will be at the end. */ + also increment the beginning of the array, to skip over the + *smallest* scores. Otherwise, just decrementing the number of + scores suffices, since the smallest is at the end. */ if (scorecount > MAX_SCORES) - scorecount -= (scorecount - MAX_SCORES); - if (reverse) - scores += (scorecount - MAX_SCORES); + { + if (reverse) + scores += (scorecount - MAX_SCORES); + scorecount = MAX_SCORES; + } if (write_scores (scorefile, scores, scorecount) < 0) { unlock_file (scorefile, lockstate); diff --git a/lib/gnulib.mk b/lib/gnulib.mk index cd6a1d00c15..030f95b7a68 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink strftime symlink sys_stat +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value intprops lstat mktime readlink socklen stdio strftime symlink sys_stat MOSTLYCLEANFILES += core *.stackdump @@ -280,6 +280,117 @@ EXTRA_DIST += stdint.in.h ## end gnulib module stdint +## begin gnulib module stdio + +BUILT_SOURCES += stdio.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ + -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ + -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ + -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ + -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \ + -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \ + -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \ + -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \ + -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \ + -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \ + -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \ + -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ + -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \ + -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ + -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ + -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \ + -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \ + -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \ + -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \ + -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \ + -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \ + -e 's|@''GNULIB_POPEN''@|$(GNULIB_POPEN)|g' \ + -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \ + -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \ + -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ + -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ + -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ + -e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \ + -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \ + -e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \ + -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ + -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ + -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ + -e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \ + -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ + -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \ + -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \ + -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \ + -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \ + -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \ + -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \ + -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \ + < $(srcdir)/stdio.in.h | \ + sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ + -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \ + -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \ + -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ + -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ + -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ + -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ + -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ + -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ + -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ + -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ + -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ + -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ + -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ + -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ + -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ + -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ + -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ + -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ + -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ + -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ + -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \ + -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ + -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ + -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ + -e 's|@''REPLACE_GETDELIM''@|$(REPLACE_GETDELIM)|g' \ + -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \ + -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \ + -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \ + -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \ + -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ + -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \ + -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \ + -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \ + -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ + -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ + -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ + -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \ + -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ + -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ + -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ + -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ + -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ + -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ + -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += stdio.h stdio.h-t + +EXTRA_DIST += stdio.in.h + +## end gnulib module stdio + ## begin gnulib module stdlib BUILT_SOURCES += stdlib.h diff --git a/lib/stdio.in.h b/lib/stdio.in.h new file mode 100644 index 00000000000..dd31ce29ed1 --- /dev/null +++ b/lib/stdio.in.h @@ -0,0 +1,1119 @@ +/* A GNU-like . + + Copyright (C) 2004, 2007-2011 Free Software Foundation, Inc. + + 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, 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. + + 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. */ + +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif +@PRAGMA_COLUMNS@ + +#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H +/* Special invocation convention: + - Inside glibc header files. + - On OSF/1 5.1 we have a sequence of nested includes + -> -> -> -> + -> -> -> . + In this situation, the functions are not yet declared, therefore we cannot + provide the C++ aliases. */ + +#@INCLUDE_NEXT@ @NEXT_STDIO_H@ + +#else +/* Normal invocation convention. */ + +#ifndef _GL_STDIO_H + +#define _GL_ALREADY_INCLUDING_STDIO_H + +/* The include_next requires a split double-inclusion guard. */ +#@INCLUDE_NEXT@ @NEXT_STDIO_H@ + +#undef _GL_ALREADY_INCLUDING_STDIO_H + +#ifndef _GL_STDIO_H +#define _GL_STDIO_H + +/* Get va_list. Needed on many systems, including glibc 2.8. */ +#include + +#include + +/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 + and eglibc 2.11.2. */ +#include + +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The __-protected variants of the attributes 'format' and 'printf' are + accepted by gcc versions 2.6.4 (effectively 2.7) and later. + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because + gnulib and libintl do '#define printf __printf__' when they override + the 'printf' function. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ +#endif +#define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ + _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) + +/* Solaris 10 declares renameat in , not in . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \ + && ! defined __GLIBC__ +# include +#endif + + +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + +/* Macros for stringification. */ +#define _GL_STDIO_STRINGIZE(token) #token +#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) + + +#if @GNULIB_DPRINTF@ +# if @REPLACE_DPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define dprintf rpl_dprintf +# endif +_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); +# else +# if !@HAVE_DPRINTF@ +_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); +# endif +_GL_CXXALIASWARN (dprintf); +#elif defined GNULIB_POSIXCHECK +# undef dprintf +# if HAVE_RAW_DECL_DPRINTF +_GL_WARN_ON_USE (dprintf, "dprintf is unportable - " + "use gnulib module dprintf for portability"); +# endif +#endif + +#if @GNULIB_FCLOSE@ +/* Close STREAM and its underlying file descriptor. */ +# if @REPLACE_FCLOSE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fclose rpl_fclose +# endif +_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); +# else +_GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); +# endif +_GL_CXXALIASWARN (fclose); +#elif defined GNULIB_POSIXCHECK +# undef fclose +/* Assume fclose is always declared. */ +_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " + "use gnulib module fclose for portable POSIX compliance"); +#endif + +#if @GNULIB_FFLUSH@ +/* Flush all pending data on STREAM according to POSIX rules. Both + output and seekable input streams are supported. + Note! LOSS OF DATA can occur if fflush is applied on an input stream + that is _not_seekable_ or on an update stream that is _not_seekable_ + and in which the most recent operation was input. Seekability can + be tested with lseek(fileno(fp),0,SEEK_CUR). */ +# if @REPLACE_FFLUSH@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fflush rpl_fflush +# endif +_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); +_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); +# else +_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); +# endif +_GL_CXXALIASWARN (fflush); +#elif defined GNULIB_POSIXCHECK +# undef fflush +/* Assume fflush is always declared. */ +_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " + "use gnulib module fflush for portable POSIX compliance"); +#endif + +/* It is very rare that the developer ever has full control of stdin, + so any use of gets warrants an unconditional warning. Assume it is + always declared, since it is required by C89. */ +#undef gets +_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); + +#if @GNULIB_FOPEN@ +# if @REPLACE_FOPEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fopen +# define fopen rpl_fopen +# endif +_GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); +# else +_GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); +# endif +_GL_CXXALIASWARN (fopen); +#elif defined GNULIB_POSIXCHECK +# undef fopen +/* Assume fopen is always declared. */ +_GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - " + "use gnulib module fopen for portability"); +#endif + +#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ +# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ + || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fprintf rpl_fprintf +# endif +# define GNULIB_overrides_fprintf 1 +_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); +# else +_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); +# endif +_GL_CXXALIASWARN (fprintf); +#endif +#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK +# if !GNULIB_overrides_fprintf +# undef fprintf +# endif +/* Assume fprintf is always declared. */ +_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " + "use gnulib module fprintf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_FPURGE@ +/* Discard all pending buffered I/O data on STREAM. + STREAM must not be wide-character oriented. + When discarding pending output, the file position is set back to where it + was before the write calls. When discarding pending input, the file + position is advanced to match the end of the previously read input. + Return 0 if successful. Upon error, return -1 and set errno. */ +# if @REPLACE_FPURGE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define fpurge rpl_fpurge +# endif +_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); +# else +# if !@HAVE_DECL_FPURGE@ +_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); +# endif +_GL_CXXALIASWARN (fpurge); +#elif defined GNULIB_POSIXCHECK +# undef fpurge +# if HAVE_RAW_DECL_FPURGE +_GL_WARN_ON_USE (fpurge, "fpurge is not always present - " + "use gnulib module fpurge for portability"); +# endif +#endif + +#if @GNULIB_FPUTC@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fputc +# define fputc rpl_fputc +# endif +_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); +# else +_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); +# endif +_GL_CXXALIASWARN (fputc); +#endif + +#if @GNULIB_FPUTS@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fputs +# define fputs rpl_fputs +# endif +_GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); +# else +_GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); +# endif +_GL_CXXALIASWARN (fputs); +#endif + +#if @GNULIB_FREOPEN@ +# if @REPLACE_FREOPEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef freopen +# define freopen rpl_freopen +# endif +_GL_FUNCDECL_RPL (freopen, FILE *, + (const char *filename, const char *mode, FILE *stream) + _GL_ARG_NONNULL ((2, 3))); +_GL_CXXALIAS_RPL (freopen, FILE *, + (const char *filename, const char *mode, FILE *stream)); +# else +_GL_CXXALIAS_SYS (freopen, FILE *, + (const char *filename, const char *mode, FILE *stream)); +# endif +_GL_CXXALIASWARN (freopen); +#elif defined GNULIB_POSIXCHECK +# undef freopen +/* Assume freopen is always declared. */ +_GL_WARN_ON_USE (freopen, + "freopen on Win32 platforms is not POSIX compatible - " + "use gnulib module freopen for portability"); +#endif + + +/* Set up the following warnings, based on which modules are in use. + GNU Coding Standards discourage the use of fseek, since it imposes + an arbitrary limitation on some 32-bit hosts. Remember that the + fseek module depends on the fseeko module, so we only have three + cases to consider: + + 1. The developer is not using either module. Issue a warning under + GNULIB_POSIXCHECK for both functions, to remind them that both + functions have bugs on some systems. _GL_NO_LARGE_FILES has no + impact on this warning. + + 2. The developer is using both modules. They may be unaware of the + arbitrary limitations of fseek, so issue a warning under + GNULIB_POSIXCHECK. On the other hand, they may be using both + modules intentionally, so the developer can define + _GL_NO_LARGE_FILES in the compilation units where the use of fseek + is safe, to silence the warning. + + 3. The developer is using the fseeko module, but not fseek. Gnulib + guarantees that fseek will still work around platform bugs in that + case, but we presume that the developer is aware of the pitfalls of + fseek and was trying to avoid it, so issue a warning even when + GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be + defined to silence the warning in particular compilation units. + In C++ compilations with GNULIB_NAMESPACE, in order to avoid that + fseek gets defined as a macro, it is recommended that the developer + uses the fseek module, even if he is not calling the fseek function. + + Most gnulib clients that perform stream operations should fall into + category 3. */ + +#if @GNULIB_FSEEK@ +# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES +# define _GL_FSEEK_WARN /* Category 2, above. */ +# undef fseek +# endif +# if @REPLACE_FSEEK@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fseek +# define fseek rpl_fseek +# endif +_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); +# else +_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); +# endif +_GL_CXXALIASWARN (fseek); +#endif + +#if @GNULIB_FSEEKO@ +# if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES +# define _GL_FSEEK_WARN /* Category 3, above. */ +# undef fseek +# endif +# if @REPLACE_FSEEKO@ +/* Provide an fseeko function that is aware of a preceding fflush(), and which + detects pipes. */ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fseeko +# define fseeko rpl_fseeko +# endif +_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); +# else +# if ! @HAVE_DECL_FSEEKO@ +_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); +# endif +_GL_CXXALIASWARN (fseeko); +# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@ + /* Provide an fseek function that is consistent with fseeko. */ + /* In order to avoid that fseek gets defined as a macro here, the + developer can request the 'fseek' module. */ +# if !GNULIB_defined_fseek_function +# undef fseek +# define fseek rpl_fseek +static inline int _GL_ARG_NONNULL ((1)) +rpl_fseek (FILE *fp, long offset, int whence) +{ +# if @REPLACE_FSEEKO@ + return rpl_fseeko (fp, offset, whence); +# else + return fseeko (fp, offset, whence); +# endif +} +# define GNULIB_defined_fseek_function 1 +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# define _GL_FSEEK_WARN /* Category 1, above. */ +# undef fseek +# undef fseeko +# if HAVE_RAW_DECL_FSEEKO +_GL_WARN_ON_USE (fseeko, "fseeko is unportable - " + "use gnulib module fseeko for portability"); +# endif +#endif + +#ifdef _GL_FSEEK_WARN +# undef _GL_FSEEK_WARN +/* Here, either fseek is undefined (but C89 guarantees that it is + declared), or it is defined as rpl_fseek (declared above). */ +_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " + "on 32-bit platforms - " + "use fseeko function for handling of large files"); +#endif + + +/* ftell, ftello. See the comments on fseek/fseeko. */ + +#if @GNULIB_FTELL@ +# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES +# define _GL_FTELL_WARN /* Category 2, above. */ +# undef ftell +# endif +# if @REPLACE_FTELL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ftell +# define ftell rpl_ftell +# endif +_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); +# else +_GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); +# endif +_GL_CXXALIASWARN (ftell); +#endif + +#if @GNULIB_FTELLO@ +# if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES +# define _GL_FTELL_WARN /* Category 3, above. */ +# undef ftell +# endif +# if @REPLACE_FTELLO@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ftello +# define ftello rpl_ftello +# endif +_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); +# else +# if ! @HAVE_DECL_FTELLO@ +_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); +# endif +_GL_CXXALIASWARN (ftello); +# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@ + /* Provide an ftell function that is consistent with ftello. */ + /* In order to avoid that ftell gets defined as a macro here, the + developer can request the 'ftell' module. */ +# if !GNULIB_defined_ftell_function +# undef ftell +# define ftell rpl_ftell +static inline long _GL_ARG_NONNULL ((1)) +rpl_ftell (FILE *f) +{ +# if @REPLACE_FTELLO@ + return rpl_ftello (f); +# else + return ftello (f); +# endif +} +# define GNULIB_defined_ftell_function 1 +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# define _GL_FTELL_WARN /* Category 1, above. */ +# undef ftell +# undef ftello +# if HAVE_RAW_DECL_FTELLO +_GL_WARN_ON_USE (ftello, "ftello is unportable - " + "use gnulib module ftello for portability"); +# endif +#endif + +#ifdef _GL_FTELL_WARN +# undef _GL_FTELL_WARN +/* Here, either ftell is undefined (but C89 guarantees that it is + declared), or it is defined as rpl_ftell (declared above). */ +_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " + "on 32-bit platforms - " + "use ftello function for handling of large files"); +#endif + + +#if @GNULIB_FWRITE@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fwrite +# define fwrite rpl_fwrite +# endif +_GL_FUNCDECL_RPL (fwrite, size_t, + (const void *ptr, size_t s, size_t n, FILE *stream) + _GL_ARG_NONNULL ((1, 4))); +_GL_CXXALIAS_RPL (fwrite, size_t, + (const void *ptr, size_t s, size_t n, FILE *stream)); +# else +_GL_CXXALIAS_SYS (fwrite, size_t, + (const void *ptr, size_t s, size_t n, FILE *stream)); + +/* Work around glibc bug 11959 + , + which sometimes causes an unwanted diagnostic for fwrite calls. + This affects only function declaration attributes, so it's not + needed for C++. */ +# if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL +static inline size_t _GL_ARG_NONNULL ((1, 4)) +rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream) +{ + size_t r = fwrite (ptr, s, n, stream); + (void) r; + return r; +} +# undef fwrite +# define fwrite rpl_fwrite +# endif +# endif +_GL_CXXALIASWARN (fwrite); +#endif + +#if @GNULIB_GETDELIM@ +/* Read input, up to (and including) the next occurrence of DELIMITER, from + STREAM, store it in *LINEPTR (and NUL-terminate it). + *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE + bytes of space. It is realloc'd as necessary. + Return the number of bytes read and stored at *LINEPTR (not including the + NUL terminator), or -1 on error or EOF. */ +# if @REPLACE_GETDELIM@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getdelim +# define getdelim rpl_getdelim +# endif +_GL_FUNCDECL_RPL (getdelim, ssize_t, + (char **lineptr, size_t *linesize, int delimiter, + FILE *stream) + _GL_ARG_NONNULL ((1, 2, 4))); +_GL_CXXALIAS_RPL (getdelim, ssize_t, + (char **lineptr, size_t *linesize, int delimiter, + FILE *stream)); +# else +# if !@HAVE_DECL_GETDELIM@ +_GL_FUNCDECL_SYS (getdelim, ssize_t, + (char **lineptr, size_t *linesize, int delimiter, + FILE *stream) + _GL_ARG_NONNULL ((1, 2, 4))); +# endif +_GL_CXXALIAS_SYS (getdelim, ssize_t, + (char **lineptr, size_t *linesize, int delimiter, + FILE *stream)); +# endif +_GL_CXXALIASWARN (getdelim); +#elif defined GNULIB_POSIXCHECK +# undef getdelim +# if HAVE_RAW_DECL_GETDELIM +_GL_WARN_ON_USE (getdelim, "getdelim is unportable - " + "use gnulib module getdelim for portability"); +# endif +#endif + +#if @GNULIB_GETLINE@ +/* Read a line, up to (and including) the next newline, from STREAM, store it + in *LINEPTR (and NUL-terminate it). + *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE + bytes of space. It is realloc'd as necessary. + Return the number of bytes read and stored at *LINEPTR (not including the + NUL terminator), or -1 on error or EOF. */ +# if @REPLACE_GETLINE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getline +# define getline rpl_getline +# endif +_GL_FUNCDECL_RPL (getline, ssize_t, + (char **lineptr, size_t *linesize, FILE *stream) + _GL_ARG_NONNULL ((1, 2, 3))); +_GL_CXXALIAS_RPL (getline, ssize_t, + (char **lineptr, size_t *linesize, FILE *stream)); +# else +# if !@HAVE_DECL_GETLINE@ +_GL_FUNCDECL_SYS (getline, ssize_t, + (char **lineptr, size_t *linesize, FILE *stream) + _GL_ARG_NONNULL ((1, 2, 3))); +# endif +_GL_CXXALIAS_SYS (getline, ssize_t, + (char **lineptr, size_t *linesize, FILE *stream)); +# endif +# if @HAVE_DECL_GETLINE@ +_GL_CXXALIASWARN (getline); +# endif +#elif defined GNULIB_POSIXCHECK +# undef getline +# if HAVE_RAW_DECL_GETLINE +_GL_WARN_ON_USE (getline, "getline is unportable - " + "use gnulib module getline for portability"); +# endif +#endif + +#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ +struct obstack; +/* Grow an obstack with formatted output. Return the number of + bytes added to OBS. No trailing nul byte is added, and the + object should be closed with obstack_finish before use. Upon + memory allocation error, call obstack_alloc_failed_handler. Upon + other error, return -1. */ +# if @REPLACE_OBSTACK_PRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define obstack_printf rpl_obstack_printf +# endif +_GL_FUNCDECL_RPL (obstack_printf, int, + (struct obstack *obs, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (obstack_printf, int, + (struct obstack *obs, const char *format, ...)); +# else +# if !@HAVE_DECL_OBSTACK_PRINTF@ +_GL_FUNCDECL_SYS (obstack_printf, int, + (struct obstack *obs, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (obstack_printf, int, + (struct obstack *obs, const char *format, ...)); +# endif +_GL_CXXALIASWARN (obstack_printf); +# if @REPLACE_OBSTACK_PRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define obstack_vprintf rpl_obstack_vprintf +# endif +_GL_FUNCDECL_RPL (obstack_vprintf, int, + (struct obstack *obs, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (obstack_vprintf, int, + (struct obstack *obs, const char *format, va_list args)); +# else +# if !@HAVE_DECL_OBSTACK_PRINTF@ +_GL_FUNCDECL_SYS (obstack_vprintf, int, + (struct obstack *obs, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (obstack_vprintf, int, + (struct obstack *obs, const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (obstack_vprintf); +#endif + +#if @GNULIB_PERROR@ +/* Print a message to standard error, describing the value of ERRNO, + (if STRING is not NULL and not empty) prefixed with STRING and ": ", + and terminated with a newline. */ +# if @REPLACE_PERROR@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define perror rpl_perror +# endif +_GL_FUNCDECL_RPL (perror, void, (const char *string)); +_GL_CXXALIAS_RPL (perror, void, (const char *string)); +# else +_GL_CXXALIAS_SYS (perror, void, (const char *string)); +# endif +_GL_CXXALIASWARN (perror); +#elif defined GNULIB_POSIXCHECK +# undef perror +/* Assume perror is always declared. */ +_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " + "use gnulib module perror for portability"); +#endif + +#if @GNULIB_POPEN@ +# if @REPLACE_POPEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef popen +# define popen rpl_popen +# endif +_GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); +# else +_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); +# endif +_GL_CXXALIASWARN (popen); +#elif defined GNULIB_POSIXCHECK +# undef popen +# if HAVE_RAW_DECL_POPEN +_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " + "use gnulib module popen or pipe for more portability"); +# endif +#endif + +#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ +# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ + || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) +# if defined __GNUC__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +/* Don't break __attribute__((format(printf,M,N))). */ +# define printf __printf__ +# endif +_GL_FUNCDECL_RPL_1 (__printf__, int, + (const char *format, ...) + __asm__ (@ASM_SYMBOL_PREFIX@ + _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) + _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); +# else +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define printf rpl_printf +# endif +_GL_FUNCDECL_RPL (printf, int, + (const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); +# endif +# define GNULIB_overrides_printf 1 +# else +_GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); +# endif +_GL_CXXALIASWARN (printf); +#endif +#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK +# if !GNULIB_overrides_printf +# undef printf +# endif +/* Assume printf is always declared. */ +_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " + "use gnulib module printf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_PUTC@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putc +# define putc rpl_fputc +# endif +_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); +# else +_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); +# endif +_GL_CXXALIASWARN (putc); +#endif + +#if @GNULIB_PUTCHAR@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef putchar +# define putchar rpl_putchar +# endif +_GL_FUNCDECL_RPL (putchar, int, (int c)); +_GL_CXXALIAS_RPL (putchar, int, (int c)); +# else +_GL_CXXALIAS_SYS (putchar, int, (int c)); +# endif +_GL_CXXALIASWARN (putchar); +#endif + +#if @GNULIB_PUTS@ +# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef puts +# define puts rpl_puts +# endif +_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (puts, int, (const char *string)); +# else +_GL_CXXALIAS_SYS (puts, int, (const char *string)); +# endif +_GL_CXXALIASWARN (puts); +#endif + +#if @GNULIB_REMOVE@ +# if @REPLACE_REMOVE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef remove +# define remove rpl_remove +# endif +_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (remove, int, (const char *name)); +# else +_GL_CXXALIAS_SYS (remove, int, (const char *name)); +# endif +_GL_CXXALIASWARN (remove); +#elif defined GNULIB_POSIXCHECK +# undef remove +/* Assume remove is always declared. */ +_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " + "use gnulib module remove for more portability"); +#endif + +#if @GNULIB_RENAME@ +# if @REPLACE_RENAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef rename +# define rename rpl_rename +# endif +_GL_FUNCDECL_RPL (rename, int, + (const char *old_filename, const char *new_filename) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (rename, int, + (const char *old_filename, const char *new_filename)); +# else +_GL_CXXALIAS_SYS (rename, int, + (const char *old_filename, const char *new_filename)); +# endif +_GL_CXXALIASWARN (rename); +#elif defined GNULIB_POSIXCHECK +# undef rename +/* Assume rename is always declared. */ +_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " + "use gnulib module rename for more portability"); +#endif + +#if @GNULIB_RENAMEAT@ +# if @REPLACE_RENAMEAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef renameat +# define renameat rpl_renameat +# endif +_GL_FUNCDECL_RPL (renameat, int, + (int fd1, char const *file1, int fd2, char const *file2) + _GL_ARG_NONNULL ((2, 4))); +_GL_CXXALIAS_RPL (renameat, int, + (int fd1, char const *file1, int fd2, char const *file2)); +# else +# if !@HAVE_RENAMEAT@ +_GL_FUNCDECL_SYS (renameat, int, + (int fd1, char const *file1, int fd2, char const *file2) + _GL_ARG_NONNULL ((2, 4))); +# endif +_GL_CXXALIAS_SYS (renameat, int, + (int fd1, char const *file1, int fd2, char const *file2)); +# endif +_GL_CXXALIASWARN (renameat); +#elif defined GNULIB_POSIXCHECK +# undef renameat +# if HAVE_RAW_DECL_RENAMEAT +_GL_WARN_ON_USE (renameat, "renameat is not portable - " + "use gnulib module renameat for portability"); +# endif +#endif + +#if @GNULIB_SNPRINTF@ +# if @REPLACE_SNPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define snprintf rpl_snprintf +# endif +_GL_FUNCDECL_RPL (snprintf, int, + (char *str, size_t size, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) + _GL_ARG_NONNULL ((3))); +_GL_CXXALIAS_RPL (snprintf, int, + (char *str, size_t size, const char *format, ...)); +# else +# if !@HAVE_DECL_SNPRINTF@ +_GL_FUNCDECL_SYS (snprintf, int, + (char *str, size_t size, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) + _GL_ARG_NONNULL ((3))); +# endif +_GL_CXXALIAS_SYS (snprintf, int, + (char *str, size_t size, const char *format, ...)); +# endif +_GL_CXXALIASWARN (snprintf); +#elif defined GNULIB_POSIXCHECK +# undef snprintf +# if HAVE_RAW_DECL_SNPRINTF +_GL_WARN_ON_USE (snprintf, "snprintf is unportable - " + "use gnulib module snprintf for portability"); +# endif +#endif + +/* Some people would argue that sprintf should be handled like gets + (for example, OpenBSD issues a link warning for both functions), + since both can cause security holes due to buffer overruns. + However, we believe that sprintf can be used safely, and is more + efficient than snprintf in those safe cases; and as proof of our + belief, we use sprintf in several gnulib modules. So this header + intentionally avoids adding a warning to sprintf except when + GNULIB_POSIXCHECK is defined. */ + +#if @GNULIB_SPRINTF_POSIX@ +# if @REPLACE_SPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define sprintf rpl_sprintf +# endif +_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); +# else +_GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); +# endif +_GL_CXXALIASWARN (sprintf); +#elif defined GNULIB_POSIXCHECK +# undef sprintf +/* Assume sprintf is always declared. */ +_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " + "use gnulib module sprintf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_TMPFILE@ +# if @REPLACE_TMPFILE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define tmpfile rpl_tmpfile +# endif +_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); +_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); +# else +_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); +# endif +_GL_CXXALIASWARN (tmpfile); +#elif defined GNULIB_POSIXCHECK +# undef tmpfile +# if HAVE_RAW_DECL_TMPFILE +_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " + "use gnulib module tmpfile for portability"); +# endif +#endif + +#if @GNULIB_VASPRINTF@ +/* Write formatted output to a string dynamically allocated with malloc(). + If the memory allocation succeeds, store the address of the string in + *RESULT and return the number of resulting bytes, excluding the trailing + NUL. Upon memory allocation error, or some other error, return -1. */ +# if @REPLACE_VASPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define asprintf rpl_asprintf +# endif +_GL_FUNCDECL_RPL (asprintf, int, + (char **result, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (asprintf, int, + (char **result, const char *format, ...)); +# else +# if !@HAVE_VASPRINTF@ +_GL_FUNCDECL_SYS (asprintf, int, + (char **result, const char *format, ...) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (asprintf, int, + (char **result, const char *format, ...)); +# endif +_GL_CXXALIASWARN (asprintf); +# if @REPLACE_VASPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vasprintf rpl_vasprintf +# endif +_GL_FUNCDECL_RPL (vasprintf, int, + (char **result, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (vasprintf, int, + (char **result, const char *format, va_list args)); +# else +# if !@HAVE_VASPRINTF@ +_GL_FUNCDECL_SYS (vasprintf, int, + (char **result, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) + _GL_ARG_NONNULL ((1, 2))); +# endif +_GL_CXXALIAS_SYS (vasprintf, int, + (char **result, const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (vasprintf); +#endif + +#if @GNULIB_VDPRINTF@ +# if @REPLACE_VDPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vdprintf rpl_vdprintf +# endif +_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); +# else +# if !@HAVE_VDPRINTF@ +_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) + _GL_ARG_NONNULL ((2))); +# endif +/* Need to cast, because on Solaris, the third parameter will likely be + __va_list args. */ +_GL_CXXALIAS_SYS_CAST (vdprintf, int, + (int fd, const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (vdprintf); +#elif defined GNULIB_POSIXCHECK +# undef vdprintf +# if HAVE_RAW_DECL_VDPRINTF +_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " + "use gnulib module vdprintf for portability"); +# endif +#endif + +#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ +# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ + || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vfprintf rpl_vfprintf +# endif +# define GNULIB_overrides_vfprintf 1 +_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); +# else +/* Need to cast, because on Solaris, the third parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vfprintf, int, + (FILE *fp, const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (vfprintf); +#endif +#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK +# if !GNULIB_overrides_vfprintf +# undef vfprintf +# endif +/* Assume vfprintf is always declared. */ +_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " + "use gnulib module vfprintf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ +# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ + || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vprintf rpl_vprintf +# endif +# define GNULIB_overrides_vprintf 1 +_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); +# else +/* Need to cast, because on Solaris, the second parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (vprintf); +#endif +#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK +# if !GNULIB_overrides_vprintf +# undef vprintf +# endif +/* Assume vprintf is always declared. */ +_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " + "use gnulib module vprintf-posix for portable " + "POSIX compliance"); +#endif + +#if @GNULIB_VSNPRINTF@ +# if @REPLACE_VSNPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vsnprintf rpl_vsnprintf +# endif +_GL_FUNCDECL_RPL (vsnprintf, int, + (char *str, size_t size, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) + _GL_ARG_NONNULL ((3))); +_GL_CXXALIAS_RPL (vsnprintf, int, + (char *str, size_t size, const char *format, va_list args)); +# else +# if !@HAVE_DECL_VSNPRINTF@ +_GL_FUNCDECL_SYS (vsnprintf, int, + (char *str, size_t size, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) + _GL_ARG_NONNULL ((3))); +# endif +_GL_CXXALIAS_SYS (vsnprintf, int, + (char *str, size_t size, const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (vsnprintf); +#elif defined GNULIB_POSIXCHECK +# undef vsnprintf +# if HAVE_RAW_DECL_VSNPRINTF +_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " + "use gnulib module vsnprintf for portability"); +# endif +#endif + +#if @GNULIB_VSPRINTF_POSIX@ +# if @REPLACE_VSPRINTF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define vsprintf rpl_vsprintf +# endif +_GL_FUNCDECL_RPL (vsprintf, int, + (char *str, const char *format, va_list args) + _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (vsprintf, int, + (char *str, const char *format, va_list args)); +# else +/* Need to cast, because on Solaris, the third parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vsprintf, int, + (char *str, const char *format, va_list args)); +# endif +_GL_CXXALIASWARN (vsprintf); +#elif defined GNULIB_POSIXCHECK +# undef vsprintf +/* Assume vsprintf is always declared. */ +_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " + "use gnulib module vsprintf-posix for portable " + "POSIX compliance"); +#endif + + +#endif /* _GL_STDIO_H */ +#endif /* _GL_STDIO_H */ +#endif diff --git a/lib/strftime.c b/lib/strftime.c index 0a02b507744..acebc9adfad 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -172,15 +172,16 @@ extern char *tzname[]; #define add(n, f) \ do \ { \ - int _n = (n); \ - int _delta = width - _n; \ - int _incr = _n + (_delta > 0 ? _delta : 0); \ - if ((size_t) _incr >= maxsize - i) \ + size_t _n = (n); \ + size_t _w = (width < 0 ? 0 : width); \ + size_t _incr = _n < _w ? _w : _n; \ + if (_incr >= maxsize - i) \ return 0; \ if (p) \ { \ - if (digits == 0 && _delta > 0) \ + if (digits == 0 && _n < _w) \ { \ + size_t _delta = width - _n; \ if (pad == L_('0')) \ memset_zero (p, _delta); \ else \ diff --git a/m4/gl-comp.m4 b/m4/gl-comp.m4 index 8bf5a64a5f9..af3cae75abb 100644 --- a/m4/gl-comp.m4 +++ b/m4/gl-comp.m4 @@ -45,10 +45,12 @@ AC_DEFUN([gl_EARLY], # Code from module mktime: # Code from module multiarch: # Code from module readlink: + # Code from module socklen: # Code from module stat: # Code from module stdbool: # Code from module stddef: # Code from module stdint: + # Code from module stdio: # Code from module stdlib: # Code from module strftime: # Code from module symlink: @@ -111,6 +113,8 @@ AC_DEFUN([gl_INIT], # Code from module readlink: gl_FUNC_READLINK gl_UNISTD_MODULE_INDICATOR([readlink]) + # Code from module socklen: + gl_TYPE_SOCKLEN_T # Code from module stat: gl_FUNC_STAT gl_SYS_STAT_MODULE_INDICATOR([stat]) @@ -120,6 +124,8 @@ AC_DEFUN([gl_INIT], gl_STDDEF_H # Code from module stdint: gl_STDINT_H + # Code from module stdio: + gl_STDIO_H # Code from module stdlib: gl_STDLIB_H # Code from module strftime: @@ -305,6 +311,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/stdbool.in.h lib/stddef.in.h lib/stdint.in.h + lib/stdio.in.h lib/stdlib.in.h lib/strftime.c lib/strftime.h @@ -327,11 +334,13 @@ AC_DEFUN([gl_FILE_LIST], [ m4/mktime.m4 m4/multiarch.m4 m4/readlink.m4 + m4/socklen.m4 m4/st_dm_mode.m4 m4/stat.m4 m4/stdbool.m4 m4/stddef_h.m4 m4/stdint.m4 + m4/stdio_h.m4 m4/stdlib_h.m4 m4/strftime.m4 m4/symlink.m4 diff --git a/m4/socklen.m4 b/m4/socklen.m4 new file mode 100644 index 00000000000..44751544485 --- /dev/null +++ b/m4/socklen.m4 @@ -0,0 +1,77 @@ +# socklen.m4 serial 10 +dnl Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Albert Chin, Windows fixes from Simon Josefsson. + +dnl Check for socklen_t: historically on BSD it is an int, and in +dnl POSIX 1g it is a type of its own, but some platforms use different +dnl types for the argument to getsockopt, getpeername, etc.: +dnl HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS. +dnl So we have to test to find something that will work. + +AC_DEFUN([gl_TYPE_SOCKLEN_T], + [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl + AC_CHECK_TYPE([socklen_t], , + [AC_MSG_CHECKING([for socklen_t equivalent]) + AC_CACHE_VAL([gl_cv_socklen_t_equiv], + [# Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + gl_cv_socklen_t_equiv= + for arg2 in "struct sockaddr" void; do + for t in int size_t "unsigned int" "long int" "unsigned long int"; do + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[#include + #include + + int getpeername (int, $arg2 *, $t *);]], + [[$t len; + getpeername (0, 0, &len);]])], + [gl_cv_socklen_t_equiv="$t"]) + test "$gl_cv_socklen_t_equiv" != "" && break + done + test "$gl_cv_socklen_t_equiv" != "" && break + done + ]) + if test "$gl_cv_socklen_t_equiv" = ""; then + AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) + fi + AC_MSG_RESULT([$gl_cv_socklen_t_equiv]) + AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], + [type to use in place of socklen_t if not defined])], + [gl_SOCKET_HEADERS])]) + +dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find +dnl it there too. But on Cygwin, wc2tcpip.h must not be included. Users +dnl of this module should use the same include pattern as gl_SOCKET_HEADERS. +dnl When you change this macro, keep also in sync: +dnl - gl_CHECK_SOCKET_HEADERS, +dnl - the Include section of modules/socklen. +AC_DEFUN([gl_SOCKET_HEADERS], +[ +/* is not needed according to POSIX, but the + in i386-unknown-freebsd4.10 and + powerpc-apple-darwin5.5 required it. */ +#include +#if HAVE_SYS_SOCKET_H +# include +#elif HAVE_WS2TCPIP_H +# include +#endif +]) + +dnl Tests for the existence of the header for socket facilities. +dnl Defines the C macros HAVE_SYS_SOCKET_H, HAVE_WS2TCPIP_H. +dnl This macro must match gl_SOCKET_HEADERS. +AC_DEFUN([gl_CHECK_SOCKET_HEADERS], + [AC_CHECK_HEADERS_ONCE([sys/socket.h]) + if test $ac_cv_header_sys_socket_h = no; then + dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make + dnl the check for those headers unconditional; yet cygwin reports + dnl that the headers are present but cannot be compiled (since on + dnl cygwin, all socket information should come from sys/socket.h). + AC_CHECK_HEADERS([ws2tcpip.h]) + fi + ]) diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 new file mode 100644 index 00000000000..7f3ae56295f --- /dev/null +++ b/m4/stdio_h.m4 @@ -0,0 +1,140 @@ +# stdio_h.m4 serial 33 +dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_STDIO_H], +[ + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + AC_REQUIRE([AC_C_INLINE]) + gl_NEXT_HEADERS([stdio.h]) + dnl No need to create extra modules for these functions. Everyone who uses + dnl likely needs them. + GNULIB_FPRINTF=1 + GNULIB_PRINTF=1 + GNULIB_VFPRINTF=1 + GNULIB_VPRINTF=1 + GNULIB_FPUTC=1 + GNULIB_PUTC=1 + GNULIB_PUTCHAR=1 + GNULIB_FPUTS=1 + GNULIB_PUTS=1 + GNULIB_FWRITE=1 + dnl This ifdef is just an optimization, to avoid performing a configure + dnl check whose result is not used. It does not make the test of + dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant. + m4_ifdef([gl_SIGNAL_SIGPIPE], [ + gl_SIGNAL_SIGPIPE + if test $gl_cv_header_signal_h_SIGPIPE != yes; then + REPLACE_STDIO_WRITE_FUNCS=1 + AC_LIBOBJ([stdio-write]) + fi + ]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use, and which is not + dnl guaranteed by C89. + gl_WARN_ON_USE_PREPARE([[#include + ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat + snprintf tmpfile vdprintf vsnprintf]) +]) + +AC_DEFUN([gl_STDIO_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) + dnl Define it also as a C macro, for the benefit of the unit tests. + gl_MODULE_INDICATOR_FOR_TESTS([$1]) +]) + +AC_DEFUN([gl_STDIO_H_DEFAULTS], +[ + GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF]) + GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE]) + GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH]) + GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN]) + GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF]) + GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX]) + GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE]) + GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC]) + GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS]) + GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN]) + GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK]) + GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO]) + GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL]) + GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO]) + GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE]) + GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM]) + GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE]) + GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF]) + GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX]) + GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR]) + GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN]) + GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF]) + GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX]) + GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC]) + GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR]) + GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS]) + GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE]) + GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME]) + GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT]) + GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF]) + GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX]) + GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE]) + GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE]) + GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF]) + GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF]) + GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF]) + GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX]) + GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF]) + GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX]) + GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF]) + GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) + HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO]) + HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO]) + HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM]) + HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE]) + HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF]) + HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF]) + HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF]) + HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF]) + HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO]) + HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO]) + HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT]) + HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF]) + HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF]) + REPLACE_DPRINTF=0; AC_SUBST([REPLACE_DPRINTF]) + REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE]) + REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) + REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) + REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) + REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) + REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) + REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK]) + REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO]) + REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL]) + REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO]) + REPLACE_GETDELIM=0; AC_SUBST([REPLACE_GETDELIM]) + REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE]) + REPLACE_OBSTACK_PRINTF=0; AC_SUBST([REPLACE_OBSTACK_PRINTF]) + REPLACE_PERROR=0; AC_SUBST([REPLACE_PERROR]) + REPLACE_POPEN=0; AC_SUBST([REPLACE_POPEN]) + REPLACE_PRINTF=0; AC_SUBST([REPLACE_PRINTF]) + REPLACE_REMOVE=0; AC_SUBST([REPLACE_REMOVE]) + REPLACE_RENAME=0; AC_SUBST([REPLACE_RENAME]) + REPLACE_RENAMEAT=0; AC_SUBST([REPLACE_RENAMEAT]) + REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF]) + REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF]) + REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS]) + REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE]) + REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF]) + REPLACE_VDPRINTF=0; AC_SUBST([REPLACE_VDPRINTF]) + REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF]) + REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF]) + REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF]) + REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF]) +]) diff --git a/src/ChangeLog b/src/ChangeLog index f489a233683..a4312efceb9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,130 @@ +2011-03-23 Paul Eggert + + Fix more problems found by GCC 4.5.2's static checks. + + * coding.c (encode_coding_raw_text): Avoid unnecessary test + the first time through the loop, since we know p0 < p1 then. + This also avoids a gcc -Wstrict-overflow warning. + + * lisp.h (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Avoid 'int' overflow + leading to a memory leak, possible in functions like + load_charset_map_from_file that can allocate an unbounded number + of objects (Bug#8318). + + * xmenu.c (set_frame_menubar): Use EMACS_UINT, not int, for indexes + that could (at least in theory) be that large. + + * xdisp.c (message_log_check_duplicate): Return unsigned long, not int. + This is less likely to overflow, and avoids undefined behavior if + overflow does occur. All callers changed. Use strtoul to scan + for the unsigned long integer. + (pint2hrstr): Simplify and tune code slightly. + This also avoids a (bogus) GCC warning with gcc -Wstrict-overflow. + + * scroll.c (do_scrolling): Work around GCC bug 48228. + See . + + * frame.c (Fmodify_frame_parameters): Simplify loop counter. + This also avoids a warning with gcc -Wstrict-overflow. + (validate_x_resource_name): Simplify count usage. + This also avoids a warning with gcc -Wstrict-overflow. + + * fileio.c (Fcopy_file): Report error if fchown or fchmod + fail (Bug#8306). + + * emacs.c (Fdaemon_initialized): Do not ignore I/O errors (Bug#8303). + + * process.c (Fmake_network_process): Use socklen_t, not int, + where POSIX says socklen_t is required in portable programs. + This fixes a porting bug on hosts like 64-bit HP-UX, where + socklen_t is wider than int (Bug#8277). + (Fmake_network_process, server_accept_connection): + (wait_reading_process_output, read_process_output): + Likewise. + + * process.c: Rename or move locals to avoid shadowing. + (list_processes_1, Fmake_network_process): + (read_process_output_error_handler, exec_sentinel_error_handler): + Rename or move locals. + (Fmake_network_process): Define label "retry_connect" only if needed. + (Fnetwork_interface_info): Fix pointer signedness. + (process_send_signal): Add cast to avoid pointer signedness problem. + (FIRST_PROC_DESC, IF_NON_BLOCKING_CONNECT): Remove unused macros. + (create_process): Use 'volatile' to avoid vfork clobbering (Bug#8298). + + Make tparam.h and terminfo.c consistent. + * cm.c (tputs, tgoto, BC, UP): Remove extern decls. Include + tparam.h instead, since it declares them. + * cm.h (PC): Remove extern decl; tparam.h now does this. + * deps.mk (cm.o, terminfo.o): Depend on tparam.h. + * terminfo.c: Include tparam.h, to check interfaces. + (tparm): Make 1st arg a const pointer in decl. Put it at top level. + (tparam): Adjust signature to match interface in tparam.h; + this removes some undefined behavior. Check that outstring and len + are zero, which they always are with Emacs. + * tparam.h (PC, BC, UP): New extern decls. + + * xftfont.c (xftfont_shape): Now static, and defined only if needed. + (xftfont_open): Rename locals to avoid shadowing. + + * ftfont.c (ftfont_resolve_generic_family): Fix pointer signedness. + (ftfont_otf_capability, ftfont_shape): Omit decls if not needed. + (OTF_TAG_SYM): Omit macro if not needed. + (ftfont_list): Remove unused local. + (get_adstyle_property, ftfont_pattern_entity): + (ftfont_lookup_cache, ftfont_open, ftfont_anchor_point): + Rename locals to avoid shadowing. + + * xfont.c (xfont_list_family): Mark var as initialized. + + * xml.c (make_dom): Now static. + + * composite.c (composition_compute_stop_pos): Rename local to + avoid shadowing. + (composition_reseat_it): Remove unused locals. + (find_automatic_composition, composition_adjust_point): Likewise. + (composition_update_it): Mark var as initialized. + (find_automatic_composition): Mark vars as initialized, + with a FIXME (Bug#8290). + + character.h: Rename locals to avoid shadowing. + * character.h (PREV_CHAR_BOUNDARY, FETCH_STRING_CHAR_ADVANCE): + (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE, FETCH_CHAR_ADVANCE): + (FETCH_CHAR_ADVANCE_NO_CHECK, INC_POS, DEC_POS, BUF_INC_POS): + (BUF_DEC_POS): Be more systematic about renaming local temporaries + to avoid shadowing. + + * textprop.c (property_change_between_p): Remove; unused. + + * intervals.c (interval_start_pos): Now static. + + * intervals.h (CHECK_TOTAL_LENGTH): Avoid empty "else". + + * atimer.c (start_atimer, append_atimer_lists, set_alarm): Rename + locals to avoid shadowing. + + * sound.c (wav_play, au_play, Fplay_sound_internal): + Fix pointer signedness. + (alsa_choose_format): Remove unused local var. + (wav_play): Initialize a variable to 0, to prevent undefined + behavior (Bug#8278). + + * region-cache.c (insert_cache_boundary): Redo var to avoid shadowing. + + * region-cache.h (pp_cache): New decl, for gcc -Wmissing-prototypes. + + * callproc.c (Fcall_process): Use 'volatile' to avoid vfork + clobbering (Bug#8298). + * sysdep.c (sys_subshell): Likewise. + Previously, the sys_subshell 'volatile' was incorrectly IF_LINTted out. + + * lisp.h (child_setup): Now NO_RETURN unless DOS_NT. + This should get cleaned up, so that child_setup has the + same signature on all platforms. + + * callproc.c (call_process_cleanup): Now static. + (relocate_fd): Rename locals to avoid shadowing. + 2011-03-22 Chong Yidong * xterm.c (x_clear_frame): Remove XClearWindow call. This appears diff --git a/src/atimer.c b/src/atimer.c index 309a4eaee4f..e10add961eb 100644 --- a/src/atimer.c +++ b/src/atimer.c @@ -86,7 +86,7 @@ SIGTYPE alarm_signal_handler (int signo); to cancel_atimer; don't free it yourself. */ struct atimer * -start_atimer (enum atimer_type type, EMACS_TIME time, atimer_callback fn, +start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn, void *client_data) { struct atimer *t; @@ -94,10 +94,10 @@ start_atimer (enum atimer_type type, EMACS_TIME time, atimer_callback fn, /* Round TIME up to the next full second if we don't have itimers. */ #ifndef HAVE_SETITIMER - if (EMACS_USECS (time) != 0) + if (EMACS_USECS (timestamp) != 0) { - EMACS_SET_USECS (time, 0); - EMACS_SET_SECS (time, EMACS_SECS (time) + 1); + EMACS_SET_USECS (timestamp, 0); + EMACS_SET_SECS (timestamp, EMACS_SECS (timestamp) + 1); } #endif /* not HAVE_SETITIMER */ @@ -123,18 +123,18 @@ start_atimer (enum atimer_type type, EMACS_TIME time, atimer_callback fn, switch (type) { case ATIMER_ABSOLUTE: - t->expiration = time; + t->expiration = timestamp; break; case ATIMER_RELATIVE: EMACS_GET_TIME (t->expiration); - EMACS_ADD_TIME (t->expiration, t->expiration, time); + EMACS_ADD_TIME (t->expiration, t->expiration, timestamp); break; case ATIMER_CONTINUOUS: EMACS_GET_TIME (t->expiration); - EMACS_ADD_TIME (t->expiration, t->expiration, time); - t->interval = time; + EMACS_ADD_TIME (t->expiration, t->expiration, timestamp); + t->interval = timestamp; break; } @@ -187,24 +187,24 @@ cancel_atimer (struct atimer *timer) } -/* Append two lists of atimers LIST1 and LIST2 and return the +/* Append two lists of atimers LIST_1 and LIST_2 and return the result list. */ static struct atimer * -append_atimer_lists (struct atimer *list1, struct atimer *list2) +append_atimer_lists (struct atimer *list_1, struct atimer *list_2) { - if (list1 == NULL) - return list2; - else if (list2 == NULL) - return list1; + if (list_1 == NULL) + return list_2; + else if (list_2 == NULL) + return list_1; else { struct atimer *p; - for (p = list1; p->next; p = p->next) + for (p = list_1; p->next; p = p->next) ; - p->next = list2; - return list1; + p->next = list_2; + return list_1; } } @@ -287,28 +287,28 @@ set_alarm (void) { if (atimers) { - EMACS_TIME now, time; + EMACS_TIME now, timestamp; #ifdef HAVE_SETITIMER struct itimerval it; #endif /* Determine s/us till the next timer is ripe. */ EMACS_GET_TIME (now); - EMACS_SUB_TIME (time, atimers->expiration, now); + EMACS_SUB_TIME (timestamp, atimers->expiration, now); #ifdef HAVE_SETITIMER /* Don't set the interval to 0; this disables the timer. */ if (EMACS_TIME_LE (atimers->expiration, now)) { - EMACS_SET_SECS (time, 0); - EMACS_SET_USECS (time, 1000); + EMACS_SET_SECS (timestamp, 0); + EMACS_SET_USECS (timestamp, 1000); } memset (&it, 0, sizeof it); - it.it_value = time; + it.it_value = timestamp; setitimer (ITIMER_REAL, &it, 0); #else /* not HAVE_SETITIMER */ - alarm (max (EMACS_SECS (time), 1)); + alarm (max (EMACS_SECS (timestamp), 1)); #endif /* not HAVE_SETITIMER */ } } @@ -442,4 +442,3 @@ init_atimer (void) /* pending_signals is initialized in init_keyboard.*/ signal (SIGALRM, alarm_signal_handler); } - diff --git a/src/callproc.c b/src/callproc.c index c53a92bbaf8..75f239d1be2 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -107,7 +107,7 @@ call_process_kill (Lisp_Object fdpid) return Qnil; } -Lisp_Object +static Lisp_Object call_process_cleanup (Lisp_Object arg) { Lisp_Object fdpid = Fcdr (arg); @@ -180,7 +180,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) (int nargs, register Lisp_Object *args) { Lisp_Object infile, buffer, current_dir, path; - int display_p; + volatile int display_p_volatile; int fd[2]; int filefd; register int pid; @@ -190,6 +190,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) int bufsize = CALLPROC_BUFFER_SIZE_MIN; int count = SPECPDL_INDEX (); + const unsigned char **volatile new_argv_volatile; register const unsigned char **new_argv; /* File to use for stderr in the child. t means use same as standard output. */ @@ -343,7 +344,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) UNGCPRO; } - display_p = INTERACTIVE && nargs >= 4 && !NILP (args[3]); + display_p_volatile = INTERACTIVE && nargs >= 4 && !NILP (args[3]); filefd = emacs_open (SSDATA (infile), O_RDONLY, 0); if (filefd < 0) @@ -371,7 +372,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) && SREF (path, 1) == ':') path = Fsubstring (path, make_number (2), Qnil); - new_argv = (const unsigned char **) + new_argv_volatile = new_argv = (const unsigned char **) alloca (max (2, nargs - 2) * sizeof (char *)); if (nargs > 4) { @@ -542,6 +543,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) pid = vfork (); + new_argv = new_argv_volatile; + if (pid == 0) { if (fd[0] >= 0) @@ -673,6 +676,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) int first = 1; EMACS_INT total_read = 0; int carryover = 0; + int display_p = display_p_volatile; int display_on_the_fly = display_p; struct coding_system saved_coding; @@ -1272,12 +1276,12 @@ relocate_fd (int fd, int minfd) #endif if (new == -1) { - const char *message1 = "Error while setting up child: "; + const char *message_1 = "Error while setting up child: "; const char *errmessage = strerror (errno); - const char *message2 = "\n"; - emacs_write (2, message1, strlen (message1)); + const char *message_2 = "\n"; + emacs_write (2, message_1, strlen (message_1)); emacs_write (2, errmessage, strlen (errmessage)); - emacs_write (2, message2, strlen (message2)); + emacs_write (2, message_2, strlen (message_2)); _exit (1); } emacs_close (fd); diff --git a/src/character.h b/src/character.h index 4c468e14d2c..91020cadedc 100644 --- a/src/character.h +++ b/src/character.h @@ -278,11 +278,11 @@ along with GNU Emacs. If not, see . */ do { \ if ((p) > (limit)) \ { \ - const unsigned char *pcb = (p); \ + const unsigned char *chp = (p); \ do { \ - pcb--; \ - } while (pcb >= limit && ! CHAR_HEAD_P (*pcb)); \ - (p) = (BYTES_BY_CHAR_HEAD (*pcb) == (p) - pcb) ? pcb : (p) - 1; \ + chp--; \ + } while (chp >= limit && ! CHAR_HEAD_P (*chp)); \ + (p) = (BYTES_BY_CHAR_HEAD (*chp) == (p) - chp) ? chp : (p) - 1; \ } \ } while (0) @@ -353,11 +353,11 @@ along with GNU Emacs. If not, see . */ CHARIDX++; \ if (STRING_MULTIBYTE (STRING)) \ { \ - unsigned char *string_ptr = &SDATA (STRING)[BYTEIDX]; \ - int string_len; \ + unsigned char *chp = &SDATA (STRING)[BYTEIDX]; \ + int chlen; \ \ - OUTPUT = STRING_CHAR_AND_LENGTH (string_ptr, string_len); \ - BYTEIDX += string_len; \ + OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \ + BYTEIDX += chlen; \ } \ else \ { \ @@ -376,11 +376,11 @@ along with GNU Emacs. If not, see . */ CHARIDX++; \ if (STRING_MULTIBYTE (STRING)) \ { \ - unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \ - int ptrlen; \ + unsigned char *chp = &SDATA (STRING)[BYTEIDX]; \ + int chlen; \ \ - OUTPUT = STRING_CHAR_AND_LENGTH (ptr, ptrlen); \ - BYTEIDX += ptrlen; \ + OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \ + BYTEIDX += chlen; \ } \ else \ { \ @@ -416,11 +416,11 @@ along with GNU Emacs. If not, see . */ CHARIDX++; \ if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) \ { \ - unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \ - int string_len; \ + unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \ + int chlen; \ \ - OUTPUT= STRING_CHAR_AND_LENGTH (ptr, string_len); \ - BYTEIDX += string_len; \ + OUTPUT= STRING_CHAR_AND_LENGTH (chp, chlen); \ + BYTEIDX += chlen; \ } \ else \ { \ @@ -436,11 +436,11 @@ along with GNU Emacs. If not, see . */ #define FETCH_CHAR_ADVANCE_NO_CHECK(OUTPUT, CHARIDX, BYTEIDX) \ do \ { \ - unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \ - int len; \ + unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \ + int chlen; \ \ - OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \ - BYTEIDX += len; \ + OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \ + BYTEIDX += chlen; \ CHARIDX++; \ } \ while (0) @@ -451,8 +451,8 @@ along with GNU Emacs. If not, see . */ #define INC_POS(pos_byte) \ do { \ - unsigned char *ptr = BYTE_POS_ADDR (pos_byte); \ - pos_byte += BYTES_BY_CHAR_HEAD (*ptr); \ + unsigned char *chp = BYTE_POS_ADDR (pos_byte); \ + pos_byte += BYTES_BY_CHAR_HEAD (*chp); \ } while (0) @@ -461,16 +461,16 @@ along with GNU Emacs. If not, see . */ #define DEC_POS(pos_byte) \ do { \ - unsigned char *ptr; \ + unsigned char *chp; \ \ pos_byte--; \ if (pos_byte < GPT_BYTE) \ - ptr = BEG_ADDR + pos_byte - BEG_BYTE; \ + chp = BEG_ADDR + pos_byte - BEG_BYTE; \ else \ - ptr = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE; \ - while (!CHAR_HEAD_P (*ptr)) \ + chp = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE; \ + while (!CHAR_HEAD_P (*chp)) \ { \ - ptr--; \ + chp--; \ pos_byte--; \ } \ } while (0) @@ -510,8 +510,8 @@ along with GNU Emacs. If not, see . */ #define BUF_INC_POS(buf, pos_byte) \ do { \ - unsigned char *bbp = BUF_BYTE_ADDRESS (buf, pos_byte); \ - pos_byte += BYTES_BY_CHAR_HEAD (*bbp); \ + unsigned char *chp = BUF_BYTE_ADDRESS (buf, pos_byte); \ + pos_byte += BYTES_BY_CHAR_HEAD (*chp); \ } while (0) @@ -520,15 +520,15 @@ along with GNU Emacs. If not, see . */ #define BUF_DEC_POS(buf, pos_byte) \ do { \ - unsigned char *p; \ + unsigned char *chp; \ pos_byte--; \ if (pos_byte < BUF_GPT_BYTE (buf)) \ - p = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE; \ + chp = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE; \ else \ - p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\ - while (!CHAR_HEAD_P (*p)) \ + chp = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\ + while (!CHAR_HEAD_P (*chp)) \ { \ - p--; \ + chp--; \ pos_byte--; \ } \ } while (0) diff --git a/src/cm.c b/src/cm.c index 108ee5720f3..6379955b48c 100644 --- a/src/cm.c +++ b/src/cm.c @@ -27,19 +27,11 @@ along with GNU Emacs. If not, see . */ #include "cm.h" #include "termhooks.h" #include "termchar.h" - - -/* For now, don't try to include termcap.h. On some systems, - configure finds a non-standard termcap.h that the main build - won't find. */ -extern void tputs (const char *, int, int (*)(int)); -extern char *tgoto (const char *, int, int); +#include "tparam.h" #define BIG 9999 /* 9999 good on VAXen. For 16 bit machines use about 2000.... */ -extern char *BC, *UP; - int cost; /* sums up costs */ /* ARGSUSED */ diff --git a/src/cm.h b/src/cm.h index 5d430598f0c..8f23990ce55 100644 --- a/src/cm.h +++ b/src/cm.h @@ -96,8 +96,6 @@ struct cm int cc_vabs; }; -extern char PC; /* Pad character */ - /* Shorthand */ #ifndef NoCMShortHand #define curY(tty) (tty)->Wcm->cm_curY diff --git a/src/coding.c b/src/coding.c index 0c2836c19f6..0596d16bf46 100644 --- a/src/coding.c +++ b/src/coding.c @@ -5266,11 +5266,12 @@ encode_coding_raw_text (struct coding_system *coding) unsigned char str[MAX_MULTIBYTE_LENGTH], *p0 = str, *p1 = str; CHAR_STRING_ADVANCE (c, p1); - while (p0 < p1) + do { EMIT_ONE_BYTE (*p0); p0++; } + while (p0 < p1); } } else diff --git a/src/composite.c b/src/composite.c index 0b0602bf283..bc5644a4612 100644 --- a/src/composite.c +++ b/src/composite.c @@ -1115,7 +1115,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, EMACS_INT charpos, if (! NILP (val)) { Lisp_Object elt; - int ridx, back, len; + int ridx, back, blen; for (ridx = 0; CONSP (val); val = XCDR (val), ridx++) { @@ -1132,17 +1132,17 @@ composition_compute_stop_pos (struct composition_it *cmp_it, EMACS_INT charpos, bpos = (NILP (string) ? CHAR_TO_BYTE (cpos) : string_char_to_byte (string, cpos)); if (STRINGP (AREF (elt, 0))) - len = fast_looking_at (AREF (elt, 0), cpos, bpos, - start + 1, limit, string); + blen = fast_looking_at (AREF (elt, 0), cpos, bpos, + start + 1, limit, string); else - len = 1; - if (len > 0) + blen = 1; + if (blen > 0) { /* Make CPOS point to the last character of - match. Note that LEN is byte-length. */ - if (len > 1) + match. Note that BLEN is byte-length. */ + if (blen > 1) { - bpos += len; + bpos += blen; if (NILP (string)) cpos = BYTE_TO_CHAR (bpos) - 1; else @@ -1248,8 +1248,8 @@ composition_reseat_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_I else if (w) { Lisp_Object lgstring = Qnil; - Lisp_Object val, elt, re; - int len, i; + Lisp_Object val, elt; + int i; val = CHAR_TABLE_REF (Vcomposition_function_table, cmp_it->ch); for (i = 0; i < cmp_it->rule_idx; i++, val = XCDR (val)); @@ -1364,7 +1364,7 @@ composition_reseat_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_I int composition_update_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, Lisp_Object string) { - int i, c; + int i, c IF_LINT (= 0); if (cmp_it->ch < 0) { @@ -1489,9 +1489,14 @@ find_automatic_composition (EMACS_INT pos, EMACS_INT limit, EMACS_INT *start, EM EMACS_INT head, tail, stop; /* Limit to check a composition after POS. */ EMACS_INT fore_check_limit; - struct position_record orig, cur, check, prev; + struct position_record orig, cur; + + /* FIXME: It's not obvious whether these two variables need initialization. + If they do, please supply initial values. + If not, please remove this comment. */ + struct position_record check IF_LINT (= {0}), prev IF_LINT (= {0}); + Lisp_Object check_val, val, elt; - int check_lookback; int c; Lisp_Object window; struct window *w; @@ -1657,7 +1662,7 @@ find_automatic_composition (EMACS_INT pos, EMACS_INT limit, EMACS_INT *start, EM EMACS_INT composition_adjust_point (EMACS_INT last_pt, EMACS_INT new_pt) { - EMACS_INT charpos, bytepos, startpos, beg, end, pos; + EMACS_INT beg, end; Lisp_Object val; int i; @@ -2032,4 +2037,3 @@ See also the documentation of `auto-composition-mode'. */); defsubr (&Sfind_composition_internal); defsubr (&Scomposition_get_gstring); } - diff --git a/src/deps.mk b/src/deps.mk index 35754dfa7de..d84e80dca44 100644 --- a/src/deps.mk +++ b/src/deps.mk @@ -65,7 +65,7 @@ coding.o: coding.c coding.h ccl.h buffer.h character.h charset.h composite.h \ window.h dispextern.h msdos.h frame.h termhooks.h \ lisp.h globals.h $(config_h) cm.o: cm.c frame.h cm.h termhooks.h termchar.h dispextern.h msdos.h \ - lisp.h globals.h $(config_h) + tparam.h lisp.h globals.h $(config_h) cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h lisp.h \ globals.h $(config_h) msdos.h dispextern.h keyboard.h keymap.h systime.h \ coding.h frame.h composite.h @@ -196,7 +196,7 @@ termcap.o: termcap.c lisp.h tparam.h msdos.h $(config_h) terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \ keyboard.h lisp.h globals.h $(config_h) dispextern.h composite.h systime.h \ msdos.h -terminfo.o: terminfo.c lisp.h globals.h $(config_h) +terminfo.o: terminfo.c tparam.h lisp.h globals.h $(config_h) tparam.o: tparam.c tparam.h lisp.h $(config_h) undo.o: undo.c buffer.h commands.h window.h dispextern.h msdos.h \ lisp.h globals.h $(config_h) diff --git a/src/emacs.c b/src/emacs.c index 052f22ea622..bc7c07a9326 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2312,6 +2312,7 @@ from the parent process and its tty file descriptors. */) (void) { int nfd; + int err = 0; if (!IS_DAEMON) error ("This function can only be called if emacs is run as a daemon"); @@ -2324,10 +2325,11 @@ from the parent process and its tty file descriptors. */) /* Get rid of stdin, stdout and stderr. */ nfd = open ("/dev/null", O_RDWR); - dup2 (nfd, 0); - dup2 (nfd, 1); - dup2 (nfd, 2); - close (nfd); + err |= nfd < 0; + err |= dup2 (nfd, 0) < 0; + err |= dup2 (nfd, 1) < 0; + err |= dup2 (nfd, 2) < 0; + err |= close (nfd) != 0; /* Closing the pipe will notify the parent that it can exit. FIXME: In case some other process inherited the pipe, closing it here @@ -2336,10 +2338,13 @@ from the parent process and its tty file descriptors. */) Instead, we should probably close the pipe in start-process and call-process to make sure the pipe is never inherited by subprocesses. */ - write (daemon_pipe[1], "\n", 1); - close (daemon_pipe[1]); + err |= write (daemon_pipe[1], "\n", 1) < 0; + err |= close (daemon_pipe[1]) != 0; /* Set it to an invalid value so we know we've already run this function. */ daemon_pipe[1] = -1; + + if (err) + error ("I/O error during daemon initialization"); return Qt; } diff --git a/src/fileio.c b/src/fileio.c index 5d33fb93878..7d2f10d517c 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1951,9 +1951,10 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */) owner and group. */ if (input_file_statable_p) { - if (! NILP (preserve_uid_gid)) - fchown (ofd, st.st_uid, st.st_gid); - fchmod (ofd, st.st_mode & 07777); + if (!NILP (preserve_uid_gid) && fchown (ofd, st.st_uid, st.st_gid) != 0) + report_file_error ("Doing chown", Fcons (newname, Qnil)); + if (fchmod (ofd, st.st_mode & 07777) != 0) + report_file_error ("Doing chmod", Fcons (newname, Qnil)); } #endif /* not MSDOS */ diff --git a/src/frame.c b/src/frame.c index 05938f3e1f0..3e00e1bf107 100644 --- a/src/frame.c +++ b/src/frame.c @@ -2529,7 +2529,7 @@ use is not recommended. Explicitly check for a frame-parameter instead. */) } /* Now process them in reverse of specified order. */ - for (i--; i >= 0; i--) + while (--i >= 0) { prop = parms[i]; val = values[i]; @@ -3713,8 +3713,7 @@ validate_x_resource_name (void) return; /* If name is entirely invalid, or nearly so, use `emacs'. */ - if (good_count == 0 - || (good_count == 1 && bad_count > 0)) + if (good_count < 2) { Vx_resource_name = build_string ("emacs"); return; diff --git a/src/ftfont.c b/src/ftfont.c index db6b29421dc..ad01149106e 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -168,11 +168,11 @@ get_adstyle_property (FcPattern *p) for (end = str; *end && *end != ' '; end++); if (*end) { - char *p = alloca (end - str + 1); - memcpy (p, str, end - str); - p[end - str] = '\0'; - end = p + (end - str); - str = p; + char *newstr = alloca (end - str + 1); + memcpy (newstr, str, end - str); + newstr[end - str] = '\0'; + end = newstr + (end - str); + str = newstr; } if (xstrcasecmp (str, "Regular") == 0 || xstrcasecmp (str, "Bold") == 0 @@ -190,18 +190,18 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) { Lisp_Object key, cache, entity; char *file, *str; - int index; + int idx; int numeric; double dbl; FcBool b; if (FcPatternGetString (p, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch) return Qnil; - if (FcPatternGetInteger (p, FC_INDEX, 0, &index) != FcResultMatch) + if (FcPatternGetInteger (p, FC_INDEX, 0, &idx) != FcResultMatch) return Qnil; key = Fcons (make_unibyte_string ((char *) file, strlen ((char *) file)), - make_number (index)); + make_number (idx)); cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY); entity = XCAR (cache); if (! NILP (entity)) @@ -265,7 +265,7 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) ASET (entity, FONT_ADSTYLE_INDEX, get_adstyle_property (p)); if ((ft_library || FT_Init_FreeType (&ft_library) == 0) - && FT_New_Face (ft_library, file, index, &ft_face) == 0) + && FT_New_Face (ft_library, file, idx, &ft_face) == 0) { BDF_PropertyRec rec; @@ -311,8 +311,9 @@ ftfont_resolve_generic_family (Lisp_Object family, FcPattern *pattern) if (FcPatternGetLangSet (pattern, FC_LANG, 0, &langset) != FcResultMatch) { /* This is to avoid the effect of locale. */ + static const FcChar8 lang[] = "en"; langset = FcLangSetCreate (); - FcLangSetAdd (langset, "en"); + FcLangSetAdd (langset, lang); FcPatternAddLangSet (pattern, FC_LANG, langset); FcLangSetDestroy (langset); } @@ -393,14 +394,14 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for) ? ! cache_data->ft_face : ! cache_data->fc_charset) { char *filename = SSDATA (XCAR (key)); - int index = XINT (XCDR (key)); + int idx = XINT (XCDR (key)); if (cache_for == FTFONT_CACHE_FOR_FACE) { if (! ft_library && FT_Init_FreeType (&ft_library) != 0) return Qnil; - if (FT_New_Face (ft_library, filename, index, &cache_data->ft_face) + if (FT_New_Face (ft_library, filename, idx, &cache_data->ft_face) != 0) return Qnil; } @@ -412,7 +413,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for) FcCharSet *charset = NULL; pat = FcPatternBuild (0, FC_FILE, FcTypeString, (FcChar8 *) filename, - FC_INDEX, FcTypeInteger, index, NULL); + FC_INDEX, FcTypeInteger, idx, NULL); if (! pat) goto finish; objset = FcObjectSetBuild (FC_CHARSET, FC_STYLE, NULL); @@ -490,8 +491,12 @@ static int ftfont_get_bitmap (struct font *, unsigned, struct font_bitmap *, int); static int ftfont_anchor_point (struct font *, unsigned, int, int *, int *); +#ifdef HAVE_LIBOTF static Lisp_Object ftfont_otf_capability (struct font *); +# ifdef HAVE_M17N_FLT static Lisp_Object ftfont_shape (Lisp_Object); +# endif +#endif #ifdef HAVE_OTF_GET_VARIATION_GLYPHS static int ftfont_variation_glyphs (struct font *, int c, @@ -618,6 +623,7 @@ struct OpenTypeSpec (P)[4] = '\0'; \ } while (0) +#ifdef HAVE_LIBOTF #define OTF_TAG_SYM(SYM, TAG) \ do { \ char str[5]; \ @@ -625,6 +631,7 @@ struct OpenTypeSpec OTF_TAG_STR (TAG, str); \ (SYM) = font_intern_prop (str, 4, 1); \ } while (0) +#endif static struct OpenTypeSpec * @@ -864,7 +871,6 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec) FcObjectSet *objset = NULL; FcCharSet *charset; Lisp_Object chars = Qnil; - FcResult result; char otlayout[15]; /* For "otlayout:XXXX" */ struct OpenTypeSpec *otspec = NULL; int spacing = -1; @@ -1153,7 +1159,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) FT_Face ft_face; FT_Size ft_size; FT_UInt size; - Lisp_Object val, filename, index, cache, font_object; + Lisp_Object val, filename, idx, cache, font_object; int scalable; int spacing; char name[256]; @@ -1168,7 +1174,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) if (NILP (cache)) return Qnil; filename = XCAR (val); - index = XCDR (val); + idx = XCDR (val); val = XCDR (cache); cache_data = XSAVE_VALUE (XCDR (cache))->pointer; ft_face = cache_data->ft_face; @@ -1210,7 +1216,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) font = XFONT_OBJECT (font_object); ftfont_info = (struct ftfont_info *) font; ftfont_info->ft_size = ft_face->size; - ftfont_info->index = XINT (index); + ftfont_info->index = XINT (idx); #ifdef HAVE_LIBOTF ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT; ftfont_info->otf = NULL; @@ -1455,7 +1461,8 @@ ftfont_get_bitmap (struct font *font, unsigned int code, struct font_bitmap *bit } static int -ftfont_anchor_point (struct font *font, unsigned int code, int index, int *x, int *y) +ftfont_anchor_point (struct font *font, unsigned int code, int idx, + int *x, int *y) { struct ftfont_info *ftfont_info = (struct ftfont_info *) font; FT_Face ft_face = ftfont_info->ft_size->face; @@ -1466,10 +1473,10 @@ ftfont_anchor_point (struct font *font, unsigned int code, int index, int *x, in return -1; if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) return -1; - if (index >= ft_face->glyph->outline.n_points) + if (idx >= ft_face->glyph->outline.n_points) return -1; - *x = ft_face->glyph->outline.points[index].x; - *y = ft_face->glyph->outline.points[index].y; + *x = ft_face->glyph->outline.points[idx].x; + *y = ft_face->glyph->outline.points[idx].y; return 0; } diff --git a/src/intervals.c b/src/intervals.c index 12b2789cc77..351677ad27e 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -586,7 +586,7 @@ split_interval_left (INTERVAL interval, EMACS_INT offset) Don't use this function on an interval which is the child of another interval! */ -int +static int interval_start_pos (INTERVAL source) { Lisp_Object parent; @@ -2559,4 +2559,3 @@ set_intervals_multibyte (int multi_flag) set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag, BEG, BEG_BYTE, Z, Z_BYTE); } - diff --git a/src/intervals.h b/src/intervals.h index f6c1c002ce0..d7c34012e1f 100644 --- a/src/intervals.h +++ b/src/intervals.h @@ -161,8 +161,13 @@ struct interval (INTERVAL_HAS_PARENT (i) ? INTERVAL_PARENT (i) : 0) /* Abort if interval I's size is negative. */ -#define CHECK_TOTAL_LENGTH(i) \ - if ((int) (i)->total_length < 0) abort (); else +#define CHECK_TOTAL_LENGTH(i) \ + do \ + { \ + if ((int) (i)->total_length < 0) \ + abort (); \ + } \ + while (0) /* Reset this interval to its vanilla, or no-property state. */ #define RESET_INTERVAL(i) \ @@ -339,4 +344,3 @@ extern Lisp_Object get_pos_property (Lisp_Object pos, Lisp_Object prop, extern void syms_of_textprop (void); #include "composite.h" - diff --git a/src/lisp.h b/src/lisp.h index 283b0989c1d..e98172ec104 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3233,7 +3233,11 @@ extern void syms_of_process (void); extern void setup_process_coding_systems (Lisp_Object); EXFUN (Fcall_process, MANY); -extern int child_setup (int, int, int, char **, int, Lisp_Object); +extern int child_setup (int, int, int, char **, int, Lisp_Object) +#ifndef DOS_NT + NO_RETURN +#endif + ; extern void init_callproc_1 (void); extern void init_callproc (void); extern void set_initial_environment (void); @@ -3598,7 +3602,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); else \ { \ buf = (type) xmalloc (size); \ - sa_must_free++; \ + sa_must_free = 1; \ record_unwind_protect (safe_alloca_unwind, \ make_save_value (buf, 0)); \ } \ @@ -3628,7 +3632,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object); buf = (Lisp_Object *) xmalloc (size_); \ arg_ = make_save_value (buf, nelt); \ XSAVE_VALUE (arg_)->dogc = 1; \ - sa_must_free++; \ + sa_must_free = 1; \ record_unwind_protect (safe_alloca_unwind, arg_); \ } \ } while (0) diff --git a/src/process.c b/src/process.c index c9b420ab2ae..4a7202388bf 100644 --- a/src/process.c +++ b/src/process.c @@ -159,9 +159,6 @@ extern Lisp_Object QCfilter; #define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) #define SERIALCONN1_P(p) (EQ ((p)->type, Qserial)) -/* Define first descriptor number available for subprocesses. */ -#define FIRST_PROC_DESC 3 - #ifndef HAVE_H_ERRNO extern int h_errno; #endif @@ -278,10 +275,6 @@ static SELECT_TYPE connect_wait_mask; /* Number of bits set in connect_wait_mask. */ static int num_pending_connects; - -#define IF_NON_BLOCKING_CONNECT(s) s -#else /* NON_BLOCKING_CONNECT */ -#define IF_NON_BLOCKING_CONNECT(s) #endif /* NON_BLOCKING_CONNECT */ /* The largest descriptor currently in use for a process object. */ @@ -1250,8 +1243,8 @@ Returns nil if format of ADDRESS is invalid. */) static Lisp_Object list_processes_1 (Lisp_Object query_only) { - register Lisp_Object tail, tem; - Lisp_Object proc, minspace, tem1; + register Lisp_Object tail; + Lisp_Object proc, minspace; register struct Lisp_Process *p; char tembuf[300]; int w_proc, w_buffer, w_tty; @@ -1453,10 +1446,10 @@ list_processes_1 (Lisp_Object query_only) } else { - tem = p->command; + Lisp_Object tem = p->command; while (1) { - tem1 = Fcar (tem); + Lisp_Object tem1 = Fcar (tem); if (NILP (tem1)) break; Finsert (1, &tem1); @@ -1919,8 +1912,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) /* child_setup must clobber environ on systems with true vfork. Protect it from permanent change. */ char **save_environ = environ; - - current_dir = ENCODE_FILE (current_dir); + volatile Lisp_Object encoded_current_dir = ENCODE_FILE (current_dir); #ifndef WINDOWSNT pid = vfork (); @@ -2061,13 +2053,13 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) child_setup_tty (xforkout); #ifdef WINDOWSNT pid = child_setup (xforkin, xforkout, xforkout, - new_argv, 1, current_dir); + new_argv, 1, encoded_current_dir); #else /* not WINDOWSNT */ #ifdef FD_CLOEXEC emacs_close (wait_child_setup[0]); #endif child_setup (xforkin, xforkout, xforkout, - new_argv, 1, current_dir); + new_argv, 1, encoded_current_dir); #endif /* not WINDOWSNT */ } environ = save_environ; @@ -3403,7 +3395,9 @@ usage: (make-network-process &rest ARGS) */) { int optn, optbits; +#ifdef WINDOWSNT retry_connect: +#endif s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); if (s < 0) @@ -3467,7 +3461,7 @@ usage: (make-network-process &rest ARGS) */) if (EQ (service, Qt)) { struct sockaddr_in sa1; - int len1 = sizeof (sa1); + socklen_t len1 = sizeof (sa1); if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) { ((struct sockaddr_in *)(lres->ai_addr))->sin_port = sa1.sin_port; @@ -3514,7 +3508,8 @@ usage: (make-network-process &rest ARGS) */) /* Unlike most other syscalls connect() cannot be called again. (That would return EALREADY.) The proper way to wait for completion is select(). */ - int sc, len; + int sc; + socklen_t len; SELECT_TYPE fdset; retry_select: FD_ZERO (&fdset); @@ -3587,7 +3582,7 @@ usage: (make-network-process &rest ARGS) */) if (!is_server) { struct sockaddr_in sa1; - int len1 = sizeof (sa1); + socklen_t len1 = sizeof (sa1); if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) contact = Fplist_put (contact, QClocal, conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1)); @@ -3705,10 +3700,10 @@ usage: (make-network-process &rest ARGS) */) { /* Setup coding systems for communicating with the network stream. */ - struct gcpro gcpro1; + struct gcpro inner_gcpro1; /* Qt denotes we have not yet called Ffind_operation_coding_system. */ Lisp_Object coding_systems = Qt; - Lisp_Object args[5], val; + Lisp_Object fargs[5], val; if (!NILP (tem)) { @@ -3731,11 +3726,11 @@ usage: (make-network-process &rest ARGS) */) coding_systems = Qnil; else { - args[0] = Qopen_network_stream, args[1] = name, - args[2] = buffer, args[3] = host, args[4] = service; - GCPRO1 (proc); - coding_systems = Ffind_operation_coding_system (5, args); - UNGCPRO; + fargs[0] = Qopen_network_stream, fargs[1] = name, + fargs[2] = buffer, fargs[3] = host, fargs[4] = service; + GCPRO1_VAR (proc, inner_gcpro); + coding_systems = Ffind_operation_coding_system (5, fargs); + UNGCPRO_VAR (inner_gcpro); } if (CONSP (coding_systems)) val = XCAR (coding_systems); @@ -3764,11 +3759,11 @@ usage: (make-network-process &rest ARGS) */) coding_systems = Qnil; else { - args[0] = Qopen_network_stream, args[1] = name, - args[2] = buffer, args[3] = host, args[4] = service; - GCPRO1 (proc); - coding_systems = Ffind_operation_coding_system (5, args); - UNGCPRO; + fargs[0] = Qopen_network_stream, fargs[1] = name, + fargs[2] = buffer, fargs[3] = host, fargs[4] = service; + GCPRO1_VAR (proc, inner_gcpro); + coding_systems = Ffind_operation_coding_system (5, fargs); + UNGCPRO_VAR (inner_gcpro); } } if (CONSP (coding_systems)) @@ -3948,7 +3943,7 @@ FLAGS is the current flags of the interface. */) CHECK_STRING (ifname); memset (rq.ifr_name, 0, sizeof rq.ifr_name); - strncpy (rq.ifr_name, SDATA (ifname), sizeof (rq.ifr_name)); + strncpy (rq.ifr_name, SSDATA (ifname), sizeof (rq.ifr_name)); s = socket (AF_INET, SOCK_STREAM, 0); if (s < 0) @@ -4192,7 +4187,7 @@ server_accept_connection (Lisp_Object server, int channel) struct sockaddr_un un; #endif } saddr; - int len = sizeof saddr; + socklen_t len = sizeof saddr; s = accept (channel, &saddr.sa, &len); @@ -4928,8 +4923,6 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, d->func (channel, d->data, 0); } - /* Really FIRST_PROC_DESC should be 0 on Unix, - but this is safer in the short run. */ for (channel = 0; channel <= max_process_desc; channel++) { if (FD_ISSET (channel, &Available) @@ -5059,7 +5052,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, /* getsockopt(,,SO_ERROR,,) is said to hang on some systems. So only use it on systems where it is known to work. */ { - int xlen = sizeof (xerrno); + socklen_t xlen = sizeof (xerrno); if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) xerrno = errno; } @@ -5128,9 +5121,9 @@ read_process_output_call (Lisp_Object fun_and_args) } static Lisp_Object -read_process_output_error_handler (Lisp_Object error) +read_process_output_error_handler (Lisp_Object error_val) { - cmd_error_internal (error, "error in process filter: "); + cmd_error_internal (error_val, "error in process filter: "); Vinhibit_quit = Qt; update_echo_area (); Fsleep_for (make_number (2), Qnil); @@ -5171,7 +5164,7 @@ read_process_output (Lisp_Object proc, register int channel) /* We have a working select, so proc_buffered_char is always -1. */ if (DATAGRAM_CHAN_P (channel)) { - int len = datagram_address[channel].len; + socklen_t len = datagram_address[channel].len; nbytes = recvfrom (channel, chars + carryover, readmax, 0, datagram_address[channel].sa, &len); } @@ -5925,7 +5918,7 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, if (sig_char && *sig_char != CDISABLE) { - send_process (proc, sig_char, 1, Qnil); + send_process (proc, (char *) sig_char, 1, Qnil); return; } /* If we can't send the signal with a character, @@ -6534,9 +6527,9 @@ exec_sentinel_unwind (Lisp_Object data) } static Lisp_Object -exec_sentinel_error_handler (Lisp_Object error) +exec_sentinel_error_handler (Lisp_Object error_val) { - cmd_error_internal (error, "error in process sentinel: "); + cmd_error_internal (error_val, "error in process sentinel: "); Vinhibit_quit = Qt; update_echo_area (); Fsleep_for (make_number (2), Qnil); diff --git a/src/region-cache.c b/src/region-cache.c index 1f9b62da9fa..53ce0e9d802 100644 --- a/src/region-cache.c +++ b/src/region-cache.c @@ -290,37 +290,37 @@ move_cache_gap (struct region_cache *c, EMACS_INT pos, EMACS_INT min_size) } -/* Insert a new boundary in cache C; it will have cache index INDEX, +/* Insert a new boundary in cache C; it will have cache index I, and have the specified POS and VALUE. */ static void -insert_cache_boundary (struct region_cache *c, EMACS_INT index, EMACS_INT pos, +insert_cache_boundary (struct region_cache *c, EMACS_INT i, EMACS_INT pos, int value) { - /* index must be a valid cache index. */ - if (index < 0 || index > c->cache_len) + /* i must be a valid cache index. */ + if (i < 0 || i > c->cache_len) abort (); /* We must never want to insert something before the dummy first boundary. */ - if (index == 0) + if (i == 0) abort (); /* We must only be inserting things in order. */ - if (! (BOUNDARY_POS (c, index-1) < pos - && (index == c->cache_len - || pos < BOUNDARY_POS (c, index)))) + if (! (BOUNDARY_POS (c, i - 1) < pos + && (i == c->cache_len + || pos < BOUNDARY_POS (c, i)))) abort (); /* The value must be different from the ones around it. However, we temporarily create boundaries that establish the same value as the subsequent boundary, so we're not going to flag that case. */ - if (BOUNDARY_VALUE (c, index-1) == value) + if (BOUNDARY_VALUE (c, i - 1) == value) abort (); - move_cache_gap (c, index, 1); + move_cache_gap (c, i, 1); - c->boundaries[index].pos = pos - c->buffer_beg; - c->boundaries[index].value = value; + c->boundaries[i].pos = pos - c->buffer_beg; + c->boundaries[i].value = value; c->gap_start++; c->gap_len--; c->cache_len++; @@ -808,4 +808,3 @@ pp_cache (struct region_cache *c) fprintf (stderr, "%ld : %d\n", (long)pos, BOUNDARY_VALUE (c, i)); } } - diff --git a/src/region-cache.h b/src/region-cache.h index 0da159285e4..8e4336c2885 100644 --- a/src/region-cache.h +++ b/src/region-cache.h @@ -111,3 +111,5 @@ extern int region_cache_backward (struct buffer *BUF, EMACS_INT POS, EMACS_INT *NEXT); +/* For debugging. */ +void pp_cache (struct region_cache *); diff --git a/src/scroll.c b/src/scroll.c index 33af18d2090..f013ebbee0e 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -245,8 +245,8 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, struct m int i, j, k; /* Set to 1 if we have set a terminal window with - set_terminal_window. */ - int terminal_window_p = 0; + set_terminal_window. It's unsigned to work around GCC bug 48228. */ + unsigned int terminal_window_p = 0; /* A queue for line insertions to be done. */ struct queue { int count, pos; }; diff --git a/src/sound.c b/src/sound.c index 3a1668e4903..a2fe7ccc8ce 100644 --- a/src/sound.c +++ b/src/sound.c @@ -595,12 +595,12 @@ wav_play (struct sound *s, struct sound_device *sd) files I found so far. If someone feels inclined to implement the whole RIFF-WAVE spec, please do. */ if (STRINGP (s->data)) - sd->write (sd, SDATA (s->data) + sizeof *header, + sd->write (sd, SSDATA (s->data) + sizeof *header, SBYTES (s->data) - sizeof *header); else { char *buffer; - int nbytes; + int nbytes = 0; int blksize = sd->period_size ? sd->period_size (sd) : 2048; int data_left = header->data_length; @@ -686,7 +686,7 @@ au_play (struct sound *s, struct sound_device *sd) sd->configure (sd); if (STRINGP (s->data)) - sd->write (sd, SDATA (s->data) + header->data_offset, + sd->write (sd, SSDATA (s->data) + header->data_offset, SBYTES (s->data) - header->data_offset); else { @@ -1104,7 +1104,6 @@ alsa_close (struct sound_device *sd) static void alsa_choose_format (struct sound_device *sd, struct sound *s) { - struct alsa_params *p = (struct alsa_params *) sd->data; if (s->type == RIFF) { struct wav_header *h = (struct wav_header *) s->header; @@ -1410,7 +1409,7 @@ Internal use only, use `play-sound' instead. */) { int len = SCHARS (attrs[SOUND_DEVICE]); current_sound_device->file = (char *) alloca (len + 1); - strcpy (current_sound_device->file, SDATA (attrs[SOUND_DEVICE])); + strcpy (current_sound_device->file, SSDATA (attrs[SOUND_DEVICE])); } if (INTEGERP (attrs[SOUND_VOLUME])) @@ -1498,4 +1497,3 @@ init_sound (void) } #endif /* HAVE_SOUND */ - diff --git a/src/sysdep.c b/src/sysdep.c index 6ef3d88c5c8..14db0fd26d0 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -488,7 +488,8 @@ sys_subshell (void) int pid; struct save_signal saved_handlers[5]; Lisp_Object dir; - unsigned char * IF_LINT (volatile) str = 0; + unsigned char *volatile str_volatile = 0; + unsigned char *str; int len; saved_handlers[0].code = SIGINT; @@ -512,7 +513,7 @@ sys_subshell (void) goto xyzzy; dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil); - str = (unsigned char *) alloca (SCHARS (dir) + 2); + str_volatile = str = (unsigned char *) alloca (SCHARS (dir) + 2); len = SCHARS (dir); memcpy (str, SDATA (dir), len); if (str[len - 1] != '/') str[len++] = '/'; @@ -544,6 +545,7 @@ sys_subshell (void) sh = "sh"; /* Use our buffer's default directory for the subshell. */ + str = str_volatile; if (str && chdir ((char *) str) != 0) { #ifndef DOS_NT diff --git a/src/terminfo.c b/src/terminfo.c index 905a8edacc7..c0418984efa 100644 --- a/src/terminfo.c +++ b/src/terminfo.c @@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ #include +#include "tparam.h" + #include #include "lisp.h" @@ -33,18 +35,19 @@ char *UP, *BC, PC; format is different too. */ +extern char *tparm (const char *str, ...); + + char * -tparam (char *string, char *outstring, - int len, int arg1, int arg2, int arg3, int arg4, - int arg5, int arg6, int arg7, int arg8, int arg9) +tparam (const char *string, char *outstring, int len, + int arg1, int arg2, int arg3, int arg4) { char *temp; - extern char *tparm (char *str, ...); - temp = tparm (string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); - if (outstring == 0) - outstring = ((char *) (xmalloc ((strlen (temp)) + 1))); - strcpy (outstring, temp); - return outstring; + /* Emacs always should pass a null OUTSTRING and zero LEN. */ + if (outstring || len) + abort (); + + temp = tparm (string, arg1, arg2, arg3, arg4); + return xstrdup (temp); } - diff --git a/src/textprop.c b/src/textprop.c index 5db6033670b..cd89efeb38d 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -974,37 +974,6 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */) return make_number (next->position); } -/* Return 1 if there's a change in some property between BEG and END. */ - -int -property_change_between_p (EMACS_INT beg, EMACS_INT end) -{ - register INTERVAL i, next; - Lisp_Object object, pos; - - XSETBUFFER (object, current_buffer); - XSETFASTINT (pos, beg); - - i = validate_interval_range (object, &pos, &pos, soft); - if (NULL_INTERVAL_P (i)) - return 0; - - next = next_interval (i); - while (! NULL_INTERVAL_P (next) && intervals_equal (i, next)) - { - next = next_interval (next); - if (NULL_INTERVAL_P (next)) - return 0; - if (next->position >= end) - return 0; - } - - if (NULL_INTERVAL_P (next)) - return 0; - - return 1; -} - DEFUN ("next-single-property-change", Fnext_single_property_change, Snext_single_property_change, 2, 4, 0, doc: /* Return the position of next property change for a specific property. @@ -2331,4 +2300,3 @@ inherits it if NONSTICKINESS is nil. The `front-sticky' and /* defsubr (&Serase_text_properties); */ /* defsubr (&Scopy_text_properties); */ } - diff --git a/src/tparam.h b/src/tparam.h index 3cd3e6053cc..dc4cdfaa28c 100644 --- a/src/tparam.h +++ b/src/tparam.h @@ -29,3 +29,7 @@ char *tgetstr (const char *, char **); char *tgoto (const char *, int, int); char *tparam (const char *, char *, int, int, int, int, int); + +extern char PC; +extern char *BC; +extern char *UP; diff --git a/src/xdisp.c b/src/xdisp.c index a7955f41e0c..457a5e3e11b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -802,8 +802,8 @@ static int cursor_row_fully_visible_p (struct window *, int, int); static int try_scrolling (Lisp_Object, int, EMACS_INT, EMACS_INT, int, int); static int try_cursor_movement (Lisp_Object, struct text_pos, int *); static int trailing_whitespace_p (EMACS_INT); -static int message_log_check_duplicate (EMACS_INT, EMACS_INT, - EMACS_INT, EMACS_INT); +static unsigned long int message_log_check_duplicate (EMACS_INT, EMACS_INT, + EMACS_INT, EMACS_INT); static void push_it (struct it *); static void pop_it (struct it *); static void sync_frame_with_window_matrix_rows (struct window *); @@ -7973,7 +7973,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte) if (nlflag) { EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte; - int dups; + unsigned long int dups; insert_1 ("\n", 1, 1, 0, 0); scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0); @@ -8001,7 +8001,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte) /* If you change this format, don't forget to also change message_log_check_duplicate. */ - sprintf (dupstr, " [%d times]", dups); + sprintf (dupstr, " [%lu times]", dups); duplen = strlen (dupstr); TEMP_SET_PT_BOTH (Z - 1, Z_BYTE - 1); insert_1 (dupstr, duplen, 1, 0, 1); @@ -8063,7 +8063,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte) Return 0 if different, 1 if the new one should just replace it, or a value N > 1 if we should also append " [N times]". */ -static int +static unsigned long int message_log_check_duplicate (EMACS_INT prev_bol, EMACS_INT prev_bol_byte, EMACS_INT this_bol, EMACS_INT this_bol_byte) { @@ -8085,10 +8085,9 @@ message_log_check_duplicate (EMACS_INT prev_bol, EMACS_INT prev_bol_byte, return 2; if (*p1++ == ' ' && *p1++ == '[') { - int n = 0; - while (*p1 >= '0' && *p1 <= '9') - n = n * 10 + *p1++ - '0'; - if (strncmp ((char *) p1, " times]\n", 8) == 0) + char *pend; + unsigned long int n = strtoul ((char *) p1, &pend, 10); + if (strncmp (pend, " times]\n", 8) == 0) return n+1; } return 0; @@ -19007,7 +19006,7 @@ pint2str (register char *buf, register int width, register EMACS_INT d) static const char power_letter[] = { - 0, /* not used */ + 0, /* no letter */ 'k', /* kilo */ 'M', /* mega */ 'G', /* giga */ @@ -19089,8 +19088,7 @@ pint2hrstr (char *buf, int width, int d) p = psuffix = buf + max (width, length); /* Print EXPONENT. */ - if (exponent) - *psuffix++ = power_letter[exponent]; + *psuffix++ = power_letter[exponent]; *psuffix = '\0'; /* Print TENTHS. */ diff --git a/src/xfont.c b/src/xfont.c index f8aace3663c..3e0fcd2cd75 100644 --- a/src/xfont.c +++ b/src/xfont.c @@ -629,7 +629,7 @@ xfont_list_family (Lisp_Object frame) char **names; int num_fonts, i; Lisp_Object list; - char *last_family; + char *last_family IF_LINT (= 0); int last_len; BLOCK_INPUT; diff --git a/src/xftfont.c b/src/xftfont.c index 695527c4236..c27a4fcf91a 100644 --- a/src/xftfont.c +++ b/src/xftfont.c @@ -280,7 +280,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) { FcResult result; Display *display = FRAME_X_DISPLAY (f); - Lisp_Object val, filename, index, font_object; + Lisp_Object val, filename, idx, font_object; FcPattern *pat = NULL, *match; struct xftfont_info *xftfont_info = NULL; struct font *font; @@ -298,7 +298,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) return Qnil; val = XCDR (val); filename = XCAR (val); - index = XCDR (val); + idx = XCDR (val); size = XINT (AREF (entity, FONT_SIZE_INDEX)); if (size == 0) size = pixel_size; @@ -335,7 +335,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) xftfont_add_rendering_parameters (pat, entity); FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename)); - FcPatternAddInteger (pat, FC_INDEX, XINT (index)); + FcPatternAddInteger (pat, FC_INDEX, XINT (idx)); BLOCK_INPUT; @@ -409,9 +409,9 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size) spacing = FC_PROPORTIONAL; if (! ascii_printable[0]) { - int i; - for (i = 0; i < 95; i++) - ascii_printable[i] = ' ' + i; + int ch; + for (ch = 0; ch < 95; ch++) + ascii_printable[ch] = ' ' + ch; } BLOCK_INPUT; if (spacing != FC_PROPORTIONAL @@ -672,7 +672,8 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_b return len; } -Lisp_Object +#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF +static Lisp_Object xftfont_shape (Lisp_Object lgstring) { struct font *font; @@ -688,6 +689,7 @@ xftfont_shape (Lisp_Object lgstring) XftUnlockFace (xftfont_info->xftfont); return val; } +#endif static int xftfont_end_for_frame (FRAME_PTR f) diff --git a/src/xmenu.c b/src/xmenu.c index eab7bb03f20..60ac27a5b8f 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -922,7 +922,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p) #endif Lisp_Object items; widget_value *wv, *first_wv, *prev_wv = 0; - int i, last_i = 0; + EMACS_UINT i, last_i = 0; int *submenu_start, *submenu_end; int *submenu_top_level_items, *submenu_n_panes; diff --git a/src/xml.c b/src/xml.c index 12ef14e6b9f..d8e6f8c3faa 100644 --- a/src/xml.c +++ b/src/xml.c @@ -28,7 +28,8 @@ along with GNU Emacs. If not, see . */ #include "lisp.h" #include "buffer.h" -Lisp_Object make_dom (xmlNode *node) +static Lisp_Object +make_dom (xmlNode *node) { if (node->type == XML_ELEMENT_NODE) {