aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqorg11 <qorg@vxempire.xyz>2020-06-17 20:13:04 +0200
committerqorg11 <qorg@vxempire.xyz>2020-06-17 20:13:04 +0200
commitf9955b4ca4f242087fb828e94d3608fe74786bc2 (patch)
tree5d72e1af77dc421064a8fe2ec949f65b3c2dad1d
parente1e3f9fa52a35e441b89735f5c707d4d9f98b641 (diff)
downloadk9core-hard-mode.tar.gz
k9core-hard-mode.tar.bz2
k9core-hard-mode.tar.zst
Hard mode programminghard-modedelete
-rw-r--r--src/Makefile24
-rw-r--r--src/dirname.c5
-rw-r--r--src/echo.c6
-rw-r--r--src/ln.c3
4 files changed, 25 insertions, 13 deletions
diff --git a/src/Makefile b/src/Makefile
index cffc24f..f4fb4f6 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,19 +1,19 @@
# This makefile is BSD compatiable: You can run it without gmake on most systems
CC = cc
-
+CFLAGS = -Wall -Werror -pedantic -Wextra
compile:
- $(CC) -c *.c
- $(CC) -o cat cat.o
- $(CC) -o kill kill.o
- $(CC) -o dirname dirname.o
- $(CC) -o echo echo.o
- $(CC) -o ln ln.o
- $(CC) -o mkdir mkdir.o
- $(CC) -o pwd pwd.o
- $(CC) -o rmdir rmdir.o
- $(CC) -o touch touch.o
- $(CC) -o yes yes.o
+ $(CC) $(CFLAGS) -c *.c
+ $(CC) $(CFLAGS) -o cat cat.o
+ $(CC) $(CFLAGS) -o kill kill.o
+ $(CC) $(CFLAGS) -o dirname dirname.o
+ $(CC) $(CFLAGS) -o echo echo.o
+ $(CC) $(CFLAGS) -o ln ln.o
+ $(CC) $(CFLAGS) -o mkdir mkdir.o
+ $(CC) $(CFLAGS) -o pwd pwd.o
+ $(CC) $(CFLAGS) -o rmdir rmdir.o
+ $(CC) $(CFLAGS) -o touch touch.o
+ $(CC) $(CFLAGS) -o yes yes.o
clean:
rm *.o cat dirname echo ln mkdir pwd rmdir touch yes kill
diff --git a/src/dirname.c b/src/dirname.c
index 831a85f..5da5ed2 100644
--- a/src/dirname.c
+++ b/src/dirname.c
@@ -4,6 +4,11 @@
int
main(int argc, char *argv[])
{
+ if(argc == 1)
+ {
+ fprintf(stderr,"No directory given\n");
+ return 1;
+ }
char *dir = dirname(argv[1]);
if(dir == NULL) {
fprintf(stderr, "%s", argv[0]);
diff --git a/src/echo.c b/src/echo.c
index b845ef5..a96eacc 100644
--- a/src/echo.c
+++ b/src/echo.c
@@ -4,6 +4,12 @@
int
main(int argc, char *argv[])
{
+ if(argc == 1)
+ {
+ printf("\n");
+ return 0;
+ }
+
int nflag;
if(!strcmp(*++argv, "-n"))
{
diff --git a/src/ln.c b/src/ln.c
index adc9ca9..d438cbb 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -16,7 +16,8 @@ main(int argc, char *argv[])
switch(opts)
{
case 'f':
- fflag=1;
+ fflag = 1;
+ break;
case 's':
if(fflag && (access(argv[3], F_OK) != 1))
unlink(argv[3]);