1
1

patches by Rostislav Beneš: mc-28-fix

rest of fixes in files cmc.c, main.c (xterm title), panelize.c, subshell.c,
tree.c, tty.c, user.c, util.c, win.c

now, basic mc's function should work well, editor and view are still broken.
Этот коммит содержится в:
Slava Zanko 2008-12-29 01:53:08 +02:00
родитель 753f65c242
Коммит 75cf62902d
9 изменённых файлов: 84 добавлений и 91 удалений

Просмотреть файл

@ -973,7 +973,7 @@ void edit_symlink_cmd (void)
p = selection (current_panel)->fname;
q = g_strdup_printf (_(" Symlink `%s\' points to: "), name_trunc (p, 32));
q = g_strdup_printf (_(" Symlink `%s\' points to: "), str_trunc (p, 32));
i = readlink (p, buffer, MC_MAXPATHLEN - 1);
if (i > 0) {

Просмотреть файл

@ -706,7 +706,7 @@ load_prompt (int fd, void *unused)
int prompt_len;
tmp_prompt = strip_ctrl_codes (subshell_prompt);
prompt_len = strlen (tmp_prompt);
prompt_len = str_term_width1 (tmp_prompt);
/* Check for prompts too big */
if (COLS > 8 && prompt_len > COLS - 8) {
@ -1607,17 +1607,12 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
void
update_xterm_title_path (void)
{
char *p, *s;
const char *p;
if (xterm_flag && xterm_title) {
p = s = g_strdup (strip_home_and_password (current_panel->cwd));
do {
if (!is_printable ((unsigned char) *s))
*s = '?';
} while (*++s);
fprintf (stdout, "\33]0;mc - %s\7", p);
p = strip_home_and_password (current_panel->cwd);
fprintf (stdout, "\33]0;mc - %s\7", str_term_form (p));
fflush (stdout);
g_free (p);
}
}
@ -2065,7 +2060,7 @@ handle_args (int argc, char *argv[])
char *end = tmp + strlen (tmp), *p = end;
if (p > tmp && p[-1] == ':')
p--;
while (p > tmp && isdigit ((unsigned char) p[-1]))
while (p > tmp && g_ascii_isdigit ((gchar) p[-1]))
p--;
if (tmp < p && p < end && p[-1] == ':') {
struct stat st;
@ -2083,7 +2078,7 @@ handle_args (int argc, char *argv[])
}
} else {
try_plus_filename:
if (*tmp == '+' && isdigit ((unsigned char) tmp[1])) {
if (*tmp == '+' && g_ascii_isdigit ((gchar) tmp[1])) {
int start_line = atoi (tmp);
if (start_line > 0) {
char *file = poptGetArg (ctx);

Просмотреть файл

@ -44,6 +44,7 @@
#include "main.h" /* repaint_screen */
#include "panelize.h"
#include "history.h"
#include "strutil.h"
#define UX 5
#define UY 2
@ -129,7 +130,7 @@ init_panelize (void)
i = sizeof (panelize_but) / sizeof (panelize_but[0]);
while (i--) {
panelize_but[i].text = _(panelize_but[i].text);
maxlen += strlen (panelize_but[i].text) + 5;
maxlen += str_term_width1 (panelize_but[i].text) + 5;
}
maxlen += 10;
@ -138,11 +139,11 @@ init_panelize (void)
panelize_cols = max (panelize_cols, maxlen);
panelize_but[2].x =
panelize_but[3].x + strlen (panelize_but[3].text) + 7;
panelize_but[3].x + str_term_width1 (panelize_but[3].text) + 7;
panelize_but[1].x =
panelize_but[2].x + strlen (panelize_but[2].text) + 5;
panelize_but[2].x + str_term_width1 (panelize_but[2].text) + 5;
panelize_but[0].x =
panelize_cols - strlen (panelize_but[0].text) - 8 - BX;
panelize_cols - str_term_width1 (panelize_but[0].text) - 8 - BX;
#endif /* ENABLE_NLS */

Просмотреть файл

@ -52,6 +52,7 @@
#include "cons.saver.h" /* handle_console() */
#include "key.h" /* XCTRL */
#include "subshell.h"
#include "strutil.h"
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
@ -700,8 +701,10 @@ static char *
subshell_name_quote (const char *s)
{
char *ret, *d;
const char *su, *n;
const char quote_cmd_start[] = "\"`printf \"%b\" '";
const char quote_cmd_end[] = "'`\"";
int c;
/* Factor 5 because we need \, 0 and 3 other digits per character. */
d = ret = g_malloc (1 + (5 * strlen (s)) + (sizeof(quote_cmd_start) - 1)
@ -724,13 +727,19 @@ subshell_name_quote (const char *s)
* sequence of the form \0nnn, where "nnn" is the numeric value of the
* character converted to octal number.
*/
for (; *s; s++) {
if (isalnum ((unsigned char) *s)) {
*d++ = (unsigned char) *s;
su = s;
for (; su[0] != '\0'; ) {
n = str_cget_next_char_safe (su);
if (str_isalnum (su)) {
memcpy (d, su, n - su);
d+= n - su;
} else {
sprintf (d, "\\0%03o", (unsigned char) *s);
d += 5;
for (c = 0; c < n - su; c++) {
sprintf (d, "\\0%03o", (unsigned char) su[c]);
d += 5;
}
}
su = n;
}
strcpy (d, quote_cmd_end);

Просмотреть файл

@ -50,6 +50,7 @@
#include "treestore.h"
#include "cmd.h"
#include "history.h"
#include "strutil.h"
#define tlines(t) (t->is_panel ? t->widget.lines-2 - (show_mini_info ? 2 : 0) : t->widget.lines)
@ -177,12 +178,14 @@ static void tree_show_mini_info (WTree *tree, int tree_lines, int tree_cols)
attrset (DLG_FOCUSC (h));
addch (PATH_SEP);
addstr ((char *) name_trunc (tree->search_buffer, tree_cols-2));
addstr (str_fit_to_term (tree->search_buffer,
tree_cols - 2, J_LEFT_FIT));
addch (' ');
attrset (DLG_FOCUSC (h));
} else {
/* Show full name of selected directory */
addstr ((char *) name_trunc (tree->selected_ptr->name, tree_cols));
addstr (str_fit_to_term (tree->selected_ptr->name,
tree_cols, J_LEFT_FIT));
}
}
@ -268,7 +271,7 @@ static void show_tree (WTree *tree)
}
/* Show full name */
addstr ((char *) name_trunc (current->name, tree_cols - 6));
addstr (str_fit_to_term (current->name, tree_cols - 6, J_LEFT_FIT));
} else{
/* Sub level directory */
@ -302,8 +305,8 @@ static void show_tree (WTree *tree)
/* Show sub-name */
addch (' ');
addstr ((char *) name_trunc (current->subname,
tree_cols - 2 - 4 - 3 * j));
addstr (str_fit_to_term (current->subname,
tree_cols - 2 - 4 - 3 * j, J_LEFT_FIT));
}
addch (' ');

Просмотреть файл

@ -32,6 +32,7 @@
#include "global.h"
#include "color.h"
#include "main.h" /* for slow_terminal */
#include "strutil.h"
#ifdef USE_NCURSES
#define WANT_TERM_H
@ -159,9 +160,9 @@ extern void
tty_print_string(const char *s)
{
#ifdef HAVE_SLANG
SLsmg_write_string(str_unconst(s));
SLsmg_write_string (str_unconst (str_term_form (s)));
#else
addstr(s);
addstr (str_term_form (s));
#endif
}

Просмотреть файл

@ -34,6 +34,7 @@
#include "execute.h"
#include "setup.h"
#include "history.h"
#include "strutil.h"
#include "../edit/edit.h" /* BLOCK_FILE */
#include "../edit/edit-widget.h" /* WEdit */
@ -184,7 +185,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
if (edit_one_file != NULL)
fname = edit_widget->filename;
else {
if (islower ((unsigned char) c))
if (g_ascii_islower ((gchar) c))
panel = current_panel;
else {
if (get_other_type () != view_listing)
@ -199,7 +200,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
else
quote_func = fake_name_quote;
c_lc = tolower ((unsigned char) c);
c_lc = g_ascii_tolower ((gchar) c);
switch (c_lc) {
case 'f':
@ -324,16 +325,22 @@ check_patterns (char *p)
point after argument. */
static char *extract_arg (char *p, char *arg, int size)
{
char *np;
while (*p && (*p == ' ' || *p == '\t' || *p == '\n'))
p++;
/* support quote space .mnu */
while (size > 1 && *p && (*p != ' ' || *(p-1) == '\\') && *p != '\t' && *p != '\n') {
*arg++ = *p++;
size--;
while (*p && (*p != ' ' || *(p-1) == '\\') && *p != '\t' && *p != '\n') {
np = str_get_next_char (p);
if (np - p >= size) break;
memcpy (arg, p, np - p);
arg+= np - p;
size-= np - p;
p = np;
}
*arg = 0;
if (!*p || *p == '\n')
p --;
str_prev_char (&p);
return p;
}
@ -410,7 +417,7 @@ static char *test_condition (WEdit *edit_widget, char *p, int *condition)
case '!':
p = test_condition (edit_widget, p, condition);
*condition = ! *condition;
p--;
str_prev_char (&p);
break;
case 'f': /* file name pattern */
p = extract_arg (p, arg, sizeof (arg));
@ -554,7 +561,7 @@ static char *test_line (WEdit *edit_widget, char *p, int *result)
debug_out (NULL, NULL, 1);
if (!*p || *p == '\n')
p --;
str_prev_char (&p);
return p;
}
@ -627,9 +634,9 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
}
} else if (expand_prefix_found){
expand_prefix_found = 0;
if (isdigit ((unsigned char) *commands)) {
if (g_ascii_isdigit ((gchar) *commands)) {
do_quote = atoi (commands);
while (isdigit ((unsigned char) *commands))
while (g_ascii_isdigit ((gchar) *commands))
commands++;
}
if (*commands == '{')
@ -746,7 +753,7 @@ user_menu_cmd (struct WEdit *edit_widget)
/* Parse the menu file */
old_patterns = easy_patterns;
p = check_patterns (data);
for (menu_lines = col = 0; *p; p++){
for (menu_lines = col = 0; *p; str_next_char (&p)){
if (menu_lines >= menu_limit){
char ** new_entries;
@ -789,7 +796,7 @@ user_menu_cmd (struct WEdit *edit_widget)
selected = menu_lines;
}
}
else if (*p != ' ' && *p != '\t' && is_printable (*p)) {
else if (*p != ' ' && *p != '\t' && str_isprint (p)) {
/* A menu entry title line */
if (accept_entry)
entries [menu_lines] = p;

Просмотреть файл

@ -230,27 +230,7 @@ fake_name_quote (const char *s, int quote_percent)
const char *
name_trunc (const char *txt, int trunc_len)
{
static char x[MC_MAXPATHLEN + MC_MAXPATHLEN];
int txt_len;
char *p;
if ((size_t) trunc_len > sizeof (x) - 1) {
trunc_len = sizeof (x) - 1;
}
txt_len = strlen (txt);
if (txt_len <= trunc_len) {
strcpy (x, txt);
} else {
int y = (trunc_len / 2) + (trunc_len % 2);
strncpy (x, txt, y);
strncpy (x + y, txt + txt_len - (trunc_len / 2), trunc_len / 2);
x[y] = '~';
}
x[trunc_len] = 0;
for (p = x; *p; p++)
if (!is_printable (*p))
*p = '?';
return x;
return str_trunc (txt, trunc_len);
}
/*
@ -260,10 +240,9 @@ name_trunc (const char *txt, int trunc_len)
*/
const char *
path_trunc (const char *path, int trunc_len) {
const char *ret;
char *secure_path = strip_password (g_strdup (path), 1);
ret = name_trunc (secure_path, trunc_len);
const char *ret = str_trunc (secure_path, trunc_len);
g_free (secure_path);
return ret;
@ -810,7 +789,7 @@ _icase_search (const char *text, const char *data, int *lng)
e += 2;
dlng += 2;
}
if (toupper((unsigned char) *d) == toupper((unsigned char) *e))
if (g_ascii_toupper((gchar) *d) == g_ascii_toupper((gchar) *e))
d++;
else {
e -= d - text;
@ -856,19 +835,23 @@ unix_error_string (int error_num)
const char *
skip_separators (const char *s)
{
for (;*s; s++)
if (*s != ' ' && *s != '\t' && *s != ',')
break;
return s;
const char *su = s;
for (;*su; str_cnext_char (&su))
if (*su != ' ' && *su != '\t' && *su != ',') break;
return su;
}
const char *
skip_numbers (const char *s)
{
for (;*s; s++)
if (!isdigit ((unsigned char) *s))
break;
return s;
const char *su = s;
for (;*su; str_cnext_char (&su))
if (!str_isdigit (su)) break;
return su;
}
/* Remove all control sequences from the argument string. We define
@ -889,6 +872,7 @@ strip_ctrl_codes (char *s)
{
char *w; /* Current position where the stripped data is written */
char *r; /* Current position where the original data is read */
char *n;
if (!s)
return 0;
@ -910,9 +894,12 @@ strip_ctrl_codes (char *s)
continue;
}
if (is_printable(*r))
*w++ = *r;
++r;
n = str_get_next_char (r);
if (str_isprint (r)) {
memmove (w, r, n - r);
w+= n - r;
}
r = n;
}
*w = 0;
return s;
@ -1473,21 +1460,10 @@ save_file_position (const char *filename, long line, long column)
extern const char *
cstrcasestr (const char *haystack, const char *needle)
{
const char *hptr;
size_t i, needle_len;
needle_len = strlen (needle);
for (hptr = haystack; *hptr != '\0'; hptr++) {
for (i = 0; i < needle_len; i++) {
if (toupper ((unsigned char) hptr[i]) !=
toupper ((unsigned char) needle[i]))
goto next_try;
}
return hptr;
next_try:
(void) 0;
}
return NULL;
char *nee = str_create_search_needle (needle, 0);
const char *result = str_search_first (haystack, nee, 0);
str_release_search_needle (nee, 0);
return result;
}
const char *

Просмотреть файл

@ -34,6 +34,7 @@
#include "win.h"
#include "key.h" /* XCTRL and ALT macros */
#include "layout.h"
#include "strutil.h"
/*
* Common handler for standard movement keys in a text area. Provided
@ -217,7 +218,7 @@ int lookup_key (char *keyname)
int i;
for (i = 0; key_name_conv_tab [i].code; i++){
if ( g_strcasecmp (key_name_conv_tab [i].name, keyname))
if (str_casecmp (key_name_conv_tab [i].name, keyname))
continue;
return key_name_conv_tab [i].code;
}