mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
replace isalpha to g_ascii_isalpha
replace strlen to str_term_width1 add #include "strutil.h" if need
This commit is contained in:
parent
3b5e2c052f
commit
b0729f75fb
18
edit/edit.c
18
edit/edit.c
@ -44,7 +44,7 @@
|
|||||||
#include "../src/user.h" /* user_menu_cmd() */
|
#include "../src/user.h" /* user_menu_cmd() */
|
||||||
#include "../src/wtools.h" /* query_dialog() */
|
#include "../src/wtools.h" /* query_dialog() */
|
||||||
#include "../src/timefmt.h" /* time formatting */
|
#include "../src/timefmt.h" /* time formatting */
|
||||||
|
#include "../src/strutil.h" /* utf string functions */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
what editor are we going to emulate? one of EDIT_KEY_EMULATION_NORMAL
|
what editor are we going to emulate? one of EDIT_KEY_EMULATION_NORMAL
|
||||||
@ -195,9 +195,9 @@ static int edit_find_filter (const char *filename)
|
|||||||
size_t i, l, e;
|
size_t i, l, e;
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return -1;
|
return -1;
|
||||||
l = strlen (filename);
|
l = str_term_width1 (filename);
|
||||||
for (i = 0; i < sizeof (all_filters) / sizeof (all_filters[0]); i++) {
|
for (i = 0; i < sizeof (all_filters) / sizeof (all_filters[0]); i++) {
|
||||||
e = strlen (all_filters[i].extension);
|
e = (all_filters[i].extension);
|
||||||
if (l > e)
|
if (l > e)
|
||||||
if (!strcmp (all_filters[i].extension, filename + l - e))
|
if (!strcmp (all_filters[i].extension, filename + l - e))
|
||||||
return i;
|
return i;
|
||||||
@ -214,8 +214,8 @@ edit_get_filter (const char *filename)
|
|||||||
if (i < 0)
|
if (i < 0)
|
||||||
return 0;
|
return 0;
|
||||||
quoted_name = name_quote (filename, 0);
|
quoted_name = name_quote (filename, 0);
|
||||||
l = strlen (quoted_name);
|
l = str_term_width1 (quoted_name);
|
||||||
p = g_malloc (strlen (all_filters[i].read) + l + 2);
|
p = g_malloc (str_term_width1 (all_filters[i].read) + l + 2);
|
||||||
sprintf (p, all_filters[i].read, quoted_name);
|
sprintf (p, all_filters[i].read, quoted_name);
|
||||||
g_free (quoted_name);
|
g_free (quoted_name);
|
||||||
return p;
|
return p;
|
||||||
@ -230,8 +230,8 @@ edit_get_write_filter (const char *write_name, const char *filename)
|
|||||||
if (i < 0)
|
if (i < 0)
|
||||||
return 0;
|
return 0;
|
||||||
writename = name_quote (write_name, 0);
|
writename = name_quote (write_name, 0);
|
||||||
l = strlen (writename);
|
l = str_term_width1 (writename);
|
||||||
p = g_malloc (strlen (all_filters[i].write) + l + 2);
|
p = g_malloc (str_term_width1 (all_filters[i].write) + l + 2);
|
||||||
sprintf (p, all_filters[i].write, writename);
|
sprintf (p, all_filters[i].write, writename);
|
||||||
g_free (writename);
|
g_free (writename);
|
||||||
return p;
|
return p;
|
||||||
@ -507,7 +507,7 @@ edit_init (WEdit *edit, int lines, int columns, const char *filename,
|
|||||||
|
|
||||||
if (option_whole_chars_search_buf != option_whole_chars_search) {
|
if (option_whole_chars_search_buf != option_whole_chars_search) {
|
||||||
size_t i;
|
size_t i;
|
||||||
size_t len = strlen (option_whole_chars_search);
|
size_t len = str_term_width1 (option_whole_chars_search);
|
||||||
|
|
||||||
strcpy (option_whole_chars_search_buf,
|
strcpy (option_whole_chars_search_buf,
|
||||||
option_whole_chars_search);
|
option_whole_chars_search);
|
||||||
@ -1689,7 +1689,7 @@ my_type_of (int c)
|
|||||||
c = 'A';
|
c = 'A';
|
||||||
else if (islower (c))
|
else if (islower (c))
|
||||||
c = 'a';
|
c = 'a';
|
||||||
else if (isalpha (c))
|
else if (g_ascii_isalpha (c))
|
||||||
c = 'a';
|
c = 'a';
|
||||||
else if (isdigit (c))
|
else if (isdigit (c))
|
||||||
c = '0';
|
c = '0';
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
#include "../src/wtools.h" /* message() */
|
#include "../src/wtools.h" /* message() */
|
||||||
#include "../src/charsets.h"
|
#include "../src/charsets.h"
|
||||||
#include "../src/selcodepage.h"
|
#include "../src/selcodepage.h"
|
||||||
|
#include "../src/strutil.h" /* utf string functions */
|
||||||
|
|
||||||
struct selection {
|
struct selection {
|
||||||
unsigned char * text;
|
unsigned char * text;
|
||||||
@ -136,11 +137,11 @@ catstrs (const char *first,...)
|
|||||||
if (!first)
|
if (!first)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
len = strlen (first);
|
len = str_term_width1 (first);
|
||||||
va_start (ap, first);
|
va_start (ap, first);
|
||||||
|
|
||||||
while ((data = va_arg (ap, char *)) != 0)
|
while ((data = va_arg (ap, char *)) != 0)
|
||||||
len += strlen (data);
|
len += str_term_width1 (data);
|
||||||
|
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
@ -440,23 +441,23 @@ void menu_save_mode_cmd (void)
|
|||||||
size_t l1;
|
size_t l1;
|
||||||
|
|
||||||
/* OK/Cancel buttons */
|
/* OK/Cancel buttons */
|
||||||
l1 = strlen (_(widgets[0].text)) + strlen (_(widgets[1].text)) + 5;
|
l1 = str_term_width1 (_(widgets[0].text)) + str_term_width1 (_(widgets[1].text)) + 5;
|
||||||
maxlen = max (maxlen, l1);
|
maxlen = max (maxlen, l1);
|
||||||
|
|
||||||
for (i = 0; i < 3; i++ ) {
|
for (i = 0; i < 3; i++ ) {
|
||||||
str[i] = _(str[i]);
|
str[i] = _(str[i]);
|
||||||
maxlen = max (maxlen, strlen (str[i]) + 7);
|
maxlen = max (maxlen, str_term_width1 (str[i]) + 7);
|
||||||
}
|
}
|
||||||
i18n_flag = 1;
|
i18n_flag = 1;
|
||||||
|
|
||||||
dlg_x = maxlen + strlen (_(widgets[3].text)) + 5 + 1;
|
dlg_x = maxlen + str_term_width1 (_(widgets[3].text)) + 5 + 1;
|
||||||
widgets[2].hotkey_pos = strlen (_(widgets[3].text)); /* input field length */
|
widgets[2].hotkey_pos = str_term_width1 (_(widgets[3].text)); /* input field length */
|
||||||
dlg_x = min (COLS, dlg_x);
|
dlg_x = min (COLS, dlg_x);
|
||||||
dialog.xlen = dlg_x;
|
dialog.xlen = dlg_x;
|
||||||
|
|
||||||
i = (dlg_x - l1)/3;
|
i = (dlg_x - l1)/3;
|
||||||
widgets[1].relative_x = i;
|
widgets[1].relative_x = i;
|
||||||
widgets[0].relative_x = i + strlen (_(widgets[1].text)) + i + 4;
|
widgets[0].relative_x = i + str_term_width1 (_(widgets[1].text)) + i + 4;
|
||||||
|
|
||||||
widgets[2].relative_x = widgets[3].relative_x = maxlen + 2;
|
widgets[2].relative_x = widgets[3].relative_x = maxlen + 2;
|
||||||
|
|
||||||
@ -599,7 +600,7 @@ raw_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
|||||||
int
|
int
|
||||||
edit_raw_key_query (const char *heading, const char *query, int cancel)
|
edit_raw_key_query (const char *heading, const char *query, int cancel)
|
||||||
{
|
{
|
||||||
int w = strlen (query) + 7;
|
int w = str_term_width1 (query) + 7;
|
||||||
struct Dlg_head *raw_dlg =
|
struct Dlg_head *raw_dlg =
|
||||||
create_dlg (0, 0, 7, w, dialog_colors, raw_callback,
|
create_dlg (0, 0, 7, w, dialog_colors, raw_callback,
|
||||||
NULL, heading,
|
NULL, heading,
|
||||||
@ -1461,7 +1462,7 @@ static long
|
|||||||
edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit_getbyte_fn get_byte, void *data, int once_only, void *d)
|
edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit_getbyte_fn get_byte, void *data, int once_only, void *d)
|
||||||
{
|
{
|
||||||
long p, q = 0;
|
long p, q = 0;
|
||||||
long l = strlen ((char *) exp), f = 0;
|
long l = str_term_width1 ((char *) exp), f = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
for (p = 0; p < l; p++) /* count conversions... */
|
for (p = 0; p < l; p++) /* count conversions... */
|
||||||
@ -1523,7 +1524,7 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit
|
|||||||
start++;
|
start++;
|
||||||
buf++; /* move the window along */
|
buf++; /* move the window along */
|
||||||
if (buf == mbuf + MAX_REPL_LEN) { /* the window is about to go past the end of array, so... */
|
if (buf == mbuf + MAX_REPL_LEN) { /* the window is about to go past the end of array, so... */
|
||||||
memmove (mbuf, buf, strlen ((char *) buf) + 1); /* reset it */
|
memmove (mbuf, buf, str_term_width1 ((char *) buf) + 1); /* reset it */
|
||||||
buf = mbuf;
|
buf = mbuf;
|
||||||
}
|
}
|
||||||
q--;
|
q--;
|
||||||
@ -1572,7 +1573,7 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit
|
|||||||
|
|
||||||
if (buf[q - 1] != '\n') { /* incomplete line: try to recover */
|
if (buf[q - 1] != '\n') { /* incomplete line: try to recover */
|
||||||
buf = mbuf + MAX_REPL_LEN / 2;
|
buf = mbuf + MAX_REPL_LEN / 2;
|
||||||
q = strlen ((const char *) buf);
|
q = str_term_width1 ((const char *) buf);
|
||||||
memmove (mbuf, buf, q);
|
memmove (mbuf, buf, q);
|
||||||
p = start + q;
|
p = start + q;
|
||||||
move_win = 1;
|
move_win = 1;
|
||||||
@ -1582,7 +1583,7 @@ edit_find_string (long start, unsigned char *exp, int *len, long last_byte, edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*len = strlen ((const char *) exp);
|
*len = str_term_width1 ((const char *) exp);
|
||||||
if (replace_case) {
|
if (replace_case) {
|
||||||
for (p = start; p <= last_byte - l; p++) {
|
for (p = start; p <= last_byte - l; p++) {
|
||||||
if ((*get_byte) (data, p) == (unsigned char)exp[0]) { /* check if first char matches */
|
if ((*get_byte) (data, p) == (unsigned char)exp[0]) { /* check if first char matches */
|
||||||
@ -1721,7 +1722,7 @@ static int snprintf_p (char *str, size_t size, const char *fmt,...)
|
|||||||
if (*p == '*') {
|
if (*p == '*') {
|
||||||
p++;
|
p++;
|
||||||
strcpy (p1, MY_itoa (*va_arg (ap, int *))); /* replace field width with a number */
|
strcpy (p1, MY_itoa (*va_arg (ap, int *))); /* replace field width with a number */
|
||||||
p1 += strlen (p1);
|
p1 += str_term_width1 (p1);
|
||||||
} else {
|
} else {
|
||||||
while (is_digit (*p) && p1 < q1 + 20)
|
while (is_digit (*p) && p1 < q1 + 20)
|
||||||
*p1++ = *p++;
|
*p1++ = *p++;
|
||||||
@ -1733,7 +1734,7 @@ static int snprintf_p (char *str, size_t size, const char *fmt,...)
|
|||||||
if (*p == '*') {
|
if (*p == '*') {
|
||||||
p++;
|
p++;
|
||||||
strcpy (p1, MY_itoa (*va_arg (ap, int *))); /* replace precision with a number */
|
strcpy (p1, MY_itoa (*va_arg (ap, int *))); /* replace precision with a number */
|
||||||
p1 += strlen (p1);
|
p1 += str_term_width1 (p1);
|
||||||
} else {
|
} else {
|
||||||
while (is_digit (*p) && p1 < q1 + 32)
|
while (is_digit (*p) && p1 < q1 + 32)
|
||||||
*p1++ = *p++;
|
*p1++ = *p++;
|
||||||
@ -1767,7 +1768,7 @@ static int snprintf_p (char *str, size_t size, const char *fmt,...)
|
|||||||
q = p;
|
q = p;
|
||||||
}
|
}
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
n = strlen (q);
|
n = str_term_width1 (q);
|
||||||
if (n >= (size_t) (e - s))
|
if (n >= (size_t) (e - s))
|
||||||
return -1;
|
return -1;
|
||||||
memcpy (s, q, n + 1);
|
memcpy (s, q, n + 1);
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "../src/widget.h" /* buttonbar_redraw() */
|
#include "../src/widget.h" /* buttonbar_redraw() */
|
||||||
#include "../src/key.h" /* is_idle() */
|
#include "../src/key.h" /* is_idle() */
|
||||||
#include "../src/charsets.h"
|
#include "../src/charsets.h"
|
||||||
|
#include "../src/strutil.h" /* utf string functions */
|
||||||
|
|
||||||
/* Text styles */
|
/* Text styles */
|
||||||
#define MOD_ABNORMAL (1 << 8)
|
#define MOD_ABNORMAL (1 << 8)
|
||||||
@ -123,11 +124,11 @@ edit_status (WEdit *edit)
|
|||||||
const int preferred_fname_len = 16;
|
const int preferred_fname_len = 16;
|
||||||
|
|
||||||
status_string (edit, status, status_size);
|
status_string (edit, status, status_size);
|
||||||
status_len = (int) strlen (status);
|
status_len = (int) str_term_width1 (status);
|
||||||
|
|
||||||
if (edit->filename)
|
if (edit->filename)
|
||||||
fname = edit->filename;
|
fname = edit->filename;
|
||||||
fname_len = strlen(fname);
|
fname_len = str_term_width1 (fname);
|
||||||
if (fname_len < preferred_fname_len)
|
if (fname_len < preferred_fname_len)
|
||||||
fname_len = preferred_fname_len;
|
fname_len = preferred_fname_len;
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "editlock.h"
|
#include "editlock.h"
|
||||||
|
|
||||||
#include "../src/wtools.h" /* edit_query_dialog () */
|
#include "../src/wtools.h" /* edit_query_dialog () */
|
||||||
|
#include "../src/strutil.h" /* utf string functions */
|
||||||
|
|
||||||
#define BUF_SIZE 255
|
#define BUF_SIZE 255
|
||||||
#define PID_BUF_SIZE 10
|
#define PID_BUF_SIZE 10
|
||||||
@ -112,7 +113,7 @@ lock_extract_info (const char *str)
|
|||||||
static char pid[PID_BUF_SIZE], who[BUF_SIZE];
|
static char pid[PID_BUF_SIZE], who[BUF_SIZE];
|
||||||
static struct lock_s lock;
|
static struct lock_s lock;
|
||||||
|
|
||||||
for (p = str + strlen (str) - 1; p >= str; p--)
|
for (p = str + str_term_width1 (str) - 1; p >= str; p--)
|
||||||
if (*p == '.')
|
if (*p == '.')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ lock_extract_info (const char *str)
|
|||||||
/* Treat text between '.' and ':' or '\0' as pid */
|
/* Treat text between '.' and ':' or '\0' as pid */
|
||||||
i = 0;
|
i = 0;
|
||||||
for (p = p + 1;
|
for (p = p + 1;
|
||||||
p < str + strlen (str) && *p != ':' && i < PID_BUF_SIZE; p++)
|
p < str + str_term_width1 (str) && *p != ':' && i < PID_BUF_SIZE; p++)
|
||||||
pid[i++] = *p;
|
pid[i++] = *p;
|
||||||
pid[i] = '\0';
|
pid[i] = '\0';
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "../src/color.h" /* use_colors */
|
#include "../src/color.h" /* use_colors */
|
||||||
#include "../src/main.h" /* mc_home */
|
#include "../src/main.h" /* mc_home */
|
||||||
#include "../src/wtools.h" /* message() */
|
#include "../src/wtools.h" /* message() */
|
||||||
|
#include "../src/strutil.h" /* utf string functions */
|
||||||
|
|
||||||
/* bytes */
|
/* bytes */
|
||||||
#define SYNTAX_MARKER_DENSITY 512
|
#define SYNTAX_MARKER_DENSITY 512
|
||||||
@ -178,7 +179,7 @@ compare_word_to_right (WEdit *edit, long i, const char *text,
|
|||||||
if (strchr (whole_left, c))
|
if (strchr (whole_left, c))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (p = (unsigned char *) text, q = p + strlen ((char *) p); p < q; p++, i++) {
|
for (p = (unsigned char *) text, q = p + str_term_width1 ((char *) p); p < q; p++, i++) {
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case SYNTAX_TOKEN_STAR:
|
case SYNTAX_TOKEN_STAR:
|
||||||
if (++p > q)
|
if (++p > q)
|
||||||
|
Loading…
Reference in New Issue
Block a user