/*
* Mini run-parts implementation for busybox
*
- * Copyright (C) 2007 Bernhard Fischer
+ * Copyright (C) 2007 Bernhard Reutner-Fischer
*
* Based on a older version that was in busybox which was 1k big..
* Copyright (C) 2001 by Emanuele Aina <emanuele.aina@tiscali.it>
#define cur (G.cur )
#define cmd (G.cmd )
-enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(struct globals)) / sizeof(cmd[0]) };
+enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };
enum {
OPT_r = (1 << 0),
return (option_mask32 & OPT_r) ? -r : r;
}
-static int act(const char *file, struct stat *statbuf, void *args ATTRIBUTE_UNUSED, int depth)
+static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUSED_PARAM, int depth)
{
if (depth == 1)
return TRUE;
return SKIP;
}
- names = xrealloc(names, (cur + 2) * sizeof(names[0]));
+ names = xrealloc_vector(names, 4, cur);
names[cur++] = xstrdup(file);
- names[cur] = NULL;
+ /*names[cur] = NULL; - xrealloc_vector did it */
return TRUE;
}
#endif
int run_parts_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int run_parts_main(int argc ATTRIBUTE_UNUSED, char **argv)
+int run_parts_main(int argc UNUSED_PARAM, char **argv)
{
const char *umask_p = "22";
llist_t *arg_list = NULL;
n = 1;
while (arg_list && n < NUM_CMD) {
- cmd[n] = arg_list->data;
- arg_list = arg_list->link;
- n++;
+ cmd[n++] = llist_pop(&arg_list);
}
/* cmd[n] = NULL; - is already zeroed out */