From 1a3266eed2e91fc0684bee464875773db1040864 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 6 Oct 2020 16:53:07 -0400 Subject: compile included true and false directly into builtins.o --- Makefile | 8 ++++---- builtins.c | 8 ++++++++ false.c | 21 --------------------- true.c | 21 --------------------- 4 files changed, 12 insertions(+), 46 deletions(-) delete mode 100644 false.c delete mode 100644 true.c diff --git a/Makefile b/Makefile index e2714c2..d0c7662 100644 --- a/Makefile +++ b/Makefile @@ -7,15 +7,15 @@ default: all CFLAGS=-g -Wall -Wextra -Wpedantic UTILITY=sh -SOURCES=alias.c bg.c builtins.c cd.c command.c false.c fc.c fg.c getopts.c \ - hash.c jobs.c kill.c newgrp.c pwd.c read.c set.c main.c true.c type.c \ +SOURCES=alias.c bg.c builtins.c cd.c command.c fc.c fg.c getopts.c \ + hash.c jobs.c kill.c newgrp.c pwd.c read.c set.c main.c type.c \ ulimit.c umask.c wait.c \ dot.c eval.c exec.c exit.c export.c readonly.c shift.c times.c trap.c \ unset.c \ interactive.c parse.c init.c getopt.c HEADERS=sh.h -OBJECTS=alias.o bg.o builtins.o cd.o command.o false.o fc.o fg.o getopts.o \ - hash.o jobs.o kill.o newgrp.o pwd.o read.o set.o main.o true.o type.o \ +OBJECTS=alias.o bg.o builtins.o cd.o command.o fc.o fg.o getopts.o \ + hash.o jobs.o kill.o newgrp.o pwd.o read.o set.o main.o type.o \ ulimit.o umask.o wait.o \ dot.o eval.o exec.o exit.o export.o readonly.o shift.o times.o trap.o \ unset.o \ diff --git a/builtins.c b/builtins.c index da39beb..a1952fa 100644 --- a/builtins.c +++ b/builtins.c @@ -168,3 +168,11 @@ int sh_is_regular_builtin(const char *util) { return is_builtin(util, regular_builtins); } + +#define main true_main +#include "true/true.c" +#undef main + +#define main false_main +#include "false/false.c" +#undef main diff --git a/false.c b/false.c deleted file mode 100644 index bc3528e..0000000 --- a/false.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * UNG's Not GNU - * - * Copyright (c) 2011-2020, Jakob Kaivo - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#define main false_main -#include "false/false.c" diff --git a/true.c b/true.c deleted file mode 100644 index cf7b585..0000000 --- a/true.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * UNG's Not GNU - * - * Copyright (c) 2011-2017, Jakob Kaivo - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#define main true_main -#include "true/true.c" -- cgit v1.2.1