mirror of https://github.com/MidnightCommander/mc
* complete.c (completion_matches): Use more suitable function
g_strndup(), instead sequence g_malloc(), strncpy(), name[len] = '\0' * widget.c (copy_region): Likewise. (delete_region): Use memmove() instead strcpy(). * user.c (debug_out): Eliminate buffer array.
This commit is contained in:
parent
f379b30232
commit
1b80f9ceac
|
@ -1,3 +1,15 @@
|
|||
2004-09-02 Pavel S. Shirshov <pavelsh@mail.ru>
|
||||
|
||||
* complete.c (completion_matches): Use more suitable function
|
||||
g_strndup(), instead sequence g_malloc(), strncpy(),
|
||||
name[len] = '\0'
|
||||
* widget.c (copy_region): Likewise. (delete_region): Use
|
||||
memmove() instead strcpy().
|
||||
* user.c (debug_out): Eliminate buffer array.
|
||||
(test_line): Likewise.
|
||||
|
||||
Based on patch from Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
2004-09-02 Pavel S. Shirshov <pavelsh@mail.ru>
|
||||
|
||||
* color.c (load_dialog_colors): Make a separate color for
|
||||
|
@ -8,7 +20,8 @@
|
|||
2004-09-01 Pavel S. Shirshov <pavelsh@mail.ru>
|
||||
|
||||
* user.c (check_format_var): Use more suitable function
|
||||
g_strndup, instead sequence g_malloc(), strncpy(), name[len] = '\0'
|
||||
g_strndup(), instead sequence g_malloc(), strncpy(),
|
||||
name[len] = '\0'
|
||||
* man2hlp.c (handle_link): Use g_strlcpy instead sequence
|
||||
strncpy(), name[len] = '\0'
|
||||
* profile.c (GetSetProfile): Likewise.
|
||||
|
|
|
@ -590,9 +590,7 @@ completion_matches (char *text, CompletionFunction entry_function)
|
|||
}
|
||||
matches = i;
|
||||
match_list [matches + 1] = NULL;
|
||||
match_list[0] = g_malloc (low + 1);
|
||||
strncpy (match_list[0], match_list[1], low);
|
||||
match_list[0][low] = 0;
|
||||
match_list[0] = g_strndup(match_list[1], low);
|
||||
}
|
||||
} else { /* There were no matches. */
|
||||
g_free (match_list);
|
||||
|
|
48
src/user.c
48
src/user.c
|
@ -428,50 +428,44 @@ static char *test_condition (WEdit *edit_widget, char *p, int *condition)
|
|||
static void
|
||||
debug_out (char *start, char *end, int cond)
|
||||
{
|
||||
static char msg [256];
|
||||
static char *msg;
|
||||
int len;
|
||||
|
||||
if (start == NULL && end == NULL){
|
||||
if (cond == 0){
|
||||
/* Init */
|
||||
msg [0] = 0;
|
||||
} else {
|
||||
/* Show output */
|
||||
if (!debug_flag)
|
||||
return;
|
||||
/* Show output */
|
||||
if (debug_flag && msg) {
|
||||
len = strlen (msg);
|
||||
if (len)
|
||||
msg [len - 1] = 0;
|
||||
message (0, _(" Debug "), "%s", msg);
|
||||
debug_flag = 0;
|
||||
|
||||
}
|
||||
debug_flag = 0;
|
||||
g_free (msg);
|
||||
msg = NULL;
|
||||
} else {
|
||||
char *type, *p;
|
||||
|
||||
/* Save debug info for later output */
|
||||
if (!debug_flag)
|
||||
return;
|
||||
/* Save the result of the condition */
|
||||
if (debug_error){
|
||||
strcat (msg, _(" ERROR: "));
|
||||
type = _(" ERROR: ");
|
||||
debug_error = 0;
|
||||
}
|
||||
else if (cond)
|
||||
strcat (msg, _(" True: "));
|
||||
type = _(" True: ");
|
||||
else
|
||||
strcat (msg, _(" False: "));
|
||||
/* Copy condition statement */
|
||||
len = strlen (msg);
|
||||
if (end == NULL){
|
||||
/* Copy one character */
|
||||
msg [len] = *start;
|
||||
msg [len + 1] = 0;
|
||||
} else {
|
||||
/* Copy many characters */
|
||||
while (start < end){
|
||||
msg [len++] = *start++;
|
||||
}
|
||||
msg [len] = 0;
|
||||
}
|
||||
strcat (msg, " \n");
|
||||
type = _(" False: ");
|
||||
/* This is for debugging, don't need to be super efficient. */
|
||||
if (end == NULL)
|
||||
p = g_strdup_printf ("%s%s%c \n", msg ? msg : "", type, *start);
|
||||
else
|
||||
p = g_strdup_printf ("%s%s%.*s \n", msg ? msg : "", type,
|
||||
(int) (end - start), start);
|
||||
g_free (msg);
|
||||
msg = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,8 +477,6 @@ static char *test_line (WEdit *edit_widget, char *p, int *result)
|
|||
char operator;
|
||||
char *debug_start, *debug_end;
|
||||
|
||||
/* Init debugger */
|
||||
debug_out (NULL, NULL, 0);
|
||||
/* Repeat till end of line */
|
||||
while (*p && *p != '\n') {
|
||||
/* support quote space .mnu */
|
||||
|
|
|
@ -1243,10 +1243,8 @@ copy_region (WInput *in, int x_first, int x_last)
|
|||
|
||||
if (kill_buffer)
|
||||
g_free (kill_buffer);
|
||||
|
||||
kill_buffer = g_malloc (last-first + 1);
|
||||
strncpy (kill_buffer, in->buffer+first, last-first);
|
||||
kill_buffer [last-first] = 0;
|
||||
|
||||
kill_buffer = g_strndup(in->buffer+first,last-first);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1254,10 +1252,11 @@ delete_region (WInput *in, int x_first, int x_last)
|
|||
{
|
||||
int first = min (x_first, x_last);
|
||||
int last = max (x_first, x_last);
|
||||
size_t len = strlen (&in->buffer [last]) + 1;
|
||||
|
||||
in->point = first;
|
||||
in->mark = first;
|
||||
strcpy (&in->buffer [first], &in->buffer [last]);
|
||||
memmove (&in->buffer [first], &in->buffer [last], len);
|
||||
in->need_push = 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue