remove trailing whitespace at end of lines
[reactos.git] / rosapps / mc / src / tree.c
index 91a185d..6eec44e 100644 (file)
@@ -4,12 +4,12 @@
    Written: 1994, 1996 Janne Kukonlehto
             1997 Norbert Warmuth
             1996 Miguel de Icaza
-           
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -78,7 +78,7 @@ int xtree_mode = 0;
 static int tree_callback (Dlg_head *h, WTree *tree, int msg, int par);
 #define tcallback (callback_fn) tree_callback
 
-/* "$Id: tree.c,v 1.1 2001/12/30 09:55:21 sedwards Exp $" */
+/* "$Id$" */
 
 /* Returns number of common characters */
 static inline int str_common (char *s1, char *s2)
@@ -125,14 +125,14 @@ static tree_entry *forw_ptr (tree_entry *ptr, int *count)
         /etc.old/X11
         /etc.old/rc.d
         /usr
-       
-   i.e. the required collating sequence when comparing two directory names is 
+
+   i.e. the required collating sequence when comparing two directory names is
         '\0' < PATH_SEP < all-other-characters-in-encoding-order
-   
+
     Since strcmp doesn't fulfil this requirement we use pathcmp when
-    inserting directory names into the list. The meaning of the return value 
-    of pathcmp and strcmp are the same (an integer less than, equal to, or 
-    greater than zero if p1 is found to be less than, to match, or be greater 
+    inserting directory names into the list. The meaning of the return value
+    of pathcmp and strcmp are the same (an integer less than, equal to, or
+    greater than zero if p1 is found to be less than, to match, or be greater
     than p2.
  */
 int
@@ -141,7 +141,7 @@ pathcmp (const char *p1, const char *p2)
     for ( ;*p1 == *p2; p1++, p2++)
         if (*p1 == '\0' )
            return 0;
-           
+
     if (*p1 == '\0')
         return -1;
     if (*p2 == '\0')
@@ -193,7 +193,7 @@ tree_entry *tree_add_entry (WTree *tree, char *name)
 
     if (!tree)
        return 0;
-    
+
     if (tree->tree_last && tree->tree_last->next)
        abort ();
 #if 0
@@ -216,7 +216,7 @@ tree_entry *tree_add_entry (WTree *tree, char *name)
        old = current;
        current = current->next;
     }
-    
+
     if (flag == 0)
        return current; /* Already in the list */
 
@@ -390,7 +390,7 @@ void tree_remove_entry (WTree *tree, char *name)
     if (name [0] == PATH_SEP && name [1] == 0)
        return;
     /* Miguel Ugly hack end */
-    
+
     base = whereis (tree, name);
     if (!base)
        return; /* Doesn't exist */
@@ -439,7 +439,7 @@ void start_tree_check (WTree *tree)
        tree = (WTree *) find_widget_type (current_dlg, tcallback);
     if (!tree)
        return;
-    
+
     /* Search for the start of subdirectories */
     mc_get_current_wd (tree->check_name, MC_MAXPATHLEN);
     tree->check_start = NULL;
@@ -483,7 +483,7 @@ void do_tree_check (WTree *tree, const char *subname)
     current = tree->check_start;
     while (current && (flag = pathcmp (current->name, name)) < 0)
        current = current->next;
-    
+
     if (flag != 0)
        /* Doesn't exist -> add it */
        current = tree_add_entry (tree, name);
@@ -528,7 +528,7 @@ void end_tree_check (WTree *tree)
        tree = (WTree *) find_widget_type (current_dlg, tcallback);
     if (!tree)
        return;
-    
+
     /* Check delete marks and delete if found */
     len = strlen (tree->check_name);
 
@@ -561,7 +561,7 @@ void load_tree (WTree *tree)
        file = fopen (filename, "r");
        free (filename);
     }
-    
+
     if (file){
        /* File open -> read contents */
        oldname [0] = 0;
@@ -572,9 +572,9 @@ void load_tree (WTree *tree)
            }
 #ifdef OS2_NT
             /* .ado: Drives for NT and OS/2 */
-            if ((len > 2)         && 
-                 isalpha(name[0]) && 
-                 (name[1] == ':') && 
+            if ((len > 2)         &&
+                 isalpha(name[0]) &&
+                 (name[1] == ':') &&
                  (name[2] == '\\')) {
                        tree_add_entry (tree, name);
                        strcpy (oldname, name);
@@ -657,17 +657,17 @@ static void tree_show_mini_info (WTree *tree, int tree_lines, int tree_cols)
        line = tree_lines+2;
     } else
        line = tree_lines+1;
-    
+
     widget_move (&tree->widget, line, 1);
     hline (' ', tree_cols);
     widget_move (&tree->widget, line, 1);
-    
+
     if (tree->searching){
        /* Show search string */
        attrset (TREE_NORMALC);
        attrset (FOCUSC);
        addch (PATH_SEP);
-       
+
        addstr (name_trunc (tree->search_buffer, tree_cols-2));
        addch (' ');
        attrset (FOCUSC);
@@ -712,7 +712,7 @@ void show_tree (WTree *tree)
        tree->topdiff = 0;
     }
     current = tree->selected_ptr;
-    
+
     /* Calculate the directory which is to be shown on the topmost line */
     if (tree_navigation_flag){
        i = 0;
@@ -747,7 +747,7 @@ void show_tree (WTree *tree)
 
        if (!current)
            continue;
-       
+
        tree->tree_shown [i] = current;
        if (current->sublevel == topsublevel){
 
@@ -782,7 +782,7 @@ void show_tree (WTree *tree)
                addch (ACS_LTEE);
            addch (ACS_HLINE);
            noacs ();
-           
+
            if (tree->active && current == tree->selected_ptr)
                /* Selected directory -> change color */
                if (!use_colors && !tree->is_panel)
@@ -796,7 +796,7 @@ void show_tree (WTree *tree)
                                tree_cols - 2 - 4 - 3 * j));
        }
        addch (' ');
-       
+
        /* Return to normal color */
        attrset (TREE_NORMALC);
 
