Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
60683192
Commit
60683192
authored
Jan 15, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delta encoding of upper/lower/title makes a glorious return (#12736)
parent
f336f41c
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1356 additions
and
3452 deletions
+1356
-3452
Objects/unicodectype.c
Objects/unicodectype.c
+13
-9
Objects/unicodetype_db.h
Objects/unicodetype_db.h
+1336
-3443
Tools/unicode/makeunicodedata.py
Tools/unicode/makeunicodedata.py
+7
-0
No files found.
Objects/unicodectype.c
View file @
60683192
...
...
@@ -27,9 +27,13 @@
#define EXTENDED_CASE_MASK 0x4000
typedef
struct
{
const
Py_UCS4
upper
;
const
Py_UCS4
lower
;
const
Py_UCS4
title
;
/*
These are either deltas to the character or offsets in
_PyUnicode_ExtendedCase.
*/
const
int
upper
;
const
int
lower
;
const
int
title
;
const
unsigned
char
decimal
;
const
unsigned
char
digit
;
const
unsigned
short
flags
;
...
...
@@ -60,7 +64,7 @@ Py_UCS4 _PyUnicode_ToTitlecase(register Py_UCS4 ch)
{
const
_PyUnicode_TypeRecord
*
ctype
=
gettyperecord
(
ch
);
return
c
type
->
title
?
ctype
->
title
:
ch
;
return
c
h
+
ctype
->
title
;
}
/* Returns 1 for Unicode characters having the category 'Lt', 0
...
...
@@ -186,7 +190,7 @@ Py_UCS4 _PyUnicode_ToUppercase(Py_UCS4 ch)
if
(
ctype
->
flags
&
EXTENDED_CASE_MASK
)
return
_PyUnicode_ExtendedCase
[
ctype
->
upper
&
0xFFFF
];
return
c
type
->
upper
?
ctype
->
upper
:
ch
;
return
c
h
+
ctype
->
upper
;
}
/* Returns the lowercase Unicode characters corresponding to ch or just
...
...
@@ -198,7 +202,7 @@ Py_UCS4 _PyUnicode_ToLowercase(Py_UCS4 ch)
if
(
ctype
->
flags
&
EXTENDED_CASE_MASK
)
return
_PyUnicode_ExtendedCase
[
ctype
->
lower
&
0xFFFF
];
return
c
type
->
lower
?
ctype
->
lower
:
ch
;
return
c
h
+
ctype
->
lower
;
}
int
_PyUnicode_ToLowerFull
(
Py_UCS4
ch
,
Py_UCS4
*
res
)
...
...
@@ -213,7 +217,7 @@ int _PyUnicode_ToLowerFull(Py_UCS4 ch, Py_UCS4 *res)
res
[
i
]
=
_PyUnicode_ExtendedCase
[
index
+
i
];
return
n
;
}
res
[
0
]
=
c
type
->
lower
?
ctype
->
lower
:
ch
;
res
[
0
]
=
c
h
+
ctype
->
lower
;
return
1
;
}
...
...
@@ -229,7 +233,7 @@ int _PyUnicode_ToTitleFull(Py_UCS4 ch, Py_UCS4 *res)
res
[
i
]
=
_PyUnicode_ExtendedCase
[
index
+
i
];
return
n
;
}
res
[
0
]
=
c
type
->
title
?
ctype
->
title
:
ch
;
res
[
0
]
=
c
h
+
ctype
->
title
;
return
1
;
}
...
...
@@ -245,7 +249,7 @@ int _PyUnicode_ToUpperFull(Py_UCS4 ch, Py_UCS4 *res)
res
[
i
]
=
_PyUnicode_ExtendedCase
[
index
+
i
];
return
n
;
}
res
[
0
]
=
c
type
->
upper
?
ctype
->
upper
:
ch
;
res
[
0
]
=
c
h
+
ctype
->
upper
;
return
1
;
}
...
...
Objects/unicodetype_db.h
View file @
60683192
This diff is collapsed.
Click to expand it.
Tools/unicode/makeunicodedata.py
View file @
60683192
...
...
@@ -443,6 +443,13 @@ def makeunicodetype(unicode, trace):
if
sc
is
None
:
if
upper
==
lower
==
title
:
upper
=
lower
=
title
=
0
else
:
upper
=
upper
-
char
lower
=
lower
-
char
title
=
title
-
char
assert
(
abs
(
upper
)
<=
2147483647
and
abs
(
lower
)
<=
2147483647
and
abs
(
title
)
<=
2147483647
)
else
:
# This happens either when some character maps to more than one
# character in uppercase, lowercase, or titlecase or the
...
...
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