Types accuracy, minor optimization, removed unneeded goto and return.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
родитель
718c91e955
Коммит
ec5791b7af
@ -123,8 +123,8 @@ typedef struct edit_stack_type {
|
|||||||
} edit_stack_type;
|
} edit_stack_type;
|
||||||
|
|
||||||
struct macro {
|
struct macro {
|
||||||
short command;
|
unsigned long command;
|
||||||
short ch;
|
int ch;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* type for file which is currently being edited */
|
/* type for file which is currently being edited */
|
||||||
@ -278,7 +278,7 @@ void edit_mail_dialog (WEdit *edit);
|
|||||||
void format_paragraph (WEdit *edit, int force);
|
void format_paragraph (WEdit *edit, int force);
|
||||||
|
|
||||||
/* either command or char_for_insertion must be passed as -1 */
|
/* either command or char_for_insertion must be passed as -1 */
|
||||||
void edit_execute_cmd (WEdit *edit, int command, int char_for_insertion);
|
void edit_execute_cmd (WEdit *edit, unsigned long command, int char_for_insertion);
|
||||||
|
|
||||||
#define get_sys_error(s) (s)
|
#define get_sys_error(s) (s)
|
||||||
|
|
||||||
|
@ -2566,7 +2566,7 @@ static const char * const shell_cmd[] = SHELL_COMMANDS_i;
|
|||||||
all of them. It also does not check for the Undo command.
|
all of them. It also does not check for the Undo command.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
|
edit_execute_cmd (WEdit *edit, unsigned long command, int char_for_insertion)
|
||||||
{
|
{
|
||||||
edit->force |= REDRAW_LINE;
|
edit->force |= REDRAW_LINE;
|
||||||
|
|
||||||
|
@ -708,13 +708,13 @@ edit_delete_macro (WEdit * edit, int k)
|
|||||||
if (!n || n == EOF)
|
if (!n || n == EOF)
|
||||||
break;
|
break;
|
||||||
n = 0;
|
n = 0;
|
||||||
while (fscanf (f, "%hd %hd, ", ¯o[n].command, ¯o[n].ch))
|
while (fscanf (f, "%lu %d, ", ¯o[n].command, ¯o[n].ch))
|
||||||
n++;
|
n++;
|
||||||
fscanf (f, ";\n");
|
fscanf (f, ";\n");
|
||||||
if (s != k) {
|
if (s != k) {
|
||||||
fprintf (g, ("key '%d 0': "), s);
|
fprintf (g, ("key '%d 0': "), s);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
fprintf (g, "%hd %hd, ", macro[i].command, macro[i].ch);
|
fprintf (g, "%lu %d, ", macro[i].command, macro[i].ch);
|
||||||
fprintf (g, ";\n");
|
fprintf (g, ";\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -754,7 +754,7 @@ int edit_save_macro_cmd (WEdit * edit, struct macro macro[], int n)
|
|||||||
if (f) {
|
if (f) {
|
||||||
fprintf (f, ("key '%d 0': "), s);
|
fprintf (f, ("key '%d 0': "), s);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
fprintf (f, "%hd %hd, ", macro[i].command, macro[i].ch);
|
fprintf (f, "%lu %d, ", macro[i].command, macro[i].ch);
|
||||||
fprintf (f, ";\n");
|
fprintf (f, ";\n");
|
||||||
fclose (f);
|
fclose (f);
|
||||||
if (saved_macros_loaded) {
|
if (saved_macros_loaded) {
|
||||||
@ -768,17 +768,16 @@ int edit_save_macro_cmd (WEdit * edit, struct macro macro[], int n)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void edit_delete_macro_cmd (WEdit * edit)
|
void
|
||||||
|
edit_delete_macro_cmd (WEdit * edit)
|
||||||
{
|
{
|
||||||
int command;
|
int command;
|
||||||
|
|
||||||
command = editcmd_dialog_raw_key_query (_ (" Delete macro "),
|
command = editcmd_dialog_raw_key_query (_ (" Delete macro "),
|
||||||
_ (" Press macro hotkey: "), 1);
|
_ (" Press macro hotkey: "), 1);
|
||||||
|
|
||||||
if (!command)
|
if (command != 0)
|
||||||
return;
|
edit_delete_macro (edit, command);
|
||||||
|
|
||||||
edit_delete_macro (edit, command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return 0 on error */
|
/* return 0 on error */
|
||||||
@ -804,10 +803,10 @@ int edit_load_macro_cmd (WEdit * edit, struct macro macro[], int *n, int k)
|
|||||||
saved_macro[i++] = s;
|
saved_macro[i++] = s;
|
||||||
if (!found) {
|
if (!found) {
|
||||||
*n = 0;
|
*n = 0;
|
||||||
while (*n < MAX_MACRO_LENGTH && 2 == fscanf (f, "%hd %hd, ", ¯o[*n].command, ¯o[*n].ch))
|
while (*n < MAX_MACRO_LENGTH && 2 == fscanf (f, "%lu %d, ", ¯o[*n].command, ¯o[*n].ch))
|
||||||
(*n)++;
|
(*n)++;
|
||||||
} else {
|
} else {
|
||||||
while (2 == fscanf (f, "%hd %hd, ", &dummy.command, &dummy.ch));
|
while (2 == fscanf (f, "%lu %d, ", &dummy.command, &dummy.ch));
|
||||||
}
|
}
|
||||||
fscanf (f, ";\n");
|
fscanf (f, ";\n");
|
||||||
if (s == k)
|
if (s == k)
|
||||||
@ -1480,7 +1479,7 @@ editcmd_find (WEdit *edit, gsize *len)
|
|||||||
#define is_digit(x) ((x) >= '0' && (x) <= '9')
|
#define is_digit(x) ((x) >= '0' && (x) <= '9')
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
edit_replace_cmd__conv_to_display(char *str)
|
edit_replace_cmd__conv_to_display (char *str)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_CHARSET
|
#ifdef HAVE_CHARSET
|
||||||
GString *tmp;
|
GString *tmp;
|
||||||
@ -1539,8 +1538,8 @@ edit_replace_cmd (WEdit *edit, int again)
|
|||||||
input1 = g_strdup (saved1 ? saved1 : "");
|
input1 = g_strdup (saved1 ? saved1 : "");
|
||||||
input2 = g_strdup (saved2 ? saved2 : "");
|
input2 = g_strdup (saved2 ? saved2 : "");
|
||||||
} else {
|
} else {
|
||||||
char *disp1 = edit_replace_cmd__conv_to_display(saved1 ? saved1 : "");
|
char *disp1 = edit_replace_cmd__conv_to_display (saved1 ? saved1 : (char *) "");
|
||||||
char *disp2 = edit_replace_cmd__conv_to_display(saved2 ? saved2 : "");
|
char *disp2 = edit_replace_cmd__conv_to_display (saved2 ? saved2 : (char *) "");
|
||||||
char *tmp_inp1, *tmp_inp2;
|
char *tmp_inp1, *tmp_inp2;
|
||||||
|
|
||||||
edit_push_action (edit, KEY_PRESS + edit->start_display);
|
edit_push_action (edit, KEY_PRESS + edit->start_display);
|
||||||
@ -2273,28 +2272,26 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block)
|
|||||||
edit->force |= REDRAW_COMPLETELY;
|
edit->force |= REDRAW_COMPLETELY;
|
||||||
|
|
||||||
/* insert result block */
|
/* insert result block */
|
||||||
if (block) {
|
if (block && !edit_block_delete_cmd (edit)) {
|
||||||
if (edit_block_delete_cmd (edit))
|
|
||||||
goto edit_block_process_cmd__EXIT;
|
|
||||||
edit_insert_file (edit, b);
|
edit_insert_file (edit, b);
|
||||||
if ((block_file = fopen (b, "w")))
|
block_file = fopen (b, "w");
|
||||||
|
if (block_file != NULL)
|
||||||
fclose (block_file);
|
fclose (block_file);
|
||||||
goto edit_block_process_cmd__EXIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_block_process_cmd__EXIT:
|
edit_block_process_cmd__EXIT:
|
||||||
g_free(b);
|
g_free (b);
|
||||||
g_free(h);
|
g_free (h);
|
||||||
g_free(o);
|
g_free (o);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prints at the cursor */
|
/* prints at the cursor */
|
||||||
/* returns the number of chars printed */
|
/* returns the number of chars printed */
|
||||||
int edit_print_string (WEdit * e, const char *s)
|
int edit_print_string (WEdit * e, const char *s)
|
||||||
{
|
{
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
while (s[i])
|
while (s[i] != '\0')
|
||||||
edit_execute_cmd (e, -1, (unsigned char) s[i++]);
|
edit_execute_cmd (e, CK_Insert_Char, (unsigned char) s[i++]);
|
||||||
e->force |= REDRAW_COMPLETELY;
|
e->force |= REDRAW_COMPLETELY;
|
||||||
edit_update_screen (e);
|
edit_update_screen (e);
|
||||||
return i;
|
return i;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user