Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
94fdc609
...
94fdc6094f6b02c854432e8c8f658afa6dd654c7
authored
2006-09-10 12:38:11 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Updated by gnulib-sync
1 parent
3f7b793b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
63 changed files
with
760 additions
and
474 deletions
lib/allocsa.h
lib/error.c
lib/error.h
lib/exit.h
lib/exitfail.c
lib/mbswidth.c
lib/obstack.c
lib/setenv.c
lib/snprintf.c
lib/vasprintf.c
lib/vasprintf.h
m4/argp.m4
m4/d-type.m4
m4/exitfail.m4
m4/fnmatch.m4
m4/getdelim.m4
m4/getline.m4
m4/getlogin_r.m4
m4/getopt.m4
m4/getpass.m4
m4/glob.m4
m4/intmax_t.m4
m4/inttostr.m4
m4/inttypes_h_gl.m4
m4/longlong_gl.m4
m4/mbchar.m4
m4/mbswidth.m4
m4/md5.m4
m4/mempcpy.m4
m4/onceonly.m4
m4/regex.m4
m4/sha1.m4
m4/stat-macros.m4
m4/stdint.m4
m4/stdint_h_gl.m4
m4/strdup.m4
m4/strndup.m4
m4/strnlen.m4
m4/strtok_r.m4
m4/xalloc.m4
mailbox/argp-help.c
mailbox/argp-namefrob.h
mailbox/argp-parse.c
mailbox/argp-pv.c
mailbox/argp.h
mailbox/fnmatch.c
mailbox/fnmatch_loop.c
mailbox/getopt.c
mailbox/gettext.h
mailbox/glob.c
mailbox/glob_.h
mailbox/inttostr.h
mailbox/mbchar.h
mailbox/printf-args.c
mailbox/regex.h
mailbox/regex_internal.c
mailbox/regex_internal.h
mailbox/stat-macros.h
mailbox/stdint_.h
mailbox/strnlen1.c
mailbox/strnlen1.h
mailbox/vasnprintf.c
mailbox/vsnprintf.c
lib/allocsa.h
View file @
94fdc60
/* Safe automatic memory allocation.
Copyright (C) 2003-200
4
Free Software Foundation, Inc.
Copyright (C) 2003-200
6
Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
...
...
@@ -23,6 +23,12 @@
#include <stddef.h>
#include <stdlib.h>
#ifdef __cplusplus
extern
"C"
{
#endif
/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
alloca(N); otherwise it returns NULL. It either returns N bytes of
memory allocated on the stack, that lasts until the function returns,
...
...
@@ -69,6 +75,11 @@ extern void freesa (void *p);
If this would be useful in your application. please speak up. */
#ifdef __cplusplus
}
#endif
/* ------------------- Auxiliary, non-public definitions ------------------- */
/* Determine the alignment of a type at compile time. */
...
...
@@ -81,6 +92,10 @@ extern void freesa (void *p);
/* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
values. */
# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
#elif defined _AIX
/* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
values. */
# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
#else
# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
#endif
...
...
lib/error.c
View file @
94fdc60
/* Error handler for noninteractive utilities
Copyright (C) 1990-1998, 2000-200
3, 2004
Free Software Foundation, Inc.
Copyright (C) 1990-1998, 2000-200
5, 2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
...
...
@@ -34,6 +34,9 @@
#endif
#ifdef _LIBC
# include <libintl.h>
# include <stdbool.h>
# include <stdint.h>
# include <wchar.h>
# define mbsrtowcs __mbsrtowcs
#endif
...
...
@@ -59,6 +62,7 @@ unsigned int error_message_count;
# define program_name program_invocation_name
# include <errno.h>
# include <limits.h>
# include <libio/libioP.h>
/* In GNU libc we want do not want to use the common name `error' directly.
...
...
@@ -88,23 +92,19 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
char
*
strerror_r
();
# endif
# ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
# endif
/* The calling program should define program_name and set it to the
name of the executing program. */
extern
char
*
program_name
;
# if HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
# endif
# endif
/* HAVE_STRERROR_R || defined strerror_r */
#endif
/* not _LIBC */
static
void
print_errno_message
(
int
errnum
)
{
char
const
*
s
=
NULL
;
char
const
*
s
;
#if defined HAVE_STRERROR_R || _LIBC
char
errbuf
[
1024
];
...
...
@@ -113,23 +113,23 @@ print_errno_message (int errnum)
# else
if
(
__strerror_r
(
errnum
,
errbuf
,
sizeof
errbuf
)
==
0
)
s
=
errbuf
;
else
s
=
0
;
# endif
#else
s
=
strerror
(
errnum
);
#endif
#if !_LIBC
if
(
!
s
&&
!
(
s
=
strerror
(
errnum
))
)
if
(
!
s
)
s
=
_
(
"Unknown system error"
);
#endif
#if _LIBC
if
(
_IO_fwide
(
stderr
,
0
)
>
0
)
{
__fwprintf
(
stderr
,
L": %s"
,
s
);
return
;
}
#endif
__fxprintf
(
NULL
,
": %s"
,
s
);
#else
fprintf
(
stderr
,
": %s"
,
s
);
#endif
}
static
void
...
...
@@ -140,26 +140,65 @@ error_tail (int status, int errnum, const char *message, va_list args)
{
# define ALLOCA_LIMIT 2000
size_t
len
=
strlen
(
message
)
+
1
;
const
wchar_t
*
wmessage
=
L"out of memory"
;
wchar_t
*
wbuf
=
(
len
<
ALLOCA_LIMIT
?
alloca
(
len
*
sizeof
*
wbuf
)
:
len
<=
SIZE_MAX
/
sizeof
*
wbuf
?
malloc
(
len
*
sizeof
*
wbuf
)
:
NULL
);
if
(
wbuf
)
{
size_t
res
;
wchar_t
*
wmessage
=
NULL
;
mbstate_t
st
;
const
char
*
tmp
=
message
;
size_t
res
;
const
char
*
tmp
;
bool
use_malloc
=
false
;
while
(
1
)
{
if
(
__libc_use_alloca
(
len
*
sizeof
(
wchar_t
)))
wmessage
=
(
wchar_t
*
)
alloca
(
len
*
sizeof
(
wchar_t
));
else
{
if
(
!
use_malloc
)
wmessage
=
NULL
;
wchar_t
*
p
=
(
wchar_t
*
)
realloc
(
wmessage
,
len
*
sizeof
(
wchar_t
));
if
(
p
==
NULL
)
{
free
(
wmessage
);
fputws_unlocked
(
L"out of memory
\n
"
,
stderr
);
return
;
}
wmessage
=
p
;
use_malloc
=
true
;
}
memset
(
&
st
,
'\0'
,
sizeof
(
st
));
res
=
mbsrtowcs
(
wbuf
,
&
tmp
,
len
,
&
st
);
wmessage
=
res
==
(
size_t
)
-
1
?
L"???"
:
wbuf
;
tmp
=
message
;
res
=
mbsrtowcs
(
wmessage
,
&
tmp
,
len
,
&
st
);
if
(
res
!=
len
)
break
;
if
(
__builtin_expect
(
len
>=
SIZE_MAX
/
2
,
0
))
{
/* This really should not happen if everything is fine. */
res
=
(
size_t
)
-
1
;
break
;
}
len
*=
2
;
}
if
(
res
==
(
size_t
)
-
1
)
{
/* The string cannot be converted. */
if
(
use_malloc
)
{
free
(
wmessage
);
use_malloc
=
false
;
}
wmessage
=
(
wchar_t
*
)
L"???"
;
}
__vfwprintf
(
stderr
,
wmessage
,
args
);
if
(
!
(
len
<
ALLOCA_LIMIT
))
free
(
wbuf
);
if
(
use_malloc
)
free
(
wmessage
);
}
else
#endif
...
...
@@ -170,11 +209,10 @@ error_tail (int status, int errnum, const char *message, va_list args)
if
(
errnum
)
print_errno_message
(
errnum
);
#if _LIBC
if
(
_IO_fwide
(
stderr
,
0
)
>
0
)
putwc
(
L'\n'
,
stderr
);
else
#endif
__fxprintf
(
NULL
,
"
\n
"
);
#else
putc
(
'\n'
,
stderr
);
#endif
fflush
(
stderr
);
if
(
status
)
exit
(
status
);
...
...
@@ -207,11 +245,10 @@ error (int status, int errnum, const char *message, ...)
else
{
#if _LIBC
if
(
_IO_fwide
(
stderr
,
0
)
>
0
)
__fwprintf
(
stderr
,
L"%s: "
,
program_name
);
else
#endif
__fxprintf
(
NULL
,
"%s: "
,
program_name
);
#else
fprintf
(
stderr
,
"%s: "
,
program_name
);
#endif
}
va_start
(
args
,
message
);
...
...
@@ -267,22 +304,19 @@ error_at_line (int status, int errnum, const char *file_name,
else
{
#if _LIBC
if
(
_IO_fwide
(
stderr
,
0
)
>
0
)
__fwprintf
(
stderr
,
L"%s: "
,
program_name
);
else
#endif
__fxprintf
(
NULL
,
"%s:"
,
program_name
);
#else
fprintf
(
stderr
,
"%s:"
,
program_name
);
#endif
}
if
(
file_name
!=
NULL
)
{
#if _LIBC
if
(
_IO_fwide
(
stderr
,
0
)
>
0
)
__fwprintf
(
stderr
,
L"%s:%d: "
,
file_name
,
line_number
);
else
__fxprintf
(
NULL
,
file_name
!=
NULL
?
"%s:%d: "
:
" "
,
file_name
,
line_number
);
#else
fprintf
(
stderr
,
file_name
!=
NULL
?
"%s:%d: "
:
" "
,
file_name
,
line_number
);
#endif
fprintf
(
stderr
,
"%s:%d: "
,
file_name
,
line_number
);
}
va_start
(
args
,
message
);
error_tail
(
status
,
errnum
,
message
,
args
);
...
...
lib/error.h
View file @
94fdc60
/* Declaration for error-reporting function
Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
Copyright (C) 1995, 1996, 1997, 2003
, 2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
...
...
@@ -21,7 +21,7 @@
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|| __STRICT_ANSI__
# define __attribute__(Spec)
/* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
...
...
lib/exit.h
View file @
94fdc60
...
...
@@ -21,7 +21,7 @@
/* Get exit() declaration. */
#include <stdlib.h>
/* Some systems do not define EXIT_*,
even with STDC_HEADERS
. */
/* Some systems do not define EXIT_*,
despite otherwise supporting C89
. */
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
...
...
lib/exitfail.c
View file @
94fdc60
/* Failure exit status
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003
, 2005
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
...
...
lib/mbswidth.c
View file @
94fdc60
/* Determine the number of screen columns needed for a string.
Copyright (C) 2000-200
5
Free Software Foundation, Inc.
Copyright (C) 2000-200
6
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
...
...
@@ -32,7 +32,7 @@
/* Get isprint(). */
#include <ctype.h>
/* Get mbstate_t, mbrtowc(), mbsinit()
, wcwidth()
. */
/* Get mbstate_t, mbrtowc(), mbsinit(). */
#if HAVE_WCHAR_H
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
<wchar.h>.
...
...
@@ -43,15 +43,15 @@
# include <wchar.h>
#endif
/* Get iswprint(), iswcntrl(). */
/* Get wcwidth(). */
#include "wcwidth.h"
/* Get iswcntrl(). */
#if HAVE_WCTYPE_H
# include <wctype.h>
#endif
#if !defined iswprint && !HAVE_ISWPRINT
# define iswprint(wc) 1
#endif
#if !defined iswcntrl && !HAVE_ISWCNTRL
# define iswcntrl(wc)
0
# define iswcntrl(wc)
(((wc) & ~0x1f) == 0 || (wc) == 0x7f)
#endif
#ifndef mbsinit
...
...
@@ -60,33 +60,6 @@
# endif
#endif
#ifndef HAVE_DECL_WCWIDTH
"this configure-time declaration test was not run"
#endif
#if !HAVE_DECL_WCWIDTH
int
wcwidth
();
#endif
#ifndef wcwidth
# if !HAVE_WCWIDTH
/* wcwidth doesn't exist, so assume all printable characters have
width 1. */
# define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -1)
# endif
#endif
/* Get ISPRINT. */
#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
/* Undefine to protect against the definition in wctype.h of Solaris 2.6. */
#undef ISPRINT
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#undef ISCNTRL
#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
/* Returns the number of columns needed to represent the multibyte
character string pointed to by STRING. If a non-printable character
occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned.
...
...
@@ -210,10 +183,10 @@ mbsnwidth (const char *string, size_t nbytes, int flags)
{
unsigned
char
c
=
(
unsigned
char
)
*
p
++
;
if
(
ISPRINT
(
c
))
if
(
isprint
(
c
))
width
++
;
else
if
(
!
(
flags
&
MBSW_REJECT_UNPRINTABLE
))
width
+=
(
ISCNTRL
(
c
)
?
0
:
1
);
width
+=
(
iscntrl
(
c
)
?
0
:
1
);
else
return
-
1
;
}
...
...
lib/obstack.c
View file @
94fdc60
/* obstack.c - subroutines used implicitly by object stack macros
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation,
Inc.
1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
, 2006 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
...
...
@@ -55,13 +55,7 @@
#ifndef ELIDE_CODE
# if HAVE_INTTYPES_H
# include <inttypes.h>
# endif
# if HAVE_STDINT_H || defined _LIBC
# include <stdint.h>
# endif
/* Determine default alignment. */
union
fooround
...
...
lib/setenv.c
View file @
94fdc60
...
...
@@ -27,7 +27,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#if _LIBC || HAVE_UNISTD_H
# include <unistd.h>
#endif
#if !_LIBC
# include "allocsa.h"
...
...
lib/snprintf.c
View file @
94fdc60
/* Formatted output to strings.
Copyright (C) 2004 Free Software Foundation, Inc.
Written by Simon Josefsson.
Copyright (C) 2004
, 2006
Free Software Foundation, Inc.
Written by Simon Josefsson
and Paul Eggert
.
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
...
...
@@ -22,13 +22,19 @@
#include "snprintf.h"
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "minmax.h"
#include "vasnprintf.h"
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
#ifndef EOVERFLOW
# define EOVERFLOW E2BIG
#endif
/* Print formatted output to string STR. Similar to sprintf, but
additional length SIZE limit how much is written into STR. Returns
string length of formatted string (which may be larger than SIZE).
...
...
@@ -39,22 +45,34 @@ snprintf (char *str, size_t size, const char *format, ...)
{
char
*
output
;
size_t
len
;
size_t
lenbuf
=
size
;
va_list
args
;
va_start
(
args
,
format
);
len
=
size
;
output
=
vasnprintf
(
str
,
&
len
,
format
,
args
)
;
output
=
vasnprintf
(
str
,
&
lenbuf
,
format
,
args
)
;
len
=
lenbuf
;
va_end
(
args
);
if
(
!
output
)
return
-
1
;
if
(
str
!=
NULL
)
if
(
len
>
size
-
1
)
/* equivalent to: (size > 0 && len >= size) */
str
[
size
-
1
]
=
'\0'
;
if
(
output
!=
str
)
{
if
(
size
)
{
size_t
pruned_len
=
(
len
<
size
?
len
:
size
-
1
);
memcpy
(
str
,
output
,
pruned_len
);
str
[
pruned_len
]
=
'\0'
;
}
free
(
output
);
}
if
(
INT_MAX
<
len
)
{
errno
=
EOVERFLOW
;
return
-
1
;
}
return
len
;
}
...
...
lib/vasprintf.c
View file @
94fdc60
/* Formatted output to strings.
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
Copyright (C) 1999, 2002
, 2006
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
...
...
@@ -22,10 +22,17 @@
/* Specification. */
#include "vasprintf.h"
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include "vasnprintf.h"
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
#ifndef EOVERFLOW
# define EOVERFLOW E2BIG
#endif
int
vasprintf
(
char
**
resultp
,
const
char
*
format
,
va_list
args
)
{
...
...
@@ -34,9 +41,14 @@ vasprintf (char **resultp, const char *format, va_list args)
if
(
result
==
NULL
)
return
-
1
;
if
(
length
>
INT_MAX
)
{
free
(
result
);
errno
=
EOVERFLOW
;
return
-
1
;
}
*
resultp
=
result
;
/* Return the number of resulting bytes, excluding the trailing NUL.
If it wouldn't fit in an 'int', vasnprintf() would have returned NULL
and set errno to EOVERFLOW. */
/* Return the number of resulting bytes, excluding the trailing NUL. */
return
length
;
}
...
...
lib/vasprintf.h
View file @
94fdc60
...
...
@@ -11,8 +11,8 @@
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,
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. */
#ifndef _VASPRINTF_H
...
...
m4/argp.m4
View file @
94fdc60
# argp.m4 serial
6
# argp.m4 serial
7
dnl Copyright (C) 2003-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
...
...
@@ -7,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_ARGP],
[
AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_GETOPT_SUBSTITUTE])
...
...
@@ -14,13 +15,13 @@ AC_DEFUN([gl_ARGP],
[AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_NAME, 1,
[Define if program_invocation_name is declared])],
[AC_DEFINE(GNULIB_PROGRAM_INVOCATION_NAME, 1,
[Define to 1 to add extern declaration of program_invocation_name to argp
-namefrob
.h])],
[Define to 1 to add extern declaration of program_invocation_name to argp.h])],
[#include <errno.h>])
AC_CHECK_DECL([program_invocation_short_name],
[AC_DEFINE(HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME, 1,
[Define if program_invocation_short_name is declared])],
[AC_DEFINE(GNULIB_PROGRAM_INVOCATION_SHORT_NAME, 1,
[Define to 1 to add extern declaration of program_invocation_short_name to argp
-namefrob
.h])],
[Define to 1 to add extern declaration of program_invocation_short_name to argp.h])],
[#include <errno.h>])
# Check if program_invocation_name and program_invocation_short_name
...
...
m4/d-type.m4
View file @
94fdc60
#serial
8
#serial
9
dnl From Jim Meyering.
dnl
dnl Check whether struct dirent has a member named d_type.
dnl
# Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
# Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004
, 2006
Free Software
# Foundation, Inc.
#
# This file is free software; the Free Software Foundation
...
...
@@ -13,26 +13,12 @@ dnl
# with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
[AC_REQUIRE([AC_HEADER_DIRENT])dnl
AC_CACHE_CHECK([for d_type member in directory struct],
[AC_CACHE_CHECK([for d_type member in directory struct],
jm_cv_struct_dirent_d_type,
[AC_TRY_LINK(dnl
[
#include <sys/types.h>
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#else /* not HAVE_DIRENT_H */
# define dirent direct
# ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif /* HAVE_SYS_NDIR_H */
# ifdef HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif /* HAVE_SYS_DIR_H */
# ifdef HAVE_NDIR_H
# include <ndir.h>
# endif /* HAVE_NDIR_H */
#endif /* HAVE_DIRENT_H */
#include <dirent.h>
],
[struct dirent dp; dp.d_type = 0;],
...
...
m4/exitfail.m4
View file @
94fdc60
# exitfail.m4 serial
5
dnl Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
# exitfail.m4 serial
6
dnl Copyright (C) 2002, 2003, 2005
, 2006
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_EXITFAIL],
[
AC_LIBSOURCES([exitfail.c, exitfail.h])
AC_LIBOBJ([exitfail])
dnl No prerequisites of lib/exitfail.c.
...
...
m4/fnmatch.m4
View file @
94fdc60
# Check for fnmatch.
# This is a modified version of autoconf's AC_FUNC_FNMATCH.
# This file should be simplified after Autoconf 2.57 is required.
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
# Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent.
# New applications should use the macros below instead.
# _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
# -------------------------------------------------------------------------
# If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
...
...
@@ -61,10 +61,9 @@ AS_IF([test $$2 = yes], [$3], [$4])
# ------------------
# Prepare the replacement of fnmatch.
AC_DEFUN([_MU_LIBOBJ_FNMATCH],
[AC_REQUIRE([AC_C_CONST])dnl
AC_REQUIRE([AC_FUNC_ALLOCA])dnl
[AC_REQUIRE([AC_FUNC_ALLOCA])dnl
AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
AC_CHECK_DECLS([
getenv
])
AC_CHECK_DECLS([
isblank], [], [], [#include <ctype.h>
])
AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
AC_CHECK_HEADERS([wchar.h wctype.h])
MU_LIBOBJ([fnmatch])
...
...
m4/getdelim.m4
View file @
94fdc60
# getdelim.m4 serial
1
# getdelim.m4 serial
2
dnl Copyright (C) 2005 Free Software dnl Foundation, Inc.
dnl Copyright (C) 2005
, 2006
Free Software dnl Foundation, Inc.
dnl
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
...
...
@@ -10,7 +10,6 @@ AC_PREREQ(2.52)
AC_DEFUN([gl_FUNC_GETDELIM],
[
MU_LIBSOURCES([getdelim.c, getdelim.h])
dnl Persuade glibc <stdio.h> to declare getdelim().
AC_REQUIRE([AC_GNU_SOURCE])
...
...
m4/getline.m4
View file @
94fdc60
# getline.m4 serial 1
3
# getline.m4 serial 1
5
dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 Free Software
dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
, 2006
Free Software
dnl Foundation, Inc.
dnl
dnl This file is free software; the Free Software Foundation
...
...
@@ -15,8 +15,6 @@ dnl have a function by that name in -linet that doesn't have anything
dnl to do with the function we need.
AC_DEFUN([gl_FUNC_GETLINE],
[
MU_LIBSOURCES([getline.c, getline.h])
dnl Persuade glibc <stdio.h> to declare getline().
AC_REQUIRE([AC_GNU_SOURCE])
...
...
@@ -47,7 +45,18 @@ AC_DEFUN([gl_FUNC_GETLINE],
}
], am_cv_func_working_getline=yes dnl The library version works.
, am_cv_func_working_getline=no dnl The library version does NOT work.
, am_cv_func_working_getline=no dnl We're cross compiling.
, dnl We're cross compiling. Assume it works on glibc2 systems.
[AC_EGREP_CPP([Lucky GNU user],
[
#include <features.h>
#ifdef __GNU_LIBRARY__
#if (__GLIBC__ >= 2)
Lucky GNU user
#endif
#endif
],
[am_cv_func_working_getline=yes],
[am_cv_func_working_getline=no])]
)])
fi
...
...
m4/getlogin_r.m4
View file @
94fdc60
#serial
2
#serial
3
# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
#
...
...
@@ -14,7 +14,6 @@ dnl
AC_DEFUN([gl_GETLOGIN_R_SUBSTITUTE],
[
gl_PREREQ_GETLOGIN_R
MU_LIBSOURCE([getlogin_r.h])
MU_LIBOBJ([getlogin_r])
])
...
...
m4/getopt.m4
View file @
94fdc60
# getopt.m4 serial 1
2
# getopt.m4 serial 1
3
dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 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.
# The getopt module assume you want GNU getopt, with getopt_long etc,
# rather than vanilla POSIX getopt. This means your
your
code should
# rather than vanilla POSIX getopt. This means your code should
# always include <getopt.h> for the getopt prototypes.
AC_DEFUN([gl_GETOPT_SUBSTITUTE],
...
...
m4/getpass.m4
View file @
94fdc60
# getpass.m4 serial
7
# getpass.m4 serial
9
dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
...
...
@@ -7,8 +7,6 @@ dnl with or without modifications, as long as this notice is preserved.
# Provide a getpass() function if the system doesn't have it.
AC_DEFUN([gl_FUNC_GETPASS],
[
AC_LIBSOURCES([getpass.c, getpass.h])
AC_REPLACE_FUNCS(getpass)
AC_CHECK_DECLS_ONCE(getpass)
if test $ac_cv_func_getpass = no; then
...
...
@@ -20,8 +18,6 @@ AC_DEFUN([gl_FUNC_GETPASS],
# arbitrary length (not just 8 bytes as on HP-UX).
AC_DEFUN([gl_FUNC_GETPASS_GNU],
[
AC_LIBSOURCES([getpass.c, getpass.h])
AC_CHECK_DECLS_ONCE(getpass)
dnl TODO: Detect when GNU getpass() is already found in glibc.
AC_LIBOBJ(getpass)
...
...
@@ -42,4 +38,5 @@ AC_DEFUN([gl_PREREQ_GETPASS], [
AC_CHECK_DECLS_ONCE([fputs_unlocked])
AC_CHECK_DECLS_ONCE([funlockfile])
AC_CHECK_DECLS_ONCE([putc_unlocked])
:
])
...
...
m4/glob.m4
View file @
94fdc60
# glob.m4 serial
3
dnl Copyright (C) 2005 Free Software Foundation, Inc.
# glob.m4 serial
7
dnl Copyright (C) 2005
, 2006
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.
# The glob module assumes you want GNU glob, with glob_pattern_p etc,
# rather than vanilla POSIX glob. This means your
your
code should
# rather than vanilla POSIX glob. This means your code should
# always include <glob.h> for the glob prototypes.
AC_DEFUN([gl_GLOB_SUBSTITUTE],
...
...
@@ -13,7 +13,6 @@ AC_DEFUN([gl_GLOB_SUBSTITUTE],
gl_PREREQ_GLOB
GLOB_H=glob.h
MU_LIBSOURCES([glob.c, glob_.h, glob-libc.h])
MU_LIBOBJ([glob])
AC_SUBST([GLOB_H])
])
...
...
@@ -73,8 +72,8 @@ if (glob ("conf*-globtest", 0, NULL, &found) == GLOB_NOMATCH) return 1;]]),
# Prerequisites of lib/glob.*.
AC_DEFUN([gl_PREREQ_GLOB],
[ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])dnl
AC_REQUIRE([AC_C_RESTRICT])dnl
AC_REQUIRE([AC_GNU_SOURCE])dnl
AC_REQUIRE([AC_HEADER_DIRENT])dnl
AC_CHECK_HEADERS_ONCE([sys/cdefs.h unistd.h])dnl
AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r])dnl
:])
...
...
m4/intmax_t.m4
View file @
94fdc60
# intmax_t.m4 serial
4
dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
# intmax_t.m4 serial
5
dnl Copyright (C) 1997-2004
, 2006
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.
...
...
@@ -46,7 +46,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
#if HAVE_INTTYPES_H_WITH_UINTMAX
#include <inttypes.h>
#endif
], [intmax_t x = -1;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
], [intmax_t x = -1;
return !x;
], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
if test $gt_cv_c_intmax_t = yes; then
AC_DEFINE(HAVE_INTMAX_T, 1,
[Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
...
...
m4/inttostr.m4
View file @
94fdc60
#serial
5
dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#serial
6
dnl Copyright (C) 2004, 2005
, 2006
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_INTTOSTR],
[
MU_LIBSOURCES([inttostr.c, inttostr.h, intprops.h])
dnl We don't technically need to list the following .c files, since their
dnl functions are named in the MU_LIBOBJ calls, but this is an unusual
dnl module and it seems a little clearer to do so.
MU_LIBSOURCES([imaxtostr.c, offtostr.c, umaxtostr.c])
MU_LIBOBJ([imaxtostr])
MU_LIBOBJ([offtostr])
MU_LIBOBJ([umaxtostr])
...
...
@@ -25,8 +18,6 @@ AC_DEFUN([gl_INTTOSTR],
# Prerequisites of lib/inttostr.h.
AC_DEFUN([gl_PREREQ_INTTOSTR], [
AC_REQUIRE([gl_AC_TYPE_INTMAX_T])
AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])
AC_REQUIRE([AC_TYPE_OFF_T])
:
])
...
...
m4/inttypes_h_gl.m4
View file @
94fdc60
# inttypes_h.m4 serial
6
dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
# inttypes_h.m4 serial
7
dnl Copyright (C) 1997-2004
, 2006
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.
...
...
@@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_INTTYPES_H],
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <inttypes.h>],
[uintmax_t i = (uintmax_t) -1;],
[uintmax_t i = (uintmax_t) -1;
return !i;
],
gl_cv_header_inttypes_h=yes,
gl_cv_header_inttypes_h=no)])
if test $gl_cv_header_inttypes_h = yes; then
...
...
m4/longlong_gl.m4
View file @
94fdc60
# longlong.m4 serial
5
dnl Copyright (C) 1999-200
4
Free Software Foundation, Inc.
# longlong.m4 serial
7
dnl Copyright (C) 1999-200
6
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 Paul Eggert.
# Define HAVE_LONG_LONG if 'long long' works.
# Define HAVE_LONG_LONG_INT if 'long long int' works.
# This fixes a bug in Autoconf 2.60, but can be removed once we
# assume 2.61 everywhere.
AC_DEFUN([AC_TYPE_LONG_LONG_INT],
[
AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[long long int ll = 9223372036854775807ll;
long long int nll = -9223372036854775807LL;
typedef int a[((-9223372036854775807LL < 0
&& 0 < 9223372036854775807ll)
? 1 : -1)];
int i = 63;]],
[[long long int llmax = 9223372036854775807ll;
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
| (llmax / ll) | (llmax % ll));]])],
[ac_cv_type_long_long_int=yes],
[ac_cv_type_long_long_int=no])])
if test $ac_cv_type_long_long_int = yes; then
AC_DEFINE([HAVE_LONG_LONG_INT], 1,
[Define to 1 if the system has the type `long long int'.])
fi
])
# This macro is obsolescent and should go away soon.
AC_DEFUN([gl_AC_TYPE_LONG_LONG],
[
AC_CACHE_CHECK([for long long], ac_cv_type_long_long,
[AC_TRY_LINK([long long ll = 1LL; int i = 63;],
[long long llmax = (long long) -1;
return ll << i | ll >> i | llmax / ll | llmax % ll;],
ac_cv_type_long_long=yes,
ac_cv_type_long_long=no)])
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
ac_cv_type_long_long=$ac_cv_type_long_long_int
if test $ac_cv_type_long_long = yes; then
AC_DEFINE(HAVE_LONG_LONG, 1,
[Define if you have the 'long long' type.])
...
...
m4/mbchar.m4
View file @
94fdc60
# mbchar.m4 serial
2
dnl Copyright (C) 2005 Free Software Foundation, Inc.
# mbchar.m4 serial
4
dnl Copyright (C) 2005
-2006
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.
...
...
@@ -10,11 +10,14 @@ dnl From Bruno Haible.
AC_DEFUN([gl_MBCHAR],
[
AC_REQUIRE([AC_GNU_SOURCE])
dnl The following line is that so the user can test
dnl
HAVE_WCHAR_H && HAVE_WCTYPE_H
before #include "mbchar.h".
AC_CHECK_HEADERS_ONCE(
wchar.h wctype.h
)
dnl Compile mbchar.c only if HAVE_WCHAR_H
&& HAVE_WCTYPE_H
.
if test $ac_cv_header_wchar_h = yes
&& test $ac_cv_header_wctype_h = yes
; then
dnl The following line is that so the user can test
HAVE_WCHAR_H
dnl before #include "mbchar.h".
AC_CHECK_HEADERS_ONCE(
[wchar.h]
)
dnl Compile mbchar.c only if HAVE_WCHAR_H.
if test $ac_cv_header_wchar_h = yes; then
MU_LIBOBJ([mbchar])
dnl Prerequisites of mbchar.h and mbchar.c.
AC_CHECK_HEADERS_ONCE([wctype.h])
AC_CHECK_FUNCS([iswcntrl])
fi
])
...
...
m4/mbswidth.m4
View file @
94fdc60
# mbswidth.m4 serial 1
1
dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc.
# mbswidth.m4 serial 1
2
dnl Copyright (C) 2000-2002, 2004
, 2006
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.
...
...
@@ -9,33 +9,11 @@ dnl From Bruno Haible.
AC_DEFUN([gl_MBSWIDTH],
[
AC_CHECK_HEADERS_ONCE(
wchar.h wctype.h
)
AC_CHECK_FUNCS_ONCE(
isascii iswprint mbsinit
)
AC_CHECK_FUNCS(
iswcntrl wcwidth
)
AC_CHECK_HEADERS_ONCE(
[wchar.h wctype.h]
)
AC_CHECK_FUNCS_ONCE(
[isascii mbsinit]
)
AC_CHECK_FUNCS(
[iswcntrl]
)
gl_FUNC_MBRTOWC
AC_CACHE_CHECK([whether wcwidth is declared], ac_cv_have_decl_wcwidth,
[AC_TRY_COMPILE([
/* AIX 3.2.5 declares wcwidth in <string.h>. */
#if HAVE_STRING_H
# include <string.h>
#endif
#if HAVE_WCHAR_H
# include <wchar.h>
#endif
], [
#ifndef wcwidth
char *p = (char *) wcwidth;
#endif
], ac_cv_have_decl_wcwidth=yes, ac_cv_have_decl_wcwidth=no)])
if test $ac_cv_have_decl_wcwidth = yes; then
ac_val=1
else
ac_val=0
fi
AC_DEFINE_UNQUOTED(HAVE_DECL_WCWIDTH, $ac_val,
[Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.])
dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth()
dnl that clashes with ours.
AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>],
...
...
m4/md5.m4
View file @
94fdc60
# md5.m4 serial
8
dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
# md5.m4 serial
9
dnl Copyright (C) 2002, 2003, 2004, 2005
, 2006
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_MD5],
[
MU_LIBSOURCES([md5.c, md5.h])
MU_LIBOBJ([md5])
dnl Prerequisites of lib/md5.c.
...
...
m4/mempcpy.m4
View file @
94fdc60
# mempcpy.m4 serial
3
dnl Copyright (C) 2003, 2004 Free Software Foundation, Inc.
# mempcpy.m4 serial
4
dnl Copyright (C) 2003, 2004
, 2006
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_FUNC_MEMPCPY],
[
MU_LIBSOURCES([mempcpy.c, mempcpy.h])
dnl Persuade glibc <string.h> to declare mempcpy().
AC_REQUIRE([AC_GNU_SOURCE])
...
...
m4/onceonly.m4
View file @
94fdc60
# onceonly_2_57.m4 serial
3
dnl Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc.
# onceonly_2_57.m4 serial
4
dnl Copyright (C) 2002-2003, 2005
-2006
Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
...
...
@@ -10,7 +10,7 @@ dnl This file defines some "once only" variants of standard autoconf macros.
dnl AC_CHECK_HEADERS_ONCE like AC_CHECK_HEADERS
dnl AC_CHECK_FUNCS_ONCE like AC_CHECK_FUNCS
dnl AC_CHECK_DECLS_ONCE like AC_CHECK_DECLS
dnl AC_REQUIRE([AC_
HEADER_STDC]) like AC_HEADER_STDC
dnl AC_REQUIRE([AC_
FUNC_STRCOLL]) like AC_FUNC_STRCOLL
dnl The advantage is that the check for each of the headers/functions/decls
dnl will be put only once into the 'configure' file. It keeps the size of
dnl the 'configure' file down, and avoids redundant output when 'configure'
...
...
m4/regex.m4
View file @
94fdc60
#serial 3
6
#serial 3
9
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
# 2006 Free Software Foundation, Inc.
...
...
@@ -14,10 +14,6 @@ AC_PREREQ([2.50])
AC_DEFUN([gl_REGEX],
[
MU_LIBSOURCES(
[regcomp.c, regex.c, regex.h,
regex_internal.c, regex_internal.h, regexec.c])
AC_ARG_WITH([included-regex],
[AC_HELP_STRING([--without-included-regex],
[don't compile regex; this is the default on
...
...
@@ -28,7 +24,7 @@ AC_DEFUN([gl_REGEX],
yes|no) ac_use_included_regex=$with_included_regex
;;
'')
# If the system regex support is good enough that it passes the
the
# If the system regex support is good enough that it passes the
# following run test, then default to *not* using the included regex.c.
# If cross compiling, assume the test would fail and use the included
# regex.c. The first failing regular expression is from `Spencer ere
...
...
@@ -163,8 +159,9 @@ AC_DEFUN([gl_REGEX],
AC_DEFUN([gl_PREREQ_REGEX],
[
AC_REQUIRE([AC_GNU_SOURCE])
AC_REQUIRE([
gl
_C_RESTRICT])
AC_REQUIRE([
AC
_C_RESTRICT])
AC_REQUIRE([AM_LANGINFO_CODESET])
AC_CHECK_HEADERS_ONCE([locale.h wchar.h wctype.h])
AC_CHECK_FUNCS_ONCE([isblank mbrtowc mempcpy wcrtomb wcscoll])
AC_CHECK_FUNCS_ONCE([mbrtowc mempcpy wcrtomb wcscoll])
AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
])
...
...
m4/sha1.m4
View file @
94fdc60
# sha1.m4 serial
6
dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
# sha1.m4 serial
7
dnl Copyright (C) 2002, 2003, 2004, 2005
, 2006
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_SHA1],
[
MU_LIBSOURCES([sha1.c, sha1.h])
MU_LIBOBJ([sha1])
dnl Prerequisites of lib/sha1.c.
...
...
m4/stat-macros.m4
View file @
94fdc60
#serial
2
#serial
3
# Copyright (C) 2005 Free Software Foundation, Inc.
# Copyright (C) 2005
, 2006
Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
...
...
@@ -8,7 +8,5 @@
AC_DEFUN([gl_STAT_MACROS],
[
MU_LIBSOURCES([stat-macros.h])
AC_REQUIRE([AC_HEADER_STAT])
])
...
...
m4/stdint.m4
View file @
94fdc60
This diff is collapsed.
Click to expand it.
m4/stdint_h_gl.m4
View file @
94fdc60
# stdint_h.m4 serial
5
dnl Copyright (C) 1997-2004 Free Software Foundation, Inc.
# stdint_h.m4 serial
6
dnl Copyright (C) 1997-2004
, 2006
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.
...
...
@@ -15,7 +15,7 @@ AC_DEFUN([gl_AC_HEADER_STDINT_H],
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <stdint.h>],
[uintmax_t i = (uintmax_t) -1;],
[uintmax_t i = (uintmax_t) -1;
return !i;
],
gl_cv_header_stdint_h=yes,
gl_cv_header_stdint_h=no)])
if test $gl_cv_header_stdint_h = yes; then
...
...
m4/strdup.m4
View file @
94fdc60
# strdup.m4 serial
6
dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
# strdup.m4 serial
7
dnl Copyright (C) 2002, 2003, 2004, 2005
, 2006
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_FUNC_STRDUP],
[
MU_LIBSOURCES([strdup.c, strdup.h])
MU_REPLACE_FUNCS(strdup)
AC_CHECK_DECLS_ONCE(strdup)
gl_PREREQ_STRDUP
...
...
m4/strndup.m4
View file @
94fdc60
# strndup.m4 serial
6
# strndup.m4 serial
8
dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
...
...
@@ -6,8 +6,6 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_STRNDUP],
[
MU_LIBSOURCES([strndup.c, strndup.h])
dnl Persuade glibc <string.h> to declare strndup().
AC_REQUIRE([AC_GNU_SOURCE])
...
...
@@ -27,13 +25,15 @@ AC_DEFUN([gl_FUNC_STRNDUP],
return s[13] != '\0';]])],
[gl_cv_func_strndup=yes],
[gl_cv_func_strndup=no],
[AC_CHECK_FUNC([strndup],
[AC_EGREP_CPP([too risky], [
#ifdef _AIX
too risky
#endif
],
[gl_cv_func_strndup=no],
[gl_cv_func_strndup=yes])])])
[gl_cv_func_strndup=yes])],
[gl_cv_func_strndup=no])])])
if test $gl_cv_func_strndup = yes; then
AC_DEFINE([HAVE_STRNDUP], 1,
[Define if you have the strndup() function and it works.])
...
...
m4/strnlen.m4
View file @
94fdc60
# strnlen.m4 serial
5
dnl Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc.
# strnlen.m4 serial
6
dnl Copyright (C) 2002-2003, 2005
, 2006
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_FUNC_STRNLEN],
[
MU_LIBSOURCES([strnlen.c, strnlen.h])
dnl Persuade glibc <string.h> to declare strnlen().
AC_REQUIRE([AC_GNU_SOURCE])
...
...
m4/strtok_r.m4
View file @
94fdc60
# strtok_r.m4 serial
2
# strtok_r.m4 serial
3
dnl Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
...
...
@@ -13,5 +13,5 @@ AC_DEFUN([gl_FUNC_STRTOK_R],
# Prerequisites of lib/strtok_r.h and lib/strtok_r.c.
AC_DEFUN([gl_PREREQ_STRTOK_R], [
AC_REQUIRE([
gl
_C_RESTRICT])
AC_REQUIRE([
AC
_C_RESTRICT])
])
...
...
m4/xalloc.m4
View file @
94fdc60
# xalloc.m4 serial 1
2
dnl Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
# xalloc.m4 serial 1
3
dnl Copyright (C) 2002, 2003, 2004, 2005
, 2006
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_XALLOC],
[
AC_LIBSOURCES([xmalloc.c, xalloc.h])
AC_LIBOBJ([xmalloc])
gl_PREREQ_XALLOC
...
...
mailbox/argp-help.c
View file @
94fdc60
...
...
@@ -1475,45 +1475,50 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
{
const
char
*
text
;
const
char
*
inp_text
;
size_t
inp_text_len
=
0
;
const
char
*
trans_text
;
void
*
input
=
0
;
int
anything
=
0
;
size_t
inp_text_limit
=
0
;
const
char
*
doc
=
dgettext
(
argp
->
argp_domain
,
argp
->
doc
);
const
struct
argp_child
*
child
=
argp
->
children
;
if
(
doc
)
if
(
argp
->
doc
)
{
char
*
vt
=
strchr
(
doc
,
'\v'
);
inp_text
=
post
?
(
vt
?
vt
+
1
:
0
)
:
doc
;
inp_text_limit
=
(
!
post
&&
vt
)
?
(
vt
-
doc
)
:
0
;
char
*
vt
=
strchr
(
argp
->
doc
,
'\v'
);
if
(
vt
)
{
if
(
post
)
inp_text
=
vt
+
1
;
else
{
inp_text_len
=
vt
-
argp
->
doc
;
inp_text
=
__strndup
(
argp
->
doc
,
inp_text_len
);
}
}
else
inp_text
=
0
;
inp_text
=
post
?
0
:
argp
->
doc
;
trans_text
=
dgettext
(
argp
->
argp_domain
,
inp_text
);
}
else
trans_text
=
inp_text
=
0
;
if
(
argp
->
help_filter
)
/* We have to filter the doc strings. */
{
if
(
inp_text_limit
)
/* Copy INP_TEXT so that it's nul-terminated. */
inp_text
=
__strndup
(
inp_text
,
inp_text_limit
);
input
=
__argp_input
(
argp
,
state
);
text
=
(
*
argp
->
help_filter
)
(
post
?
ARGP_KEY_HELP_POST_DOC
:
ARGP_KEY_HELP_PRE_DOC
,
inp
_text
,
input
);
trans
_text
,
input
);
}
else
text
=
(
const
char
*
)
inp
_text
;
text
=
(
const
char
*
)
trans
_text
;
if
(
text
)
{
if
(
pre_blank
)
__argp_fmtstream_putc
(
stream
,
'\n'
);
if
(
text
==
inp_text
&&
inp_text_limit
)
__argp_fmtstream_write
(
stream
,
inp_text
,
inp_text_limit
);
else
__argp_fmtstream_puts
(
stream
,
text
);
if
(
__argp_fmtstream_point
(
stream
)
>
__argp_fmtstream_lmargin
(
stream
))
...
...
@@ -1522,9 +1527,10 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
anything
=
1
;
}
if
(
text
&&
text
!=
inp
_text
)
if
(
text
&&
text
!=
trans
_text
)
free
((
char
*
)
text
);
/* Free TEXT returned from the help filter. */
if
(
inp_text
&&
inp_text_limit
&&
argp
->
help_filter
)
if
(
inp_text
&&
inp_text_len
)
free
((
char
*
)
inp_text
);
/* We copied INP_TEXT, so free it now. */
if
(
post
&&
argp
->
help_filter
)
...
...
mailbox/argp-namefrob.h
View file @
94fdc60
...
...
@@ -141,20 +141,6 @@
# define putchar_unlocked(x) putchar (x)
# endif
/* GNULIB makes sure both program_invocation_name and
program_invocation_short_name are available */
#ifdef GNULIB_PROGRAM_INVOCATION_NAME
extern
char
*
program_invocation_name
;
# undef HAVE_DECL_PROGRAM_INVOCATION_NAME
# define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
#endif
#ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME
extern
char
*
program_invocation_short_name
;
# undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
# define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1
#endif
#endif
/* !_LIBC */
#ifndef __set_errno
...
...
mailbox/argp-parse.c
View file @
94fdc60
...
...
@@ -877,6 +877,20 @@ __argp_parse (const struct argp *argp, int argc, char **argv, unsigned flags,
to be parsed (which in some cases isn't actually an error). */
int
arg_ebadkey
=
0
;
#ifndef _LIBC
if
(
!
(
flags
&
ARGP_PARSE_ARGV0
))
{
#ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
if
(
!
program_invocation_name
)
program_invocation_name
=
argv
[
0
];
#endif
#ifdef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
if
(
!
program_invocation_short_name
)
program_invocation_short_name
=
__argp_base_name
(
argv
[
0
]);
#endif
}
#endif
if
(
!
(
flags
&
ARGP_NO_HELP
))
/* Add our own options. */
{
...
...
mailbox/argp-pv.c
View file @
94fdc60
/* Default definition for ARGP_PROGRAM_VERSION.
Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
Copyright (C) 1996, 1997, 1999
, 2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <miles@gnu.ai.mit.edu>.
...
...
@@ -19,6 +19,6 @@
/* If set by the user program to a non-zero value, then a default option
--version is added (unless the ARGP_NO_HELP flag is used), which will
print this
this
string followed by a newline and exit (unless the
print this string followed by a newline and exit (unless the
ARGP_NO_EXIT flag is used). Overridden by ARGP_PROGRAM_VERSION_HOOK. */
const
char
*
argp_program_version
;
...
...
mailbox/argp.h
View file @
94fdc60
...
...
@@ -94,7 +94,10 @@ struct argp_option
/* The doc string for this option. If both NAME and KEY are 0, This string
will be printed outdented from the normal option column, making it
useful as a group header (it will be the first thing printed in its
group); in this usage, it's conventional to end the string with a `:'. */
group); in this usage, it's conventional to end the string with a `:'.
Write the initial value as N_("TEXT") if you want xgettext to collect
it into a POT file. */
const
char
*
doc
;
/* The group this option is in. In a long help message, options are sorted
...
...
@@ -243,7 +246,9 @@ struct argp
/* If non-NULL, a string containing extra text to be printed before and
after the options in a long help message (separated by a vertical tab
`\v' character). */
`\v' character).
Write the initial value as N_("BEFORE-TEXT") "\v" N_("AFTER-TEXT") if
you want xgettext to collect the two pieces of text into a POT file. */
const
char
*
doc
;
/* A vector of argp_children structures, terminated by a member with a 0
...
...
@@ -418,6 +423,20 @@ extern error_t __argp_parse (const struct argp *__restrict __argp,
/* Global variables. */
/* GNULIB makes sure both program_invocation_name and
program_invocation_short_name are available */
#ifdef GNULIB_PROGRAM_INVOCATION_NAME
extern
char
*
program_invocation_name
;
# undef HAVE_DECL_PROGRAM_INVOCATION_NAME
# define HAVE_DECL_PROGRAM_INVOCATION_NAME 1
#endif
#ifdef GNULIB_PROGRAM_INVOCATION_SHORT_NAME
extern
char
*
program_invocation_short_name
;
# undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
# define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 1
#endif
/* If defined or set by the user program to a non-zero value, then a default
option --version is added (unless the ARGP_NO_HELP flag is used), which
will print this string followed by a newline and exit (unless the
...
...
mailbox/fnmatch.c
View file @
94fdc60
...
...
@@ -86,34 +86,10 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
#if defined _LIBC || !defined __GNU_LIBRARY__ || !HAVE_FNMATCH_GNU
# if defined STDC_HEADERS || !defined isascii
# define ISASCII(c) 1
# else
# define ISASCII(c) isascii(c)
# endif
# ifdef isblank
# define ISBLANK(c) (ISASCII (c) && isblank (c))
# else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
# endif
# ifdef isgraph
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
# else
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
# if ! (defined isblank || HAVE_DECL_ISBLANK)
# define isblank(c) ((c) == ' ' || (c) == '\t')
# endif
# define ISPRINT(c) (ISASCII (c) && isprint (c))
# define ISDIGIT(c) (ISASCII (c) && isdigit (c))
# define ISALNUM(c) (ISASCII (c) && isalnum (c))
# define ISALPHA(c) (ISASCII (c) && isalpha (c))
# define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
# define ISLOWER(c) (ISASCII (c) && islower (c))
# define ISPUNCT(c) (ISASCII (c) && ispunct (c))
# define ISSPACE(c) (ISASCII (c) && isspace (c))
# define ISUPPER(c) (ISASCII (c) && isupper (c))
# define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
# if defined _LIBC || WIDE_CHAR_SUPPORT
...
...
@@ -169,11 +145,7 @@ static int posixly_correct;
# endif
/* Note that this evaluates C many times. */
# ifdef _LIBC
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
# else
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
# endif
# define CHAR char
# define UCHAR unsigned char
# define INT int
...
...
mailbox/fnmatch_loop.c
View file @
94fdc60
...
...
@@ -288,18 +288,18 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
goto
matched
;
# endif
#else
if
((
STREQ
(
str
,
L_
(
"alnum"
))
&&
ISALNUM
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"alpha"
))
&&
ISALPHA
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"blank"
))
&&
ISBLANK
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"cntrl"
))
&&
ISCNTRL
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"digit"
))
&&
ISDIGIT
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"graph"
))
&&
ISGRAPH
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"lower"
))
&&
ISLOWER
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"print"
))
&&
ISPRINT
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"punct"
))
&&
ISPUNCT
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"space"
))
&&
ISSPACE
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"upper"
))
&&
ISUPPER
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"xdigit"
))
&&
ISXDIGIT
((
UCHAR
)
*
n
)))
if
((
STREQ
(
str
,
L_
(
"alnum"
))
&&
isalnum
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"alpha"
))
&&
isalpha
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"blank"
))
&&
isblank
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"cntrl"
))
&&
iscntrl
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"digit"
))
&&
isdigit
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"graph"
))
&&
isgraph
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"lower"
))
&&
islower
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"print"
))
&&
isprint
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"punct"
))
&&
ispunct
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"space"
))
&&
isspace
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"upper"
))
&&
isupper
((
UCHAR
)
*
n
))
||
(
STREQ
(
str
,
L_
(
"xdigit"
))
&&
isxdigit
((
UCHAR
)
*
n
)))
goto
matched
;
#endif
c
=
*
p
++
;
...
...
mailbox/getopt.c
View file @
94fdc60
...
...
@@ -31,7 +31,7 @@
#include <string.h>
#include <unistd.h>
#ifdef VMS
#ifdef
__
VMS
# include <unixlib.h>
#endif
...
...
mailbox/gettext.h
View file @
94fdc60
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002, 2004 Free Software Foundation, Inc.
Copyright (C) 1995-1998, 2000-2002, 2004
-2006
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
...
...
@@ -75,4 +75,168 @@
initializer for static 'char[]' or 'const char[]' variables. */
#define gettext_noop(String) String
/* The separator between msgctxt and msgid in a .mo file. */
#define GETTEXT_CONTEXT_GLUE "\004"
/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
short and rarely need to change.
The letter 'p' stands for 'particular' or 'special'. */
#define pgettext(Msgctxt, Msgid) \
pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#define dpgettext(Domainname, Msgctxt, Msgid) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
#define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static
const
char
*
pgettext_aux
(
const
char
*
domain
,
const
char
*
msg_ctxt_id
,
const
char
*
msgid
,
int
category
)
{
const
char
*
translation
=
dcgettext
(
domain
,
msg_ctxt_id
,
category
);
if
(
translation
==
msg_ctxt_id
)
return
msgid
;
else
return
translation
;
}
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static
const
char
*
npgettext_aux
(
const
char
*
domain
,
const
char
*
msg_ctxt_id
,
const
char
*
msgid
,
const
char
*
msgid_plural
,
unsigned
long
int
n
,
int
category
)
{
const
char
*
translation
=
dcngettext
(
domain
,
msg_ctxt_id
,
msgid_plural
,
n
,
category
);
if
(
translation
==
msg_ctxt_id
||
translation
==
msgid_plural
)
return
(
n
==
1
?
msgid
:
msgid_plural
);
else
return
translation
;
}
/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
can be arbitrary expressions. But for string literals these macros are
less efficient than those above. */
#include <string.h>
#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
(__GNUC__ >= 3 || defined __cplusplus)
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
#include <stdlib.h>
#endif
#define pgettext_expr(Msgctxt, Msgid) \
dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static
const
char
*
dcpgettext_expr
(
const
char
*
domain
,
const
char
*
msgctxt
,
const
char
*
msgid
,
int
category
)
{
size_t
msgctxt_len
=
strlen
(
msgctxt
)
+
1
;
size_t
msgid_len
=
strlen
(
msgid
)
+
1
;
const
char
*
translation
;
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
char
msg_ctxt_id
[
msgctxt_len
+
msgid_len
];
#else
char
buf
[
1024
];
char
*
msg_ctxt_id
=
(
msgctxt_len
+
msgid_len
<=
sizeof
(
buf
)
?
buf
:
(
char
*
)
malloc
(
msgctxt_len
+
msgid_len
));
if
(
msg_ctxt_id
!=
NULL
)
#endif
{
memcpy
(
msg_ctxt_id
,
msgctxt
,
msgctxt_len
-
1
);
msg_ctxt_id
[
msgctxt_len
-
1
]
=
'\004'
;
memcpy
(
msg_ctxt_id
+
msgctxt_len
,
msgid
,
msgid_len
);
translation
=
dcgettext
(
domain
,
msg_ctxt_id
,
category
);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if
(
msg_ctxt_id
!=
buf
)
free
(
msg_ctxt_id
);
#endif
if
(
translation
!=
msg_ctxt_id
)
return
translation
;
}
return
msgid
;
}
#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
static
const
char
*
dcnpgettext_expr
(
const
char
*
domain
,
const
char
*
msgctxt
,
const
char
*
msgid
,
const
char
*
msgid_plural
,
unsigned
long
int
n
,
int
category
)
{
size_t
msgctxt_len
=
strlen
(
msgctxt
)
+
1
;
size_t
msgid_len
=
strlen
(
msgid
)
+
1
;
const
char
*
translation
;
#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
char
msg_ctxt_id
[
msgctxt_len
+
msgid_len
];
#else
char
buf
[
1024
];
char
*
msg_ctxt_id
=
(
msgctxt_len
+
msgid_len
<=
sizeof
(
buf
)
?
buf
:
(
char
*
)
malloc
(
msgctxt_len
+
msgid_len
));
if
(
msg_ctxt_id
!=
NULL
)
#endif
{
memcpy
(
msg_ctxt_id
,
msgctxt
,
msgctxt_len
-
1
);
msg_ctxt_id
[
msgctxt_len
-
1
]
=
'\004'
;
memcpy
(
msg_ctxt_id
+
msgctxt_len
,
msgid
,
msgid_len
);
translation
=
dcngettext
(
domain
,
msg_ctxt_id
,
msgid_plural
,
n
,
category
);
#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
if
(
msg_ctxt_id
!=
buf
)
free
(
msg_ctxt_id
);
#endif
if
(
!
(
translation
==
msg_ctxt_id
||
translation
==
msgid_plural
))
return
translation
;
}
return
(
n
==
1
?
msgid
:
msgid_plural
);
}
#endif
/* _LIBGETTEXT_H */
...
...
mailbox/glob.c
View file @
94fdc60
...
...
@@ -47,31 +47,12 @@
# define __set_errno(val) errno = (val)
#endif
#if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
# ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
# ifdef HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif
# ifdef HAVE_NDIR_H
# include <ndir.h>
# endif
# ifdef HAVE_VMSDIR_H
# include "vmsdir.h"
# endif
/* HAVE_VMSDIR_H */
#endif
#include <dirent.h>
/* In GNU systems, <dirent.h> defines this macro for us. */
#ifdef _D_NAMLEN
# undef NAMLEN
# define NAMLEN(d) _D_NAMLEN(d)
#ifndef _D_EXACT_NAMLEN
# define _D_EXACT_NAMLEN(dirent) strlen ((dirent)->d_name)
#endif
/* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
...
...
@@ -97,13 +78,6 @@
/* If the system has the `struct dirent64' type we use it internally. */
#if defined _LIBC && !defined COMPILE_GLOB64
# if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
# define CONVERT_D_NAMLEN(d64, d32)
# else
# define CONVERT_D_NAMLEN(d64, d32) \
(d64)->d_namlen = (d32)->d_namlen;
# endif
# if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__
# define CONVERT_D_INO(d64, d32)
# else
...
...
@@ -119,8 +93,7 @@
# endif
# define CONVERT_DIRENT_DIRENT64(d64, d32) \
memcpy ((d64)->d_name, (d32)->d_name, NAMLEN (d32) + 1); \
CONVERT_D_NAMLEN (d64, d32) \
memcpy ((d64)->d_name, (d32)->d_name, _D_EXACT_NAMLEN (d32) + 1); \
CONVERT_D_INO (d64, d32) \
CONVERT_D_TYPE (d64, d32)
#endif
...
...
@@ -511,7 +484,6 @@ glob (pattern, flags, errfunc, pglob)
oldcount
=
pglob
->
gl_pathc
+
pglob
->
gl_offs
;
#ifndef VMS
if
((
flags
&
(
GLOB_TILDE
|
GLOB_TILDE_CHECK
))
&&
dirname
[
0
]
==
'~'
)
{
if
(
dirname
[
1
]
==
'\0'
||
dirname
[
1
]
==
'/'
)
...
...
@@ -679,7 +651,6 @@ glob (pattern, flags, errfunc, pglob)
}
# endif
/* Not Amiga && not WINDOWS32. */
}
#endif
/* Not VMS. */
/* Now test whether we looked for "~" or "~NAME". In this case we
can give the answer now. */
...
...
@@ -1132,7 +1103,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
{
int
fnm_flags
=
((
!
(
flags
&
GLOB_PERIOD
)
?
FNM_PERIOD
:
0
)
|
((
flags
&
GLOB_NOESCAPE
)
?
FNM_NOESCAPE
:
0
)
#if defined _AMIGA || defined VMS
#if defined _AMIGA || defined
__
VMS
|
FNM_CASEFOLD
#endif
);
...
...
@@ -1205,7 +1176,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
struct
globlink
*
new
=
__alloca
(
sizeof
(
struct
globlink
));
char
*
p
;
len
=
NAMLEN
(
d
);
len
=
_D_EXACT_
NAMLEN
(
d
);
new
->
name
=
malloc
(
len
+
1
+
((
flags
&
GLOB_MARK
)
&&
isdir
));
if
(
new
->
name
==
NULL
)
...
...
mailbox/glob_.h
View file @
94fdc60
...
...
@@ -46,10 +46,6 @@
#endif
#ifndef HAVE_DIRENT_H
# define dirent direct
#endif
#define glob rpl_glob
#define globfree rpl_globfree
#define glob_pattern_p rpl_glob_pattern_p
...
...
mailbox/inttostr.h
View file @
94fdc60
/* inttostr.h -- convert integers to printable strings
Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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
...
...
@@ -18,13 +19,7 @@
/* Written by Paul Eggert */
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#include <stdint.h>
#include <sys/types.h>
#include "intprops.h"
...
...
mailbox/mbchar.h
View file @
94fdc60
/* Multibyte character data type.
Copyright (C) 2001, 2005 Free Software Foundation, Inc.
Copyright (C) 2001, 2005
-2006
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
...
...
@@ -156,7 +156,133 @@
#include <time.h>
#include <wchar.h>
#include <wctype.h>
/* BeOS 5 has the functions but no <wctype.h>. */
#if HAVE_WCTYPE_H
# include <wctype.h>
#endif
/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
Assume all 12 functions are implemented the same way, or not at all. */
#if !defined iswalnum && !HAVE_ISWCNTRL
static
inline
int
iswalnum
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
(
wc
>=
'0'
&&
wc
<=
'9'
)
||
((
wc
&
~
0x20
)
>=
'A'
&&
(
wc
&
~
0x20
)
<=
'Z'
)
:
0
);
}
# define iswalnum iswalnum
#endif
#if !defined iswalpha && !HAVE_ISWCNTRL
static
inline
int
iswalpha
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
(
wc
&
~
0x20
)
>=
'A'
&&
(
wc
&
~
0x20
)
<=
'Z'
:
0
);
}
# define iswalpha iswalpha
#endif
#if !defined iswblank && !HAVE_ISWCNTRL
static
inline
int
iswblank
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
wc
==
' '
||
wc
==
'\t'
:
0
);
}
# define iswblank iswblank
#endif
#if !defined iswcntrl && !HAVE_ISWCNTRL
static
inline
int
iswcntrl
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
(
wc
&
~
0x1f
)
==
0
||
wc
==
0x7f
:
0
);
}
# define iswcntrl iswcntrl
#endif
#if !defined iswdigit && !HAVE_ISWCNTRL
static
inline
int
iswdigit
(
wint_t
wc
)
{
return
(
wc
>=
'0'
&&
wc
<=
'9'
);
}
# define iswdigit iswdigit
#endif
#if !defined iswgraph && !HAVE_ISWCNTRL
static
inline
int
iswgraph
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
wc
>=
'!'
&&
wc
<=
'~'
:
1
);
}
# define iswgraph iswgraph
#endif
#if !defined iswlower && !HAVE_ISWCNTRL
static
inline
int
iswlower
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
wc
>=
'a'
&&
wc
<=
'z'
:
0
);
}
# define iswlower iswlower
#endif
#if !defined iswprint && !HAVE_ISWCNTRL
static
inline
int
iswprint
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
wc
>=
' '
&&
wc
<=
'~'
:
1
);
}
# define iswprint iswprint
#endif
#if !defined iswpunct && !HAVE_ISWCNTRL
static
inline
int
iswpunct
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
wc
>=
'!'
&&
wc
<=
'~'
&&
!
((
wc
>=
'0'
&&
wc
<=
'9'
)
||
((
wc
&
~
0x20
)
>=
'A'
&&
(
wc
&
~
0x20
)
<=
'Z'
))
:
1
);
}
# define iswpunct iswpunct
#endif
#if !defined iswspace && !HAVE_ISWCNTRL
static
inline
int
iswspace
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
wc
==
' '
||
wc
==
'\t'
||
wc
==
'\n'
||
wc
==
'\v'
||
wc
==
'\f'
||
wc
==
'\r'
:
0
);
}
# define iswspace iswspace
#endif
#if !defined iswupper && !HAVE_ISWCNTRL
static
inline
int
iswupper
(
wint_t
wc
)
{
return
(
wc
>=
0
&&
wc
<
128
?
wc
>=
'A'
&&
wc
<=
'Z'
:
0
);
}
# define iswupper iswupper
#endif
#if !defined iswxdigit && !HAVE_ISWCNTRL
static
inline
int
iswxdigit
(
wint_t
wc
)
{
return
(
wc
>=
'0'
&&
wc
<=
'9'
)
||
((
wc
&
~
0x20
)
>=
'A'
&&
(
wc
&
~
0x20
)
<=
'F'
);
}
# define iswxdigit iswxdigit
#endif
#include "wcwidth.h"
#define MBCHAR_BUF_SIZE 24
...
...
mailbox/printf-args.c
View file @
94fdc60
/* Decomposed printf argument list.
Copyright (C) 1999, 2002-2003, 2006 Free Software Foundation, Inc.
Copyright (C) 1999, 2002-2003, 200
5-200
6 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
...
...
@@ -79,7 +79,13 @@ printf_fetchargs (va_list args, arguments *a)
break
;
#ifdef HAVE_WINT_T
case
TYPE_WIDE_CHAR
:
ap
->
a
.
a_wide_char
=
va_arg
(
args
,
wint_t
);
/* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
default argument promotions", this is not the case in mingw32,
where wint_t is 'unsigned short'. */
ap
->
a
.
a_wide_char
=
(
sizeof
(
wint_t
)
<
sizeof
(
int
)
?
va_arg
(
args
,
int
)
:
va_arg
(
args
,
wint_t
));
break
;
#endif
case
TYPE_STRING
:
...
...
mailbox/regex.h
View file @
94fdc60
...
...
@@ -37,12 +37,6 @@ extern "C" {
# define __USE_GNU_REGEX 1
#endif
#ifdef __VMS
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
should be there. */
# include <stddef.h>
#endif
#ifdef _REGEX_LARGE_OFFSETS
/* Use types and values that are wide enough to represent signed and
...
...
@@ -641,9 +635,10 @@ extern int re_exec (const char *);
# endif
# endif
#endif
/* gcc 3.1 and up support the [restrict] syntax
, but g++ doesn't
. */
/* gcc 3.1 and up support the [restrict] syntax. */
#ifndef __restrict_arr
# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) && !defined __cplusplus
# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \
&& !defined __GNUG__
# define __restrict_arr __restrict
# else
# define __restrict_arr
...
...
mailbox/regex_internal.c
View file @
94fdc60
...
...
@@ -488,27 +488,34 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
mbstate_t
prev_st
;
Idx
rawbuf_idx
;
size_t
mbclen
;
w
char_t
wc
=
0
;
w
int_t
wc
=
WEOF
;
/* Skip the characters which are not necessary to check. */
for
(
rawbuf_idx
=
pstr
->
raw_mbs_idx
+
pstr
->
valid_raw_len
;
rawbuf_idx
<
new_raw_idx
;)
{
wchar_t
wc2
;
Idx
remain_len
;
remain_len
=
pstr
->
len
-
rawbuf_idx
;
prev_st
=
pstr
->
cur_state
;
mbclen
=
mbrtowc
(
&
wc
,
(
const
char
*
)
pstr
->
raw_mbs
+
rawbuf_idx
,
mbclen
=
mbrtowc
(
&
wc
2
,
(
const
char
*
)
pstr
->
raw_mbs
+
rawbuf_idx
,
remain_len
,
&
pstr
->
cur_state
);
if
(
BE
(
mbclen
==
(
size_t
)
-
2
||
mbclen
==
(
size_t
)
-
1
||
mbclen
==
0
,
0
))
{
/* We treat these cases as a singlebyte character. */
/* We treat these cases as a single byte character. */
if
(
mbclen
==
0
||
remain_len
==
0
)
wc
=
L'\0'
;
else
wc
=
*
(
unsigned
char
*
)
(
pstr
->
raw_mbs
+
rawbuf_idx
);
mbclen
=
1
;
pstr
->
cur_state
=
prev_st
;
}
else
wc
=
wc2
;
/* Then proceed the next character. */
rawbuf_idx
+=
mbclen
;
}
*
last_wc
=
(
wint_t
)
wc
;
*
last_wc
=
wc
;
return
rawbuf_idx
;
}
#endif
/* RE_ENABLE_I18N */
...
...
@@ -627,7 +634,6 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
}
#endif
pstr
->
valid_len
=
0
;
pstr
->
valid_raw_len
=
0
;
#ifdef RE_ENABLE_I18N
if
(
pstr
->
mb_cur_max
>
1
)
{
...
...
@@ -690,6 +696,16 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
if
(
wc
==
WEOF
)
pstr
->
valid_len
=
re_string_skip_chars
(
pstr
,
idx
,
&
wc
)
-
idx
;
if
(
wc
==
WEOF
)
pstr
->
tip_context
=
re_string_context_at
(
pstr
,
pstr
->
valid_raw_len
-
1
,
eflags
);
else
pstr
->
tip_context
=
((
BE
(
pstr
->
word_ops_used
!=
0
,
0
)
&&
IS_WIDE_WORD_CHAR
(
wc
))
?
CONTEXT_WORD
:
((
IS_WIDE_NEWLINE
(
wc
)
&&
pstr
->
newline_anchor
)
?
CONTEXT_NEWLINE
:
0
));
if
(
BE
(
pstr
->
valid_len
,
0
))
{
for
(
wcs_idx
=
0
;
wcs_idx
<
pstr
->
valid_len
;
++
wcs_idx
)
...
...
@@ -698,17 +714,12 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
memset
(
pstr
->
mbs
,
-
1
,
pstr
->
valid_len
);
}
pstr
->
valid_raw_len
=
pstr
->
valid_len
;
pstr
->
tip_context
=
((
BE
(
pstr
->
word_ops_used
!=
0
,
0
)
&&
IS_WIDE_WORD_CHAR
(
wc
))
?
CONTEXT_WORD
:
((
IS_WIDE_NEWLINE
(
wc
)
&&
pstr
->
newline_anchor
)
?
CONTEXT_NEWLINE
:
0
));
}
else
#endif
/* RE_ENABLE_I18N */
{
int
c
=
pstr
->
raw_mbs
[
pstr
->
raw_mbs_idx
+
offset
-
1
];
pstr
->
valid_raw_len
=
0
;
if
(
pstr
->
trans
)
c
=
pstr
->
trans
[
c
];
pstr
->
tip_context
=
(
bitset_contain
(
pstr
->
word_char
,
c
)
...
...
mailbox/regex_internal.h
View file @
94fdc60
...
...
@@ -43,20 +43,17 @@
#if defined HAVE_WCTYPE_H || defined _LIBC
# include <wctype.h>
#endif
/* HAVE_WCTYPE_H || _LIBC */
#if defined HAVE_STDINT_H || defined _LIBC
# include <stdint.h>
#endif
/* HAVE_STDINT_H || _LIBC */
#include <stdint.h>
#if defined _LIBC
# include <bits/libc-lock.h>
#else
# define __libc_lock_define(CLASS,NAME)
# define __libc_lock_init(NAME) do { } while (0)
# define __libc_lock_lock(NAME) do { } while (0)
# define __libc_lock_unlock(NAME) do { } while (0)
#endif
/* In case that the system doesn't have isblank(). */
#if !defined _LIBC && !
defined HAVE
_ISBLANK && !defined isblank
#if !defined _LIBC && !
HAVE_DECL
_ISBLANK && !defined isblank
# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
#endif
...
...
@@ -711,7 +708,9 @@ struct re_dfa_t
#ifdef DEBUG
char
*
re_str
;
#endif
#ifdef _LIBC
__libc_lock_define
(,
lock
)
#endif
};
#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
...
...
mailbox/stat-macros.h
View file @
94fdc60
/* stat-related macros
Copyright (C) 1993, 1994, 2001, 2002, 2004 Free Software Foundation, Inc.
Copyright (C) 1993, 1994, 2001, 2002, 2004, 2006 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
...
...
@@ -33,7 +34,6 @@
# undef S_ISBLK
# undef S_ISCHR
# undef S_ISDIR
# undef S_ISDOOR
# undef S_ISFIFO
# undef S_ISLNK
# undef S_ISNAM
...
...
@@ -70,12 +70,8 @@
# endif
# ifndef S_ISDOOR
/* Solaris 2.5 and up */
# ifdef S_IFDOOR
# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
# else
# define S_ISDOOR(m) 0
# endif
# endif
# ifndef S_ISFIFO
# ifdef S_IFIFO
...
...
@@ -119,6 +115,10 @@
# endif
# endif
# ifndef S_ISPORT
/* Solaris 10 and up */
# define S_ISPORT(m) 0
# endif
# ifndef S_ISREG
# ifdef S_IFREG
# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
...
...
@@ -161,7 +161,7 @@
# endif
# endif
/*
contiguous
*/
/*
high performance ("contiguous data")
*/
# ifndef S_ISCTG
# define S_ISCTG(p) 0
# endif
...
...
@@ -176,6 +176,11 @@
# define S_ISOFL(p) 0
# endif
/* 4.4BSD whiteout */
# ifndef S_ISWHT
# define S_ISWHT(m) 0
# endif
/* If any of the following are undefined,
define them to their de facto standard values. */
# if !S_ISUID
...
...
mailbox/stdint_.h
View file @
94fdc60
This diff is collapsed.
Click to expand it.
mailbox/strnlen1.c
View file @
94fdc60
/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
Copyright (C) 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it
under the terms of the GNU Library General Public License as published
by
the Free Software Foundation; either version 2, or (at your option)
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
Library
General Public License for more details.
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 Library 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. */
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. */
#ifdef HAVE_CONFIG_H
# include <config.h>
...
...
mailbox/strnlen1.h
View file @
94fdc60
/* Find the length of STRING + 1, but scan at most MAXLEN bytes.
Copyright (C) 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it
under the terms of the GNU Library General Public License as published
by
the Free Software Foundation; either version 2, or (at your option)
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
Library
General Public License for more details.
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 Library 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. */
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. */
#ifndef _STRNLEN1_H
#define _STRNLEN1_H
...
...
mailbox/vasnprintf.c
View file @
94fdc60
...
...
@@ -40,7 +40,7 @@
#include <stdlib.h>
/* abort(), malloc(), realloc(), free() */
#include <string.h>
/* memcpy(), strlen() */
#include <errno.h>
/* errno */
#include <limits.h>
/* CHAR_BIT
, INT_MAX
*/
#include <limits.h>
/* CHAR_BIT */
#include <float.h>
/* DBL_MAX_EXP, LDBL_MAX_EXP */
#if WIDE_CHAR_VERSION
# include "wprintf-parse.h"
...
...
@@ -51,11 +51,6 @@
/* Checked size_t computations. */
#include "xsize.h"
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
#ifndef EOVERFLOW
# define EOVERFLOW E2BIG
#endif
#ifdef HAVE_WCHAR_T
# ifdef HAVE_WCSLEN
# define local_wcslen wcslen
...
...
@@ -869,19 +864,12 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar
free
(
buf_malloced
);
CLEANUP
();
*
lengthp
=
length
;
if
(
length
>
INT_MAX
)
goto
length_overflow
;
/* Note that we can produce a big string of a length > INT_MAX. POSIX
says that snprintf() fails with errno = EOVERFLOW in this case, but
that's only because snprintf() returns an 'int'. This function does
not have this limitation. */
return
result
;
length_overflow:
/* We could produce such a big string, but its length doesn't fit into
an 'int'. POSIX says that snprintf() fails with errno = EOVERFLOW in
this case. */
if
(
result
!=
resultbuf
)
free
(
result
);
errno
=
EOVERFLOW
;
return
NULL
;
out_of_memory:
if
(
!
(
result
==
resultbuf
||
result
==
NULL
))
free
(
result
);
...
...
mailbox/vsnprintf.c
View file @
94fdc60
/* Formatted output to strings.
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004
, 2006
Free Software Foundation, Inc.
Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
This program is free software; you can redistribute it and/or modify
...
...
@@ -23,6 +23,8 @@
/* Specification. */
#include "vsnprintf.h"
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -30,6 +32,11 @@
#include "vasnprintf.h"
/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
#ifndef EOVERFLOW
# define EOVERFLOW E2BIG
#endif
/* Print formatted output to string STR. Similar to vsprintf, but
additional length SIZE limit how much is written into STR. Returns
string length of formatted string (which may be larger than SIZE).
...
...
@@ -40,19 +47,31 @@ vsnprintf (char *str, size_t size, const char *format, va_list args)
{
char
*
output
;
size_t
len
;
size_t
lenbuf
=
size
;
len
=
size
;
output
=
vasnprintf
(
str
,
&
len
,
format
,
args
)
;
output
=
vasnprintf
(
str
,
&
lenbuf
,
format
,
args
)
;
len
=
lenbuf
;
if
(
!
output
)
return
-
1
;
if
(
str
!=
NULL
)
if
(
len
>
size
-
1
)
/* equivalent to: (size > 0 && len >= size) */
str
[
size
-
1
]
=
'\0'
;
if
(
output
!=
str
)
{
if
(
size
)
{
size_t
pruned_len
=
(
len
<
size
?
len
:
size
-
1
);
memcpy
(
str
,
output
,
pruned_len
);
str
[
pruned_len
]
=
'\0'
;
}
free
(
output
);
}
if
(
len
>
INT_MAX
)
{
errno
=
EOVERFLOW
;
return
-
1
;
}
return
len
;
}
...
...
Please
register
or
sign in
to post a comment