Drop wchar header check as always defined since C95

This commit is contained in:
George Peter Banyard 2020-03-29 01:10:15 +01:00
parent aa47543cb4
commit 457380cae7
10 changed files with 73 additions and 117 deletions

View File

@ -573,7 +573,6 @@ inet_ntop \
inet_pton \
localtime_r \
lchown \
mbrlen \
memmove \
mkstemp \
mmap \

View File

@ -1,6 +1,6 @@
diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
--- libmagic.orig/apprentice.c 2019-02-20 03:35:27.000000000 +0100
+++ libmagic/apprentice.c 2020-02-27 11:45:38.445854000 +0100
+++ libmagic/apprentice.c 2019-12-19 20:37:54.476535900 +0100
@@ -29,6 +29,8 @@
* apprentice - make one pass through /etc/magic, learning its secrets.
*/
@ -974,7 +974,7 @@ diff -u libmagic.orig/apprentice.c libmagic/apprentice.c
}
diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
--- libmagic.orig/ascmagic.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/ascmagic.c 2020-02-26 23:18:22.605400700 +0100
+++ libmagic/ascmagic.c 2019-12-19 20:37:54.628894400 +0100
@@ -96,7 +96,7 @@
rv = file_ascmagic_with_encoding(ms, &bb,
ubuf, ulen, code, type, text);
@ -1005,7 +1005,7 @@ diff -u libmagic.orig/ascmagic.c libmagic/ascmagic.c
}
diff -u libmagic.orig/buffer.c libmagic/buffer.c
--- libmagic.orig/buffer.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/buffer.c 2020-02-27 11:45:38.445854000 +0100
+++ libmagic/buffer.c 2019-12-19 20:37:54.639865800 +0100
@@ -31,19 +31,23 @@
#endif /* lint */
@ -1062,7 +1062,7 @@ diff -u libmagic.orig/buffer.c libmagic/buffer.c
diff -u libmagic.orig/cdf.c libmagic/cdf.c
--- libmagic.orig/cdf.c 2019-02-20 03:35:27.000000000 +0100
+++ libmagic/cdf.c 2020-02-27 11:45:38.445854000 +0100
+++ libmagic/cdf.c 2019-12-19 20:37:55.233790900 +0100
@@ -43,7 +43,17 @@
#include <err.h>
#endif
@ -1341,7 +1341,7 @@ diff -u libmagic.orig/cdf.c libmagic/cdf.c
#endif
diff -u libmagic.orig/cdf.h libmagic/cdf.h
--- libmagic.orig/cdf.h 2019-02-20 02:24:19.000000000 +0100
+++ libmagic/cdf.h 2020-02-27 11:45:38.445854000 +0100
+++ libmagic/cdf.h 2019-12-19 20:37:55.431591900 +0100
@@ -35,10 +35,10 @@
#ifndef _H_CDF_
#define _H_CDF_
@ -1366,7 +1366,7 @@ diff -u libmagic.orig/cdf.h libmagic/cdf.h
#define CDF_SECID_FREE -1
diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
--- libmagic.orig/cdf_time.c 2019-03-12 21:43:05.000000000 +0100
+++ libmagic/cdf_time.c 2020-02-26 23:18:22.611402900 +0100
+++ libmagic/cdf_time.c 2019-12-19 20:37:55.483459500 +0100
@@ -23,6 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
@ -1395,7 +1395,7 @@ diff -u libmagic.orig/cdf_time.c libmagic/cdf_time.c
(void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n",
diff -u libmagic.orig/compress.c libmagic/compress.c
--- libmagic.orig/compress.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/compress.c 2020-02-27 11:45:38.445854000 +0100
+++ libmagic/compress.c 2019-12-19 20:37:55.501422500 +0100
@@ -45,13 +45,11 @@
#endif
#include <string.h>
@ -1545,7 +1545,7 @@ diff -u libmagic.orig/compress.c libmagic/compress.c
+#endif
diff -u libmagic.orig/der.c libmagic/der.c
--- libmagic.orig/der.c 2019-02-20 03:35:27.000000000 +0100
+++ libmagic/der.c 2020-02-27 11:45:38.445854000 +0100
+++ libmagic/der.c 2019-12-19 20:37:55.522331900 +0100
@@ -51,7 +51,9 @@
#include "magic.h"
#include "der.h"
@ -1575,7 +1575,7 @@ diff -u libmagic.orig/der.c libmagic/der.c
snprintf(buf + z, blen - z, "%.2x", d[i]);
diff -u libmagic.orig/elfclass.h libmagic/elfclass.h
--- libmagic.orig/elfclass.h 2019-02-20 02:30:19.000000000 +0100
+++ libmagic/elfclass.h 2020-02-26 23:18:22.613401700 +0100
+++ libmagic/elfclass.h 2019-12-19 20:37:55.539285200 +0100
@@ -41,7 +41,7 @@
return toomany(ms, "program headers", phnum);
flags |= FLAGS_IS_CORE;
@ -1605,7 +1605,7 @@ diff -u libmagic.orig/elfclass.h libmagic/elfclass.h
CAST(int, elf_getu16(swap, elfhdr.e_shstrndx)),
diff -u libmagic.orig/encoding.c libmagic/encoding.c
--- libmagic.orig/encoding.c 2019-04-15 18:48:41.000000000 +0200
+++ libmagic/encoding.c 2020-02-26 23:18:22.614402300 +0100
+++ libmagic/encoding.c 2019-12-19 20:37:55.547264800 +0100
@@ -89,13 +89,13 @@
*code_mime = "binary";
@ -1636,7 +1636,7 @@ diff -u libmagic.orig/encoding.c libmagic/encoding.c
}
diff -u libmagic.orig/file.h libmagic/file.h
--- libmagic.orig/file.h 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/file.h 2020-02-27 11:45:38.445854000 +0100
+++ libmagic/file.h 2020-03-29 18:05:08.870164300 +0200
@@ -33,18 +33,9 @@
#ifndef __file_h__
#define __file_h__
@ -1923,7 +1923,7 @@ diff -u libmagic.orig/file.h libmagic/file.h
#endif
diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
--- libmagic.orig/fsmagic.c 2019-05-07 04:26:48.000000000 +0200
+++ libmagic/fsmagic.c 2020-02-26 23:18:22.616403500 +0100
+++ libmagic/fsmagic.c 2019-12-19 20:37:55.740986600 +0100
@@ -66,26 +66,10 @@
# define minor(dev) ((dev) & 0xff)
#endif
@ -2216,8 +2216,8 @@ diff -u libmagic.orig/fsmagic.c libmagic/fsmagic.c
case S_IFSOCK:
diff -u libmagic.orig/funcs.c libmagic/funcs.c
--- libmagic.orig/funcs.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/funcs.c 2020-02-27 11:45:38.445854000 +0100
@@ -31,7 +31,6 @@
+++ libmagic/funcs.c 2020-03-30 15:56:57.404908500 +0200
@@ -31,87 +31,80 @@
#endif /* lint */
#include "magic.h"
@ -2225,7 +2225,16 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -48,70 +47,68 @@
#include <ctype.h>
-#if defined(HAVE_WCHAR_H)
#include <wchar.h>
-#endif
-#if defined(HAVE_WCTYPE_H)
#include <wctype.h>
-#endif
#include <limits.h>
#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)~0)
#endif
@ -2237,15 +2246,15 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
-{
- int len;
- char *buf, *newstr;
+#include "php.h"
+#include "main/php_network.h"
-
- if (ms->event_flags & EVENT_HAD_ERR)
- return 0;
- len = vasprintf(&buf, fmt, ap);
- if (len < 0)
- goto out;
-
+#include "php.h"
+#include "main/php_network.h"
- if (ms->o.buf != NULL) {
- len = asprintf(&newstr, "%s%s", ms->o.buf, buf);
- free(buf);
@ -2333,7 +2342,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
ms->event_flags |= EVENT_HAD_ERR;
ms->error = error;
}
@@ -158,8 +155,6 @@
@@ -158,8 +151,6 @@
file_error(ms, errno, "error reading");
}
@ -2342,7 +2351,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
protected int
file_separator(struct magic_set *ms)
{
@@ -207,8 +202,8 @@
@@ -207,8 +198,8 @@
*/
/*ARGSUSED*/
protected int
@ -2353,7 +2362,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
const void *buf, size_t nb)
{
int m = 0, rv = 0, looks_text = 0;
@@ -218,6 +213,19 @@
@@ -218,6 +209,19 @@
const char *ftype = NULL;
char *rbuf = NULL;
struct buffer b;
@ -2373,7 +2382,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
buffer_init(&b, fd, st, buf, nb);
ms->mode = b.st.st_mode;
@@ -250,8 +258,8 @@
@@ -250,8 +254,8 @@
}
}
#endif
@ -2384,7 +2393,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) == 0) {
m = file_zmagic(ms, &b, inname);
if ((ms->flags & MAGIC_DEBUG) != 0)
@@ -363,17 +371,16 @@
@@ -363,17 +367,16 @@
if (file_printf(ms, "%s", code_mime) == -1)
rv = -1;
}
@ -2404,7 +2413,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
protected int
file_reset(struct magic_set *ms, int checkloaded)
@@ -383,11 +390,11 @@
@@ -383,11 +386,11 @@
return -1;
}
if (ms->o.buf) {
@ -2418,7 +2427,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
ms->o.pbuf = NULL;
}
ms->event_flags &= ~EVENT_HAD_ERR;
@@ -425,7 +432,7 @@
@@ -425,13 +428,13 @@
return NULL;
}
psize = len * 4 + 1;
@ -2427,7 +2436,14 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
file_oomem(ms, psize);
return NULL;
}
@@ -489,8 +496,8 @@
ms->o.pbuf = pbuf;
-#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
+#if defined(HAVE_WCWIDTH)
{
mbstate_t state;
wchar_t nextchar;
@@ -489,8 +492,8 @@
if (level >= ms->c.len) {
len = (ms->c.len = 20 + level) * sizeof(*ms->c.li);
ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?
@ -2438,7 +2454,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
if (ms->c.li == NULL) {
file_oomem(ms, len);
return -1;
@@ -513,76 +520,38 @@
@@ -513,76 +516,38 @@
protected int
file_replace(struct magic_set *ms, const char *pat, const char *rep)
{
@ -2477,7 +2493,8 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
- file_regfree(&rx);
- return rv;
-}
-
+ zval_ptr_dtor(&patt);
-protected int
-file_regcomp(file_regex_t *rx, const char *pat, int flags)
-{
@ -2490,12 +2507,16 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
- rx->old_lc_ctype = setlocale(LC_CTYPE, "C");
-#endif
- rx->pat = pat;
+ zval_ptr_dtor(&patt);
+ repl = zend_string_init(rep, strlen(rep), 0);
+ res = php_pcre_replace_impl(pce, NULL, ms->o.buf, strlen(ms->o.buf), repl, -1, &rep_cnt);
- return rx->rc = regcomp(&rx->rx, pat, flags);
-}
+ repl = zend_string_init(rep, strlen(rep), 0);
+ res = php_pcre_replace_impl(pce, NULL, ms->o.buf, strlen(ms->o.buf), repl, -1, &rep_cnt);
+ zend_string_release_ex(repl, 0);
+ if (NULL == res) {
+ rep_cnt = -1;
+ goto out;
+ }
-protected int
-file_regexec(file_regex_t *rx, const char *str, size_t nmatch,
@ -2506,11 +2527,8 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
- memset(pmatch, 0, nmatch * sizeof(*pmatch));
- return regexec(&rx->rx, str, nmatch, pmatch, eflags);
-}
+ zend_string_release_ex(repl, 0);
+ if (NULL == res) {
+ rep_cnt = -1;
+ goto out;
+ }
+ strncpy(ms->o.buf, ZSTR_VAL(res), ZSTR_LEN(res));
+ ms->o.buf[ZSTR_LEN(res)] = '\0';
-protected void
-file_regfree(file_regex_t *rx)
@ -2524,15 +2542,13 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
- (void)setlocale(LC_CTYPE, rx->old_lc_ctype);
-#endif
-}
+ strncpy(ms->o.buf, ZSTR_VAL(res), ZSTR_LEN(res));
+ ms->o.buf[ZSTR_LEN(res)] = '\0';
+ zend_string_release_ex(res, 0);
-protected void
-file_regerror(file_regex_t *rx, int rc, struct magic_set *ms)
-{
- char errmsg[512];
+ zend_string_release_ex(res, 0);
-
- (void)regerror(rc, &rx->rx, errmsg, sizeof(errmsg));
- file_magerror(ms, "regex error %d for `%s', (%s)", rc, rx->pat,
- errmsg);
@ -2541,7 +2557,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
}
protected file_pushbuf_t *
@@ -593,7 +562,7 @@
@@ -593,7 +558,7 @@
if (ms->event_flags & EVENT_HAD_ERR)
return NULL;
@ -2550,7 +2566,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
return NULL;
pb->buf = ms->o.buf;
@@ -611,8 +580,8 @@
@@ -611,8 +576,8 @@
char *rbuf;
if (ms->event_flags & EVENT_HAD_ERR) {
@ -2561,7 +2577,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
return NULL;
}
@@ -621,7 +590,7 @@
@@ -621,7 +586,7 @@
ms->o.buf = pb->buf;
ms->offset = pb->offset;
@ -2572,7 +2588,7 @@ diff -u libmagic.orig/funcs.c libmagic/funcs.c
diff -u libmagic.orig/magic.c libmagic/magic.c
--- libmagic.orig/magic.c 2019-05-07 04:27:11.000000000 +0200
+++ libmagic/magic.c 2020-02-26 23:18:22.621402800 +0100
+++ libmagic/magic.c 2019-12-19 20:37:55.783491600 +0100
@@ -25,11 +25,6 @@
* SUCH DAMAGE.
*/
@ -3036,8 +3052,8 @@ diff -u libmagic.orig/magic.c libmagic/magic.c
public const char *
magic_error(struct magic_set *ms)
diff -u libmagic.orig/magic.h libmagic/magic.h
--- libmagic.orig/magic.h 2020-03-02 15:24:27.253951700 +0100
+++ libmagic/magic.h 2020-02-26 23:18:22.622402300 +0100
--- libmagic.orig/magic.h 2020-03-30 16:09:56.288564100 +0200
+++ libmagic/magic.h 2019-12-19 20:37:55.792489700 +0100
@@ -124,6 +124,7 @@
const char *magic_getpath(const char *, int);
@ -3048,7 +3064,7 @@ diff -u libmagic.orig/magic.h libmagic/magic.h
diff -u libmagic.orig/print.c libmagic/print.c
--- libmagic.orig/print.c 2019-03-12 21:43:05.000000000 +0100
+++ libmagic/print.c 2020-02-26 23:18:22.625401800 +0100
+++ libmagic/print.c 2019-12-19 20:37:55.808452700 +0100
@@ -28,6 +28,7 @@
/*
* print.c - debugging printout routines
@ -3122,7 +3138,7 @@ diff -u libmagic.orig/print.c libmagic/print.c
goto out;
diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
--- libmagic.orig/readcdf.c 2019-03-12 21:43:05.000000000 +0100
+++ libmagic/readcdf.c 2020-02-27 11:45:38.445854000 +0100
+++ libmagic/readcdf.c 2020-03-21 14:20:14.170673900 +0100
@@ -31,7 +31,11 @@
#include <assert.h>
@ -3241,7 +3257,7 @@ diff -u libmagic.orig/readcdf.c libmagic/readcdf.c
if (i != -1)
diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
--- libmagic.orig/softmagic.c 2019-05-17 04:24:59.000000000 +0200
+++ libmagic/softmagic.c 2020-03-02 15:23:10.176763300 +0100
+++ libmagic/softmagic.c 2020-03-25 17:15:23.794665300 +0100
@@ -43,6 +43,10 @@
#include <time.h>
#include "der.h"
@ -3608,7 +3624,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c
case FILE_INDIRECT:
diff -u libmagic.orig/strcasestr.c libmagic/strcasestr.c
--- libmagic.orig/strcasestr.c 2014-09-11 17:05:33.000000000 +0200
+++ libmagic/strcasestr.c 2019-11-29 08:49:38.434136600 +0100
+++ libmagic/strcasestr.c 2019-12-19 20:37:55.833385900 +0100
@@ -39,6 +39,8 @@
#include "file.h"

View File

@ -35,12 +35,8 @@ FILE_RCSID("@(#)$File: funcs.c,v 1.104 2019/05/07 02:27:11 christos Exp $")
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#if defined(HAVE_WCHAR_H)
#include <wchar.h>
#endif
#if defined(HAVE_WCTYPE_H)
#include <wctype.h>
#endif
#include <limits.h>
#ifndef SIZE_MAX
@ -438,7 +434,7 @@ file_getbuffer(struct magic_set *ms)
}
ms->o.pbuf = pbuf;
#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
#if defined(HAVE_WCWIDTH)
{
mbstate_t state;
wchar_t nextchar;

View File

@ -39,29 +39,8 @@
#include "mysqli_mysqlnd.h"
#else
/*
The libmysql headers (a PITA) also define it and there will be an warning.
Undef it and later we might need to define it again.
*/
#ifdef HAVE_MBRLEN
#undef HAVE_MBRLEN
#define WE_HAD_MBRLEN
#endif
#ifdef HAVE_MBSTATE_T
#undef HAVE_MBSTATE_T
#define WE_HAD_MBSTATE_T
#endif
#include <my_global.h>
#if !defined(HAVE_MBRLEN) && defined(WE_HAD_MBRLEN)
#define HAVE_MBRLEN 1
#endif
#if !defined(HAVE_MBSTATE_T) && defined(WE_HAD_MBSTATE_T)
#define HAVE_MBSTATE_T 1
#endif
/*
We need more than mysql.h because we need CHARSET_INFO in one place.
This order has been borrowed from the ODBC driver. Nothing can be removed

View File

@ -921,7 +921,7 @@ static void basic_globals_ctor(php_basic_globals *basic_globals_p) /* {{{ */
zend_hash_init(&BG(url_adapt_session_hosts_ht), 0, NULL, NULL, 1);
zend_hash_init(&BG(url_adapt_output_hosts_ht), 0, NULL, NULL, 1);
#if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
#if defined(_REENTRANT)
memset(&BG(mblen_state), 0, sizeof(BG(mblen_state)));
#endif

View File

@ -19,10 +19,7 @@
#define BASIC_FUNCTIONS_H
#include <sys/stat.h>
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#include "php_filestat.h"
@ -219,7 +216,7 @@ typedef struct _php_basic_globals {
HashTable *user_filter_map;
/* file.c */
#if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
#if defined(_REENTRANT)
mbstate_t mblen_state;
#endif

View File

@ -388,27 +388,6 @@ if test "$ac_cv_strptime_decl_fails" = "yes"; then
AC_DEFINE([HAVE_STRPTIME_DECL_FAILS], 1, [whether strptime() declaration fails])
fi
dnl
dnl Check for i18n capabilities
dnl
AC_CHECK_HEADERS([wchar.h])
AC_CHECK_FUNCS([mblen])
AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_WCHAR_H
# include <wchar.h>
#endif
]],[[
mbstate_t a;
]])],[
ac_cv_type_mbstate_t=yes
],[
ac_cv_type_mbstate_t=no
])])
if test "$ac_cv_type_mbstate_t" = "yes"; then
AC_DEFINE([HAVE_MBSTATE_T], 1, [Define if your system has mbstate_t in wchar.h])
fi
dnl
dnl Check for atomic operation API availability in Solaris
dnl

View File

@ -34,6 +34,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <wchar.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -109,10 +110,6 @@ php_file_globals file_globals;
# include <fnmatch.h>
#endif
#ifdef HAVE_WCHAR_H
# include <wchar.h>
#endif
/* }}} */
#define PHP_STREAM_TO_ZVAL(stream, arg) \

View File

@ -136,12 +136,9 @@ PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2
PHPAPI int string_natural_compare_function(zval *result, zval *op1, zval *op2);
PHPAPI int string_natural_case_compare_function(zval *result, zval *op1, zval *op2);
#ifndef HAVE_MBLEN
# define php_mblen(ptr, len) 1
# define php_mb_reset()
#elif defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
#if defined(_REENTRANT)
# ifdef PHP_WIN32
# include <wchar.h>
# include <wchar.h>
# endif
# define php_mblen(ptr, len) ((int) mbrlen(ptr, len, &BG(mblen_state)))
# define php_mb_reset() memset(&BG(mblen_state), 0, sizeof(BG(mblen_state)))

View File

@ -116,8 +116,6 @@
#define HAVE_INET_PTON 1
#define HAVE_INET_NTOP 1
#define HAVE_MBLEN
/* vs.net 2005 has a 64-bit time_t. This will likely break
* 3rdParty libs that were built with older compilers; switch
* back to 32-bit */
@ -126,8 +124,6 @@
#endif
#define _REENTRANT 1
#define HAVE_MBRLEN 1
#define HAVE_MBSTATE_T 1
#define HAVE_GETRUSAGE