Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
fc799ba0
Commit
fc799ba0
authored
12 years ago
by
Ken Wakasa
Browse files
Options
Downloads
Patches
Plain Diff
Clean up sign conversions in binary_format.h (done by -Wsign-conversion)
Change-Id: I9ca88c22ee5bbb66d50640e1d96021fbe71fc8ab
parent
203b2138
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
native/jni/src/binary_format.h
+13
-12
13 additions, 12 deletions
native/jni/src/binary_format.h
with
13 additions
and
12 deletions
native/jni/src/binary_format.h
+
13
−
12
View file @
fc799ba0
...
...
@@ -20,6 +20,7 @@
#include
<cstdlib>
#include
<limits>
#include
<map>
#include
<stdint.h>
#include
"bloom_filter.h"
#include
"char_utils.h"
...
...
@@ -63,8 +64,8 @@ class BinaryFormat {
static
const
int
SHORTCUT_LIST_SIZE_SIZE
=
2
;
static
int
detectFormat
(
const
uint8_t
*
const
dict
);
static
unsigned
int
getHeaderSize
(
const
uint8_t
*
const
dict
);
static
unsigned
int
getFlags
(
const
uint8_t
*
const
dict
);
static
int
getHeaderSize
(
const
uint8_t
*
const
dict
);
static
int
getFlags
(
const
uint8_t
*
const
dict
);
static
void
readHeaderValue
(
const
uint8_t
*
const
dict
,
const
char
*
const
key
,
int
*
outValue
,
const
int
outValueSize
);
static
int
readHeaderValueInt
(
const
uint8_t
*
const
dict
,
const
char
*
const
key
);
...
...
@@ -112,25 +113,25 @@ class BinaryFormat {
// Originally, format version 1 had a 16-bit magic number, then the version number `01'
// then options that must be 0. Hence the first 32-bits of the format are always as follow
// and it's okay to consider them a magic number as a whole.
static
const
u
int
32_t
FORMAT_VERSION_1_MAGIC_NUMBER
=
0x78B10100
;
static
const
unsigned
int
FORMAT_VERSION_1_HEADER_SIZE
=
5
;
static
const
int
FORMAT_VERSION_1_MAGIC_NUMBER
=
0x78B10100
;
static
const
int
FORMAT_VERSION_1_HEADER_SIZE
=
5
;
// The versions of Latin IME that only handle format version 1 only test for the magic
// number, so we had to change it so that version 2 files would be rejected by older
// implementations. On this occasion, we made the magic number 32 bits long.
static
const
u
int
32_t
FORMAT_VERSION_2_MAGIC_NUMBER
=
0x9BC13AFE
;
static
const
int
FORMAT_VERSION_2_MAGIC_NUMBER
=
-
1681835266
;
//
0x9BC13AFE
static
const
int
CHARACTER_ARRAY_TERMINATOR_SIZE
=
1
;
static
const
int
32_t
MINIMAL_ONE_BYTE_CHARACTER_VALUE
=
0x20
;
static
const
int
32_t
CHARACTER_ARRAY_TERMINATOR
=
0x1F
;
static
const
int
MINIMAL_ONE_BYTE_CHARACTER_VALUE
=
0x20
;
static
const
int
CHARACTER_ARRAY_TERMINATOR
=
0x1F
;
static
const
int
MULTIPLE_BYTE_CHARACTER_ADDITIONAL_SIZE
=
2
;
static
const
unsigned
int
NO_FLAGS
=
0
;
static
const
int
NO_FLAGS
=
0
;
static
int
skipAllAttributes
(
const
uint8_t
*
const
dict
,
const
uint8_t
flags
,
const
int
pos
);
static
int
skipBigrams
(
const
uint8_t
*
const
dict
,
const
uint8_t
flags
,
const
int
pos
);
};
AK_FORCE_INLINE
int
BinaryFormat
::
detectFormat
(
const
uint8_t
*
const
dict
)
{
// The magic number is stored big-endian.
const
u
int
32_t
magicNumber
=
(
dict
[
0
]
<<
24
)
+
(
dict
[
1
]
<<
16
)
+
(
dict
[
2
]
<<
8
)
+
dict
[
3
];
const
int
magicNumber
=
(
dict
[
0
]
<<
24
)
+
(
dict
[
1
]
<<
16
)
+
(
dict
[
2
]
<<
8
)
+
dict
[
3
];
switch
(
magicNumber
)
{
case
FORMAT_VERSION_1_MAGIC_NUMBER
:
// Format 1 header is exactly 5 bytes long and looks like:
...
...
@@ -150,7 +151,7 @@ AK_FORCE_INLINE int BinaryFormat::detectFormat(const uint8_t *const dict) {
}
}
inline
unsigned
int
BinaryFormat
::
getFlags
(
const
uint8_t
*
const
dict
)
{
inline
int
BinaryFormat
::
getFlags
(
const
uint8_t
*
const
dict
)
{
switch
(
detectFormat
(
dict
))
{
case
1
:
return
NO_FLAGS
;
// TODO: NO_FLAGS is unused anywhere else?
...
...
@@ -159,7 +160,7 @@ inline unsigned int BinaryFormat::getFlags(const uint8_t *const dict) {
}
}
inline
unsigned
int
BinaryFormat
::
getHeaderSize
(
const
uint8_t
*
const
dict
)
{
inline
int
BinaryFormat
::
getHeaderSize
(
const
uint8_t
*
const
dict
)
{
switch
(
detectFormat
(
dict
))
{
case
1
:
return
FORMAT_VERSION_1_HEADER_SIZE
;
...
...
@@ -167,7 +168,7 @@ inline unsigned int BinaryFormat::getHeaderSize(const uint8_t *const dict) {
// See the format of the header in the comment in detectFormat() above
return
(
dict
[
8
]
<<
24
)
+
(
dict
[
9
]
<<
16
)
+
(
dict
[
10
]
<<
8
)
+
dict
[
11
];
default:
return
std
::
numeric_limits
<
unsigned
int
>::
max
();
return
std
::
numeric_limits
<
int
>::
max
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment