diff --git a/edit/ChangeLog b/edit/ChangeLog index 9c50626b3..cbcb4be26 100644 --- a/edit/ChangeLog +++ b/edit/ChangeLog @@ -1,5 +1,8 @@ 2002-11-12 Pavel Roskin + * *.c: Fix all global functions without declarations - declare, + make static or remove. + * syntax.c (syntax_change_callback): Remove, it's unused. (edit_set_syntax_change_callback): Likewise. diff --git a/edit/edit.c b/edit/edit.c index be87d9be2..1da2887d1 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -145,7 +145,8 @@ char *edit_get_buffer_as_text (WEdit * e) /* returns 1 on error */ /* loads file OR text into buffers. Only one must be none-NULL. */ /* cursor set to start of file */ -int init_dynamic_edit_buffers (WEdit * edit, const char *filename, const char *text) +static int +init_dynamic_edit_buffers (WEdit * edit, const char *filename, const char *text) { long buf; int j, file = -1, buf2; @@ -225,7 +226,8 @@ static int edit_find_filter (const char *filename) return -1; } -char *edit_get_filter (const char *filename) +static char * +edit_get_filter (const char *filename) { int i, l; char *p; @@ -251,7 +253,8 @@ char *edit_get_write_filter (char *writename, const char *filename) return p; } -long edit_insert_stream (WEdit * edit, FILE * f) +static long +edit_insert_stream (WEdit * edit, FILE * f) { int c; long i = 0; @@ -360,7 +363,8 @@ static int check_file_access (WEdit *edit, const char *filename, struct stat *st } /* returns 1 on error */ -int edit_open_file (WEdit * edit, const char *filename, const char *text, unsigned long text_size) +static int +edit_open_file (WEdit * edit, const char *filename, const char *text, unsigned long text_size) { struct stat st; if (text) { @@ -697,7 +701,8 @@ void edit_push_action (WEdit * edit, long c,...) TODO: if the user undos until the stack bottom, and the stack has not wrapped, then the file should be as it was when he loaded up. Then set edit->modified to 0. */ -long pop_action (WEdit * edit) +static long +pop_action (WEdit * edit) { long c; unsigned long sp = edit->stack_pointer; @@ -851,7 +856,8 @@ int edit_delete (WEdit * edit) } -int edit_backspace (WEdit * edit) +static int +edit_backspace (WEdit * edit) { int p; if (!edit->curs1) @@ -1245,7 +1251,8 @@ static int is_in_indent (WEdit *edit) static int left_of_four_spaces (WEdit *edit); -void edit_move_to_prev_col (WEdit * edit, long p) +static void +edit_move_to_prev_col (WEdit * edit, long p) { edit_cursor_move (edit, edit_move_forward3 (edit, p, edit->prev_col, 0) - edit->curs1); @@ -1286,7 +1293,8 @@ void edit_move_up (WEdit * edit, unsigned long i, int scroll) } } -int is_blank (WEdit * edit, long offset) +static int +is_blank (WEdit *edit, long offset) { long s, f; int c; @@ -1302,7 +1310,8 @@ int is_blank (WEdit * edit, long offset) /* returns the offset of line i */ -long edit_find_line (WEdit * edit, int line) +static long +edit_find_line (WEdit *edit, int line) { int i, j = 0; int m = 2000000000; @@ -1508,18 +1517,6 @@ void edit_push_markers (WEdit * edit) edit_push_action (edit, MARK_2 + edit->mark2); } -void free_selections (void) -{ - int i; - for (i = 0; i < NUM_SELECTION_HISTORY; i++) - if (selection_history[i].text) { - free (selection_history[i].text); - selection_history[i].text = 0; - selection_history[i].len = 0; - } - current_selection = 0; -} - /* return -1 on nothing to store or error, zero otherwise */ void edit_get_selection (WEdit * edit) { @@ -1689,7 +1686,8 @@ static void edit_left_delete_word (WEdit * edit) the start column position is not recorded, and hence does not undo as it happed. But who would notice. */ -void edit_do_undo (WEdit * edit) +static void +edit_do_undo (WEdit * edit) { long ac; long count = 0; @@ -1839,7 +1837,8 @@ void edit_insert_indent (WEdit * edit, int indent) edit_insert (edit, ' '); } -void edit_auto_indent (WEdit * edit, int extra, int no_advance) +static void +edit_auto_indent (WEdit * edit, int extra, int no_advance) { long p; int indent; @@ -1890,8 +1889,6 @@ static void edit_tab_cmd (WEdit * edit) return; } -void format_paragraph (WEdit * edit, int force); - static void check_and_wrap_line (WEdit * edit) { int curs, c; @@ -2049,7 +2046,6 @@ int edit_execute_key_command (WEdit * edit, int command, int char_for_insertion) } static const char * const shell_cmd[] = SHELL_COMMANDS_i -void edit_mail_dialog (WEdit * edit); /* This executes a command at a lower level than macro recording. diff --git a/edit/edit.h b/edit/edit.h index 8fa851429..78a022979 100644 --- a/edit/edit.h +++ b/edit/edit.h @@ -301,6 +301,12 @@ void book_mark_inc (WEdit * edit, int line); void book_mark_dec (WEdit * edit, int line); void user_menu (WEdit *edit); +int line_is_blank (WEdit *edit, long line); +int edit_indent_width (WEdit *edit, long p); +void edit_insert_indent (WEdit *edit, int indent); +void edit_options_dialog (void); +void edit_mail_dialog (WEdit *edit); +void format_paragraph (WEdit *edit, int force); /* either command or char_for_insertion must be passed as -1 */ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion); @@ -312,7 +318,6 @@ int edit_execute_cmd (WEdit * edit, int command, int char_for_insertion); #define FONT_MEAN_WIDTH 1 #define get_sys_error(s) (s) -#define itoa MY_itoa #define edit_get_load_file(d,f,h) input_dialog (h, _(" Enter file name: "), f) #define edit_get_save_file(d,f,h) input_dialog (h, _(" Enter file name: "), f) diff --git a/edit/editcmd.c b/edit/editcmd.c index 5ae19c604..8e4494fa5 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -84,7 +84,8 @@ static void *memmove (void *dest, const void *src, size_t n) #endif /* !HAVE_MEMMOVE */ /* #define itoa MY_itoa <---- this line is now in edit.h */ -char *itoa (int i) +static char * +MY_itoa (int i) { static char t[14]; char *s = t + 13; @@ -451,7 +452,7 @@ int edit_save_as_cmd (WEdit * edit) /* {{{ Macro stuff starts here */ -int +static int raw_callback (struct Dlg_head *h, int key, int Msg) { switch (Msg) { @@ -514,7 +515,8 @@ static int saved_macros_loaded = 0; This is just to stop the macro file be loaded over and over for keys that aren't defined to anything. On slow systems this could be annoying. */ -int macro_exists (int k) +static int +macro_exists (int k) { int i; for (i = 0; i < MAX_MACROS && saved_macro[i]; i++) @@ -524,7 +526,8 @@ int macro_exists (int k) } /* returns 1 on error */ -int edit_delete_macro (WEdit * edit, int k) +static int +edit_delete_macro (WEdit * edit, int k) { struct macro macro[MAX_MACRO_LENGTH]; FILE *f, *g; @@ -713,7 +716,8 @@ int edit_new_cmd (WEdit * edit) } /* returns 1 on error */ -int edit_load_file_from_filename (WEdit * edit, char *exp) +static int +edit_load_file_from_filename (WEdit * edit, char *exp) { if (!edit_reload (edit, exp, 0, "", 0)) return 1; @@ -770,7 +774,8 @@ int eval_marks (WEdit * edit, long *start_mark, long *end_mark) #define space_width 1 -void edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width) +static void +edit_insert_column_of_text (WEdit * edit, unsigned char *data, int size, int width) { long cursor; int i, col; @@ -927,7 +932,8 @@ void edit_block_move_cmd (WEdit * edit) edit->force |= REDRAW_PAGE; } -void edit_delete_column_of_text (WEdit * edit) +static void +edit_delete_column_of_text (WEdit * edit) { long p, q, r, m1, m2; int b, c, d; @@ -1024,7 +1030,8 @@ int edit_block_delete_cmd (WEdit * edit) #define B_REPLACE_ONE B_USER+2 #define B_SKIP_REPLACE B_USER+3 -int edit_replace_prompt (WEdit * edit, char *replace_text, int xpos, int ypos) +static int +edit_replace_prompt (WEdit * edit, char *replace_text, int xpos, int ypos) { QuickWidget quick_widgets[] = { @@ -1072,7 +1079,8 @@ int edit_replace_prompt (WEdit * edit, char *replace_text, int xpos, int ypos) } } -void edit_replace_dialog (WEdit * edit, char **search_text, char **replace_text, char **arg_order) +static void +edit_replace_dialog (WEdit * edit, char **search_text, char **replace_text, char **arg_order) { int treplace_scanf = replace_scanf; int treplace_regexp = replace_regexp; @@ -1155,7 +1163,8 @@ void edit_replace_dialog (WEdit * edit, char **search_text, char **replace_text, } -void edit_search_dialog (WEdit * edit, char **search_text) +static void +edit_search_dialog (WEdit * edit, char **search_text) { int treplace_scanf = replace_scanf; int treplace_regexp = replace_regexp; @@ -1228,7 +1237,8 @@ static long sargs[NUM_REPL_ARGS][256 / sizeof (long)]; /* This function is a modification of mc-3.2.10/src/view.c:regexp_view_search() */ /* returns -3 on error in pattern, -1 on not found, found_len = 0 if either */ -int string_regexp_search (char *pattern, char *string, int len, int match_type, int match_bol, int icase, int *found_len, void *d) +static int +string_regexp_search (char *pattern, char *string, int len, int match_type, int match_bol, int icase, int *found_len, void *d) { static regex_t r; static char *old_pattern = NULL; @@ -1265,7 +1275,8 @@ int string_regexp_search (char *pattern, char *string, int len, int match_type, /* thanks to Liviu Daia for getting this (and the above) routines to work properly - paul */ -long edit_find_string (long start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, int once_only, void *d) +static long +edit_find_string (long start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, int once_only, void *d) { long p, q = 0; long l = strlen ((char *) exp), f = 0; @@ -1422,7 +1433,8 @@ long edit_find_string (long start, unsigned char *exp, int *len, long last_byte, } -long edit_find_forwards (long search_start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, int once_only, void *d) +static long +edit_find_forwards (long search_start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, int once_only, void *d) { /*front end to find_string to check for whole words */ long p; @@ -1445,7 +1457,8 @@ long edit_find_forwards (long search_start, unsigned char *exp, int *len, long l return p; } -long edit_find (long search_start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, void *d) +static long +edit_find (long search_start, unsigned char *exp, int *len, long last_byte, int (*get_byte) (void *, long), void *data, void *d) { long p; if (replace_backwards) { @@ -1518,7 +1531,7 @@ static int sprintf_p (char *str, const char *fmt,...) *p1++ = *p++; if (*p == '*') { p++; - strcpy (p1, 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); } else { while (is_digit (*p)) @@ -1528,7 +1541,7 @@ static int sprintf_p (char *str, const char *fmt,...) *p1++ = *p++; if (*p == '*') { p++; - strcpy (p1, 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); } else { while (is_digit (*p)) @@ -2512,7 +2525,8 @@ static int compllist_callback (void *data) /* let the user select its preferred completion */ -void edit_completion_dialog (WEdit *edit, int max_len, int word_len, +static void +edit_completion_dialog (WEdit *edit, int max_len, int word_len, struct selection *compl, int num_compl) { int start_x, start_y, offset, i; diff --git a/edit/editdraw.c b/edit/editdraw.c index b38a6fc2f..fada418c0 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -103,35 +103,6 @@ void edit_status (WEdit * edit) free (s); } -/* result is boolean */ -int cursor_in_screen (WEdit * edit, long row) -{ - if (row < 0 || row >= edit->num_widget_lines) - return 0; - else - return 1; -} - -/* returns rows from the first displayed line to the cursor */ -int cursor_from_display_top (WEdit * edit) -{ - if (edit->curs1 < edit->start_display) - return -edit_move_forward (edit, edit->curs1, 0, edit->start_display); - else - return edit_move_forward (edit, edit->start_display, 0, edit->curs1); -} - -/* returns how far the cursor is out of the screen */ -int cursor_out_of_screen (WEdit * edit) -{ - int row = cursor_from_display_top (edit); - if (row >= edit->num_widget_lines) - return row - edit->num_widget_lines + 1; - if (row < 0) - return row; - return 0; -} - /* this scrolls the text so that cursor is on the screen */ void edit_scroll_screen_over_cursor (WEdit * edit) { @@ -345,8 +316,9 @@ static void edit_draw_this_char (WEdit * edit, long curs, long row) } /* cursor must be in screen for other than REDRAW_PAGE passed in force */ -void render_edit_text (WEdit * edit, long start_row, long start_column, long end_row, - long end_column) +static void +render_edit_text (WEdit * edit, long start_row, long start_column, long end_row, + long end_column) { long row = 0, curs_row; static int prev_curs_row = 0; @@ -458,7 +430,8 @@ void render_edit_text (WEdit * edit, long start_row, long start_column, long end return; } -void edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, int col_end) +static void +edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, int col_end) { if (page) /* if it was an expose event, 'page' would be set */ edit->force |= REDRAW_PAGE | REDRAW_IN_BOUNDS; diff --git a/edit/editmenu.c b/edit/editmenu.c index 489428d04..e34ccb5fa 100644 --- a/edit/editmenu.c +++ b/edit/editmenu.c @@ -40,22 +40,8 @@ static void menu_key (int i) send_message ((Widget *) wedit, WIDGET_KEY, i); } -void edit_wrap_cmd (void) -{ - char *f; - char s[12]; - sprintf (s, "%d", option_word_wrap_line_length); - f = input_dialog (_(" Word wrap "), - _(" Enter line length, 0 for off: "), s); - if (f) { - if (*f) { - option_word_wrap_line_length = atoi (f); - } - g_free (f); - } -} - -void edit_about_cmd (void) +static void +edit_about_cmd (void) { edit_message_dialog (wedit->mainid, 20, 20, _(" About "), _("\n" @@ -68,45 +54,220 @@ void edit_about_cmd (void) ); } -void menu_mail_cmd (void) { menu_cmd (CK_Mail); } -void menu_load_cmd (void) { menu_cmd (CK_Load); } -void menu_new_cmd (void) { menu_cmd (CK_New); } -void menu_save_cmd (void) { menu_cmd (CK_Save); } -void menu_save_as_cmd (void) { menu_cmd (CK_Save_As); } -void menu_insert_file_cmd (void) { menu_cmd (CK_Insert_File); } -void menu_quit_cmd (void) { menu_cmd (CK_Exit); } -void menu_mark_cmd (void) { menu_cmd (CK_Mark); } -void menu_markcol_cmd (void) { menu_cmd (CK_Column_Mark); } -void menu_ins_cmd (void) { menu_cmd (CK_Toggle_Insert); } -void menu_copy_cmd (void) { menu_cmd (CK_Copy); } -void menu_move_cmd (void) { menu_cmd (CK_Move); } -void menu_delete_cmd (void) { menu_cmd (CK_Remove); } -void menu_cut_cmd (void) { menu_cmd (CK_Save_Block); } -void menu_search_cmd (void) { menu_cmd (CK_Find); } -void menu_search_again_cmd (void) { menu_cmd (CK_Find_Again); } -void menu_replace_cmd (void) { menu_cmd (CK_Replace); } -void menu_begin_record_cmd (void) { menu_cmd (CK_Begin_Record_Macro); } -void menu_end_record_cmd (void) { menu_cmd (CK_End_Record_Macro); } -void menu_wrap_cmd (void) { edit_wrap_cmd (); } -void menu_exec_macro_cmd (void) { menu_key (XCTRL ('a')); } -void menu_exec_macro_delete_cmd (void) { menu_cmd (CK_Delete_Macro); } -void menu_c_form_cmd (void) { menu_key (KEY_F (19)); } -void menu_ispell_cmd (void) { menu_cmd (CK_Pipe_Block (1)); } -void menu_sort_cmd (void) { menu_cmd (CK_Sort); } -void menu_date_cmd (void) { menu_cmd (CK_Date); } -void menu_undo_cmd (void) { menu_cmd (CK_Undo); } -void menu_beginning_cmd (void) { menu_cmd (CK_Beginning_Of_Text); } -void menu_end_cmd (void) { menu_cmd (CK_End_Of_Text); } -void menu_refresh_cmd (void) { menu_cmd (CK_Refresh); } -void menu_goto_line (void) { menu_cmd (CK_Goto); } -void menu_goto_bracket (void) { menu_cmd (CK_Match_Bracket); } -void menu_lit_cmd (void) { menu_key (XCTRL ('q')); } -void menu_format_paragraph (void) { menu_cmd (CK_Paragraph_Format); } -void edit_options_dialog (void); -void menu_options (void) { edit_options_dialog (); } -void menu_user_menu_cmd (void) { menu_key (KEY_F (11)); } +static void +menu_mail_cmd (void) +{ + menu_cmd (CK_Mail); +} -void edit_user_menu_cmd (void) { menu_edit_cmd (1); } +static void +menu_load_cmd (void) +{ + menu_cmd (CK_Load); +} + +static void +menu_new_cmd (void) +{ + menu_cmd (CK_New); +} + +static void +menu_save_cmd (void) +{ + menu_cmd (CK_Save); +} + +static void +menu_save_as_cmd (void) +{ + menu_cmd (CK_Save_As); +} + +static void +menu_insert_file_cmd (void) +{ + menu_cmd (CK_Insert_File); +} + +static void +menu_quit_cmd (void) +{ + menu_cmd (CK_Exit); +} + +static void +menu_mark_cmd (void) +{ + menu_cmd (CK_Mark); +} + +static void +menu_markcol_cmd (void) +{ + menu_cmd (CK_Column_Mark); +} + +static void +menu_ins_cmd (void) +{ + menu_cmd (CK_Toggle_Insert); +} + +static void +menu_copy_cmd (void) +{ + menu_cmd (CK_Copy); +} + +static void +menu_move_cmd (void) +{ + menu_cmd (CK_Move); +} + +static void +menu_delete_cmd (void) +{ + menu_cmd (CK_Remove); +} + +static void +menu_cut_cmd (void) +{ + menu_cmd (CK_Save_Block); +} + +static void +menu_search_cmd (void) +{ + menu_cmd (CK_Find); +} + +static void +menu_search_again_cmd (void) +{ + menu_cmd (CK_Find_Again); +} + +static void +menu_replace_cmd (void) +{ + menu_cmd (CK_Replace); +} + +static void +menu_begin_record_cmd (void) +{ + menu_cmd (CK_Begin_Record_Macro); +} + +static void +menu_end_record_cmd (void) +{ + menu_cmd (CK_End_Record_Macro); +} + +static void +menu_exec_macro_cmd (void) +{ + menu_key (XCTRL ('a')); +} + +static void +menu_exec_macro_delete_cmd (void) +{ + menu_cmd (CK_Delete_Macro); +} + +static void +menu_c_form_cmd (void) +{ + menu_key (KEY_F (19)); +} + +static void +menu_ispell_cmd (void) +{ + menu_cmd (CK_Pipe_Block (1)); +} + +static void +menu_sort_cmd (void) +{ + menu_cmd (CK_Sort); +} + +static void +menu_date_cmd (void) +{ + menu_cmd (CK_Date); +} + +static void +menu_undo_cmd (void) +{ + menu_cmd (CK_Undo); +} + +static void +menu_beginning_cmd (void) +{ + menu_cmd (CK_Beginning_Of_Text); +} + +static void +menu_end_cmd (void) +{ + menu_cmd (CK_End_Of_Text); +} + +static void +menu_refresh_cmd (void) +{ + menu_cmd (CK_Refresh); +} + +static void +menu_goto_line (void) +{ + menu_cmd (CK_Goto); +} + +static void +menu_goto_bracket (void) +{ + menu_cmd (CK_Match_Bracket); +} + +static void +menu_lit_cmd (void) +{ + menu_key (XCTRL ('q')); +} + +static void +menu_format_paragraph (void) +{ + menu_cmd (CK_Paragraph_Format); +} + +static void +menu_options (void) +{ + edit_options_dialog (); +} +static void +menu_user_menu_cmd (void) +{ + menu_key (KEY_F (11)); +} + +void +edit_user_menu_cmd (void) +{ + menu_edit_cmd (1); +} static menu_entry FileMenu[] = { @@ -298,7 +459,7 @@ void edit_done_menu (void) } -void +static void edit_drop_menu_cmd (WEdit * e, int which) { if (edit_menubar->active) diff --git a/edit/editoptions.c b/edit/editoptions.c index 9c0ded70b..3dabddb72 100644 --- a/edit/editoptions.c +++ b/edit/editoptions.c @@ -36,7 +36,8 @@ static char *key_emu_str[] = static char *wrap_str[] = {N_("None"), N_("Dynamic paragraphing"), N_("Type writer wrap"), NULL}; -void i18n_translate_array (char *array[]) +static void +i18n_translate_array (char *array[]) { while (*array!=NULL) { *array = _(*array); diff --git a/edit/editwidget.c b/edit/editwidget.c index 64d90221e..4e0b11bb4 100644 --- a/edit/editwidget.c +++ b/edit/editwidget.c @@ -30,7 +30,7 @@ int column_highlighting = 0; static int edit_callback (WEdit *edit, int msg, int par); -int +static int edit_event (WEdit * edit, Gpm_Event * event, int *result) { *result = MOU_NORMAL; @@ -105,7 +105,7 @@ edit_event (WEdit * edit, Gpm_Event * event, int *result) } -int +static int edit_mouse_event (Gpm_Event *event, void *x) { int result; @@ -279,7 +279,7 @@ static void cmd_F10 (WEdit * edit) send_message ((Widget *) edit, WIDGET_KEY, KEY_F (10)); } -void +static void edit_labels (WEdit *edit) { Dlg_head *h = edit->widget.parent; @@ -300,7 +300,8 @@ edit_labels (WEdit *edit) } -long get_key_state (void) +static long +get_key_state (void) { return (long) get_modifier (); } diff --git a/edit/syntax.c b/edit/syntax.c index 5bf425c16..b695bfabe 100644 --- a/edit/syntax.c +++ b/edit/syntax.c @@ -496,7 +496,8 @@ static void get_args (char *l, char **args, int *argc) int try_alloc_color_pair (char *fg, char *bg); -int this_try_alloc_color_pair (char *fg, char *bg) +static int +this_try_alloc_color_pair (char *fg, char *bg) { char f[80], b[80], *p; if (bg) diff --git a/edit/wordproc.c b/edit/wordproc.c index d8674c2b1..b48707509 100644 --- a/edit/wordproc.c +++ b/edit/wordproc.c @@ -23,8 +23,6 @@ #define tab_width option_tab_spacing -int line_is_blank (WEdit * edit, long line); - #define NO_FORMAT_CHARS_START "-+*\\,.;:&>" static long @@ -255,8 +253,6 @@ static void replace_at (WEdit * edit, long q, int c) edit_insert_ahead (edit, c); } -void edit_insert_indent (WEdit * edit, int indent); - /* replaces a block of text */ static void put_paragraph (WEdit * edit, unsigned char *t, long p, long q, int indent, int size) { @@ -296,8 +292,6 @@ static void put_paragraph (WEdit * edit, unsigned char *t, long p, long q, int i edit_cursor_move (edit, cursor - edit->curs1); /* restore cursor position */ } -int edit_indent_width (WEdit * edit, long p); - static int test_indent (WEdit * edit, long p, long q) { int indent;