Skip to content

Commit ffc98e2

Browse files
committed
Support icu provided by Windows
1 parent 490bd6f commit ffc98e2

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

fuzz/libpsl_fuzzer.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ typedef unsigned __int8 uint8_t;
3535
#include <stdlib.h> /* malloc, free */
3636
#include <string.h> /* memcpy */
3737

38-
#if defined(WITH_LIBICU)
38+
#ifdef WITH_LIBICU
39+
#ifndef WITH_LIBICU_WIN
3940
#include <unicode/uclean.h>
41+
#else
42+
#include <icu.h>
43+
#endif
4044
#endif
4145

4246
#include "libpsl.h"

fuzz/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fuzzer_cargs = [
66
foreach test_case : ['fuzzer', 'load_fuzzer', 'load_dafsa_fuzzer']
77
if enable_runtime == 'libidn2'
88
test_name = 'libpsl_idn2_' + test_case
9-
elif enable_runtime == 'libicu'
9+
elif enable_runtime == 'libicu' or enable_runtime == 'libicu-win'
1010
test_name = 'libpsl_icu_' + test_case
1111
elif enable_runtime == 'libidn'
1212
test_name = 'libpsl_idn_' + test_case

meson.build

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ buildtype = get_option('buildtype')
1414
notfound = dependency('', required : false)
1515
libidn2_dep = notfound
1616
libicu_dep = notfound
17+
libicu_win_dep = notfound
1718
libidn_dep = notfound
1819
libunistring = notfound
1920
networking_deps = notfound
@@ -40,10 +41,16 @@ if ['libidn2', 'auto'].contains(enable_runtime)
4041
endif
4142

4243
if ['libicu', 'auto'].contains(enable_runtime)
44+
libicu_win_dep = cc.find_library('icu', required: false)
4345
libicu_dep = dependency('icu-uc', 'ICU',
4446
components: 'uc',
4547
required : false)
46-
if libicu_dep.found()
48+
if libicu_win_dep.found()
49+
libicu_dep = libicu_win_dep
50+
if enable_runtime == 'auto'
51+
enable_runtime = 'libicu'
52+
endif
53+
elif libicu_dep.found()
4754
if enable_runtime == 'auto'
4855
enable_runtime = 'libicu'
4956
endif
@@ -89,6 +96,7 @@ config = configuration_data()
8996
config.set_quoted('PACKAGE_VERSION', meson.project_version())
9097
config.set('WITH_LIBIDN2', enable_runtime == 'libidn2')
9198
config.set('WITH_LIBICU', enable_runtime == 'libicu')
99+
config.set('WITH_LIBICU_WIN', libicu_win_dep.found())
92100
config.set('WITH_LIBIDN', enable_runtime == 'libidn')
93101
config.set('ENABLE_BUILTIN', enable_builtin)
94102
config.set('HAVE_UNISTD_H', cc.check_header('unistd.h'))

src/psl.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ typedef SSIZE_T ssize_t;
7070
#endif
7171

7272
#ifdef WITH_LIBICU
73-
# include <unicode/uversion.h>
74-
# include <unicode/ustring.h>
75-
# include <unicode/uidna.h>
76-
# include <unicode/ucnv.h>
73+
# ifndef WITH_LIBICU_WIN
74+
# include <unicode/uversion.h>
75+
# include <unicode/ustring.h>
76+
# include <unicode/uidna.h>
77+
# include <unicode/ucnv.h>
78+
# else
79+
# include <icu.h>
80+
# endif
7781
#elif defined(WITH_LIBIDN2)
7882
# include <iconv.h>
7983
# include <idn2.h>
@@ -116,6 +120,10 @@ typedef SSIZE_T ssize_t;
116120
#define PRIV_PSL_FLAG_PRIVATE (1<<3) /* entry of PRIVATE section */
117121
#define PRIV_PSL_FLAG_PLAIN (1<<4) /* just used for PSL syntax checking */
118122

123+
#ifdef WITH_LIBICU_WIN
124+
# define U_ICU_VERSION "Windows"
125+
#endif
126+
119127
typedef struct {
120128
char
121129
label_buf[128];

0 commit comments

Comments
 (0)