forked from ariadne/pkgconf
libpkgconf: define SIZE_FMT_SPECIFIER on POSIX and Windows platforms and use it in place of %zu
The MSVCRT runtime as used on Windows does not support %zu, but instead recommends %Iu. As we want to remain portable to other runtimes, even on Windows, we do not use %Iu, but instead expand it logically to either %lu or %llu depending on if it's _WIN32 or _WIN64 headers. On POSIX, we assume C99 support is available and always use %zu, as pkgconf has never supported anything earlier than C99 officially. Closes #125.feature/tap-sh
parent
a6d6b88d14
commit
47ce9765a8
|
@ -319,7 +319,7 @@ pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t linen
|
|||
size_t len;
|
||||
va_list va;
|
||||
|
||||
len = snprintf(errbuf, sizeof errbuf, "%s:%zu [%s]: ", filename, lineno, funcname);
|
||||
len = snprintf(errbuf, sizeof errbuf, "%s:" SIZE_FMT_SPECIFIER " [%s]: ", filename, lineno, funcname);
|
||||
|
||||
va_start(va, format);
|
||||
vsnprintf(errbuf + len, sizeof(errbuf) - len, format, va);
|
||||
|
|
|
@ -299,7 +299,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE *
|
|||
|
||||
lineno++;
|
||||
|
||||
PKGCONF_TRACE(client, "%s:%zu > [%s]", filename, lineno, readbuf);
|
||||
PKGCONF_TRACE(client, "%s:" SIZE_FMT_SPECIFIER " > [%s]", filename, lineno, readbuf);
|
||||
|
||||
p = readbuf;
|
||||
while (*p && (isalpha((unsigned int)*p) || isdigit((unsigned int)*p) || *p == '_' || *p == '.'))
|
||||
|
@ -313,7 +313,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE *
|
|||
{
|
||||
if (!warned_key_whitespace)
|
||||
{
|
||||
pkgconf_warn(client, "%s:%zu: warning: whitespace encountered while parsing key section\n",
|
||||
pkgconf_warn(client, "%s:" SIZE_FMT_SPECIFIER ": warning: whitespace encountered while parsing key section\n",
|
||||
pkg->filename, lineno);
|
||||
warned_key_whitespace = true;
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE *
|
|||
{
|
||||
if (!warned_value_whitespace && op == '=')
|
||||
{
|
||||
pkgconf_warn(client, "%s:%zu: warning: trailing whitespace encountered while parsing value section\n",
|
||||
pkgconf_warn(client, "%s:" SIZE_FMT_SPECIFIER ": warning: trailing whitespace encountered while parsing value section\n",
|
||||
pkg->filename, lineno);
|
||||
warned_value_whitespace = true;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
# include <windows.h>
|
||||
# include <malloc.h>
|
||||
# define PATH_DEV_NULL "nul"
|
||||
# ifdef _WIN64
|
||||
# define SIZE_FMT_SPECIFIER "%llu"
|
||||
# else
|
||||
# define SIZE_FMT_SPECIFIER "%lu"
|
||||
# endif
|
||||
# ifndef ssize_t
|
||||
# ifndef __MINGW32__
|
||||
# include <BaseTsd.h>
|
||||
|
@ -47,6 +52,7 @@
|
|||
# endif
|
||||
#else
|
||||
# define PATH_DEV_NULL "/dev/null"
|
||||
# define SIZE_FMT_SPECIFIER "%zu"
|
||||
# include <dirent.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue