summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2021-11-08 11:57:54 +0000
committerReuben Thomas <rrt@sc3d.org>2021-11-08 11:57:54 +0000
commit9e3bd0386bdf7f1ac428b885df4d58840b5ddd12 (patch)
tree1ab947c20fe00ffefa598a3aede877ec79771095
parent7903b7460c93d5bf68e1b37b2f7ed573d8586e94 (diff)
downloadenchant-9e3bd0386bdf7f1ac428b885df4d58840b5ddd12.tar.gz
Clean up whitespace in main sources
-rw-r--r--src/enchant++.h86
-rw-r--r--src/enchant-provider.h20
-rw-r--r--src/enchant.c40
-rw-r--r--src/enchant.h6
-rw-r--r--src/pwl.c54
5 files changed, 103 insertions, 103 deletions
diff --git a/src/enchant++.h b/src/enchant++.h
index 68ebaf9..458a707 100644
--- a/src/enchant++.h
+++ b/src/enchant++.h
@@ -35,7 +35,7 @@
#include <vector>
#include <exception>
-namespace enchant
+namespace enchant
{
void set_prefix_dir (const std::string prefix) {
enchant_set_prefix_dir (prefix.c_str ());
@@ -46,7 +46,7 @@ namespace enchant
class Exception : public std::exception
{
public:
- explicit Exception (const char * ex)
+ explicit Exception (const char * ex)
: std::exception (), m_ex ("") {
if (ex)
m_ex = ex;
@@ -54,7 +54,7 @@ namespace enchant
virtual ~Exception () noexcept {
}
-
+
virtual const char * what () const noexcept {
return m_ex.c_str();
}
@@ -66,17 +66,17 @@ namespace enchant
class Dict
{
friend class enchant::Broker;
-
+
public:
-
+
~Dict () {
enchant_broker_free_dict (m_broker, m_dict);
}
-
+
bool check (const std::string & utf8word) {
int val;
- val = enchant_dict_check (m_dict, utf8word.c_str(),
+ val = enchant_dict_check (m_dict, utf8word.c_str(),
utf8word.size());
if (val == 0)
return true;
@@ -89,70 +89,70 @@ namespace enchant
return false; // never reached
}
- void suggest (const std::string & utf8word,
+ void suggest (const std::string & utf8word,
std::vector<std::string> & out_suggestions) {
size_t n_suggs;
char ** suggs;
-
+
out_suggestions.clear ();
-
- suggs = enchant_dict_suggest (m_dict, utf8word.c_str(),
+
+ suggs = enchant_dict_suggest (m_dict, utf8word.c_str(),
utf8word.size(), &n_suggs);
-
+
if (suggs && n_suggs) {
out_suggestions.reserve(n_suggs);
for (size_t i = 0; i < n_suggs; i++) {
out_suggestions.push_back (suggs[i]);
}
-
+
enchant_dict_free_string_list (m_dict, suggs);
}
}
-
+
std::vector<std::string> suggest (const std::string & utf8word) {
std::vector<std::string> result;
suggest (utf8word, result);
return result;
}
-
+
void add (const std::string & utf8word) {
- enchant_dict_add (m_dict, utf8word.c_str(),
+ enchant_dict_add (m_dict, utf8word.c_str(),
utf8word.size());
}
-
+
void add_to_session (const std::string & utf8word) {
- enchant_dict_add_to_session (m_dict, utf8word.c_str(),
+ enchant_dict_add_to_session (m_dict, utf8word.c_str(),
utf8word.size());
}
-
+
void is_added (const std::string & utf8word) {
- enchant_dict_is_added (m_dict, utf8word.c_str(),
+ enchant_dict_is_added (m_dict, utf8word.c_str(),
utf8word.size());
}
-
+
void remove (const std::string & utf8word) {
- enchant_dict_remove (m_dict, utf8word.c_str(),
+ enchant_dict_remove (m_dict, utf8word.c_str(),
utf8word.size());
}
-
+
void remove_from_session (const std::string & utf8word) {
- enchant_dict_remove_from_session (m_dict, utf8word.c_str(),
+ enchant_dict_remove_from_session (m_dict, utf8word.c_str(),
utf8word.size());
}
void is_removed (const std::string & utf8word) {
- enchant_dict_is_removed (m_dict, utf8word.c_str(),
+ enchant_dict_is_removed (m_dict, utf8word.c_str(),
utf8word.size());
}
- void store_replacement (const std::string & utf8bad,
+ void store_replacement (const std::string & utf8bad,
const std::string & utf8good) {
- enchant_dict_store_replacement (m_dict,
+ enchant_dict_store_replacement (m_dict,
utf8bad.c_str(), utf8bad.size(),
utf8good.c_str(), utf8good.size());
}
-
+
const std::string & get_lang () const {
return m_lang;
}
@@ -172,7 +172,7 @@ namespace enchant
private:
// space reserved for API/ABI expansion
- void * _private[5];
+ void * _private[5];
static void s_describe_fn (const char * const lang,
const char * const provider_name,
@@ -180,7 +180,7 @@ namespace enchant
const char * const provider_file,
void * user_data) {
enchant::Dict * dict = static_cast<enchant::Dict *> (user_data);
-
+
dict->m_lang = lang;
dict->m_provider_name = provider_name;
dict->m_provider_desc = provider_desc;
@@ -196,7 +196,7 @@ namespace enchant
Dict ();
Dict (const Dict & rhs);
Dict& operator=(const Dict & rhs);
-
+
EnchantDict * m_dict;
EnchantBroker * m_broker;
@@ -205,12 +205,12 @@ namespace enchant
std::string m_provider_desc;
std::string m_provider_file;
}; // class enchant::Dict
-
+
class Broker
{
-
+
public:
-
+
Broker ()
: m_broker (enchant_broker_init ())
{
@@ -222,40 +222,40 @@ namespace enchant
Dict * request_dict (const std::string & lang) {
EnchantDict * dict = enchant_broker_request_dict (m_broker, lang.c_str());
-
+
if (!dict) {
throw enchant::Exception (enchant_broker_get_error (m_broker));
return 0; // never reached
}
-
+
return new Dict (dict, m_broker);
}
Dict * request_pwl_dict (const std::string & pwl) {
EnchantDict * dict = enchant_broker_request_pwl_dict (m_broker, pwl.c_str());
-
+
if (!dict) {
throw enchant::Exception (enchant_broker_get_error (m_broker));
return 0; // never reached
}
-
+
return new Dict (dict, m_broker);
}
-
+
bool dict_exists (const std::string & lang) {
if (enchant_broker_dict_exists (m_broker, lang.c_str()))
return true;
return false;
}
-
+
void set_ordering (const std::string & tag, const std::string & ordering) {
enchant_broker_set_ordering (m_broker, tag.c_str(), ordering.c_str());
}
-
+
void describe (EnchantBrokerDescribeFn fn, void * user_data = NULL) {
enchant_broker_describe (m_broker, fn, user_data);
}
-
+
void list_dicts (EnchantDictDescribeFn fn, void * user_data = NULL) {
enchant_broker_list_dicts (m_broker, fn, user_data);
}
@@ -265,7 +265,7 @@ namespace enchant
// not implemented
Broker (const Broker & rhs);
Broker& operator=(const Broker & rhs);
-
+
EnchantBroker * m_broker;
}; // class enchant::Broker
} // enchant namespace
diff --git a/src/enchant-provider.h b/src/enchant-provider.h
index 34e2218..66656b0 100644
--- a/src/enchant-provider.h
+++ b/src/enchant-provider.h
@@ -128,22 +128,22 @@ struct str_enchant_dict
int (*check) (struct str_enchant_dict * me, const char *const word,
size_t len);
-
+
/* returns utf8*/
char **(*suggest) (struct str_enchant_dict * me,
const char *const word, size_t len,
size_t * out_n_suggs);
-
+
void (*add_to_personal) (struct str_enchant_dict * me,
const char *const word, size_t len);
-
+
void (*add_to_session) (struct str_enchant_dict * me,
const char *const word, size_t len);
-
+
void (*store_replacement) (struct str_enchant_dict * me,
const char *const mis, size_t mis_len,
const char *const cor, size_t cor_len);
-
+
void (*add_to_exclude) (struct str_enchant_dict * me,
const char *const word, size_t len);
@@ -152,21 +152,21 @@ struct str_enchant_dict
int (*is_word_character) (struct str_enchant_dict * me,
uint32_t uc_in, size_t n);
};
-
+
struct str_enchant_provider
{
void *user_data;
void *enchant_private_data;
EnchantBroker * owner;
-
+
void (*dispose) (struct str_enchant_provider * me);
-
+
EnchantDict *(*request_dict) (struct str_enchant_provider * me,
const char *const tag);
-
+
void (*dispose_dict) (struct str_enchant_provider * me,
EnchantDict * dict);
-
+
int (*dictionary_exists) (struct str_enchant_provider * me,
const char *const tag);
diff --git a/src/enchant.c b/src/enchant.c
index 228d0cb..65a4d5f 100644
--- a/src/enchant.c
+++ b/src/enchant.c
@@ -56,14 +56,14 @@
static const char *charset;
-typedef enum
+typedef enum
{
MODE_NONE,
MODE_A,
MODE_L
} IspellMode_t;
-static void
+static void
print_version (FILE * to)
{
fprintf (to, "@(#) International Ispell Version 3.1.20 (but really Enchant %s)\n", PACKAGE_VERSION);
@@ -110,8 +110,8 @@ consume_line (FILE * in, GString * str)
if (utf) {
g_string_assign (str, utf);
g_free (utf);
- }
- /* Else str->str stays the same. we'll assume that it's
+ }
+ /* Else str->str stays the same. we'll assume that it's
already utf8 and glib is just being stupid. */
}
@@ -170,7 +170,7 @@ do_mode_a (EnchantDict * dict, EnchantPWL * pwl, GString * word, size_t start_po
printf ("%u ", (unsigned int)lineCount);
print_utf (word->str);
printf (" %u %u:", (unsigned int)n_suggs, (unsigned int)start_pos);
-
+
for (size_t i = 0; i < n_suggs; i++) {
putchar (' ');
print_utf (suggs[i]);
@@ -211,11 +211,11 @@ tokenize_line (EnchantDict * dict, GString * line)
while (cur_pos < line->len && *utf) {
gunichar uc;
- /* Skip non-word characters. */
+ /* Skip non-word characters. */
cur_pos = g_utf8_pointer_to_offset ((const char*)line->str, utf);
uc = g_utf8_get_char (utf);
while (cur_pos < line->len && *utf && !enchant_dict_is_word_character (dict, uc, 0)) {
- utf = g_utf8_next_char (utf);
+ utf = g_utf8_next_char (utf);
uc = g_utf8_get_char (utf);
cur_pos = g_utf8_pointer_to_offset ((const char*)line->str, utf);
}
@@ -224,13 +224,13 @@ tokenize_line (EnchantDict * dict, GString * line)
/* Skip over word characters. */
while (cur_pos < line->len && *utf && enchant_dict_is_word_character (dict, uc, 1)) {
g_string_append_unichar (word, uc);
- utf = g_utf8_next_char (utf);
+ utf = g_utf8_next_char (utf);
uc = g_utf8_get_char (utf);
cur_pos = g_utf8_pointer_to_offset ((const char*)line->str, utf);
}
- /* Skip backwards over any characters that can't appear at the end of a word. */
- for (gchar *i_utf = word->str + word->len;
+ /* Skip backwards over any characters that can't appear at the end of a word. */
+ for (gchar *i_utf = word->str + word->len;
(i_utf = g_utf8_find_prev_char (word->str, i_utf)) != NULL;
g_string_truncate (word, i_utf - word->str)) {
uc = g_utf8_get_char (i_utf);
@@ -239,8 +239,8 @@ tokenize_line (EnchantDict * dict, GString * line)
}
/* Save (word, position) tuple. */
- if (word->len) {
- tokens = g_slist_append (tokens, g_string_new_len (word->str, word->len));
+ if (word->len) {
+ tokens = g_slist_append (tokens, g_string_new_len (word->str, word->len));
tokens = g_slist_append (tokens, GINT_TO_POINTER(start_pos));
g_string_truncate (word, 0);
}
@@ -255,7 +255,7 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
{
EnchantBroker * broker;
EnchantDict * dict;
-
+
GString * str, * word = NULL;
GSList * tokens, *token_ptr;
gchar * lang;
@@ -269,13 +269,13 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
if (dictionary)
lang = strdup (dictionary);
else {
- lang = enchant_get_user_language();
+ lang = enchant_get_user_language();
if(!lang)
return 1;
- }
+ }
/* Enchant will get rid of trailing information like de_DE@euro or de_DE.ISO-8859-15 */
-
+
broker = enchant_broker_init ();
dict = enchant_broker_request_dict (broker, lang);
@@ -289,7 +289,7 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
free (lang);
str = g_string_new (NULL);
-
+
while (!was_last_line) {
gboolean mode_A_no_command = FALSE;
was_last_line = consume_line (in, str);
@@ -403,8 +403,8 @@ parse_file (FILE * in, IspellMode_t mode, gboolean countLines, gchar *dictionary
if (token_ptr)
g_slist_free (token_ptr);
}
- }
-
+ }
+
if (mode == MODE_A && corrected_something)
putchar('\n');
g_string_truncate (str, 0);
@@ -512,6 +512,6 @@ int main (int argc, char ** argv)
enchant_pwl_free (pwl);
if (file)
fclose (fp);
-
+
return rval;
}
diff --git a/src/enchant.h b/src/enchant.h
index db5ce6a..20e2d24 100644
--- a/src/enchant.h
+++ b/src/enchant.h
@@ -111,7 +111,7 @@ int enchant_broker_dict_exists (EnchantBroker * broker, const char * const tag);
* language that does not explictly declare an ordering.
*/
void enchant_broker_set_ordering (EnchantBroker * broker,
- const char * const tag,
+ const char * const tag,
const char * const ordering);
/**
* enchant_broker_get_error
@@ -136,7 +136,7 @@ typedef void (*EnchantBrokerDescribeFn) (const char * const provider_name,
const char * const provider_desc,
const char * const provider_dll_file,
void * user_data);
-
+
/**
* enchant_broker_describe
* @broker: A non-null #EnchantBroker
@@ -176,7 +176,7 @@ int enchant_dict_check (EnchantDict * dict, const char *const word, ssize_t len)
* Returns: A %null terminated list of UTF-8 encoded suggestions, or %null
*/
char **enchant_dict_suggest (EnchantDict * dict, const char *const word,
- ssize_t len, size_t * out_n_suggs);
+ ssize_t len, size_t * out_n_suggs);
/**
* enchant_dict_add
diff --git a/src/pwl.c b/src/pwl.c
index 23c812d..f6d8df5 100644
--- a/src/pwl.c
+++ b/src/pwl.c
@@ -76,7 +76,7 @@ static const gunichar BOM = 0xfeff;
/* A PWL dictionary is stored as a Trie-like data structure EnchantTrie.
* The EnchantTrie datatype is completely recursive - all child nodes
- * are simply EnchantTrie pointers. This means that all functions
+ * are simply EnchantTrie pointers. This means that all functions
* that potentially modify a trie need to return the modified trie,
* as additional memory may have been allocated.
*
@@ -203,7 +203,7 @@ EnchantPWL* enchant_pwl_init(void)
*
* Returns: a new PWL object used to store/check/suggest words
* or NULL if the file cannot be opened or created
- */
+ */
EnchantPWL* enchant_pwl_init_with_file(const char * file)
{
g_return_val_if_fail (file != NULL, NULL);
@@ -234,13 +234,13 @@ static void enchant_pwl_refresh_from_file(EnchantPWL* pwl)
pwl->words_in_trie = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
FILE *f = g_fopen(pwl->filename, "r");
- if (!f)
+ if (!f)
return;
pwl->file_changed = stats.st_mtime;
enchant_lock_file (f);
-
+
char buffer[BUFSIZ + 1];
size_t line_number = 1;
for (; NULL != (fgets (buffer, sizeof (buffer), f)); ++line_number)
@@ -249,12 +249,12 @@ static void enchant_pwl_refresh_from_file(EnchantPWL* pwl)
if(line_number == 1 && BOM == g_utf8_get_char(line))
line = g_utf8_next_char(line);
- if(line[strlen(line)-1] != '\n' && !feof(f)) /* ignore lines longer than BUFSIZ. */
+ if(line[strlen(line)-1] != '\n' && !feof(f)) /* ignore lines longer than BUFSIZ. */
{
g_warning ("Line too long (ignored) in %s at line:%zu\n", pwl->filename, line_number);
while (NULL != (fgets (buffer, sizeof (buffer), f)))
{
- if (line[strlen(buffer)-1]=='\n')
+ if (line[strlen(buffer)-1]=='\n')
break;
}
continue;
@@ -269,7 +269,7 @@ static void enchant_pwl_refresh_from_file(EnchantPWL* pwl)
g_warning ("Bad UTF-8 sequence in %s at line:%zu\n", pwl->filename, line_number);
}
}
-
+
enchant_unlock_file (f);
fclose (f);
}
@@ -290,7 +290,7 @@ static void enchant_pwl_add_to_trie(EnchantPWL *pwl,
g_free (normalized_word);
return;
}
-
+
g_hash_table_insert (pwl->words_in_trie, normalized_word, g_strndup(word,len));
pwl->trie = enchant_trie_insert(pwl->trie, normalized_word);
@@ -309,7 +309,7 @@ static void enchant_pwl_remove_from_trie(EnchantPWL *pwl,
pwl->trie = NULL; /* make trie empty if has no content */
}
}
-
+
g_free(normalized_word);
}
@@ -350,7 +350,7 @@ void enchant_pwl_add(EnchantPWL *pwl,
putc ('\n', f);
enchant_unlock_file (f);
fclose (f);
- }
+ }
}
}
@@ -400,7 +400,7 @@ void enchant_pwl_remove(EnchantPWL *pwl,
fwrite (searchstart, sizeof(char), length - (searchstart - contents), f);
break;
}
- else
+ else
{
char* foundend = needle+len;
if((needle == filestart || contents[needle-contents-1] == '\n' || contents[needle-contents-1] == '\r') &&
@@ -418,7 +418,7 @@ void enchant_pwl_remove(EnchantPWL *pwl,
}
}
g_free(key);
-
+
GStatBuf stats;
if(g_stat(pwl->filename, &stats)==0)
pwl->file_changed = stats.st_mtime;
@@ -426,7 +426,7 @@ void enchant_pwl_remove(EnchantPWL *pwl,
enchant_unlock_file (f);
fclose (f);
- }
+ }
g_free(contents);
}
}
@@ -503,7 +503,7 @@ static _GL_ATTRIBUTE_PURE int enchant_is_title_case(const char * const word, siz
if ((type != G_UNICODE_UPPERCASE_LETTER && type != G_UNICODE_TITLECASE_LETTER) ||
ch != g_unichar_totitle(ch))
return 0;
-
+
for (const char* it = g_utf8_next_char(word); it < word + len; it = g_utf8_next_char(it))
{
type = g_unichar_type(g_utf8_get_char(it));
@@ -538,7 +538,7 @@ int enchant_pwl_check(EnchantPWL *pwl, const char *const word, ssize_t len)
enchant_pwl_refresh_from_file(pwl);
int exists = enchant_pwl_contains(pwl, word, len);
-
+
if(exists)
return 0;
@@ -571,8 +571,8 @@ static void enchant_pwl_check_cb(char* match,EnchantTrieMatcher* matcher)
(*((int*)(matcher->cbdata)))++;
}
-static void enchant_pwl_case_and_denormalize_suggestions(EnchantPWL *pwl,
- const char *const word, size_t len,
+static void enchant_pwl_case_and_denormalize_suggestions(EnchantPWL *pwl,
+ const char *const word, size_t len,
EnchantSuggList* suggs_list)
{
gchar* (*utf8_case_convert_function)(const gchar*str, gssize len) = NULL;
@@ -580,7 +580,7 @@ static void enchant_pwl_case_and_denormalize_suggestions(EnchantPWL *pwl,
utf8_case_convert_function = enchant_utf8_strtitle;
else if (enchant_is_all_caps(word, len))
utf8_case_convert_function = g_utf8_strup;
-
+
for (size_t i = 0; i < suggs_list->n_suggs; ++i)
{
gchar* suggestion = g_hash_table_lookup (pwl->words_in_trie, suggs_list->suggs[i]);
@@ -591,7 +591,7 @@ static void enchant_pwl_case_and_denormalize_suggestions(EnchantPWL *pwl,
cased_suggestion = utf8_case_convert_function(suggestion, suggestion_len);
else
cased_suggestion = g_strndup(suggestion, suggestion_len);
-
+
g_free(suggs_list->suggs[i]);
suggs_list->suggs[i] = cased_suggestion;
}
@@ -614,7 +614,7 @@ static int best_distance(char** suggs, const char *const word, size_t len)
return best_dist;
}
-/* gives the best set of suggestions from pwl that are at least as good as the
+/* gives the best set of suggestions from pwl that are at least as good as the
* given suggs (if suggs == NULL just best from pwl) */
char** enchant_pwl_suggest(EnchantPWL *pwl, const char *const word,
ssize_t len, char** suggs, size_t* out_n_suggs)
@@ -644,7 +644,7 @@ char** enchant_pwl_suggest(EnchantPWL *pwl, const char *const word,
(*out_n_suggs) = sugg_list.n_suggs;
enchant_pwl_case_and_denormalize_suggestions(pwl, word, len, &sugg_list);
-
+
return sugg_list.suggs;
}
@@ -677,7 +677,7 @@ static void enchant_pwl_suggest_cb(char* match,EnchantTrieMatcher* matcher)
}
int changes = 1; /* num words added to list */
-
+
/* Remove all elements with worse score */
for(size_t i=loc; i < sugg_list->n_suggs; i++){
g_free(sugg_list->suggs[i]);
@@ -740,7 +740,7 @@ static EnchantTrie* enchant_trie_insert(EnchantTrie* trie,const char *const word
}
} else {
/* Create new hash table for subtries, and reinsert */
- trie->subtries = g_hash_table_new_full(g_str_hash,
+ trie->subtries = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, NULL);
char *tmpWord = trie->value;
trie->value = NULL;
@@ -801,7 +801,7 @@ static void enchant_trie_remove(EnchantTrie* trie,const char *const word)
}
}
-static EnchantTrie* enchant_trie_get_subtrie(EnchantTrie* trie,
+static EnchantTrie* enchant_trie_get_subtrie(EnchantTrie* trie,
EnchantTrieMatcher* matcher,
char** nxtChS)
{
@@ -850,7 +850,7 @@ static void enchant_trie_find_matches(EnchantTrie* trie,EnchantTrieMatcher *matc
value = trie->value;
if(matcher->mode == case_insensitive)
value = g_utf8_strdown(value, -1);
- matcher->num_errors = errs + edit_dist(value,
+ matcher->num_errors = errs + edit_dist(value,
&(matcher->word[matcher->word_pos]));
if(matcher->mode == case_insensitive)
g_free(value);
@@ -936,7 +936,7 @@ static void enchant_trie_find_matches_cb(void* keyV,void* subtrieV,void* matcher
}
g_free(key2);
-
+
matcher->word_pos = oldPos;
}
@@ -1013,7 +1013,7 @@ static int edit_dist(const char* utf8word1, const char* utf8word2)
gunichar * word2 = g_utf8_to_ucs4_fast(utf8word2, -1, &len2);
int * table = g_new0(int, (len1+1)*(len2+1));
-
+
/* Initialise outer rows of table */
for (glong i = 0; i < len1 + 1; i++)
table[i*(len2+1)] = i;