From 7aafee75c8492ddd90b6ad92b6846428439c72b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Sun, 18 Apr 2021 19:36:47 +0300 Subject: [PATCH] Get dc(1) to build --- .gitignore | 1 + LICENSE.nortti | 19 +++++++++++++++++++ Makefile | 36 ++++++++++++++++++++++++++++++++++++ dc/COPYING | 2 ++ dc/dc.c | 5 +++-- 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 LICENSE.nortti create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edbbc9a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dc/dc diff --git a/LICENSE.nortti b/LICENSE.nortti new file mode 100644 index 0000000..172948b --- /dev/null +++ b/LICENSE.nortti @@ -0,0 +1,19 @@ + Copyright (c) 2021 nortti + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute + it freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source distribution. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d9f781b --- /dev/null +++ b/Makefile @@ -0,0 +1,36 @@ +DESTDIR ?= +PREFIX ?= /usr/local +EXEC_PREFIX ?= $(PREFIX) +BINDIR ?= $(EXEC_PREFIX)/bin +LIBEXECDIR ?= $(EXEC_PREFIX)/libexec +DATAROOTDIR ?= $(PREFIX)/share +MANDIR ?= $(DATAROOTDIR)/man + +BINS := dc/dc +MAN1S := dc/dc.1 + +.SUFFIXES: +.SUFFIXES: .c .o + +.PHONY: all install uninstall clean distclean + +all: $(BINS) + +dc/dc: dc/dc.c dc/dc.h + $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $< $(LDFLAGS) + +.c.o: + $(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< + +install: $(BINS) $(MAN1S) + install -D -m 755 -t '$(DESTDIR)$(BINDIR)' $(BINS) + install -D -m 644 -t '$(DESTDIR)$(MANDIR)/man1' $(MAN1S) + +uninstall: + cd $(DESTDIR)$(BINDIR) && rm $(BINS) + cd $(DESTDIR)$(MANDIR)/man1 && rm $(MAN1S) + +clean: + rm -f $(BINS) + +distclean: clean diff --git a/dc/COPYING b/dc/COPYING index 171f1bf..aa99418 100644 --- a/dc/COPYING +++ b/dc/COPYING @@ -3,3 +3,5 @@ dc.c is derived from 4.4BSD. See LICENSE.bsd Additionally, the files have been modified by Gunnar Ritter. See LICENSE.gritter + +dc.c has been modified by nortti. See LICENSE.nortti diff --git a/dc/dc.c b/dc/dc.c index e9252d1..68ff9c1 100644 --- a/dc/dc.c +++ b/dc/dc.c @@ -43,13 +43,14 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Sccsid @(#)dc.c 1.21 (gritter) 12/25/06> */ +/* Modified by nortti, 2021 */ +#define _XOPEN_SOURCE 500 #include #include #include #include #include -#include "sigset.h" #include #include #include @@ -1669,7 +1670,7 @@ command(void){ } *sl = 0; if((pid = fork()) == 0){ - execl(SHELL,"sh","-c",line,NULL); + execl("/bin/sh","sh","-c",line,NULL); exit(0100); } savint = sigset(SIGINT, SIG_IGN);