[fix] Removing C++ checks from all but the main API functions

This commit is contained in:
Al
2015-08-07 16:30:07 -04:00
parent 359a1efb03
commit 9b69d1f67a
19 changed files with 45 additions and 105 deletions

View File

@@ -1,9 +1,7 @@
#ifndef ADDRESS_DICTIONARY_H #ifndef ADDRESS_DICTIONARY_H
#define ADDRESS_DICTIONARY_H #define ADDRESS_DICTIONARY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -76,8 +74,6 @@ bool address_dictionary_module_setup(void);
void address_dictionary_module_teardown(void); void address_dictionary_module_teardown(void);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -1,9 +1,7 @@
#ifndef COLLECTIONS_H #ifndef COLLECTIONS_H
#define COLLECTIONS_H #define COLLECTIONS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -45,8 +43,6 @@ VECTOR_INIT_NUMERIC(double_array, double)
VECTOR_INIT(char_array, char) VECTOR_INIT(char_array, char)
VECTOR_INIT(uchar_array, unsigned char) VECTOR_INIT(uchar_array, unsigned char)
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -2,9 +2,7 @@
#define FEATURES_H #define FEATURES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
@@ -15,8 +13,6 @@ extern "C" {
void feature_array_add(cstring_array *features, size_t count, ...); void feature_array_add(cstring_array *features, size_t count, ...);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -2,9 +2,7 @@
#define FILE_UTILS_H #define FILE_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -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); bool file_write_chars(FILE *file, const char *buf, size_t len);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -2,9 +2,7 @@
#define GAZETTEERS_H #define GAZETTEERS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -65,9 +63,7 @@ typedef struct gazetteer {
} gazetteer_t; } gazetteer_t;
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -1,9 +1,7 @@
#ifndef GEONAMES_DICTIONARY_H #ifndef GEONAMES_DICTIONARY_H
#define GEONAMES_DICTIONARY_H #define GEONAMES_DICTIONARY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -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_len(char *key, size_t len);
geonames_generic_t *geodb_get(char *key); geonames_generic_t *geodb_get(char *key);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -25,9 +25,7 @@ THE SOFTWARE.
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
enum { enum {
GEOHASH_OK, 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_decode(char* r, size_t length, double *latitude, double *longitude);
int geohash_neighbors(char *hashcode, char* dst, size_t dst_length, int *string_count); int geohash_neighbors(char *hashcode, char* dst, size_t dst_length, int *string_count);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -1,9 +1,7 @@
#ifndef GEONAMES_H #ifndef GEONAMES_H
#define GEONAMES_H #define GEONAMES_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -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_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); bool geonames_generic_deserialize(gn_type *type, geoname_t *geoname, gn_postal_code_t *postal_code, char_array *str);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -1,6 +1,10 @@
#ifndef LIBPOSTAL_H #ifndef LIBPOSTAL_H
#define LIBPOSTAL_H #define LIBPOSTAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -58,4 +62,8 @@ char **expand_address(char *input, normalize_options_t options, uint64_t *n);
bool libpostal_setup(void); bool libpostal_setup(void);
void libpostal_teardown(void); void libpostal_teardown(void);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -21,9 +21,7 @@ As well as normalizations for individual string tokens:
#ifndef NORMALIZE_H #ifndef NORMALIZE_H
#define NORMALIZE_H #define NORMALIZE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -65,8 +63,6 @@ void normalize_token(cstring_array *array, char *str, token_t token, uint64_t op
// Takes NORMALIZE_STRING_* options // Takes NORMALIZE_STRING_* options
string_tree_t *normalize_string(char *str, uint64_t options); string_tree_t *normalize_string(char *str, uint64_t options);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -2,9 +2,7 @@
#define NUMEX_H #define NUMEX_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -151,8 +149,6 @@ bool numex_table_save(char *filename);
bool numex_module_setup(char *filename); bool numex_module_setup(char *filename);
void numex_module_teardown(void); void numex_module_teardown(void);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -1,9 +1,7 @@
#ifndef SCANNER_H #ifndef SCANNER_H
#define SCANNER_H #define SCANNER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
@@ -24,8 +22,6 @@ token_array *tokenize_keep_whitespace(const char *input);
token_array *tokenize(const char *input); token_array *tokenize(const char *input);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -94,8 +94,8 @@ bool string_is_lower(char *s) {
return true; return true;
} }
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) {
uint num_replacements = 0; uint32_t num_replacements = 0;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
for (int j = 0; j < trans_len; j++) { for (int j = 0; j < trans_len; j++) {

View File

@@ -1,9 +1,7 @@
#ifndef STRING_UTILS_H #ifndef STRING_UTILS_H
#define STRING_UTILS_H #define STRING_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -51,7 +49,7 @@ void string_upper(char *s);
bool string_starts_with(const char *str, const char *start); bool string_starts_with(const char *str, const char *start);
bool string_ends_with(const char *str, const char *ending); 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 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); 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 #endif

View File

@@ -1,9 +1,7 @@
#ifndef TOKEN_TYPES_H #ifndef TOKEN_TYPES_H
#define 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 // Doing these as #defines so we can duplicate the values exactly in Python
@@ -62,8 +60,6 @@ extern "C" {
#define WHITESPACE 300 #define WHITESPACE 300
#define NEWLINE 301 #define NEWLINE 301
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -1,9 +1,7 @@
#ifndef TOKENS_H #ifndef TOKENS_H
#define TOKENS_H #define TOKENS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
@@ -34,8 +32,6 @@ char *tokenized_string_get_token(tokenized_string_t *self, uint32_t index);
void tokenized_string_destroy(tokenized_string_t *self); void tokenized_string_destroy(tokenized_string_t *self);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -15,9 +15,7 @@
#ifndef TRIE_H #ifndef TRIE_H
#define TRIE_H #define TRIE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -142,7 +140,5 @@ trie_t *trie_load(char *path);
void trie_destroy(trie_t *self); void trie_destroy(trie_t *self);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -1,9 +1,7 @@
#ifndef TRIE_SEARCH_H #ifndef TRIE_SEARCH_H
#define TRIE_SEARCH_H #define TRIE_SEARCH_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -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_from_index(trie_t *self, char *word, uint32_t start_node_id);
phrase_t trie_search_prefixes(trie_t *self, char *word); phrase_t trie_search_prefixes(trie_t *self, char *word);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -1,9 +1,7 @@
#ifndef VECTOR_H #ifndef VECTOR_H
#define VECTOR_H #define VECTOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h> #include <stdlib.h>
@@ -67,8 +65,6 @@ extern "C" {
__VECTOR_DESTROY_FREE_DATA(name, type, free_func) __VECTOR_DESTROY_FREE_DATA(name, type, free_func)
#ifdef __cplusplus
}
#endif
#endif #endif