@@ -838,7 +838,7 @@ void tree_move_backward (WTree *tree, int i)
 {
     tree_entry *current;
     int j = 0;
-    
+
     if (tree_navigation_flag){
        current = tree->selected_ptr;
        while (j < i && current->prev
@@ -909,7 +909,7 @@ int tree_move_to_parent (WTree *tree)
 {
     tree_entry *current;
     tree_entry *old;
-    
+
     if (!tree->selected_ptr)
        return 0;
     old = tree->selected_ptr;
@@ -976,7 +976,7 @@ static int event_callback (Gpm_Event *event, WTree *tree)
 
     if (tree->is_panel)
        event->y--;
-    
+
     event->y--;
 
     if (!tree->active)
@@ -1043,7 +1043,7 @@ static void tree_do_search (WTree *tree, int key)
 
     if (!search_tree (tree, tree->search_buffer))
        tree->search_buffer [--l] = 0;
-    
+
     show_tree (tree);
     maybe_chdir (tree);
 }
@@ -1058,7 +1058,7 @@ void tree_rescan_cmd (WTree *tree)
     if (!tree->selected_ptr || !mc_get_current_wd (old_dir, MC_MAXPATHLEN) ||
        mc_chdir (tree->selected_ptr->name))
        return;
-    
+
     start_tree_check (tree);
     dirp = opendir (".");
     if (dirp){
@@ -1264,7 +1264,7 @@ static void move_end (WTree *tree)
 static int move_left (WTree *tree)
 {
     int v;
-    
+
     if (tree_navigation_flag){
        v = tree_move_to_parent (tree);
        show_tree (tree);
@@ -1323,15 +1323,15 @@ static void start_search (WTree *tree)
     int i;
 
     if (tree->searching){
-    
+
        if (tree->selected_ptr == tree->tree_last)
            tree_move_to_top(tree);
        else {
-       /* set navigation mode temporarily to 'Static' because in 
+       /* set navigation mode temporarily to 'Static' because in
         * dynamic navigation mode tree_move_forward will not move
         * to a lower sublevel if necessary (sequent searches must
         * start with the directory followed the last found directory)
-         */     
+         */
            i = tree_navigation_flag;
            tree_navigation_flag = 0;
            tree_move_forward (tree, 1);
@@ -1427,7 +1427,7 @@ static void tree_frame (Dlg_head *h, WTree *tree)
     if (tree->is_panel)
        draw_double_box (h, tree->widget.y, tree->widget.x, tree->widget.lines,
                         tree->widget.cols);
-    
+
     if (show_mini_info && tree->is_panel){
        widget_move (tree, tlines (tree) + 1, 1);
        hline (ACS_HLINE, tree->widget.cols - 2);
@@ -1449,29 +1449,29 @@ static int tree_callback (Dlg_head *h, WTree *tree, int msg, int par)
     case WIDGET_FOCUS:
        tree->active = 1;
        define_label (h, (Widget *)tree, 1, _("Help"), (voidfn) tree_help_cmd);
-       define_label_data (h, (Widget *)tree, 
+       define_label_data (h, (Widget *)tree,
            2, _("Rescan"), (buttonbarfn)tree_rescan_cmd, tree);
-       define_label_data (h, (Widget *)tree, 
+       define_label_data (h, (Widget *)tree,
            3, _("Forget"), (buttonbarfn)tree_forget_cmd, tree);
-       define_label_data (h, (Widget *)tree, 
+       define_label_data (h, (Widget *)tree,
            5, _("Copy"),   (buttonbarfn) tree_copy_cmd, tree);
-       define_label_data (h, (Widget *)tree, 
+       define_label_data (h, (Widget *)tree,
            6, _("RenMov"), (buttonbarfn) tree_move_cmd, tree);
 #if 0
        /* FIXME: mkdir is currently defunct */
-       define_label_data (h, (Widget *)tree, 
+       define_label_data (h, (Widget *)tree,
            7, _("Mkdir"),  (buttonbarfn) tree_mkdir_cmd, tree);
 #else
         define_label (h, (Widget *)tree, 7, "", 0);
 #endif
-       define_label_data (h, (Widget *)tree, 
+       define_label_data (h, (Widget *)tree,
            8, _("Rmdir"),  (buttonbarfn) tree_rmdir_cmd, tree);
        set_navig_label (h);
        redraw_labels (h, (Widget *)tree);
 
-       
+
        /* FIXME: Should find a better way of only displaying the
-          currently selected item */ 
+          currently selected item */
        show_tree (tree);
        return 1;
 
@@ -1500,7 +1500,7 @@ WTree *tree_new (int is_panel, int y, int x, int lines, int cols)
     tree->searching = 0;
     tree->done = 0;
     tree->active = 0;
-    
+
     /* We do not want to keep the cursor */
     widget_want_cursor (tree->widget, 0);
     load_tree (tree);
@@ -1521,7 +1521,7 @@ static int my_mkdir_rec (char *s, mode_t mode)
 {
     char *p, *q;
     int result;
-    
+
     if (!mc_mkdir (s, mode))
         return 0;
 
@@ -1535,7 +1535,7 @@ static int my_mkdir_rec (char *s, mode_t mode)
     free (p);
     if (!(result = my_mkdir_rec (q, mode))) {
        result = mc_mkdir (s, mode);
-    } 
+    }
     free (q);
     return result;
 }
@@ -1543,9 +1543,9 @@ static int my_mkdir_rec (char *s, mode_t mode)
 int my_mkdir (char *s, mode_t mode)
 {
     int result;
-#if FIXME    
+#if FIXME
     WTree *tree = 0;
-#endif    
+#endif
 
     result = mc_mkdir (s, mode);
 #ifdef OS2_NT
@@ -1555,7 +1555,7 @@ int my_mkdir (char *s, mode_t mode)
 #endif
     if (result) {
         char *p = vfs_canon (s);
-        
+
         result = my_mkdir_rec (p, mode);
         free (p);
     }
@@ -1574,9 +1574,9 @@ int my_mkdir (char *s, mode_t mode)
 int my_rmdir (char *s)
 {
     int result;
-#if FIXME    
+#if FIXME
     WTree *tree = 0;
-#endif    
+#endif
 
     /* FIXME: Should receive a Wtree! */
     result = mc_rmdir (s);