Skip to content

Commit 666eeed

Browse files
committed
Put version number in one place
1 parent 7be58ca commit 666eeed

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

scripts/unicode.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@
5454
# these are the surrogate codepoints, which are not valid rust characters
5555
surrogate_codepoints = (0xd800, 0xdfff)
5656

57+
UNICODE_VERSION = (10, 0, 0)
58+
59+
UNICODE_VERSION_NUMBER = "%s.%s.%s" %UNICODE_VERSION
60+
5761
def is_surrogate(n):
5862
return surrogate_codepoints[0] <= n <= surrogate_codepoints[1]
5963

6064
def fetch(f):
6165
if not os.path.exists(os.path.basename(f)):
62-
os.system("curl -O http://www.unicode.org/Public/10.0.0/ucd/%s"
63-
% f)
66+
os.system("curl -O http://www.unicode.org/Public/%s/ucd/%s"
67+
% (UNICODE_VERSION_NUMBER, f))
6468

6569
if not os.path.exists(os.path.basename(f)):
6670
sys.stderr.write("cannot load %s" % f)
@@ -305,18 +309,13 @@ def emit_break_module(f, break_table, break_cats, name):
305309
with open(r, "w") as rf:
306310
# write the file's preamble
307311
rf.write(preamble)
308-
309-
# download and parse all the data
310-
fetch("ReadMe.txt")
311-
with open("ReadMe.txt") as readme:
312-
pattern = r"for Version (\d+)\.(\d+)\.(\d+) of the Unicode"
313-
unicode_version = re.search(pattern, readme.read()).groups()
314312
rf.write("""
315313
/// The version of [Unicode](http://www.unicode.org/)
316314
/// that this version of unicode-segmentation is based on.
317315
pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
318-
""" % unicode_version)
316+
""" % UNICODE_VERSION)
319317

318+
# download and parse all the data
320319
gencats = load_gencats("UnicodeData.txt")
321320
derived = load_properties("DerivedCoreProperties.txt", ["Alphabetic"])
322321

scripts/unicode_gen_breaktests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def create_grapheme_data(f):
172172
stype = "&'static [(&'static str, &'static [&'static str])]"
173173
dtype = "&'static [(&'static str, &'static [&'static str], &'static [&'static str])]"
174174
f.write(" // official Unicode test data\n")
175-
f.write(" // http://www.unicode.org/Public/10.0.0/ucd/auxiliary/GraphemeBreakTest.txt\n")
175+
f.write(" // http://www.unicode.org/Public/%s/ucd/auxiliary/GraphemeBreakTest.txt\n" % unicode.UNICODE_VERSION_NUMBER)
176176
unicode.emit_table(f, "TEST_SAME", test_same, stype, True, showfun, True)
177177
unicode.emit_table(f, "TEST_DIFF", test_diff, dtype, True, showfun, True)
178178

@@ -187,7 +187,7 @@ def create_words_data(f):
187187

188188
wtype = "&'static [(&'static str, &'static [&'static str])]"
189189
f.write(" // official Unicode test data\n")
190-
f.write(" // http://www.unicode.org/Public/10.0.0/ucd/auxiliary/WordBreakTest.txt\n")
190+
f.write(" // http://www.unicode.org/Public/%s/ucd/auxiliary/WordBreakTest.txt\n" % unicode.UNICODE_VERSION_NUMBER)
191191
unicode.emit_table(f, "TEST_WORD", test, wtype, True, showfun, True)
192192

193193
def create_sentence_data(f):
@@ -201,7 +201,7 @@ def create_sentence_data(f):
201201

202202
wtype = "&'static [(&'static str, &'static [&'static str])]"
203203
f.write(" // official Unicode test data\n")
204-
f.write(" // http://www.unicode.org/Public/10.0.0/ucd/auxiliary/SentenceBreakTest.txt\n")
204+
f.write(" // http://www.unicode.org/Public/%s/ucd/auxiliary/SentenceBreakTest.txt\n" % unicode.UNICODE_VERSION_NUMBER)
205205
unicode.emit_table(f, "TEST_SENTENCE", test, wtype, True, showfun, True)
206206

207207
if __name__ == "__main__":

0 commit comments

Comments
 (0)