Kaydet (Commit) 1b122c6b authored tarafından Enrico Tröger's avatar Enrico Tröger

Fixed wrong charset detection on UTF-8 (and maybe other) systems.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@554 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst b3b50b41
......@@ -2,6 +2,10 @@
* src/filetypes.c, src/highlighting.c, tagmanager/tm_tag.c,
tagmanager/tm_workspace.c: Fixed autocompletion for filetype C++.
* src/utils.c: Removed unneeded functions:
utils_glist_strings_free() and utils_glist_from_string().
* src/encodings.c: Fixed wrong charset detection on UTF-8
(and maybe other) systems.
2006-07-13 Nick Treleaven <nick.treleaven@btinternet.com>
......
......@@ -192,33 +192,17 @@ const gchar *encodings_get_charset(const GeanyEncoding* enc)
/* Encodings */
GList *encodings_get_encodings(GList *encoding_strings)
GList *encodings_get_encodings(void)
{
GList *res = NULL;
gint i;
if (encoding_strings != NULL)
for (i = 0; i < GEANY_ENCODINGS_MAX; i++)
{
GList *tmp;
const GeanyEncoding *enc;
tmp = encoding_strings;
while (tmp)
{
const char *charset = tmp->data;
if (strcmp(charset, "current") == 0)
g_get_charset(&charset);
g_return_val_if_fail(charset != NULL, NULL);
enc = encodings_get_from_charset(charset);
if (enc != NULL)
res = g_list_append(res, (gpointer)enc);
tmp = g_list_next(tmp);
}
if (&encodings[i] != NULL)
res = g_list_append(res, (gpointer)&encodings[i]);
}
return res;
}
......
......@@ -35,9 +35,9 @@
typedef struct
{
gint idx;
gchar *charset;
gchar *name;
gint idx;
gchar *charset;
gchar *name;
} GeanyEncoding;
......@@ -48,7 +48,7 @@ const GeanyEncoding* encodings_get_from_index(gint index);
gchar* encodings_to_string(const GeanyEncoding* enc);
const gchar* encodings_get_charset(const GeanyEncoding* enc);
GList* encodings_get_encodings(GList *encoding_strings);
GList* encodings_get_encodings(void);
void encodings_init(void);
......
......@@ -863,11 +863,8 @@ gchar *utils_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_encod
GList *encodings = NULL;
GList *start;
gchar *locale_charset = NULL;
GList *encoding_strings;
encoding_strings = utils_glist_from_string("UTF-8");
encodings = encodings_get_encodings(encoding_strings);
utils_glist_strings_free(encoding_strings);
encodings = encodings_get_encodings();
if (g_get_charset((const gchar**)&locale_charset) == FALSE)
{
......@@ -1593,67 +1590,6 @@ void utils_replace_tabs(gint idx)
g_free(replacement);
}
/* GList of strings operations */
GList *utils_glist_from_string(const gchar *string)
{
gchar *str, *temp, buff[256];
GList *list;
gchar *word_start, *word_end;
gboolean the_end;
list = NULL;
the_end = FALSE;
temp = g_strdup(string);
str = temp;
if (!str)
return NULL;
while (1)
{
gint i;
gchar *ptr;
/* Remove leading spaces */
while (isspace (*str) && *str != '\0')
str++;
if (*str == '\0')
break;
/* Find start and end of word */
word_start = str;
while (!isspace (*str) && *str != '\0')
str++;
word_end = str;
/* Copy the word into the buffer */
for (ptr = word_start, i = 0; ptr < word_end; ptr++, i++)
buff[i] = *ptr;
buff[i] = '\0';
if (strlen (buff))
list = g_list_append(list, g_strdup (buff));
if (*str == '\0')
break;
}
if (temp)
g_free(temp);
return list;
}
/* Free the strings and GList */
void utils_glist_strings_free(GList *list)
{
GList *node;
node = list;
while (node)
{
if (node->data)
g_free(node->data);
node = g_list_next(node);
}
g_list_free(list);
}
gchar *utils_get_hostname(void)
{
......
......@@ -155,10 +155,6 @@ gchar utils_brace_opposite(gchar ch);
void utils_replace_tabs(gint idx);
GList *utils_glist_from_string(const gchar *string);
void utils_glist_strings_free(GList * list);
gchar *utils_get_hostname(void);
gint utils_make_settings_dir(const gchar *dir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment