Skip to content

Commit c754b0a

Browse files
committed
Fixed warning
1 parent 6d2c8e4 commit c754b0a

File tree

4 files changed

+286
-44
lines changed

4 files changed

+286
-44
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,10 @@ This produces the following help text:
122122
### 2.3.0
123123

124124
* Arabic script added.
125-
126-
* Greek script extended to be AEU-capable.
127125

128126
* Tibetan script changed so all characters can be easily typed on a computer keyboard.
129127

130-
* Greek, Hebrew and Arab, the languages that have (implied) vowels in mapcode sequences,
128+
* Greek, Hebrew and Arabic, the scripts that have (implied) vowels in mapcode sequences,
131129
have been extended with ABJAD conversion, to prevent more than two consecutive non-digits
132130
from occurring. (As a result, mapcodes in Greek, Arab and Hebrew scripts are now often
133131
one character longer than in the roman script.)

mapcodelib/mapcoder.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,7 +2175,9 @@ static int binfindmatch(const int parentcode, const char *str) {
21752175
makeupper(alphaCode);
21762176
{ // binary-search the result
21772177
const alphaRec *p;
2178-
alphaRec t = {alphaCode, parentcode};
2178+
alphaRec t;
2179+
t.alphaCode = alphaCode;
2180+
t.ccode = parentcode;
21792181

21802182
p = (const alphaRec *) bsearch(&t, alphaSearch, NRTERREC, sizeof(alphaRec), cmp_alphacode);
21812183
if (p) {
@@ -2497,15 +2499,15 @@ static char *convertToAbjad(char *str, const char *source, int maxlen) {
24972499
}
24982500
repack_if_alldigits(str, 0);
24992501
if (rest) {
2500-
len = (int) strlen(str);
2502+
int totalLen = (int) strlen(str);
25012503
int needed = (int) strlen(rest);
2502-
int tocopy = maxlen - len - 1;
2504+
int tocopy = maxlen - totalLen - 1;
25032505
if (tocopy > needed) {
25042506
tocopy = needed;
25052507
}
25062508
if (tocopy > 0) {
2507-
memcpy(str + len, rest, tocopy);
2508-
str[len + tocopy] = 0;
2509+
memcpy(str + totalLen, rest, tocopy);
2510+
str[totalLen + tocopy] = 0;
25092511
}
25102512
}
25112513
return str;

mapcodelib/mapcoder.h

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ extern "C" {
2929
#define SUPPORT_HIGH_PRECISION // Define to enable high-precision extension logic.
3030

3131
#define MAX_NR_OF_MAPCODE_RESULTS 22 // Max. number of results ever returned by encoder (e.g. for 26.904899, 95.138515).
32-
#define MAX_PROPER_MAPCODE_LEN 10 // Max. number of characters in a proper mapcode (including the dot).
32+
#define MAX_PROPER_MAPCODE_LEN 11 // Max. number of characters in a proper mapcode (including the dot).
3333
#define MAX_PRECISION_DIGITS 8 // Max. number of extension characters (excluding the hyphen). Must be even.
34-
#define MAX_PRECISION_FACTOR 810000 // 30 to the power (MAX_PRECISION_DIGITS/2)
34+
#define MAX_PRECISION_FACTOR 810000 // 30 to the power (MAX_PRECISION_DIGITS/2).
3535
#define MAX_ISOCODE_LEN 7 // Max. number of characters of a valid territory code; although nothing longer than SIX characters is ever generated (RU-KAM), users can input SEVEN characters (RUS-KAM).
3636
#define MAX_CLEAN_MAPCODE_LEN (MAX_PROPER_MAPCODE_LEN + 1 + MAX_PRECISION_DIGITS) // Max. number of characters in a clean mapcode (excluding zero-terminator).
3737
#define MAX_MAPCODE_RESULT_LEN (MAX_ISOCODE_LEN + 1 + MAX_CLEAN_MAPCODE_LEN + 1) // Max. number of characters to store a single result (including zero-terminator).
@@ -140,7 +140,7 @@ int encodeLatLonToSingleMapcode(
140140
* Pass 0 if not available.
141141
*
142142
* Returns:
143-
* 0 if encoding succeeded, nonzero in case of error
143+
* 0 if encoding succeeded, nonzero in case of error.
144144
*/
145145
int decodeMapcodeToLatLon(
146146
double *lat,
@@ -289,42 +289,44 @@ int multipleBordersNearby(
289289
* Decode a string to Roman characters.
290290
*
291291
* Arguments:
292-
* string - String to decode.
292+
* string - String to decode, allocated by caller.
293293
* asciibuf - Buffer to be filled with the result
294294
* maxlen - Size of asciibuf
295295
*
296296
* Returns:
297-
* Pointer to asciibuf, which holds the result.
297+
* Pointer to same buffers as asciibuf (allocated by caller), which holds the result.
298298
*/
299299
char *convertToRoman(char *asciibuf, int maxlen, const UWORD *string);
300300

301-
/**
302-
* old variant, not thread-safe: uses a pre-allocated static buffer, overwritten by the next call
303-
* Returns converted string. allocated by the library. String must NOT be
304-
* de-allocated by the caller. It will be overwritten by a subsequent call to this method!
305-
*/
306-
const char *decodeToRoman(const UWORD *string);
307-
308301
/**
309302
* Encode a string to Alphabet characters for a language.
310303
*
311304
* Arguments:
312-
* string - String to encode.
305+
* string - String to encode, allocated by caller.
313306
* alphabet - Alphabet to use.
314307
* unibuf - Buffer to be filled with the result.
315308
* maxlen - Size of unibuf.
316309
*
317-
*
318310
* Returns:
319-
* Encoded string. The string is allocated by the library and must NOT be
320-
* de-allocated by the caller. It will be overwritten by a subsequent call to this method!
311+
* Encoded string, points at buffer from 'unibuf', allocated by caller.
321312
*/
322313
UWORD *convertToAlphabet(UWORD *unibuf, int maxlength, const char *string, int alphabet);
323314

315+
316+
/* DEPRECATED METHODS AND CONSTANT - WILL BE DROPPED IN FUTURE RELEASES. */
317+
318+
/**
319+
* DEPRECATED ODL VARIANT, NOT THREAD-SAFE:
320+
* Uses a pre-allocated static buffer, overwritten by the next call
321+
* Returns converted string. allocated by the library. String must NOT be
322+
* de-allocated by the caller. It will be overwritten by a subsequent call to this method!
323+
*/
324+
const char *decodeToRoman(const UWORD *string);
325+
324326
/**
325-
* old variant, not thread-safe: uses a pre-allocated static buffer, overwritten by the next call
326-
* Returns converted string. allocated by the library. String must NOT be
327-
* de-allocated by the caller. It will be overwritten by a subsequent call to this method!
327+
* DEPRECATED ODL VARIANT, NOT THREAD-SAFE:
328+
* Returns converted string. allocated by the library. String must NOT be
329+
* de-allocated by the caller. It will be overwritten by a subsequent call to this method!
328330
*/
329331
const UWORD *encodeToAlphabet(const char *string, int alphabet);
330332

0 commit comments

Comments
 (0)