Project builds with option --disable-charsets

This commit is contained in:
Slava Zanko 2009-05-07 12:20:34 +03:00
parent d0c20d7844
commit 09bc5434f6
6 changed files with 82 additions and 20 deletions

View File

@ -1146,6 +1146,7 @@ editcmd_find (WEdit *edit, gsize *len)
static char *
edit_replace_cmd__conv_to_display(char *str)
{
#ifdef HAVE_CHARSET
GString *tmp;
tmp = str_convert_to_display (str);
@ -1155,11 +1156,15 @@ edit_replace_cmd__conv_to_display(char *str)
}
g_string_free (tmp, FALSE);
return str;
#else
return g_strdup(str);
#endif
}
static char *
edit_replace_cmd__conv_to_input(char *str)
{
#ifdef HAVE_CHARSET
GString *tmp;
tmp = str_convert_to_input (str);
@ -1169,6 +1174,9 @@ edit_replace_cmd__conv_to_input(char *str)
}
g_string_free (tmp, FALSE);
return str;
#else
return g_strdup(str);
#endif
}
/* call with edit = 0 before shutdown to close memory leaks */
void

View File

@ -459,7 +459,7 @@ confirm_box (void)
}
}
#define DISPY 11
#define DISPY 12
#define DISPX 46
@ -469,16 +469,16 @@ static int new_mode;
static int new_meta;
static const char *display_bits_str [] =
{ N_("Full 8 bits output"), N_("ISO 8859-1"), N_("7 bits") };
{ N_("UTF-8 output"), N_("Full 8 bits output"), N_("ISO 8859-1"), N_("7 bits") };
static QuickWidget display_widgets [] = {
{ quick_button, 4, 6, 4, DISPY, N_("&Cancel"),
{ quick_button, DISPX/2+7, DISPX, 7, DISPY, N_("&Cancel"),
0, B_CANCEL, 0, 0, NULL , NULL, NULL},
{ quick_button, 4, 6, 3, DISPY, N_("&OK"),
{ quick_button, DISPX/2+7, DISPX, 8, DISPY, N_("&OK"),
0, B_ENTER, 0, 0, NULL , NULL, NULL},
{ quick_checkbox, 4, DISPX, 7, DISPY, N_("F&ull 8 bits input"),
{ quick_checkbox, 4, DISPX, 8, DISPY, N_("F&ull 8 bits input"),
0, 0, &new_meta, 0, NULL , NULL, NULL},
{ quick_radio, 4, DISPX, 3, DISPY, "", 3, 0,
{ quick_radio, 4, DISPX, 3, DISPY, "", 4, 0,
&new_mode, const_cast(char **, display_bits_str), NULL , NULL, NULL},
NULL_QuickWidget
};
@ -541,8 +541,8 @@ display_bits_box (void)
if (quick_dialog (&display_bits) != B_ENTER)
return;
eight_bit_clean = new_mode < 2;
full_eight_bits = new_mode == 0;
eight_bit_clean = new_mode < 3;
full_eight_bits = new_mode < 2;
#ifndef HAVE_SLANG
meta (stdscr, eight_bit_clean);
#else

View File

@ -81,13 +81,17 @@ mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
gboolean * just_letters)
{
gchar *converted_str, *next_char, *converted_str2;
gchar *converted_str, *next_char;
gsize converted_str_len;
gsize tmp_len;
#ifdef HAVE_CHARSET
gsize converted_str_len;
gchar *converted_str2;
converted_str = mc_search__recode_str (str, str_len, charset, cp_display, &converted_str_len);
#else
converted_str = g_strndup(str, str_len);
#endif
next_char = (char *) str_cget_next_char (converted_str);
@ -95,8 +99,10 @@ mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
converted_str[tmp_len] = '\0';
#ifdef HAVE_CHARSET
converted_str2 =
mc_search__recode_str (converted_str, tmp_len, cp_display, charset, &converted_str_len);
#endif
if (str_isalnum (converted_str) && !str_isdigit (converted_str))
*just_letters = TRUE;
@ -104,8 +110,12 @@ mc_search__get_one_symbol (const char *charset, const char *str, gsize str_len,
*just_letters = FALSE;
#ifdef HAVE_CHARSET
g_free (converted_str);
return converted_str2;
#else
return converted_str;
#endif
}
/* --------------------------------------------------------------------------------------------- */
@ -126,6 +136,8 @@ mc_search__get_char (mc_search_t * mc_search, const void *user_data, gsize curre
GString *
mc_search__tolower_case_str (const char *charset, const char *str, gsize str_len)
{
GString *ret;
#ifdef HAVE_CHARSET
gchar *converted_str, *tmp_str1, *tmp_str2, *tmp_str3;
gsize converted_str_len;
gsize tmp_len;
@ -149,7 +161,23 @@ mc_search__tolower_case_str (const char *charset, const char *str, gsize str_len
if (tmp_str2 == NULL)
return NULL;
return g_string_new_len (tmp_str2, tmp_len);
ret = g_string_new_len (tmp_str2, tmp_len);
g_free(tmp_str2);
return ret;
#else
const gchar *tmp_str1 = str;
gchar *converted_str, *tmp_str2;
gsize converted_str_len = str_len;
tmp_str2 = converted_str = g_strndup(str, str_len);
while (str_tolower (tmp_str1, &tmp_str2, &converted_str_len))
tmp_str1 += str_length_char (tmp_str1);
ret = g_string_new_len (converted_str, str_len);
g_free(converted_str);
return ret;
#endif
}
/* --------------------------------------------------------------------------------------------- */
@ -157,6 +185,8 @@ mc_search__tolower_case_str (const char *charset, const char *str, gsize str_len
GString *
mc_search__toupper_case_str (const char *charset, const char *str, gsize str_len)
{
GString *ret;
#ifdef HAVE_CHARSET
gchar *converted_str, *tmp_str1, *tmp_str2, *tmp_str3;
gsize converted_str_len;
gsize tmp_len;
@ -181,7 +211,23 @@ mc_search__toupper_case_str (const char *charset, const char *str, gsize str_len
if (tmp_str2 == NULL)
return NULL;
return g_string_new_len (tmp_str2, tmp_len);
ret = g_string_new_len (tmp_str2, tmp_len);
g_free(tmp_str2);
return ret;
#else
const gchar *tmp_str1 = str;
gchar *converted_str, *tmp_str2;
gsize converted_str_len = str_len;
tmp_str2 = converted_str = g_strndup(str, str_len);
while (str_toupper (tmp_str1, &tmp_str2, &converted_str_len))
tmp_str1 += str_length_char (tmp_str1);
ret = g_string_new_len (converted_str, str_len);
g_free(converted_str);
return ret;
#endif
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -89,7 +89,7 @@ mc_search__conditions_new (mc_search_t * mc_search)
{
GPtrArray *ret;
ret = g_ptr_array_new ();
#ifdef HAVE_CHARSET
if (mc_search->is_all_charsets) {
gsize loop1, recoded_str_len;
gchar *buffer;
@ -118,6 +118,12 @@ mc_search__conditions_new (mc_search_t * mc_search)
mc_search->original_len,
cp_source));
}
#else
g_ptr_array_add (ret,
(gpointer) mc_search__cond_struct_new (mc_search, mc_search->original,
mc_search->original_len,
str_detect_termencoding()));
#endif
return ret;
}
@ -374,8 +380,8 @@ mc_search_getstart_rezult_by_num(mc_search_t *mc_search, int index)
if (mc_search->search_type == MC_SEARCH_T_NORMAL)
return 0;
#if GLIB_CHECK_VERSION (2, 14, 0)
guint start_pos;
guint end_pos;
gint start_pos;
gint end_pos;
g_match_info_fetch_pos (mc_search->regex_match_info, index, &start_pos, &end_pos);
return (int) start_pos;
#else /* GLIB_CHECK_VERSION (2, 14, 0) */
@ -398,8 +404,8 @@ mc_search_getend_rezult_by_num(mc_search_t *mc_search, int index)
if (mc_search->search_type == MC_SEARCH_T_NORMAL)
return 0;
#if GLIB_CHECK_VERSION (2, 14, 0)
guint start_pos;
guint end_pos;
gint start_pos;
gint end_pos;
g_match_info_fetch_pos (mc_search->regex_match_info, index, &start_pos, &end_pos);
return (int) end_pos;
#else /* GLIB_CHECK_VERSION (2, 14, 0) */

View File

@ -318,8 +318,8 @@ str_translate_char (GIConv conv, const char *keys, size_t ch_size,
}
static const char *
str_detect_termencoding ()
const char *
str_detect_termencoding (void)
{
return (nl_langinfo (CODESET));
}

View File

@ -506,4 +506,6 @@ void str_release_key (char *key, int case_sen);
*/
int str_isutf8 (const char *codeset_name);
const char *str_detect_termencoding (void);
#endif /* MC_STRUTIL_H*/