diff --git a/TODO b/TODO index 5c4e7a7..0ea525e 100644 --- a/TODO +++ b/TODO @@ -9,7 +9,6 @@ tr cut shuf stty -stat sort test tar @@ -34,12 +33,8 @@ Other: hexdump Loginutils: - su - adduser - addgroup - deluser - passwd - delgroup + userctl + groupctl getty Modutils (linux only): @@ -59,7 +54,4 @@ FIX: head echo (escape) xargs (-I) - ls (unicode) que (unicode) - nl - df diff --git a/include/libmu/human.h b/include/libmu/human.h index 7b4192e..8b7ba5d 100644 --- a/include/libmu/human.h +++ b/include/libmu/human.h @@ -7,8 +7,8 @@ #define MU_HUMAN_BUF_SIZE 16 char *mu_humansize(off_t n, off_t block) { - static char buf[MU_HUMAN_BUF_SIZE + 1]; - memset(buf, '\0', sizeof(buf)); + static char mu_hs_buf[MU_HUMAN_BUF_SIZE + 1]; + memset(mu_hs_buf, '\0', sizeof(mu_hs_buf)); char *postfixes = "BKMGTPE"; @@ -19,12 +19,12 @@ char *mu_humansize(off_t n, off_t block) { size /= block; if (i) - snprintf(buf, sizeof(buf), "%.1f%c", size, postfixes[i]); + snprintf(mu_hs_buf, sizeof(mu_hs_buf), "%.1f%c", size, postfixes[i]); else - snprintf(buf, sizeof(buf), "%ju", n); + snprintf(mu_hs_buf, sizeof(mu_hs_buf), "%ju", n); - return buf; + return mu_hs_buf; } #endif diff --git a/src/coreutils/df/df.c b/src/coreutils/df/df.c index b5d988d..34a904d 100644 --- a/src/coreutils/df/df.c +++ b/src/coreutils/df/df.c @@ -43,7 +43,12 @@ int main(int argc, char **argv) { return 1; } - puts("Filesystem Size Used Available Use% Mounted on"); + if (h_flag) + puts("Filesystem Size Used Available Use% Mounted on"); + + else + puts("Filesystem Size Used Available Use% Mounted on"); + int ret = 0; struct mntent *me; diff --git a/src/coreutils/nl/nl.c b/src/coreutils/nl/nl.c index bfe4ee3..0115edd 100644 --- a/src/coreutils/nl/nl.c +++ b/src/coreutils/nl/nl.c @@ -24,7 +24,7 @@ int nl(const char *path) { size_t size = 0; while (getline(&buf, &size, fp) != EOF) { if (strlen(buf) > 1) - fprintf(stdout, "%*d\t%s\n", w_flag, lines++, buf); + fprintf(stdout, "%*d\t%s", w_flag, lines++, buf); else fprintf(stdout, "%*s\t%s", w_flag, " ", buf); diff --git a/src/coreutils/stat/build.sh b/src/coreutils/stat/build.sh deleted file mode 100755 index 6d8974b..0000000 --- a/src/coreutils/stat/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -project_dir=$(pwd) -echo ./*.c $CFLAGS -o $OUTPUT$(basename $project_dir) | xargs $CC diff --git a/src/coreutils/stat/stat.c b/src/coreutils/stat/stat.c deleted file mode 100644 index 6c12ea8..0000000 --- a/src/coreutils/stat/stat.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include -#include -#include "get_stat.h" - -int main(int argc, char **argv) { -} diff --git a/src/findutils/grep/grep.c b/src/findutils/grep/grep.c index dadee50..fd118de 100644 --- a/src/findutils/grep/grep.c +++ b/src/findutils/grep/grep.c @@ -20,11 +20,14 @@ int addpattern(char *str) { } } - regexs = realloc(regexs, (r_size + 1) * sizeof(PATTERN)); - if (regexs == NULL) { - fprintf(stderr, "grep: malloc failed\n"); + PATTERN *regexs_tmp = realloc(regexs, (r_size + 1) * sizeof(PATTERN)); + if (regexs_tmp == NULL) { + free(regexs); + + fprintf(stderr, "grep: realloc failed\n"); return 1; } + regexs = regexs_tmp; regexs[r_size].pattern = str; @@ -44,7 +47,7 @@ int main(int argc, char **argv) { break; default: - printf("grep [e] [PATTERN | -e PATTERN] [FILE]\n"); + printf("grep [e] [FILE]\n\t-e PTRN Pattern to match\n"); return 0; } } @@ -59,4 +62,3 @@ int main(int argc, char **argv) { free(regexs); return 0; } - diff --git a/src/findutils/xargs/xargs.c b/src/findutils/xargs/xargs.c index 1496844..a675c04 100644 --- a/src/findutils/xargs/xargs.c +++ b/src/findutils/xargs/xargs.c @@ -52,10 +52,11 @@ int add_arg(const char *str, int chars, int flag) { else if (s_flag > 0 && chars > s_flag) return ERROR; - if (!flag && I_flag) { - for (int i = 0; i < args; i++) - if (strstr(cmd[i], I_flag)) - cmd[i] = strdup(str); + if (!flag && I_flag && strstr(str, I_flag) != NULL) { + size_t len = strlen(I_flag) + strlen(str); + cmd[args] = malloc(len + 1); + if (cmd[args] == NULL) + return ERROR; return I_FLAG; } @@ -139,8 +140,10 @@ PUSH: continue; } - arg = realloc(arg, (arg_size++) + 1); - if (arg == NULL) { + char *tmp = realloc(arg, (arg_size++) + 1); + if (tmp == NULL) { + free(arg); + fprintf(stderr, "xargs: realloc failed\n"); return ERROR; }