From 9b69d1f67a83329a0daef4bd0a85f91952a12725 Mon Sep 17 00:00:00 2001 From: Al Date: Fri, 7 Aug 2015 16:30:07 -0400 Subject: [PATCH] [fix] Removing C++ checks from all but the main API functions --- src/address_dictionary.h | 8 ++------ src/collections.h | 8 ++------ src/features.h | 8 ++------ src/file_utils.h | 8 ++------ src/gazetteers.h | 8 ++------ src/geodb.h | 8 ++------ src/geohash/geohash.h | 8 ++------ src/geonames.h | 8 ++------ src/libpostal.h | 8 ++++++++ src/normalize.h | 8 ++------ src/numex.h | 8 ++------ src/scanner.h | 8 ++------ src/string_utils.c | 4 ++-- src/string_utils.h | 10 +++------- src/token_types.h | 8 ++------ src/tokens.h | 8 ++------ src/trie.h | 8 ++------ src/trie_search.h | 8 ++------ src/vector.h | 8 ++------ 19 files changed, 45 insertions(+), 105 deletions(-) diff --git a/src/address_dictionary.h b/src/address_dictionary.h index f7177310..6b5ddcae 100644 --- a/src/address_dictionary.h +++ b/src/address_dictionary.h @@ -1,9 +1,7 @@ #ifndef ADDRESS_DICTIONARY_H #define ADDRESS_DICTIONARY_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -76,8 +74,6 @@ bool address_dictionary_module_setup(void); void address_dictionary_module_teardown(void); -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/collections.h b/src/collections.h index 602aff00..39e6ec7c 100644 --- a/src/collections.h +++ b/src/collections.h @@ -1,9 +1,7 @@ #ifndef COLLECTIONS_H #define COLLECTIONS_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -45,8 +43,6 @@ VECTOR_INIT_NUMERIC(double_array, double) VECTOR_INIT(char_array, char) VECTOR_INIT(uchar_array, unsigned char) -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/features.h b/src/features.h index 9a818103..34db088a 100644 --- a/src/features.h +++ b/src/features.h @@ -2,9 +2,7 @@ #define FEATURES_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -15,8 +13,6 @@ extern "C" { void feature_array_add(cstring_array *features, size_t count, ...); -#ifdef __cplusplus -} -#endif + #endif \ No newline at end of file diff --git a/src/file_utils.h b/src/file_utils.h index 19af174a..83fd0a8d 100644 --- a/src/file_utils.h +++ b/src/file_utils.h @@ -2,9 +2,7 @@ #define FILE_UTILS_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -54,8 +52,6 @@ bool file_read_chars(FILE *file, char *buf, size_t len); bool file_write_chars(FILE *file, const char *buf, size_t len); -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/gazetteers.h b/src/gazetteers.h index 20e8b801..dc45270c 100644 --- a/src/gazetteers.h +++ b/src/gazetteers.h @@ -2,9 +2,7 @@ #define GAZETTEERS_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -65,9 +63,7 @@ typedef struct gazetteer { } gazetteer_t; -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/geodb.h b/src/geodb.h index 1701abdd..f12984af 100644 --- a/src/geodb.h +++ b/src/geodb.h @@ -1,9 +1,7 @@ #ifndef GEONAMES_DICTIONARY_H #define GEONAMES_DICTIONARY_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -64,8 +62,6 @@ void geodb_destroy(geodb_t *self); geonames_generic_t *geodb_get_len(char *key, size_t len); geonames_generic_t *geodb_get(char *key); -#ifdef __cplusplus -} -#endif + #endif \ No newline at end of file diff --git a/src/geohash/geohash.h b/src/geohash/geohash.h index ae78614c..fc674937 100644 --- a/src/geohash/geohash.h +++ b/src/geohash/geohash.h @@ -25,9 +25,7 @@ THE SOFTWARE. #include #include -#ifdef __cplusplus -extern "C" { -#endif + enum { GEOHASH_OK, @@ -42,8 +40,6 @@ int geohash_encode(double latitude, double longitude, char* r, size_t capacity); int geohash_decode(char* r, size_t length, double *latitude, double *longitude); int geohash_neighbors(char *hashcode, char* dst, size_t dst_length, int *string_count); -#ifdef __cplusplus -} -#endif + #endif \ No newline at end of file diff --git a/src/geonames.h b/src/geonames.h index 1cbdce6d..d98bc786 100644 --- a/src/geonames.h +++ b/src/geonames.h @@ -1,9 +1,7 @@ #ifndef GEONAMES_H #define GEONAMES_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -107,8 +105,6 @@ VECTOR_INIT(gn_generic_array, geonames_generic_t); bool geonames_generic_serialize(geonames_generic_t *gn, char_array *str); bool geonames_generic_deserialize(gn_type *type, geoname_t *geoname, gn_postal_code_t *postal_code, char_array *str); -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/libpostal.h b/src/libpostal.h index bd6fa91f..e8fe69b6 100644 --- a/src/libpostal.h +++ b/src/libpostal.h @@ -1,6 +1,10 @@ #ifndef LIBPOSTAL_H #define LIBPOSTAL_H +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -58,4 +62,8 @@ char **expand_address(char *input, normalize_options_t options, uint64_t *n); bool libpostal_setup(void); void libpostal_teardown(void); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/normalize.h b/src/normalize.h index 21dd7e8e..c8a18025 100644 --- a/src/normalize.h +++ b/src/normalize.h @@ -21,9 +21,7 @@ As well as normalizations for individual string tokens: #ifndef NORMALIZE_H #define NORMALIZE_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -65,8 +63,6 @@ void normalize_token(cstring_array *array, char *str, token_t token, uint64_t op // Takes NORMALIZE_STRING_* options string_tree_t *normalize_string(char *str, uint64_t options); -#ifdef __cplusplus -} -#endif + #endif \ No newline at end of file diff --git a/src/numex.h b/src/numex.h index e1b3ca8a..f60a12c8 100644 --- a/src/numex.h +++ b/src/numex.h @@ -2,9 +2,7 @@ #define NUMEX_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -151,8 +149,6 @@ bool numex_table_save(char *filename); bool numex_module_setup(char *filename); void numex_module_teardown(void); -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/scanner.h b/src/scanner.h index aaeea16e..e6193451 100644 --- a/src/scanner.h +++ b/src/scanner.h @@ -1,9 +1,7 @@ #ifndef SCANNER_H #define SCANNER_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -24,8 +22,6 @@ token_array *tokenize_keep_whitespace(const char *input); token_array *tokenize(const char *input); -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/string_utils.c b/src/string_utils.c index 9dcbfb9e..2599c56b 100644 --- a/src/string_utils.c +++ b/src/string_utils.c @@ -94,8 +94,8 @@ bool string_is_lower(char *s) { return true; } -uint string_translate(char *str, size_t len, char *word_chars, char *word_repls, size_t trans_len) { - uint num_replacements = 0; +uint32_t string_translate(char *str, size_t len, char *word_chars, char *word_repls, size_t trans_len) { + uint32_t num_replacements = 0; for (int i = 0; i < len; i++) { for (int j = 0; j < trans_len; j++) { diff --git a/src/string_utils.h b/src/string_utils.h index 9f83b418..614d2f00 100644 --- a/src/string_utils.h +++ b/src/string_utils.h @@ -1,9 +1,7 @@ #ifndef STRING_UTILS_H #define STRING_UTILS_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -51,7 +49,7 @@ void string_upper(char *s); bool string_starts_with(const char *str, const char *start); bool string_ends_with(const char *str, const char *ending); -uint string_translate(char *str, size_t len, char *word_chars, char *word_repls, size_t trans_len); +uint32_t string_translate(char *str, size_t len, char *word_chars, char *word_repls, size_t trans_len); char *utf8_reversed_string(const char *s); // returns a copy, caller frees ssize_t utf8proc_iterate_reversed(const uint8_t *str, ssize_t start, int32_t *dst); @@ -245,8 +243,6 @@ void string_tree_iterator_destroy(string_tree_iterator_t *self); } -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/token_types.h b/src/token_types.h index 472f345e..8ae0c144 100644 --- a/src/token_types.h +++ b/src/token_types.h @@ -1,9 +1,7 @@ #ifndef TOKEN_TYPES_H #define TOKEN_TYPES_H -#ifdef __cplusplus -extern "C" { -#endif + // Doing these as #defines so we can duplicate the values exactly in Python @@ -62,8 +60,6 @@ extern "C" { #define WHITESPACE 300 #define NEWLINE 301 -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/tokens.h b/src/tokens.h index 3a49f4fd..0737aedf 100644 --- a/src/tokens.h +++ b/src/tokens.h @@ -1,9 +1,7 @@ #ifndef TOKENS_H #define TOKENS_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -34,8 +32,6 @@ char *tokenized_string_get_token(tokenized_string_t *self, uint32_t index); void tokenized_string_destroy(tokenized_string_t *self); -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/trie.h b/src/trie.h index 75ad5bc6..d48f7658 100644 --- a/src/trie.h +++ b/src/trie.h @@ -15,9 +15,7 @@ #ifndef TRIE_H #define TRIE_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -142,7 +140,5 @@ trie_t *trie_load(char *path); void trie_destroy(trie_t *self); -#ifdef __cplusplus -} -#endif + #endif diff --git a/src/trie_search.h b/src/trie_search.h index d63c5c1a..9ecfaffa 100644 --- a/src/trie_search.h +++ b/src/trie_search.h @@ -1,9 +1,7 @@ #ifndef TRIE_SEARCH_H #define TRIE_SEARCH_H -#ifdef __cplusplus -extern "C" { -#endif + #include #include @@ -36,8 +34,6 @@ phrase_t trie_search_suffixes(trie_t *self, char *word); phrase_t trie_search_prefixes_from_index(trie_t *self, char *word, uint32_t start_node_id); phrase_t trie_search_prefixes(trie_t *self, char *word); -#ifdef __cplusplus -} -#endif + #endif \ No newline at end of file diff --git a/src/vector.h b/src/vector.h index f92f93b8..b12c4cdc 100644 --- a/src/vector.h +++ b/src/vector.h @@ -1,9 +1,7 @@ #ifndef VECTOR_H #define VECTOR_H -#ifdef __cplusplus -extern "C" { -#endif + #include @@ -67,8 +65,6 @@ extern "C" { __VECTOR_DESTROY_FREE_DATA(name, type, free_func) -#ifdef __cplusplus -} -#endif + #endif