Browse Source

* Code cleanup: Added const qualifier for variables and
function declarations where possible. No functional changes.

Roland Illig 20 years ago
parent
commit
8458240147
10 changed files with 28 additions and 23 deletions
  1. 5 0
      src/ChangeLog
  2. 2 2
      src/boxes.c
  3. 2 2
      src/boxes.h
  4. 2 2
      src/cmd.c
  5. 2 2
      src/cmd.h
  6. 1 1
      src/color.c
  7. 1 1
      src/color.h
  8. 5 5
      src/dir.c
  9. 6 6
      src/dir.h
  10. 2 2
      src/ext.c

+ 5 - 0
src/ChangeLog

@@ -1,3 +1,8 @@
+2004-08-29  Roland Illig  <roland.illig@gmx.de>
+
+	* Code cleanup: Added const qualifier for variables and
+	function declarations where possible. No functional changes.
+
 2004-08-26  Roland Illig  <roland.illig@gmx.de>
 
 	* cmd.c (do_link): Fixed memory leak and cleaned up code.

+ 2 - 2
src/boxes.c

@@ -658,7 +658,7 @@ tree_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
 
 /* Show tree in a box, not on a panel */
 char *
-tree_box (char *current_dir)
+tree_box (const char *current_dir)
 {
     WTree    *mytree;
     Dlg_head *dlg;
@@ -825,7 +825,7 @@ cd_dialog (void)
 }
 
 void
-symlink_dialog (char *existing, char *new, char **ret_existing,
+symlink_dialog (const char *existing, const char *new, char **ret_existing,
 		char **ret_new)
 {
     QuickDialog Quick_input;

+ 2 - 2
src/boxes.h

@@ -10,8 +10,8 @@ void    display_bits_box (void);
 void    configure_vfs    (void);
 void    jobs_cmd         (void);
 char   *cd_dialog        (void);
-void    symlink_dialog   (char *existing, char *new,
+void    symlink_dialog   (const char *existing, const char *new,
 			  char **ret_existing, char **ret_new);
-char   *tree_box         (char *current_dir);
+char   *tree_box         (const char *current_dir);
 
 #endif

+ 2 - 2
src/cmd.c

@@ -82,7 +82,7 @@ int use_internal_edit = 1;
 
 
 int
-view_file_at_line (char *filename, int plain_view, int internal,
+view_file_at_line (const char *filename, int plain_view, int internal,
 		   int start_line)
 {
     static char *viewer = 0;
@@ -149,7 +149,7 @@ view_file_at_line (char *filename, int plain_view, int internal,
  *   internal:   If set uses the internal viewer, otherwise an external viewer.
  */
 int
-view_file (char *filename, int plain_view, int internal)
+view_file (const char *filename, int plain_view, int internal)
 {
     return view_file_at_line (filename, plain_view, internal, 0);
 }

+ 2 - 2
src/cmd.h

@@ -8,9 +8,9 @@ void smblink_cmd (void);
 void undelete_cmd (void);
 void help_cmd (void);
 void dirsizes_cmd (void);
-int view_file_at_line (char *filename, int plain_view, int internal,
+int view_file_at_line (const char *filename, int plain_view, int internal,
 		       int start_line);
-int view_file (char *filename, int normal, int internal);
+int view_file (const char *filename, int normal, int internal);
 void view_cmd (void);
 void view_file_cmd (void);
 void view_simple_cmd (void);

+ 1 - 1
src/color.c

@@ -367,7 +367,7 @@ mc_init_pair (int index, CTYPE foreground, CTYPE background)
 }
 
 int
-try_alloc_color_pair (char *fg, char *bg)
+try_alloc_color_pair (const char *fg, const char *bg)
 {
     struct colors_avail *p = &c;
 

+ 1 - 1
src/color.h

@@ -88,6 +88,6 @@ extern int alarm_colors[4];
 void init_colors (void);
 void done_colors (void);
 void mc_init_pair (int index, CTYPE foreground, CTYPE background);
-int try_alloc_color_pair (char *fg, char *bg);
+int try_alloc_color_pair (const char *fg, const char *bg);
 
 #endif /* __COLOR_H */

+ 5 - 5
src/dir.c

@@ -424,7 +424,7 @@ handle_dirent (dir_list *list, char *filter, struct dirent *dp,
    If you change handle_path then check also handle_dirent. */
 /* Return values: -1 = failure, 0 = don't add, 1 = add to the list */
 int
-handle_path (dir_list *list, char *path,
+handle_path (dir_list *list, const char *path,
 	     struct stat *buf1, int next_free, int *link_to_dir,
 	     int *stale_link)
 {
@@ -461,8 +461,8 @@ handle_path (dir_list *list, char *path,
 }
 
 int
-do_load_dir (char *path, dir_list *list, sortfn *sort, int reverse,
-	     int case_sensitive, char *filter)
+do_load_dir (const char *path, dir_list *list, sortfn *sort, int reverse,
+	     int case_sensitive, const char *filter)
 {
     DIR *dirp;
     struct dirent *dp;
@@ -561,8 +561,8 @@ alloc_dir_copy (int size)
 
 /* If filter is null, then it is a match */
 int
-do_reload_dir (char *path, dir_list *list, sortfn *sort, int count,
-	       int rev, int case_sensitive, char *filter)
+do_reload_dir (const char *path, dir_list *list, sortfn *sort, int count,
+	       int rev, int case_sensitive, const char *filter)
 {
     DIR *dirp;
     struct dirent *dp;

+ 6 - 6
src/dir.h

@@ -29,15 +29,15 @@ typedef struct {
 
 typedef int sortfn (const void *, const void *);
 
-int do_load_dir (char *path, dir_list * list, sortfn * sort, int reverse,
-		 int case_sensitive, char *filter);
+int do_load_dir (const char *path, dir_list * list, sortfn * sort, int reverse,
+		 int case_sensitive, const char *filter);
 void do_sort (dir_list * list, sortfn * sort, int top, int reverse,
 	      int case_sensitive);
-int do_reload_dir (char *path, dir_list * list, sortfn * sort, int count,
-		   int reverse, int case_sensitive, char *filter);
+int do_reload_dir (const char *path, dir_list * list, sortfn * sort, int count,
+		   int reverse, int case_sensitive, const char *filter);
 void clean_dir (dir_list * list, int count);
 int set_zero_dir (dir_list * list);
-int handle_path (dir_list *list, char *path, struct stat *buf1,
+int handle_path (dir_list *list, const char *path, struct stat *buf1,
 		 int next_free, int *link_to_dir, int *stale_link);
 
 /* Sorting functions */
@@ -66,7 +66,7 @@ int sort_group (const file_entry *a, const file_entry *b);
 #define SORT_TYPES_TOTAL (SORT_TYPES + SORT_TYPES_EXTRA)
 
 typedef struct {
-    char    *sort_name;
+    const char    *sort_name;
     int     (*sort_fn)(const file_entry *, const file_entry *);
 } sort_orders_t;
 

+ 2 - 2
src/ext.c

@@ -411,7 +411,7 @@ regex_check_type (char *filename, char *ptr, int *have_type)
  * if the value for %d exists, then the viewer is started up at that line number.
  */
 int
-regex_command (char *filename, char *action, int *move_dir)
+regex_command (const char *filename, const char *action, int *move_dir)
 {
     char *p, *q, *r, c;
     int file_len = strlen (filename);
@@ -427,7 +427,7 @@ regex_command (char *filename, char *action, int *move_dir)
     /* Check for the special View:%d parameter */
     if (strncmp (action, "View:", 5) == 0) {
 	view_at_line_number = atoi (action + 5);
-	action[4] = 0;
+	action = "View";
     } else {
 	view_at_line_number = 0;
     }

Some files were not shown because too many files changed in this diff