Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
5a72c505
Commit
5a72c505
authored
Dec 18, 2019
by
antirez
Browse files
Fix GEOHASH negative shifting in a more compatible way.
parent
e6e58e45
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/geo.c
View file @
5a72c505
...
@@ -737,7 +737,15 @@ void geohashCommand(client *c) {
...
@@ -737,7 +737,15 @@ void geohashCommand(client *c) {
char
buf
[
12
];
char
buf
[
12
];
int
i
;
int
i
;
for
(
i
=
0
;
i
<
11
;
i
++
)
{
for
(
i
=
0
;
i
<
11
;
i
++
)
{
int
idx
=
(
hash
.
bits
>>
(
52
-
((
i
+
1
)
*
5
)))
&
0x1f
;
int
idx
;
if
(
i
==
10
)
{
/* We have just 52 bits, but the API used to output
* an 11 bytes geohash. For compatibility we assume
* zero. */
idx
=
0
;
}
else
{
idx
=
(
hash
.
bits
>>
(
52
-
((
i
+
1
)
*
5
)))
&
0x1f
;
}
buf
[
i
]
=
geoalphabet
[
idx
];
buf
[
i
]
=
geoalphabet
[
idx
];
}
}
buf
[
11
]
=
'\0'
;
buf
[
11
]
=
'\0'
;
...
...
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