mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Fix GEOHASH negative shifting in a more compatible way.
This commit is contained in:
parent
e6e58e455c
commit
5a72c5058c
10
src/geo.c
10
src/geo.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';
|
||||||
|
Loading…
Reference in New Issue
Block a user