build system cleanup: rename FEATURE_AWK_MATH to FEATURE_AWK_LIBM;
[oweals/busybox.git] / editors / diff.c
index 4e51f6f76886f5a1a13ac4b772d6557af391c57b..0e96c8496c12f880d4565a99944088dfc9deb798 100644 (file)
@@ -161,14 +161,14 @@ struct globals {
 } while (0)
 
 
-/*static void print_only(const char *path, size_t dirlen, const char *entry)*/
+#if ENABLE_FEATURE_DIFF_DIR
 static void print_only(const char *path, const char *entry)
 {
        printf("Only in %s: %s\n", path, entry);
 }
+#endif
 
 
-/*static void print_status(int val, char *path1, char *path2, char *entry)*/
 static void print_status(int val, char *_path1, char *_path2)
 {
        /*const char *const _entry = entry ? entry : "";*/
@@ -1059,6 +1059,7 @@ static unsigned diffreg(char *file1, char *file2, int flags)
 
        member = (int *) nfile[1];
        equiv(sfile[0], slen[0], sfile[1], slen[1], member);
+//TODO: xrealloc_vector?
        member = xrealloc(member, (slen[1] + 2) * sizeof(int));
 
        class = (int *) nfile[0];
@@ -1163,13 +1164,12 @@ static void do_diff(char *dir1, char *path1, char *dir2, char *path2)
 
 #if ENABLE_FEATURE_DIFF_DIR
 /* This function adds a filename to dl, the directory listing. */
-static int add_to_dirlist(const char *filename,
-               struct stat *sb ATTRIBUTE_UNUSED,
+static int FAST_FUNC add_to_dirlist(const char *filename,
+               struct stat *sb UNUSED_PARAM,
                void *userdata,
-               int depth ATTRIBUTE_UNUSED)
+               int depth UNUSED_PARAM)
 {
-       /* +2: with space for eventual trailing NULL */
-       dl = xrealloc(dl, (dl_count+2) * sizeof(dl[0]));
+       dl = xrealloc_vector(dl, 5, dl_count);
        dl[dl_count] = xstrdup(filename + (int)(ptrdiff_t)userdata);
        dl_count++;
        return TRUE;
@@ -1189,7 +1189,7 @@ static char **get_recursive_dirlist(char *path)
                recursive_action(path, ACTION_RECURSE|ACTION_FOLLOWLINKS,
                                        add_to_dirlist, /* file_action */
                                        NULL, /* dir_action */
-                                       (void*)(strlen(path) + 1),
+                                       (void*)(ptrdiff_t)(strlen(path) + 1),
                                        0);
        } else {
                DIR *dp;
@@ -1271,7 +1271,7 @@ static void diffdir(char *p1, char *p2)
 
 
 int diff_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int diff_main(int argc ATTRIBUTE_UNUSED, char **argv)
+int diff_main(int argc UNUSED_PARAM, char **argv)
 {
        int gotstdin = 0;
        char *f1, *f2;
@@ -1289,14 +1289,9 @@ int diff_main(int argc ATTRIBUTE_UNUSED, char **argv)
        while (L_arg) {
                if (label1 && label2)
                        bb_show_usage();
-               if (!label1)
-                       label1 = L_arg->data;
-               else { /* then label2 is NULL */
+               if (label1) /* then label2 is NULL */
                        label2 = label1;
-                       label1 = L_arg->data;
-               }
-               /* we leak L_arg here... */
-               L_arg = L_arg->link;
+               label1 = llist_pop(&L_arg);
        }
 
        /*