Skip to content

Commit df71da4

Browse files
committed
Merge pull request #17 from JuliaLang/tk/dllexport
RFC: add DLLEXPORT to utf8proc_get_property
2 parents a733c7f + d61d551 commit df71da4

File tree

3 files changed

+43
-31
lines changed

3 files changed

+43
-31
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MAKE=make
66

77
# settings
88

9-
cflags = -O2 -std=c99 -pedantic -Wall -fpic $(CFLAGS)
9+
cflags = -O2 -std=c99 -pedantic -Wall -fpic -DMOJIBAKE_EXPORTS $(CFLAGS)
1010
cc = $(CC) $(cflags)
1111
AR = ar
1212

mojibake.h

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,18 @@ enum {false, true};
7575
#endif
7676
#include <limits.h>
7777

78+
#ifdef _WIN32
79+
# ifdef MOJIBAKE_EXPORTS
80+
# define DLLEXPORT __declspec(dllexport)
81+
# else
82+
# define DLLEXPORT __declspec(dllimport)
83+
# endif
84+
#elif __GNUC__ >= 4
85+
# define DLLEXPORT __attribute__ ((visibility("default")))
86+
#else
87+
# define DLLEXPORT
88+
#endif
89+
7890
#ifdef __cplusplus
7991
extern "C" {
8092
#endif
@@ -241,16 +253,16 @@ typedef struct utf8proc_property_struct {
241253
#define UTF8PROC_DECOMP_TYPE_FRACTION 15
242254
#define UTF8PROC_DECOMP_TYPE_COMPAT 16
243255

244-
extern const int8_t utf8proc_utf8class[256];
256+
DLLEXPORT extern const int8_t utf8proc_utf8class[256];
245257

246-
const char *utf8proc_version(void);
258+
DLLEXPORT const char *utf8proc_version(void);
247259

248-
const char *utf8proc_errmsg(ssize_t errcode);
260+
DLLEXPORT const char *utf8proc_errmsg(ssize_t errcode);
249261
/*
250262
* Returns a static error string for the given error code.
251263
*/
252264

253-
ssize_t utf8proc_iterate(const uint8_t *str, ssize_t strlen, int32_t *dst);
265+
DLLEXPORT ssize_t utf8proc_iterate(const uint8_t *str, ssize_t strlen, int32_t *dst);
254266
/*
255267
* Reads a single char from the UTF-8 sequence being pointed to by 'str'.
256268
* The maximum number of bytes read is 'strlen', unless 'strlen' is
@@ -261,12 +273,12 @@ ssize_t utf8proc_iterate(const uint8_t *str, ssize_t strlen, int32_t *dst);
261273
* negative error code is returned.
262274
*/
263275

264-
bool utf8proc_codepoint_valid(int32_t uc);
276+
DLLEXPORT bool utf8proc_codepoint_valid(int32_t uc);
265277
/*
266278
* Returns 1, if the given unicode code-point is valid, otherwise 0.
267279
*/
268280

269-
ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst);
281+
DLLEXPORT ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst);
270282
/*
271283
* Encodes the unicode char with the code point 'uc' as an UTF-8 string in
272284
* the byte array being pointed to by 'dst'. This array has to be at least
@@ -276,7 +288,7 @@ ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst);
276288
* This function does not check if 'uc' is a valid unicode code point.
277289
*/
278290

279-
const utf8proc_property_t *utf8proc_get_property(int32_t uc);
291+
DLLEXPORT const utf8proc_property_t *utf8proc_get_property(int32_t uc);
280292
/*
281293
* Returns a pointer to a (constant) struct containing information about
282294
* the unicode char with the given code point 'uc'.
@@ -286,7 +298,7 @@ const utf8proc_property_t *utf8proc_get_property(int32_t uc);
286298
* 0x10FFFF, otherwise the program might crash!
287299
*/
288300

289-
ssize_t utf8proc_decompose_char(
301+
DLLEXPORT ssize_t utf8proc_decompose_char(
290302
int32_t uc, int32_t *dst, ssize_t bufsize,
291303
int options, int *last_boundclass
292304
);
@@ -314,7 +326,7 @@ ssize_t utf8proc_decompose_char(
314326
* 0x10FFFF, otherwise the program might crash!
315327
*/
316328

317-
ssize_t utf8proc_decompose(
329+
DLLEXPORT ssize_t utf8proc_decompose(
318330
const uint8_t *str, ssize_t strlen,
319331
int32_t *buffer, ssize_t bufsize, int options
320332
);
@@ -332,7 +344,7 @@ ssize_t utf8proc_decompose(
332344
* buffer size is returned.
333345
*/
334346

335-
ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options);
347+
DLLEXPORT ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options);
336348
/*
337349
* Reencodes the sequence of unicode characters given by the pointer
338350
* 'buffer' and 'length' as UTF-8.
@@ -355,7 +367,7 @@ ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options);
355367
* crash!
356368
*/
357369

358-
ssize_t utf8proc_map(
370+
DLLEXPORT ssize_t utf8proc_map(
359371
const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options
360372
);
361373
/*
@@ -374,10 +386,10 @@ ssize_t utf8proc_map(
374386
* 'malloc', and has theirfore to be freed with 'free'.
375387
*/
376388

377-
uint8_t *utf8proc_NFD(const uint8_t *str);
378-
uint8_t *utf8proc_NFC(const uint8_t *str);
379-
uint8_t *utf8proc_NFKD(const uint8_t *str);
380-
uint8_t *utf8proc_NFKC(const uint8_t *str);
389+
DLLEXPORT uint8_t *utf8proc_NFD(const uint8_t *str);
390+
DLLEXPORT uint8_t *utf8proc_NFC(const uint8_t *str);
391+
DLLEXPORT uint8_t *utf8proc_NFKD(const uint8_t *str);
392+
DLLEXPORT uint8_t *utf8proc_NFKC(const uint8_t *str);
381393
/*
382394
* Returns a pointer to newly allocated memory of a NFD, NFC, NFKD or NFKC
383395
* normalized version of the null-terminated string 'str'.

utf8proc.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#include "utf8proc_data.c"
4444

4545

46-
const int8_t utf8proc_utf8class[256] = {
46+
DLLEXPORT const int8_t utf8proc_utf8class[256] = {
4747
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
4848
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
4949
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -95,11 +95,11 @@ const int8_t utf8proc_utf8class[256] = {
9595
#define UTF8PROC_BOUNDCLASS_LVT 10
9696

9797

98-
const char *utf8proc_version(void) {
98+
DLLEXPORT const char *utf8proc_version(void) {
9999
return "1.1.6";
100100
}
101101

102-
const char *utf8proc_errmsg(ssize_t errcode) {
102+
DLLEXPORT const char *utf8proc_errmsg(ssize_t errcode) {
103103
switch (errcode) {
104104
case UTF8PROC_ERROR_NOMEM:
105105
return "Memory for processing UTF-8 data could not be allocated.";
@@ -116,7 +116,7 @@ const char *utf8proc_errmsg(ssize_t errcode) {
116116
}
117117
}
118118

119-
ssize_t utf8proc_iterate(
119+
DLLEXPORT ssize_t utf8proc_iterate(
120120
const uint8_t *str, ssize_t strlen, int32_t *dst
121121
) {
122122
int length;
@@ -156,14 +156,14 @@ ssize_t utf8proc_iterate(
156156
return length;
157157
}
158158

159-
bool utf8proc_codepoint_valid(int32_t uc) {
159+
DLLEXPORT bool utf8proc_codepoint_valid(int32_t uc) {
160160
if (uc < 0 || uc >= 0x110000 ||
161161
((uc & 0xFFFF) >= 0xFFFE) || (uc >= 0xD800 && uc < 0xE000) ||
162162
(uc >= 0xFDD0 && uc < 0xFDF0)) return false;
163163
else return true;
164164
}
165165

166-
ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst) {
166+
DLLEXPORT ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst) {
167167
if (uc < 0x00) {
168168
return 0;
169169
} else if (uc < 0x80) {
@@ -193,7 +193,7 @@ ssize_t utf8proc_encode_char(int32_t uc, uint8_t *dst) {
193193
} else return 0;
194194
}
195195

196-
const utf8proc_property_t *utf8proc_get_property(int32_t uc) {
196+
DLLEXPORT const utf8proc_property_t *utf8proc_get_property(int32_t uc) {
197197
/* ASSERT: uc >= 0 && uc < 0x110000 */
198198
return utf8proc_properties + (
199199
utf8proc_stage2table[
@@ -206,7 +206,7 @@ const utf8proc_property_t *utf8proc_get_property(int32_t uc) {
206206
return utf8proc_decompose_char((replacement_uc), dst, bufsize, \
207207
options & ~UTF8PROC_LUMP, last_boundclass)
208208

209-
ssize_t utf8proc_decompose_char(int32_t uc, int32_t *dst, ssize_t bufsize,
209+
DLLEXPORT ssize_t utf8proc_decompose_char(int32_t uc, int32_t *dst, ssize_t bufsize,
210210
int options, int *last_boundclass) {
211211
/* ASSERT: uc >= 0 && uc < 0x110000 */
212212
const utf8proc_property_t *property;
@@ -351,7 +351,7 @@ ssize_t utf8proc_decompose_char(int32_t uc, int32_t *dst, ssize_t bufsize,
351351
return 1;
352352
}
353353

354-
ssize_t utf8proc_decompose(
354+
DLLEXPORT ssize_t utf8proc_decompose(
355355
const uint8_t *str, ssize_t strlen,
356356
int32_t *buffer, ssize_t bufsize, int options
357357
) {
@@ -413,7 +413,7 @@ ssize_t utf8proc_decompose(
413413
return wpos;
414414
}
415415

416-
ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) {
416+
DLLEXPORT ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) {
417417
/* UTF8PROC_NULLTERM option will be ignored, 'length' is never ignored
418418
ASSERT: 'buffer' has one spare byte of free space at the end! */
419419
if (options & (UTF8PROC_NLF2LS | UTF8PROC_NLF2PS | UTF8PROC_STRIPCC)) {
@@ -528,7 +528,7 @@ ssize_t utf8proc_reencode(int32_t *buffer, ssize_t length, int options) {
528528
}
529529
}
530530

531-
ssize_t utf8proc_map(
531+
DLLEXPORT ssize_t utf8proc_map(
532532
const uint8_t *str, ssize_t strlen, uint8_t **dstptr, int options
533533
) {
534534
int32_t *buffer;
@@ -557,28 +557,28 @@ ssize_t utf8proc_map(
557557
return result;
558558
}
559559

560-
uint8_t *utf8proc_NFD(const uint8_t *str) {
560+
DLLEXPORT uint8_t *utf8proc_NFD(const uint8_t *str) {
561561
uint8_t *retval;
562562
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
563563
UTF8PROC_DECOMPOSE);
564564
return retval;
565565
}
566566

567-
uint8_t *utf8proc_NFC(const uint8_t *str) {
567+
DLLEXPORT uint8_t *utf8proc_NFC(const uint8_t *str) {
568568
uint8_t *retval;
569569
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
570570
UTF8PROC_COMPOSE);
571571
return retval;
572572
}
573573

574-
uint8_t *utf8proc_NFKD(const uint8_t *str) {
574+
DLLEXPORT uint8_t *utf8proc_NFKD(const uint8_t *str) {
575575
uint8_t *retval;
576576
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
577577
UTF8PROC_DECOMPOSE | UTF8PROC_COMPAT);
578578
return retval;
579579
}
580580

581-
uint8_t *utf8proc_NFKC(const uint8_t *str) {
581+
DLLEXPORT uint8_t *utf8proc_NFKC(const uint8_t *str) {
582582
uint8_t *retval;
583583
utf8proc_map(str, 0, &retval, UTF8PROC_NULLTERM | UTF8PROC_STABLE |
584584
UTF8PROC_COMPOSE | UTF8PROC_COMPAT);

0 commit comments

Comments
 (0)