From: Bruno Haible Date: Thu, 27 Sep 2001 14:00:33 +0000 (+0000) Subject: New include files xmalloc.h and strstr.h. X-Git-Tag: v0.11~453 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7890459c6bb7ca019aee065eb6129c3901325aeb;p=thirdparty%2Fgettext.git New include files xmalloc.h and strstr.h. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index dcb1d614a..04a1cd749 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,28 @@ +2001-09-09 Bruno Haible + + * xmalloc.h: New file. + * strstr.h: New file. + * system.h (xmalloc, xrealloc, xstrdup): Remove declarations, now in + xmalloc.h. + (parse_printf_format, asprintf): Remove declarations. + (strstr): Remove declaration, now in strstr.h. + * xmalloc.c: Include xmalloc.h. Modernize. Assume exists. + * xstrdup.c: Include xmalloc.h. Modernize. Assume exists. + * concatpath.c: Include xmalloc.h. + * findprog.c: Likewise. + * fstrcmp.c: Include xmalloc.h instead of system.h. + * javacomp.c: Likewise. + * javaexec.c: Likewise. + * sh-quote.c: Likewise. + * hash.c: Include xmalloc.h. Don't declare xmalloc, xcalloc. + * xgetcwd.c: Include stdlib.h and xmalloc.h. Don't declare xmalloc, + xstrdup, free. + * Makefile.am (libnlsut_a_HEADER): Add xmalloc.h. + (LIBADD_HEADER): Add strstr.h. + + * Makefile.am (INCLUDES): Add -I$(top_srcdir)/intl. Needed because + some files include "libgettext.h", in the case $builddir != $srcdir. + 2001-09-25 Bruno Haible * javacomp.c (compile_java_class): Recognize javac exit code 2. diff --git a/lib/Makefile.am b/lib/Makefile.am index 235a87ea7..3adfb832e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -32,7 +32,7 @@ xmalloc.c xstrdup.c libnlsut_a_HEADER = c-ctype.h execute.h findprog.h fstrcmp.h full-write.h \ gcd.h getopt.h hash.h javacomp.h javaexec.h lbrkprop.h linebreak.h mbswidth.h \ obstack.h pathmax.h pipe.h progname.h sh-quote.h system.h tmpdir.h \ -utf8-ucs4.h utf16-ucs4.h wait-process.h xerror.h +utf8-ucs4.h utf16-ucs4.h wait-process.h xerror.h xmalloc.h # Sources that are compiled only on platforms that lack the functions. @@ -40,7 +40,7 @@ LIBADD_SOURCE = alloca.c error.c getline.c memset.c mkdtemp.c setenv.c \ stpcpy.c stpncpy.c strcasecmp.c strcspn.c strncasecmp.c strpbrk.c strstr.c \ strtol.c strtoul.c vasprintf.c -LIBADD_HEADER = error.h getline.h mkdtemp.h setenv.h strpbrk.h +LIBADD_HEADER = error.h getline.h mkdtemp.h setenv.h strpbrk.h strstr.h # Unused sources. @@ -60,7 +60,7 @@ stdbool.h.in \ gen-lbrkprop.c 3level.h DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@ -INCLUDES = -I. -I$(srcdir) -I.. -I../intl +INCLUDES = -I. -I$(srcdir) -I.. -I../intl -I$(top_srcdir)/intl all-local: @STDBOOL_H@ diff --git a/lib/concatpath.c b/lib/concatpath.c index cc9088d85..1d494f992 100644 --- a/lib/concatpath.c +++ b/lib/concatpath.c @@ -25,6 +25,8 @@ /* Specification. */ #include "system.h" +#include "xmalloc.h" + /* Concatenate a directory pathname, a relative pathname and an optional suffix. The directory may end with the directory separator. The second argument may not start with the directory separator (it is relative). diff --git a/lib/findprog.c b/lib/findprog.c index 5b18d562b..601376824 100644 --- a/lib/findprog.c +++ b/lib/findprog.c @@ -31,6 +31,7 @@ # include #endif +#include "xmalloc.h" #include "system.h" diff --git a/lib/fstrcmp.c b/lib/fstrcmp.c index 7604aa5ce..ef73d1f18 100644 --- a/lib/fstrcmp.c +++ b/lib/fstrcmp.c @@ -41,7 +41,7 @@ #include #include -#include "system.h" +#include "xmalloc.h" /* @@ -622,7 +622,7 @@ fstrcmp (string1, string2) ((number of chars in common) / (average length of the strings)). This is admittedly biased towards finding that the strings are similar, however it does produce meaningful results. */ - return ((double) (string[0].data_length + string[1].data_length - - string[1].edit_count - string[0].edit_count) / (string[0].data_length - + string[1].data_length)); + return ((double) (string[0].data_length + string[1].data_length + - string[1].edit_count - string[0].edit_count) + / (string[0].data_length + string[1].data_length)); } diff --git a/lib/hash.c b/lib/hash.c index f7f9ff334..c76e587e7 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -50,6 +50,8 @@ # include #endif +#include "xmalloc.h" + #define obstack_chunk_alloc xmalloc #define obstack_chunk_free free @@ -65,9 +67,6 @@ # define bcopy(S, D, N) memcpy ((D), (S), (N)) #endif -extern void *xmalloc PARAMS ((size_t __n)); -extern void *xcalloc PARAMS ((size_t __n, size_t __m)); - typedef struct hash_entry { unsigned long used; diff --git a/lib/javacomp.c b/lib/javacomp.c index 1c0449810..04598a809 100644 --- a/lib/javacomp.c +++ b/lib/javacomp.c @@ -30,7 +30,7 @@ #include "execute.h" #include "setenv.h" #include "sh-quote.h" -#include "system.h" +#include "xmalloc.h" #include "error.h" #include "libgettext.h" diff --git a/lib/javaexec.c b/lib/javaexec.c index 3053b37e3..162685556 100644 --- a/lib/javaexec.c +++ b/lib/javaexec.c @@ -30,7 +30,7 @@ #include "execute.h" #include "setenv.h" #include "sh-quote.h" -#include "system.h" +#include "xmalloc.h" #include "error.h" #include "libgettext.h" diff --git a/lib/sh-quote.c b/lib/sh-quote.c index 4ecbc528e..8cc300f92 100644 --- a/lib/sh-quote.c +++ b/lib/sh-quote.c @@ -26,7 +26,7 @@ #include #include "strpbrk.h" -#include "system.h" +#include "xmalloc.h" #define SHELL_SPECIAL_CHARS "\t\n !\"#$&'()*;<=>?[\\]`{|}~" diff --git a/lib/strstr.h b/lib/strstr.h new file mode 100644 index 000000000..5b897579a --- /dev/null +++ b/lib/strstr.h @@ -0,0 +1,36 @@ +/* Searching in a string. + Copyright (C) 2001 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 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef PARAMS +# if defined (__GNUC__) || __STDC__ +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +#endif + +#if HAVE_STRSTR + +/* Get strstr() declaration. */ +#include + +#else + +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +extern char *strstr PARAMS ((const char *haystack, const char *needle)); + +#endif diff --git a/lib/system.h b/lib/system.h index 54af31d62..20bae4a10 100644 --- a/lib/system.h +++ b/lib/system.h @@ -40,18 +40,11 @@ unsigned long strtoul (); /* Wrapper functions with error checking for standard functions. */ extern char *xgetcwd PARAMS ((void)); -extern void *xmalloc PARAMS ((size_t __n)); -extern void *xrealloc PARAMS ((void *__p, size_t __n)); -extern char *xstrdup PARAMS ((const char *__string)); extern char *stpcpy PARAMS ((char *__dst, const char *__src)); extern char *stpncpy PARAMS ((char *__dst, const char *__src, size_t __n)); -extern size_t parse_printf_format PARAMS ((const char *__fmt, size_t __n, - int *__argtypes)); -extern int asprintf PARAMS ((char **, const char *, ...)); extern int strcasecmp PARAMS ((const char *__s1, const char *__s2)); extern int strncasecmp PARAMS ((const char *__s1, const char *__s2, size_t __n)); -extern char *strstr PARAMS ((const char *__str, const char *__sub)); #include #if !STDC_HEADERS && HAVE_MEMORY_H diff --git a/lib/xgetcwd.c b/lib/xgetcwd.c index 896be5d6a..401f0802a 100644 --- a/lib/xgetcwd.c +++ b/lib/xgetcwd.c @@ -21,6 +21,7 @@ # include #endif +#include #include #include #ifndef errno @@ -37,9 +38,7 @@ char *getwd (); # define getcwd(Buf, Max) getwd (Buf) #endif -extern void *xmalloc (); -extern char *xstrdup (); -extern void free (); +#include "xmalloc.h" /* Return the current directory, newly allocated, arbitrarily long. Return NULL and set errno on error. */ diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 8e5df0f09..f0e1eea17 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -19,65 +19,35 @@ # include #endif -#if __STDC__ -# define VOID void -#else -# define VOID char -#endif - -#include +/* Specification. */ +#include "xmalloc.h" -#if HAVE_STDLIB_H -# include -#else -VOID *calloc (); -VOID *malloc (); -VOID *realloc (); -void free (); -#endif - -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define textdomain(Domain) -# define _(Text) Text -#endif +#include #include "error.h" +#include "libgettext.h" #ifndef EXIT_FAILURE # define EXIT_FAILURE 1 #endif -#ifndef NULL -# define NULL ((VOID *) 0) -#endif +#define _(str) gettext (str) -/* Prototypes for functions defined here. */ -#if defined (__GNUC__) || (defined (__STDC__) && __STDC__) -static VOID *fixup_null_alloc (size_t n); -VOID *xmalloc (size_t n); -VOID *xcalloc (size_t n, size_t s); -VOID *xrealloc (VOID *p, size_t n); -#endif + +/* Prototypes for local functions. Needed to ensure compiler checking of + function argument counts despite of K&R C function definition syntax. */ +static void *fixup_null_alloc PARAMS ((size_t n)); /* Exit value when the requested amount of memory is not available. The caller may set it to some other value. */ int xmalloc_exit_failure = EXIT_FAILURE; -#if __STDC__ && (HAVE_VPRINTF || HAVE_DOPRNT) -extern void error (int, int, const char *, ...); -#else -extern void error (); -#endif - -static VOID * +static void * fixup_null_alloc (n) size_t n; { - VOID *p; + void *p; p = 0; if (n == 0) @@ -89,11 +59,11 @@ fixup_null_alloc (n) /* Allocate N bytes of memory dynamically, with error checking. */ -VOID * +void * xmalloc (n) size_t n; { - VOID *p; + void *p; p = malloc (n); if (p == NULL) @@ -103,11 +73,11 @@ xmalloc (n) /* Allocate memory for N elements of S bytes, with error checking. */ -VOID * +void * xcalloc (n, s) size_t n, s; { - VOID *p; + void *p; p = calloc (n, s); if (p == NULL) @@ -119,9 +89,9 @@ xcalloc (n, s) with error checking. If P is NULL, run xmalloc. */ -VOID * +void * xrealloc (p, n) - VOID *p; + void *p; size_t n; { if (p == NULL) diff --git a/lib/xmalloc.h b/lib/xmalloc.h new file mode 100644 index 000000000..880bb405d --- /dev/null +++ b/lib/xmalloc.h @@ -0,0 +1,44 @@ +/* malloc with out of memory checking. + Copyright (C) 2001 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _XMALLOC_H +#define _XMALLOC_H + +#include + + +/* Defined in xmalloc.c. */ + +/* Allocate SIZE bytes of memory dynamically, with error checking. */ +extern void *xmalloc PARAMS ((size_t size)); + +/* Allocate memory for NMEMB elements of SIZE bytes, with error checking. */ +extern void *xcalloc PARAMS ((size_t nmemb, size_t size)); + +/* Change the size of an allocated block of memory PTR to SIZE bytes, + with error checking. If PTR is NULL, run xmalloc. */ +extern void *xrealloc PARAMS ((void *ptr, size_t size)); + + +/* Defined in xstrdup.c. */ + +/* Return a newly allocated copy of STRING. */ +extern char *xstrdup PARAMS ((const char *string)); + + +#endif /* _XMALLOC_H */ diff --git a/lib/xstrdup.c b/lib/xstrdup.c index d71f7ae4e..ca117a7c6 100644 --- a/lib/xstrdup.c +++ b/lib/xstrdup.c @@ -1,5 +1,5 @@ /* xstrdup.c -- copy a string with out of memory checking - Copyright (C) 1990, 1996, 2000 Free Software Foundation, Inc. + Copyright (C) 1990, 1996, 2000, 2001 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 @@ -19,17 +19,10 @@ # include #endif -#if HAVE_STRING_H -# include -#else -# include -#endif +/* Specification. */ +#include "xmalloc.h" -#if defined (__GNUC__) || (defined (__STDC__) && __STDC__) -extern char *xmalloc (size_t); -#else -extern char *xmalloc (); -#endif +#include /* Return a newly allocated copy of STRING. */ diff --git a/src/ChangeLog b/src/ChangeLog index 39bd81f20..8b5aee2b7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,37 @@ +2001-09-09 Bruno Haible + + * file-list.c: Include system.h. + * format-c.c: Include xmalloc.h instead of system.h. + * format-ycp.c: Likewise. + * read-po.c: Likewise. + * x-po.c: Likewise. + * format-java.c: Include xmalloc.h. + * format-lisp.c: Likewise. + * format-python.c: Likewise. + * gettext.c: Likewise. + * msgen.c: Likewise. + * msgexec.c: Likewise. + * msggrep.c: Likewise. + * ngettext.c: Likewise. + * po-lex.c: Likewise. + * read-mo.c: Likewise. + * x-c.c: Likewise. + * message.c: Include xmalloc.h and strstr.h. + * msgfmt.c: Likewise. + * write-po.c: Likewise. + * msgl-cat.c: Include string.h, xmalloc.h and strstr.h. + * msgl-iconv.c: Likewise. + * msgl-charset.c: Include strstr.h. + * po-charset.c: Likewise. + * po-gram-gen.y: Include stdlib.h, xmalloc.h instead of system.h. + * po-hash-gen.y: Likewise. + * str-list.c: Likewise. + * po.c: Include string.h, xmalloc.h instead of system.h. + * write-java.c: Include string.h, xmalloc.h. + * x-java.l: Include stdlib.h, xmalloc.h, strstr.h instead of system.h. + * xgettext.c: Include xmalloc.h, strstr.h, xerror.h. + (main, construct_header): Use xasprintf instead of asprintf. + 2001-09-24 Bruno Haible * po-lex.c (mb_iseq): Compare the byte sequence, not the Unicode diff --git a/src/file-list.c b/src/file-list.c index e2da4612f..cfe8edd1c 100644 --- a/src/file-list.c +++ b/src/file-list.c @@ -29,6 +29,7 @@ #include "str-list.h" #include "error.h" +#include "system.h" #include "getline.h" #include "libgettext.h" diff --git a/src/format-c.c b/src/format-c.c index e8ec0a16f..dd67c3b34 100644 --- a/src/format-c.c +++ b/src/format-c.c @@ -24,7 +24,7 @@ #include #include "format.h" -#include "system.h" +#include "xmalloc.h" #include "error.h" #include "progname.h" #include "libgettext.h" diff --git a/src/format-java.c b/src/format-java.c index fbc5549e5..1000d2597 100644 --- a/src/format-java.c +++ b/src/format-java.c @@ -26,6 +26,7 @@ #include "format.h" #include "c-ctype.h" +#include "xmalloc.h" #include "system.h" #include "error.h" #include "progname.h" diff --git a/src/format-lisp.c b/src/format-lisp.c index b8fc09069..267fb5e5d 100644 --- a/src/format-lisp.c +++ b/src/format-lisp.c @@ -26,6 +26,7 @@ #include "format.h" #include "c-ctype.h" #include "gcd.h" +#include "xmalloc.h" #include "system.h" #include "error.h" #include "progname.h" diff --git a/src/format-python.c b/src/format-python.c index 6840f0394..a19a751b0 100644 --- a/src/format-python.c +++ b/src/format-python.c @@ -25,6 +25,7 @@ #include #include "format.h" +#include "xmalloc.h" #include "system.h" #include "error.h" #include "progname.h" diff --git a/src/format-ycp.c b/src/format-ycp.c index 61bd74a24..80066ffa3 100644 --- a/src/format-ycp.c +++ b/src/format-ycp.c @@ -24,7 +24,7 @@ #include #include "format.h" -#include "system.h" +#include "xmalloc.h" #include "error.h" #include "progname.h" #include "libgettext.h" diff --git a/src/gettext.c b/src/gettext.c index fd2817569..f89725ce2 100644 --- a/src/gettext.c +++ b/src/gettext.c @@ -27,6 +27,7 @@ #include #include "error.h" +#include "xmalloc.h" #include "system.h" #ifdef TESTS diff --git a/src/message.c b/src/message.c index cac5c6dd5..1a3cf466c 100644 --- a/src/message.c +++ b/src/message.c @@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include "fstrcmp.h" +#include "xmalloc.h" +#include "strstr.h" #include "system.h" diff --git a/src/msgcmp.c b/src/msgcmp.c index 039dcc4ca..390786b7b 100644 --- a/src/msgcmp.c +++ b/src/msgcmp.c @@ -30,7 +30,7 @@ #include "error.h" #include "progname.h" #include "message.h" -#include +#include "system.h" #include "libgettext.h" #include "po.h" #include "str-list.h" diff --git a/src/msgen.c b/src/msgen.c index e4526b959..1dc7f0a94 100644 --- a/src/msgen.c +++ b/src/msgen.c @@ -32,6 +32,7 @@ #include "message.h" #include "read-po.h" #include "write-po.h" +#include "xmalloc.h" #include "system.h" #include "libgettext.h" diff --git a/src/msgexec.c b/src/msgexec.c index 83898449b..86f476fce 100644 --- a/src/msgexec.c +++ b/src/msgexec.c @@ -44,6 +44,7 @@ #include "write-po.h" #include "str-list.h" #include "msgl-charset.h" +#include "xmalloc.h" #include "system.h" #include "findprog.h" #include "pipe.h" diff --git a/src/msgfmt.c b/src/msgfmt.c index aa2da2b70..3e2da47b0 100644 --- a/src/msgfmt.c +++ b/src/msgfmt.c @@ -34,6 +34,8 @@ #include "xerror.h" #include "getline.h" #include "format.h" +#include "xmalloc.h" +#include "strstr.h" #include "system.h" #include "msgfmt.h" #include "write-mo.h" diff --git a/src/msggrep.c b/src/msggrep.c index de1ab4f56..85688ea3a 100644 --- a/src/msggrep.c +++ b/src/msggrep.c @@ -42,6 +42,7 @@ #include "write-po.h" #include "str-list.h" #include "msgl-charset.h" +#include "xmalloc.h" #include "system.h" #include "full-write.h" #include "findprog.h" diff --git a/src/msgl-cat.c b/src/msgl-cat.c index 8a5f0dd11..a8809a5b1 100644 --- a/src/msgl-cat.c +++ b/src/msgl-cat.c @@ -25,6 +25,7 @@ #include "msgl-cat.h" #include +#include #include "error.h" #include "xerror.h" @@ -33,6 +34,8 @@ #include "po-charset.h" #include "msgl-ascii.h" #include "msgl-iconv.h" +#include "xmalloc.h" +#include "strstr.h" #include "system.h" #include "libgettext.h" diff --git a/src/msgl-charset.c b/src/msgl-charset.c index 45f01b9f2..b803bbbbb 100644 --- a/src/msgl-charset.c +++ b/src/msgl-charset.c @@ -32,6 +32,7 @@ #include "progname.h" #include "xerror.h" #include "message.h" +#include "strstr.h" #include "system.h" #include "libgettext.h" diff --git a/src/msgl-iconv.c b/src/msgl-iconv.c index e34c32887..b5fe4087f 100644 --- a/src/msgl-iconv.c +++ b/src/msgl-iconv.c @@ -26,6 +26,7 @@ #include #include +#include #if HAVE_ICONV # include @@ -36,6 +37,8 @@ #include "message.h" #include "po-charset.h" #include "msgl-ascii.h" +#include "xmalloc.h" +#include "strstr.h" #include "system.h" #include "libgettext.h" diff --git a/src/ngettext.c b/src/ngettext.c index cf932de87..9f3bc4ba2 100644 --- a/src/ngettext.c +++ b/src/ngettext.c @@ -27,6 +27,7 @@ #include #include "error.h" +#include "xmalloc.h" #include "system.h" #include "libgettext.h" diff --git a/src/po-charset.c b/src/po-charset.c index f4fd12fc6..d01da1934 100644 --- a/src/po-charset.c +++ b/src/po-charset.c @@ -26,6 +26,7 @@ #include "error.h" #include "xerror.h" +#include "strstr.h" #include "system.h" #include "libgettext.h" diff --git a/src/po-gram-gen.y b/src/po-gram-gen.y index da39d492c..256291a38 100644 --- a/src/po-gram-gen.y +++ b/src/po-gram-gen.y @@ -26,11 +26,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "po-gram.h" #include +#include #include "str-list.h" #include "po-lex.h" #include "error.h" -#include "system.h" +#include "xmalloc.h" #include "libgettext.h" #include "po.h" diff --git a/src/po-hash-gen.y b/src/po-hash-gen.y index 7232ee7b9..90b770735 100644 --- a/src/po-hash-gen.y +++ b/src/po-hash-gen.y @@ -27,8 +27,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "po-hash.h" #include +#include -#include "system.h" +#include "xmalloc.h" #include "po.h" /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), diff --git a/src/po-lex.c b/src/po-lex.c index ba5f27237..b664d0f37 100644 --- a/src/po-lex.c +++ b/src/po-lex.c @@ -57,6 +57,7 @@ #include "str-list.h" #include "po-charset.h" +#include "xmalloc.h" #include "system.h" #include "error.h" #include "open-po.h" diff --git a/src/po.c b/src/po.c index 951d72f35..589d36eef 100644 --- a/src/po.c +++ b/src/po.c @@ -26,10 +26,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "po.h" #include +#include #include "po-charset.h" #include "po-hash.h" -#include "system.h" +#include "xmalloc.h" /* Prototypes for local functions. Needed to ensure compiler checking of function argument counts despite of K&R C function definition syntax. */ diff --git a/src/read-mo.c b/src/read-mo.c index b740479b9..deb739b2a 100644 --- a/src/read-mo.c +++ b/src/read-mo.c @@ -32,6 +32,7 @@ #include "gettext.h" #include "error.h" +#include "xmalloc.h" #include "system.h" #include "message.h" #include "libgettext.h" diff --git a/src/read-po.c b/src/read-po.c index 2e08b0c06..ad540f6d3 100644 --- a/src/read-po.c +++ b/src/read-po.c @@ -27,7 +27,7 @@ #include #include "po.h" -#include "system.h" +#include "xmalloc.h" #include "libgettext.h" #define _(str) gettext (str) diff --git a/src/str-list.c b/src/str-list.c index 4609434f7..98a8adb80 100644 --- a/src/str-list.c +++ b/src/str-list.c @@ -25,8 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "str-list.h" #include +#include -#include "system.h" +#include "xmalloc.h" /* Initialize an empty list of strings. */ diff --git a/src/write-java.c b/src/write-java.c index 04d006ea8..c65f2e638 100644 --- a/src/write-java.c +++ b/src/write-java.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,7 @@ #include "pathmax.h" #include "plural-exp.h" #include "po-charset.h" +#include "xmalloc.h" #include "system.h" #include "tmpdir.h" #include "utf8-ucs4.h" diff --git a/src/write-po.c b/src/write-po.c index c10182722..0313b2851 100644 --- a/src/write-po.c +++ b/src/write-po.c @@ -37,6 +37,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "c-ctype.h" #include "linebreak.h" #include "msgl-ascii.h" +#include "xmalloc.h" +#include "strstr.h" #include "system.h" #include "error.h" #include "xerror.h" diff --git a/src/x-c.c b/src/x-c.c index 282c27d9a..5f50af1e9 100644 --- a/src/x-c.c +++ b/src/x-c.c @@ -33,6 +33,7 @@ #include "xgettext.h" #include "error.h" #include "progname.h" +#include "xmalloc.h" #include "system.h" #include "hash.h" #include "libgettext.h" diff --git a/src/x-java.l b/src/x-java.l index 4238e4e11..dd317e501 100644 --- a/src/x-java.l +++ b/src/x-java.l @@ -22,12 +22,14 @@ #endif #include +#include #include #include "message.h" #include "x-java.h" #include "xgettext.h" -#include "system.h" +#include "xmalloc.h" +#include "strstr.h" typedef enum { diff --git a/src/x-po.c b/src/x-po.c index 0e49ddec4..3063ba3d8 100644 --- a/src/x-po.c +++ b/src/x-po.c @@ -29,7 +29,7 @@ #include "message.h" #include "x-po.h" #include "xgettext.h" -#include "system.h" +#include "xmalloc.h" #include "po.h" #include "po-lex.h" #include "libgettext.h" diff --git a/src/xgettext.c b/src/xgettext.c index 75a801cf7..1e1051a19 100644 --- a/src/xgettext.c +++ b/src/xgettext.c @@ -43,6 +43,9 @@ #include "progname.h" #include "xerror.h" #include "getline.h" +#include "xmalloc.h" +#include "strstr.h" +#include "xerror.h" #include "system.h" #include "po.h" #include "message.h" @@ -311,13 +314,7 @@ main (argc, argv) if (optarg[len - 1] == '/') output_dir = xstrdup (optarg); else - { - asprintf (&output_dir, "%s/", optarg); - if (output_dir == NULL) - /* We are about to construct the absolute path to the - directory for the output files but asprintf failed. */ - error (EXIT_FAILURE, errno, _("while preparing output")); - } + output_dir = xasprintf ("%s/", optarg); } break; case 's': @@ -1103,7 +1100,7 @@ construct_header () tz_sign = '-'; } - asprintf (&msgstr, "\ + msgstr = xasprintf ("\ Project-Id-Version: PACKAGE VERSION\n\ POT-Creation-Date: %d-%02d-%02d %02d:%02d%c%02ld%02ld\n\ PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n\ @@ -1119,9 +1116,6 @@ Content-Transfer-Encoding: 8bit\n", local_time.tm_min, tz_sign, tz_min / 60, tz_min % 60); - if (msgstr == NULL) - error (EXIT_FAILURE, errno, _("while preparing output")); - mp = message_alloc ("", NULL, msgstr, strlen (msgstr) + 1, &pos); if (foreign_user)