mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Fix conflicts after rebasing
This commit is contained in:
commit
ac8ae55181
@ -214,14 +214,15 @@ int edit_get_prev_utf (WEdit * edit, long byte_index, int *char_width)
|
||||
}
|
||||
|
||||
if ( byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0 ) {
|
||||
*char_width = 1;
|
||||
*char_width = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
str = edit_get_byte_ptr (edit, byte_index);
|
||||
buf = edit_get_buf_ptr (edit, byte_index);
|
||||
/* get prev utf8 char */
|
||||
str = g_utf8_find_prev_char (buf, str);
|
||||
if ( str != buf )
|
||||
str = g_utf8_find_prev_char (buf, str);
|
||||
|
||||
res = g_utf8_get_char_validated (str, -1);
|
||||
if ( res < 0 ) {
|
||||
|
@ -66,6 +66,9 @@
|
||||
static void status_string (WEdit * edit, char *s, int w)
|
||||
{
|
||||
char byte_str[16];
|
||||
unsigned char cur_byte = 0;
|
||||
unsigned int cur_utf = 0;
|
||||
int cw = 1;
|
||||
|
||||
/*
|
||||
* If we are at the end of file, print <EOF>,
|
||||
@ -74,28 +77,32 @@ static void status_string (WEdit * edit, char *s, int w)
|
||||
*/
|
||||
if (edit->curs1 < edit->last_byte) {
|
||||
if ( !edit->utf8 ) {
|
||||
unsigned char cur_byte = edit_get_byte (edit, edit->curs1);
|
||||
g_snprintf (byte_str, sizeof (byte_str), "%c %3d 0x%02X",
|
||||
is_printable (cur_byte) ? cur_byte : '.',
|
||||
cur_byte = edit_get_byte (edit, edit->curs1);
|
||||
|
||||
g_snprintf (byte_str, sizeof (byte_str), "%4d 0x%03X",
|
||||
(int) cur_byte,
|
||||
(unsigned) cur_byte);
|
||||
} else {
|
||||
int cw = 1;
|
||||
unsigned int cur_utf = edit_get_utf (edit, edit->curs1, &cw);
|
||||
cur_utf = edit_get_utf (edit, edit->curs1, &cw);
|
||||
if ( cw > 0 ) {
|
||||
g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
|
||||
(unsigned) cur_utf,
|
||||
(unsigned) cur_utf);
|
||||
} else {
|
||||
cur_utf = edit_get_byte (edit, edit->curs1);
|
||||
g_snprintf (byte_str, sizeof (byte_str), "%04d 0x%03X",
|
||||
(int) cur_utf,
|
||||
(unsigned) cur_utf);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
strcpy (byte_str, "<EOF>");
|
||||
strcpy (byte_str, "<EOF> ");
|
||||
}
|
||||
|
||||
/* The field lengths just prevent the status line from shortening too much */
|
||||
g_snprintf (s, w,
|
||||
"[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb)= %s C:%s",
|
||||
"[%c%c%c%c] %2ld L:[%3ld+%2ld %3ld/%3ld] *(%-4ld/%4ldb)= %s cp:%s",
|
||||
edit->mark1 != edit->mark2 ? ( column_highlighting ? 'C' : 'B') : '-',
|
||||
edit->modified ? 'M' : '-',
|
||||
edit->macro_i < 0 ? '-' : 'R',
|
||||
@ -110,7 +117,9 @@ static void status_string (WEdit * edit, char *s, int w)
|
||||
edit->curs1,
|
||||
edit->last_byte,
|
||||
byte_str,
|
||||
get_codepage_id( source_codepage ));
|
||||
get_codepage_id ( source_codepage )
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -37,9 +37,9 @@
|
||||
|
||||
//names, that are used for utf-8
|
||||
static const char *str_utf8_encodings[] = {
|
||||
"utf-8",
|
||||
"utf8",
|
||||
NULL
|
||||
"utf-8",
|
||||
"utf8",
|
||||
NULL
|
||||
};
|
||||
|
||||
// standard 8bit encodings, no wide or multibytes characters
|
||||
@ -284,17 +284,11 @@ str_translate_char (GIConv conv, char *keys, size_t ch_size,
|
||||
left = (ch_size == (size_t) (-1)) ? strlen (keys) : ch_size;
|
||||
|
||||
cnv = g_iconv (conv, &keys, &left, &output, &out_size);
|
||||
if (cnv == (size_t) (-1))
|
||||
{
|
||||
if (errno == EINVAL)
|
||||
return ESTR_PROBLEM;
|
||||
else
|
||||
return ESTR_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
output[0] = '\0';
|
||||
return 0;
|
||||
if (cnv == (size_t)(-1)) {
|
||||
if (errno == EINVAL) return ESTR_PROBLEM; else return ESTR_FAILURE;
|
||||
} else {
|
||||
output[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,7 +310,6 @@ str_test_encoding_class (const char *encoding, const char **table)
|
||||
result += (g_ascii_strncasecmp (encoding, table[t],
|
||||
strlen (table[t])) == 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -352,7 +345,8 @@ void
|
||||
str_init_strings (const char *termenc)
|
||||
{
|
||||
codeset = g_strdup ((termenc != NULL)
|
||||
? termenc : str_detect_termencoding ());
|
||||
? termenc
|
||||
: str_detect_termencoding ());
|
||||
|
||||
str_cnv_not_convert = g_iconv_open (codeset, codeset);
|
||||
if (str_cnv_not_convert == INVALID_CONV)
|
||||
@ -425,7 +419,7 @@ str_get_next_char (char *text)
|
||||
const char *
|
||||
str_cget_next_char (const char *text)
|
||||
{
|
||||
used_class.cnext_char (&text);
|
||||
used_class.cnext_char(&text);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ str_8bit_offset_to_pos (const char *text, size_t length)
|
||||
static int
|
||||
str_8bit_column_to_pos (const char *text, size_t pos)
|
||||
{
|
||||
return (int) pos;
|
||||
return (int)pos;
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -512,7 +512,7 @@ str_ascii_offset_to_pos (const char *text, size_t length)
|
||||
static int
|
||||
str_ascii_column_to_pos (const char *text, size_t pos)
|
||||
{
|
||||
return (int) pos;
|
||||
return (int)pos;
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -342,7 +342,6 @@ str_utf8_vfs_convert_to (GIConv coder, const char *string,
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
// result = _str_utf8_vfs_convert_to (coder, string, size, buffer);
|
||||
result = str_nconvert (coder, (char *) string, size, buffer);
|
||||
|
||||
return result;
|
||||
@ -387,43 +386,30 @@ str_utf8_make_make_term_form (const char *text, size_t length)
|
||||
}
|
||||
}
|
||||
|
||||
while (length != 0 && text[0] != '\0')
|
||||
{
|
||||
uni = g_utf8_get_char_validated (text, -1);
|
||||
if ((uni != (gunichar) (-1)) && (uni != (gunichar) (-2)))
|
||||
{
|
||||
if (g_unichar_isprint (uni))
|
||||
{
|
||||
left = g_unichar_to_utf8 (uni, actual);
|
||||
actual += left;
|
||||
if (!str_unichar_iscombiningmark (uni))
|
||||
{
|
||||
result.width++;
|
||||
if (g_unichar_iswide (uni))
|
||||
result.width++;
|
||||
}
|
||||
else
|
||||
result.compose = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
actual[0] = '.';
|
||||
actual++;
|
||||
result.width++;
|
||||
}
|
||||
text = g_utf8_next_char (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
text++;
|
||||
//actual[0] = '?';
|
||||
memcpy (actual, replch, strlen (replch));
|
||||
actual += strlen (replch);
|
||||
result.width++;
|
||||
}
|
||||
if (length != (size_t) (-1))
|
||||
length--;
|
||||
}
|
||||
while (length != 0 && text[0] != '\0') {
|
||||
uni = g_utf8_get_char_validated (text, -1);
|
||||
if ((uni != (gunichar)(-1)) && (uni != (gunichar)(-2))) {
|
||||
if (g_unichar_isprint(uni)) {
|
||||
left = g_unichar_to_utf8 (uni, actual);
|
||||
actual+= left;
|
||||
if (!str_unichar_iscombiningmark (uni)) {
|
||||
result.width++;
|
||||
if (g_unichar_iswide(uni)) result.width++;
|
||||
} else result.compose = 1;
|
||||
} else {
|
||||
actual[0] = '.';
|
||||
actual++;
|
||||
result.width++;
|
||||
}
|
||||
text = g_utf8_next_char (text);
|
||||
} else {
|
||||
text++;
|
||||
//actual[0] = '?';
|
||||
memcpy (actual, replch, strlen (replch));
|
||||
actual+= strlen (replch);
|
||||
result.width++;
|
||||
}
|
||||
if (length != (size_t) (-1)) length--; }
|
||||
actual[0] = '\0';
|
||||
|
||||
return &result;
|
||||
@ -1219,50 +1205,47 @@ str_utf8_create_key_gen (const char *text, int case_sen,
|
||||
{
|
||||
char *result;
|
||||
|
||||
if (case_sen)
|
||||
{
|
||||
result = str_utf8_normalize (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *start, *end;
|
||||
char *fold, *key;
|
||||
GString *fixed = g_string_new ("");
|
||||
if (case_sen) {
|
||||
result = str_utf8_normalize (text);
|
||||
} else {
|
||||
const char *start, *end;
|
||||
char *fold, *key;
|
||||
GString *fixed = g_string_new ("");
|
||||
|
||||
start = text;
|
||||
while (!g_utf8_validate (start, -1, &end) && start[0] != '\0')
|
||||
{
|
||||
if (start != end)
|
||||
{
|
||||
fold = g_utf8_casefold (start, end - start);
|
||||
key = keygen (fold, -1);
|
||||
g_string_append (fixed, key);
|
||||
g_free (key);
|
||||
g_free (fold);
|
||||
}
|
||||
g_string_append_c (fixed, end[0]);
|
||||
start = end + 1;
|
||||
}
|
||||
start = text;
|
||||
while (!g_utf8_validate (start, -1, &end) && start[0] != '\0')
|
||||
{
|
||||
if (start != end)
|
||||
{
|
||||
fold = g_utf8_casefold (start, end - start);
|
||||
key = keygen (fold, -1);
|
||||
g_string_append (fixed, key);
|
||||
g_free (key);
|
||||
g_free (fold);
|
||||
}
|
||||
g_string_append_c (fixed, end[0]);
|
||||
start = end + 1;
|
||||
}
|
||||
|
||||
if (start == text)
|
||||
{
|
||||
fold = g_utf8_casefold (text, -1);
|
||||
result = keygen (fold, -1);
|
||||
g_free (fold);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (start[0] != '\0' && start != end)
|
||||
{
|
||||
fold = g_utf8_casefold (start, end - start);
|
||||
key = keygen (fold, -1);
|
||||
g_string_append (fixed, key);
|
||||
g_free (key);
|
||||
g_free (fold);
|
||||
}
|
||||
result = g_strdup (fixed->str);
|
||||
}
|
||||
g_string_free (fixed, TRUE);
|
||||
if (start == text)
|
||||
{
|
||||
fold = g_utf8_casefold (text, -1);
|
||||
result = keygen (fold, -1);
|
||||
g_free (fold);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (start[0] != '\0' && start != end)
|
||||
{
|
||||
fold = g_utf8_casefold (start, end - start);
|
||||
key = keygen (fold, -1);
|
||||
g_string_append (fixed, key);
|
||||
g_free (key);
|
||||
g_free (fold);
|
||||
}
|
||||
result = g_strdup (fixed->str);
|
||||
}
|
||||
g_string_free (fixed, TRUE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
42
src/view.c
42
src/view.c
@ -2457,24 +2457,24 @@ view_display_text (WView * view)
|
||||
} else {
|
||||
addch ('.');
|
||||
}
|
||||
} else {
|
||||
GString *comb = g_string_new ("");
|
||||
if (str_isprint (info.cact)) {
|
||||
g_string_append(comb,info.cact);
|
||||
} else {
|
||||
g_string_append(comb,".");
|
||||
}
|
||||
while (str_iscombiningmark (info.cnxt)) {
|
||||
view_read_continue (view, &info);
|
||||
g_string_append(comb,info.cact);
|
||||
}
|
||||
addstr (str_term_form (comb->str));
|
||||
g_string_free (comb, TRUE);
|
||||
}
|
||||
} else {
|
||||
GString *comb = g_string_new ("");
|
||||
if (str_isprint (info.cact)) {
|
||||
g_string_append(comb,info.cact);
|
||||
} else {
|
||||
g_string_append(comb,".");
|
||||
}
|
||||
while (str_iscombiningmark (info.cnxt)) {
|
||||
view_read_continue (view, &info);
|
||||
g_string_append(comb,info.cact);
|
||||
}
|
||||
addstr (str_term_form (comb->str));
|
||||
g_string_free (comb, TRUE);
|
||||
}
|
||||
} else {
|
||||
while (str_iscombiningmark (info.cnxt)) {
|
||||
view_read_continue (view, &info);
|
||||
}
|
||||
while (str_iscombiningmark (info.cnxt)) {
|
||||
view_read_continue (view, &info);
|
||||
}
|
||||
}
|
||||
col+= w;
|
||||
|
||||
@ -2780,7 +2780,6 @@ view_get_line_at (WView *view, offset_type from, GString * buffer,
|
||||
continue;
|
||||
|
||||
if (view_read_test_nroff_back (view, &info)) {
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
g_string_truncate (buffer, buffer->len-1);
|
||||
continue;
|
||||
}
|
||||
@ -3653,12 +3652,13 @@ static void view_cmk_moveto_bottom (void *w, int n) {
|
||||
static void
|
||||
view_select_encoding (WView *view)
|
||||
{
|
||||
char *enc;
|
||||
char *enc = NULL;
|
||||
GIConv conv;
|
||||
struct cache_line *line;
|
||||
|
||||
enc = input_dialog ("Encoding", "Paste encoding", NULL, "");
|
||||
do_select_codepage ();
|
||||
|
||||
enc = g_strdup( get_codepage_id ( source_codepage ) );
|
||||
if (enc != NULL) {
|
||||
conv = str_crt_conv_from (enc);
|
||||
if (conv != (iconv_t)(-1)) {
|
||||
@ -3668,7 +3668,9 @@ view_select_encoding (WView *view)
|
||||
line = view_offset_to_line (view, view->dpy_start);
|
||||
view_set_first_showed (view, line);
|
||||
}
|
||||
g_free(enc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user