Skip to content

Commit a5c9de2

Browse files
committed
Merge pull request #58 from petercolberg/master
Fix build warnings
2 parents f67f1a7 + b10b64d commit a5c9de2

11 files changed

Lines changed: 122 additions & 74 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*.dylib
1010
*.dSYM
1111
*.out
12+
*.new
1213
data/*.txt
1314
data/*.ttf
1415
data/*.sfd
@@ -18,9 +19,9 @@ bench/icu
1819
bench/unistring
1920
normtest
2021
graphemetest
21-
utf8proc_data.c.new
2222
printproperty
2323
charwidth
2424
valid
2525
iterate
2626
case
27+
/tmp/

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ before_install:
1010
- sudo apt-get update -qq -y
1111
- sudo apt-get install libpcre3-dev julia fontforge -y
1212
script:
13-
- make prefix=`pwd`/local install
13+
- make manifest && diff MANIFEST.new MANIFEST
1414
- make check
1515
- make data && diff data/utf8proc_data.c.new utf8proc_data.c
16+
- make clean && git status --ignored --porcelain && test -z "$(git status --ignored --porcelain)"
1617
- (mkdir build_static && cd build_static && cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON && make)
1718
- (mkdir build_shared && cd build_shared && cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=ON && make)
1819
env:

MANIFEST

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include/
2+
include/utf8proc.h
3+
lib/
4+
lib/libutf8proc.a
5+
lib/libutf8proc.so -> libutf8proc.so.1.3.0
6+
lib/libutf8proc.so.1 -> libutf8proc.so.1.3.0
7+
lib/libutf8proc.so.1.3.0

Makefile

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ MAKE=make
55
AR?=ar
66
CC?=gcc
77
INSTALL=install
8+
FIND=find
89

910
# compiler settings
1011
CFLAGS ?= -O2
@@ -17,7 +18,7 @@ UCFLAGS = $(CFLAGS) $(PICFLAG) $(C99FLAG) $(WCFLAGS) -DUTF8PROC_EXPORTS
1718
# from the utf8proc version number because it indicates ABI compatibility,
1819
# not API compatibility: MAJOR should be incremented whenever *binary*
1920
# compatibility is broken, even if the API is backward-compatible
20-
# Be sure to also update these in CMakeLists.txt!
21+
# Be sure to also update these in MANIFEST and CMakeLists.txt!
2122
MAJOR=1
2223
MINOR=3
2324
PATCH=0
@@ -38,12 +39,17 @@ includedir=$(prefix)/include
3839

3940
# meta targets
4041

41-
.PHONY: all, clean, update, data
42+
.PHONY: all clean data update manifest install
4243

4344
all: libutf8proc.a libutf8proc.$(SHLIB_EXT)
4445

4546
clean:
46-
rm -f utf8proc.o libutf8proc.a libutf8proc.$(SHLIB_VERS_EXT) libutf8proc.$(SHLIB_EXT) test/normtest test/graphemetest test/printproperty test/charwidth test/valid test/iterate
47+
rm -f utf8proc.o libutf8proc.a libutf8proc.$(SHLIB_VERS_EXT) libutf8proc.$(SHLIB_EXT)
48+
ifneq ($(OS),Darwin)
49+
rm -f libutf8proc.so.$(MAJOR)
50+
endif
51+
rm -f test/tests.o test/normtest test/graphemetest test/printproperty test/charwidth test/valid test/iterate test/case
52+
rm -rf MANIFEST.new tmp
4753
$(MAKE) -C bench clean
4854
$(MAKE) -C data clean
4955

@@ -52,6 +58,8 @@ data: data/utf8proc_data.c.new
5258
update: data/utf8proc_data.c.new
5359
cp -f data/utf8proc_data.c.new utf8proc_data.c
5460

61+
manifest: MANIFEST.new
62+
5563
# real targets
5664

5765
data/utf8proc_data.c.new: libutf8proc.$(SHLIB_EXT) data/data_generator.rb data/charwidths.jl
@@ -84,12 +92,17 @@ install: libutf8proc.a libutf8proc.$(SHLIB_EXT) libutf8proc.$(SHLIB_VERS_EXT)
8492
mkdir -m 755 -p $(DESTDIR)$(libdir)
8593
$(INSTALL) -m 644 libutf8proc.a $(DESTDIR)$(libdir)
8694
$(INSTALL) -m 755 libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)
87-
ln -f -s $(libdir)/libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.$(SHLIB_EXT)
95+
ln -f -s libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.$(SHLIB_EXT)
8896
ifneq ($(OS),Darwin)
89-
ln -f -s $(libdir)/libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.so.$(MAJOR)
90-
ln -f -s $(libdir)/libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.so.$(MAJOR).$(MINOR)
97+
ln -f -s libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.so.$(MAJOR)
9198
endif
9299

100+
MANIFEST.new:
101+
rm -rf tmp
102+
$(MAKE) install prefix=/usr DESTDIR=$(PWD)/tmp
103+
$(FIND) tmp/usr -mindepth 1 -type l -printf "%P -> %l\n" -or -type f -printf "%P\n" -or -type d -printf "%P/\n" | LC_ALL=C sort > $@
104+
rm -rf tmp
105+
93106
# Test programs
94107

95108
data/NormalizationTest.txt:
@@ -98,26 +111,29 @@ data/NormalizationTest.txt:
98111
data/GraphemeBreakTest.txt:
99112
$(MAKE) -C data GraphemeBreakTest.txt
100113

101-
test/normtest: test/normtest.c utf8proc.o utf8proc.h test/tests.h
102-
$(CC) $(UCFLAGS) test/normtest.c utf8proc.o -o $@
114+
test/tests.o: test/tests.c test/tests.h utf8proc.h
115+
$(CC) $(UCFLAGS) -c -o test/tests.o test/tests.c
116+
117+
test/normtest: test/normtest.c test/tests.o utf8proc.o utf8proc.h test/tests.h
118+
$(CC) $(UCFLAGS) test/normtest.c test/tests.o utf8proc.o -o $@
103119

104-
test/graphemetest: test/graphemetest.c utf8proc.o utf8proc.h test/tests.h
105-
$(CC) $(UCFLAGS) test/graphemetest.c utf8proc.o -o $@
120+
test/graphemetest: test/graphemetest.c test/tests.o utf8proc.o utf8proc.h test/tests.h
121+
$(CC) $(UCFLAGS) test/graphemetest.c test/tests.o utf8proc.o -o $@
106122

107-
test/printproperty: test/printproperty.c utf8proc.o utf8proc.h test/tests.h
108-
$(CC) $(UCFLAGS) test/printproperty.c utf8proc.o -o $@
123+
test/printproperty: test/printproperty.c test/tests.o utf8proc.o utf8proc.h test/tests.h
124+
$(CC) $(UCFLAGS) test/printproperty.c test/tests.o utf8proc.o -o $@
109125

110-
test/charwidth: test/charwidth.c utf8proc.o utf8proc.h test/tests.h
111-
$(CC) $(UCFLAGS) test/charwidth.c utf8proc.o -o $@
126+
test/charwidth: test/charwidth.c test/tests.o utf8proc.o utf8proc.h test/tests.h
127+
$(CC) $(UCFLAGS) test/charwidth.c test/tests.o utf8proc.o -o $@
112128

113-
test/valid: test/valid.c utf8proc.o utf8proc.h test/tests.h
114-
$(CC) $(UCFLAGS) test/valid.c utf8proc.o -o $@
129+
test/valid: test/valid.c test/tests.o utf8proc.o utf8proc.h test/tests.h
130+
$(CC) $(UCFLAGS) test/valid.c test/tests.o utf8proc.o -o $@
115131

116-
test/iterate: test/iterate.c utf8proc.o utf8proc.h test/tests.h
117-
$(CC) $(UCFLAGS) test/iterate.c utf8proc.o -o $@
132+
test/iterate: test/iterate.c test/tests.o utf8proc.o utf8proc.h test/tests.h
133+
$(CC) $(UCFLAGS) test/iterate.c test/tests.o utf8proc.o -o $@
118134

119-
test/case: test/case.c utf8proc.o utf8proc.h test/tests.h
120-
$(CC) $(UCFLAGS) test/case.c utf8proc.o -o $@
135+
test/case: test/case.c test/tests.o utf8proc.o utf8proc.h test/tests.h
136+
$(CC) $(UCFLAGS) test/case.c test/tests.o utf8proc.o -o $@
121137

122138
check: test/normtest data/NormalizationTest.txt test/graphemetest data/GraphemeBreakTest.txt test/printproperty test/case test/charwidth test/valid test/iterate bench/bench.c bench/util.c bench/util.h utf8proc.o
123139
$(MAKE) -C bench

data/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ GraphemeBreakTest.txt:
5959
$(CURL) $(CURLFLAGS) $(URLCACHE)http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt | $(PERL) -pe 's,÷,/,g;s,×,+,g' > $@
6060

6161
clean:
62-
rm -f UnicodeData.txt EastAsianWidth.txt DerivedCoreProperties.txt CompositionExclusions.txt CaseFolding.txt NormalizationTest.txt GraphemeBreakTest.txt CharWidths.txt unifont*.ttf unifont*.sfd
62+
rm -f UnicodeData.txt EastAsianWidth.txt GraphemeBreakProperty.txt DerivedCoreProperties.txt CompositionExclusions.txt CaseFolding.txt NormalizationTest.txt GraphemeBreakTest.txt CharWidths.txt unifont*.ttf unifont*.sfd
63+
rm -f utf8proc_data.c.new

data/charwidths.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@
88

99
#############################################################################
1010
# Julia 0.3/0.4 compatibility (taken from Compat package)
11+
if VERSION < v"0.4.0-dev+1387"
12+
typealias AbstractString String
13+
end
1114
if VERSION < v"0.4.0-dev+1419"
12-
const UInt16 = Uint16
15+
const UInt32 = Uint32
16+
end
17+
if VERSION < v"0.4.0-dev+3874"
18+
Base.parse{T<:Integer}(::Type{T}, s::AbstractString) = parseint(T, s)
1319
end
1420

1521
CharWidths = Dict{Int,Int}()
@@ -52,7 +58,7 @@ end
5258
# Widths from GNU Unifont
5359

5460
#Read sfdfile for character widths
55-
function parsesfd(filename::String, CharWidths::Dict{Int,Int}=Dict{Int,Int}())
61+
function parsesfd(filename::AbstractString, CharWidths::Dict{Int,Int}=Dict{Int,Int}())
5662
state=:seekchar
5763
lineno = 0
5864
codepoint = width = nothing
@@ -65,8 +71,8 @@ function parsesfd(filename::String, CharWidths::Dict{Int,Int}=Dict{Int,Int}())
6571
state = :readdata
6672
end
6773
elseif state==:readdata #Encoding: 65538 -1 2, Width: 1024
68-
contains(line, "Encoding:") && (codepoint = int(split(line)[3]))
69-
contains(line, "Width:") && (width = int(split(line)[2]))
74+
contains(line, "Encoding:") && (codepoint = parse(Int, split(line)[3]))
75+
contains(line, "Width:") && (width = parse(Int, split(line)[2]))
7076
if codepoint!=nothing && width!=nothing && codepoint >= 0
7177
w=div(width, 512) # 512 units to the en
7278
if w > 0
@@ -100,8 +106,8 @@ for line in readlines(open("EastAsianWidth.txt"))
100106
width = strip(tokens[2])
101107
#Parse code point range into Julia UnitRange
102108
rangetokens = split(charrange, "..")
103-
charstart = uint32("0x"*rangetokens[1])
104-
charend = uint32("0x"*rangetokens[length(rangetokens)>1 ? 2 : 1])
109+
charstart = parse(UInt32, "0x"*rangetokens[1])
110+
charend = parse(UInt32, "0x"*rangetokens[length(rangetokens)>1 ? 2 : 1])
105111

106112
#Assign widths
107113
for c in charstart:charend

test/charwidth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <ctype.h>
33
#include <wchar.h>
44

5-
int my_isprint(int c) {
5+
static int my_isprint(int c) {
66
int cat = utf8proc_get_property(c)->category;
77
return (UTF8PROC_CATEGORY_LU <= cat && cat <= UTF8PROC_CATEGORY_ZS) ||
88
(c == 0x0601 || c == 0x0602 || c == 0x0603 || c == 0x06dd);

test/iterate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ static int error;
88
#define CHECKVALID(pos, val, len) buf[pos] = val; testbytes(buf,len,len,__LINE__)
99
#define CHECKINVALID(pos, val, len) buf[pos] = val; testbytes(buf,len,UTF8PROC_ERROR_INVALIDUTF8,__LINE__)
1010

11-
void testbytes(unsigned char *buf, int len, utf8proc_ssize_t retval, int line)
11+
static void testbytes(unsigned char *buf, int len, utf8proc_ssize_t retval, int line)
1212
{
1313
utf8proc_int32_t out[16];
1414
utf8proc_ssize_t ret;

test/printproperty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ int main(int argc, char **argv)
77
int i;
88

99
for (i = 1; i < argc; ++i) {
10-
int c;
10+
unsigned int c;
1111
if (!strcmp(argv[i], "-V")) {
1212
printf("utf8proc version %s\n", utf8proc_version());
1313
continue;

test/tests.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* Common functions for our test programs. */
2+
3+
#include "tests.h"
4+
5+
size_t lineno = 0;
6+
7+
void check(int cond, const char *format, ...)
8+
{
9+
if (!cond) {
10+
va_list args;
11+
fprintf(stderr, "line %zd: ", lineno);
12+
va_start(args, format);
13+
vfprintf(stderr, format, args);
14+
va_end(args);
15+
fprintf(stderr, "\n");
16+
exit(1);
17+
}
18+
}
19+
20+
size_t skipspaces(const char *buf, size_t i)
21+
{
22+
while (isspace(buf[i])) ++i;
23+
return i;
24+
}
25+
26+
/* if buf points to a sequence of codepoints encoded as hexadecimal strings,
27+
separated by whitespace, and terminated by any character not in
28+
[0-9a-fA-F] or whitespace, then stores the corresponding utf8 string
29+
in dest, returning the number of bytes read from buf */
30+
size_t encode(char *dest, const char *buf)
31+
{
32+
size_t i = 0, j, d = 0;
33+
for (;;) {
34+
int c;
35+
i = skipspaces(buf, i);
36+
for (j=i; buf[j] && strchr("0123456789abcdef", tolower(buf[j])); ++j)
37+
; /* find end of hex input */
38+
if (j == i) { /* no codepoint found */
39+
dest[d] = 0; /* NUL-terminate destination string */
40+
return i + 1;
41+
}
42+
check(sscanf(buf + i, "%x", (unsigned int *)&c) == 1, "invalid hex input %s", buf+i);
43+
i = j; /* skip to char after hex input */
44+
d += utf8proc_encode_char(c, (utf8proc_uint8_t *) (dest + d));
45+
}
46+
}

0 commit comments

Comments
 (0)