Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
0f0f34ee
Commit
0f0f34ee
authored
Jan 30, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unicode: add maketables to build, fix build
R=r CC=golang-dev
https://golang.org/cl/4073046
parent
50387928
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
33 deletions
+32
-33
src/pkg/unicode/Makefile
src/pkg/unicode/Makefile
+4
-5
src/pkg/unicode/maketables.go
src/pkg/unicode/maketables.go
+28
-28
No files found.
src/pkg/unicode/Makefile
View file @
0f0f34ee
...
...
@@ -18,13 +18,12 @@ maketables: maketables.go
$(LD)
-o
maketables maketables.
$O
tables
:
maketables
$(GC)
maketables.go
$(LD)
-o
maketables maketables.
$O
./maketables
--tables
=
all
>
tables.go
gofmt
-w
tables.go
rm
-f
maketables
testtables
:
maketables
echo
'***'
Be sure to make tables and make
install
first
@
echo
'***'
Be sure to make tables and make
install
first
./maketables
-test
rm
-f
maketables
all
:
maketables
CLEANFILES
+=
maketables
src/pkg/unicode/maketables.go
View file @
0f0f34ee
...
...
@@ -50,8 +50,8 @@ var test = flag.Bool("test",
false
,
"test existing tables; can be used to compare web data with package data"
)
var
scriptRe
=
regexp
.
MustCompile
(
`
([0-9A-F]+)(\.\.[0-9A-F]+)? *; ([A-Za-z_]+)
`
)
var
die
=
log
.
New
(
os
.
Stderr
,
nil
,
""
,
log
.
Lexit
|
log
.
Lshortfile
)
var
scriptRe
=
regexp
.
MustCompile
(
`
^([0-9A-F]+)(\.\.[0-9A-F]+)? *; ([A-Za-z_]+)$
`
)
var
logger
=
log
.
New
(
os
.
Stderr
,
""
,
log
.
Lshortfile
)
var
category
=
map
[
string
]
bool
{
"letter"
:
true
}
// Nd Lu etc. letter is a special case
...
...
@@ -141,11 +141,11 @@ const (
func
parseCategory
(
line
string
)
(
state
State
)
{
field
:=
strings
.
Split
(
line
,
";"
,
-
1
)
if
len
(
field
)
!=
NumField
{
die
.
Log
f
(
"%5s: %d fields (expected %d)
\n
"
,
line
,
len
(
field
),
NumField
)
logger
.
Exit
f
(
"%5s: %d fields (expected %d)
\n
"
,
line
,
len
(
field
),
NumField
)
}
point
,
err
:=
strconv
.
Btoui64
(
field
[
FCodePoint
],
16
)
if
err
!=
nil
{
die
.
Log
(
"%.5s...:"
,
err
)
logger
.
Exitf
(
"%.5s...: %s"
,
line
,
err
)
}
lastChar
=
uint32
(
point
)
if
point
==
0
{
...
...
@@ -157,7 +157,7 @@ func parseCategory(line string) (state State) {
char
:=
&
chars
[
point
]
char
.
field
=
field
if
char
.
codePoint
!=
0
{
die
.
Logf
(
"point %U reused
\n
"
)
logger
.
Exitf
(
"point %U reused"
,
point
)
}
char
.
codePoint
=
lastChar
char
.
category
=
field
[
FGeneralCategory
]
...
...
@@ -167,7 +167,7 @@ func parseCategory(line string) (state State) {
// Decimal digit
_
,
err
:=
strconv
.
Atoi
(
field
[
FNumericValue
])
if
err
!=
nil
{
die
.
Log
(
"%U: bad numeric field: %s"
,
point
,
err
)
logger
.
Exitf
(
"%U: bad numeric field: %s"
,
point
,
err
)
}
case
"Lu"
:
char
.
letter
(
field
[
FCodePoint
],
field
[
FSimpleLowercaseMapping
],
field
[
FSimpleTitlecaseMapping
])
...
...
@@ -208,7 +208,7 @@ func (char *Char) letterValue(s string, cas string) int {
v
,
err
:=
strconv
.
Btoui64
(
s
,
16
)
if
err
!=
nil
{
char
.
dump
(
cas
)
die
.
Log
f
(
"%U: bad letter(%s): %s"
,
char
.
codePoint
,
s
,
err
)
logger
.
Exit
f
(
"%U: bad letter(%s): %s"
,
char
.
codePoint
,
s
,
err
)
}
return
int
(
v
)
}
...
...
@@ -242,7 +242,7 @@ func version() string {
return
f
}
}
die
.
Log
(
"unknown version"
)
logger
.
Exit
(
"unknown version"
)
return
"Unknown"
}
...
...
@@ -260,10 +260,10 @@ func loadChars() {
}
resp
,
_
,
err
:=
http
.
Get
(
*
dataURL
)
if
err
!=
nil
{
die
.
Log
(
err
)
logger
.
Exit
(
err
)
}
if
resp
.
StatusCode
!=
200
{
die
.
Log
(
"bad GET status for UnicodeData.txt"
,
resp
.
Status
)
logger
.
Exit
(
"bad GET status for UnicodeData.txt"
,
resp
.
Status
)
}
input
:=
bufio
.
NewReader
(
resp
.
Body
)
var
first
uint32
=
0
...
...
@@ -273,21 +273,21 @@ func loadChars() {
if
err
==
os
.
EOF
{
break
}
die
.
Log
(
err
)
logger
.
Exit
(
err
)
}
switch
parseCategory
(
line
[
0
:
len
(
line
)
-
1
])
{
case
SNormal
:
if
first
!=
0
{
die
.
Log
f
(
"bad state normal at U+%04X"
,
lastChar
)
logger
.
Exit
f
(
"bad state normal at U+%04X"
,
lastChar
)
}
case
SFirst
:
if
first
!=
0
{
die
.
Log
f
(
"bad state first at U+%04X"
,
lastChar
)
logger
.
Exit
f
(
"bad state first at U+%04X"
,
lastChar
)
}
first
=
lastChar
case
SLast
:
if
first
==
0
{
die
.
Log
f
(
"bad state last at U+%04X"
,
lastChar
)
logger
.
Exit
f
(
"bad state last at U+%04X"
,
lastChar
)
}
for
i
:=
first
+
1
;
i
<=
lastChar
;
i
++
{
chars
[
i
]
=
chars
[
first
]
...
...
@@ -336,7 +336,7 @@ func printCategories() {
ndecl
:=
0
for
_
,
name
:=
range
list
{
if
_
,
ok
:=
category
[
name
];
!
ok
{
die
.
Log
(
"unknown category"
,
name
)
logger
.
Exit
(
"unknown category"
,
name
)
}
// We generate an UpperCase name to serve as concise documentation and an _UnderScored
// name to store the data. This stops godoc dumping all the tables but keeps them
...
...
@@ -437,11 +437,11 @@ func dumpRange(header string, inCategory Op) {
func
fullCategoryTest
(
list
[]
string
)
{
for
_
,
name
:=
range
list
{
if
_
,
ok
:=
category
[
name
];
!
ok
{
die
.
Log
(
"unknown category"
,
name
)
logger
.
Exit
(
"unknown category"
,
name
)
}
r
,
ok
:=
unicode
.
Categories
[
name
]
if
!
ok
{
die
.
Log
(
"unknown table"
,
name
)
logger
.
Exit
(
"unknown table"
,
name
)
}
if
name
==
"letter"
{
verifyRange
(
name
,
letterOp
,
r
)
...
...
@@ -475,21 +475,21 @@ func parseScript(line string, scripts map[string][]Script) {
}
field
:=
strings
.
Split
(
line
,
";"
,
-
1
)
if
len
(
field
)
!=
2
{
die
.
Log
f
(
"%s: %d fields (expected 2)
\n
"
,
line
,
len
(
field
))
logger
.
Exit
f
(
"%s: %d fields (expected 2)
\n
"
,
line
,
len
(
field
))
}
matches
:=
scriptRe
.
MatchStrings
(
line
)
matches
:=
scriptRe
.
FindStringSubmatch
(
line
)
if
len
(
matches
)
!=
4
{
die
.
Log
f
(
"%s: %d matches (expected 3)
\n
"
,
line
,
len
(
matches
))
logger
.
Exit
f
(
"%s: %d matches (expected 3)
\n
"
,
line
,
len
(
matches
))
}
lo
,
err
:=
strconv
.
Btoui64
(
matches
[
1
],
16
)
if
err
!=
nil
{
die
.
Log
(
"%.5s...:"
,
err
)
logger
.
Exitf
(
"%.5s...: %s"
,
line
,
err
)
}
hi
:=
lo
if
len
(
matches
[
2
])
>
2
{
// ignore leading ..
hi
,
err
=
strconv
.
Btoui64
(
matches
[
2
][
2
:
],
16
)
if
err
!=
nil
{
die
.
Log
(
"%.5s...:"
,
err
)
logger
.
Exitf
(
"%.5s...: %s"
,
line
,
err
)
}
}
name
:=
matches
[
3
]
...
...
@@ -515,11 +515,11 @@ func foldAdjacent(r []Script) []unicode.Range {
func
fullScriptTest
(
list
[]
string
,
installed
map
[
string
][]
unicode
.
Range
,
scripts
map
[
string
][]
Script
)
{
for
_
,
name
:=
range
list
{
if
_
,
ok
:=
scripts
[
name
];
!
ok
{
die
.
Log
(
"unknown script"
,
name
)
logger
.
Exit
(
"unknown script"
,
name
)
}
_
,
ok
:=
installed
[
name
]
if
!
ok
{
die
.
Log
(
"unknown table"
,
name
)
logger
.
Exit
(
"unknown table"
,
name
)
}
for
_
,
script
:=
range
scripts
[
name
]
{
for
r
:=
script
.
lo
;
r
<=
script
.
hi
;
r
++
{
...
...
@@ -551,10 +551,10 @@ func printScriptOrProperty(doProps bool) {
var
err
os
.
Error
resp
,
_
,
err
:=
http
.
Get
(
*
url
+
file
)
if
err
!=
nil
{
die
.
Log
(
err
)
logger
.
Exit
(
err
)
}
if
resp
.
StatusCode
!=
200
{
die
.
Log
(
"bad GET status for "
,
file
,
":"
,
resp
.
Status
)
logger
.
Exit
(
"bad GET status for "
,
file
,
":"
,
resp
.
Status
)
}
input
:=
bufio
.
NewReader
(
resp
.
Body
)
for
{
...
...
@@ -563,7 +563,7 @@ func printScriptOrProperty(doProps bool) {
if
err
==
os
.
EOF
{
break
}
die
.
Log
(
err
)
logger
.
Exit
(
err
)
}
parseScript
(
line
[
0
:
len
(
line
)
-
1
],
table
)
}
...
...
@@ -808,7 +808,7 @@ func printCaseRange(lo, hi *caseState) {
fmt
.
Printf
(
"
\t
CaseRange{0x%04X, 0x%04X, d{UpperLower, UpperLower, UpperLower}},
\n
"
,
lo
.
point
,
hi
.
point
)
case
hi
.
point
>
lo
.
point
&&
lo
.
isLowerUpper
()
:
die
.
Log
(
"LowerUpper sequence: should not happen: U+%04X. If it's real, need to fix To()"
,
lo
.
point
)
logger
.
Exitf
(
"LowerUpper sequence: should not happen: U+%04X. If it's real, need to fix To()"
,
lo
.
point
)
fmt
.
Printf
(
"
\t
CaseRange{0x%04X, 0x%04X, d{LowerUpper, LowerUpper, LowerUpper}},
\n
"
,
lo
.
point
,
hi
.
point
)
default
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment