ref: 31fef787682d48b84879917047669ce8a281bd5b
parent: 7422cf29d5bf6b0b5b8c4089e7dd0607299c4d2f
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Aug 23 13:39:37 EDT 2017
[lib] Change libcc to libscc After moving all the libraries together it was a bit confusing to have a c and cc libraries. Naming cc as scc removes any confusion.
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -4,7 +4,7 @@
# Makefile is only used as a template for makefile.
# If you modify Makefile remember to run make dep
-LIBDIR = ../lib/cc
+LIBDIR = ../lib/scc
include ../config.mk
include $(LIBDIR)/libdep.mk
@@ -13,7 +13,7 @@
OBJ = types.o decl.o lex.o error.o symbol.o main.o expr.o \
code.o stmt.o cpp.o fold.o init.o builtin.o
-HDR = cc1.h ../inc/cc.h ../inc/$(STD)/cstd.h ../inc/sysincludes.h
+HDR = cc1.h ../inc/scc.h ../inc/$(STD)/cstd.h ../inc/sysincludes.h
all:
mkdir -p ../rootdir/libexec/scc/
@@ -21,7 +21,7 @@
cpp.o: stallman.msg
-$(LIBDIR)/libcc.a:
+$(LIBDIR)/libscc.a:
cd $(LIBDIR) && $(MAKE)
dep:
--- a/cc1/builtin.c
+++ b/cc1/builtin.c
@@ -3,7 +3,7 @@
#include <stdio.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
static Node *
--- a/cc1/code.c
+++ b/cc1/code.c
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <stdarg.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
static void emitbin(unsigned, void *),
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -8,7 +8,7 @@
#include <time.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
static char *argp, *macroname;
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -6,7 +6,7 @@
#include <string.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
#define NOSCLASS 0
--- a/cc1/error.c
+++ b/cc1/error.c
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
#define MAXERRNUM 10
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -6,7 +6,7 @@
#include <string.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
#define XCHG(lp, rp, np) (np = lp, lp = rp, rp = np)
--- a/cc1/fold.c
+++ b/cc1/fold.c
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
--- a/cc1/gendep.sh
+++ b/cc1/gendep.sh
@@ -19,8 +19,8 @@
all: cc1-$i
OBJ-$i= \$(OBJ) target/$i/arch.o
\$(OBJ-$i): \$(HDR)
-cc1-$i: \$(OBJ-$i) \$(LIBDIR)/libcc.a
- \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$i) -lcc -o \$@
+cc1-$i: \$(OBJ-$i) \$(LIBDIR)/libscc.a
+ \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$i) -lscc -o \$@
EOF
echo
--- a/cc1/init.c
+++ b/cc1/init.c
@@ -6,7 +6,7 @@
#include <string.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
--- a/cc1/lex.c
+++ b/cc1/lex.c
@@ -10,7 +10,7 @@
#include <string.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
unsigned yytoken;
--- a/cc1/main.c
+++ b/cc1/main.c
@@ -7,7 +7,7 @@
#include <errno.h>
#include "../inc/arg.h"
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
char *argv0, *infile;
--- a/cc1/stmt.c
+++ b/cc1/stmt.c
@@ -5,7 +5,7 @@
#include <stdio.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
#define NEGATE 1
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
#define NR_SYM_HASH 64
--- a/cc1/target/amd64-sysv/arch.c
+++ b/cc1/target/amd64-sysv/arch.c
@@ -2,7 +2,7 @@
static char sccsid[] = "@(#) ./cc1/arch/amd64-sysv/arch.c";
#include <stdio.h>
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc1.h"
#define RANK_BOOL 0
--- a/cc1/target/i386-sysv/arch.c
+++ b/cc1/target/i386-sysv/arch.c
@@ -2,7 +2,7 @@
static char sccsid[] = "@(#) ./cc1/arch/i386-sysv/arch.c";
#include <stdio.h>
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc1.h"
#define RANK_BOOL 0
--- a/cc1/target/z80-scc/arch.c
+++ b/cc1/target/z80-scc/arch.c
@@ -2,7 +2,7 @@
static char sccsid[] = "@(#) ./cc1/arch/z80/arch.c";
#include <stdio.h>
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc1.h"
#define RANK_BOOL 0
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -7,7 +7,7 @@
#include <string.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc1.h"
#define NR_TYPE_HASH 16
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -4,7 +4,7 @@
# Makefile is only used as a template for makefile.
# If you modify Makefile remember to run make dep
-LIBDIR = ../lib/cc
+LIBDIR = ../lib/scc
include ../config.mk
include $(LIBDIR)/libdep.mk
@@ -11,7 +11,7 @@
MOREFLAGS = -I../inc/$(STD)
OBJ = main.o parser.o peep.o symbol.o node.o code.o optm.o
-HDR = cc2.h ../inc/$(STD)/cstd.h ../inc/cc.h
+HDR = cc2.h ../inc/$(STD)/cstd.h ../inc/scc.h
all:
mkdir -p ../rootdir/libexec/scc/
@@ -20,7 +20,7 @@
dep:
MKQBE=${MKQBE} ./gendep.sh $(TARGETS)
-$(LIBDIR)/libcc.a:
+$(LIBDIR)/libscc.a:
cd $(LIBDIR) && $(MAKE)
main.o: error.h
--- a/cc2/code.c
+++ b/cc2/code.c
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <string.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc2.h"
Inst *pc, *prog;
--- a/cc2/gendep.sh
+++ b/cc2/gendep.sh
@@ -7,8 +7,8 @@
include target/$1/target.mk
\$(OBJ-$1): \$(HDR)
all: cc2-$1
-cc2-$1: \$(OBJ-$1) \$(LIBDIR)/libcc.a
- \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$1) -lcc -o \$@
+cc2-$1: \$(OBJ-$1) \$(LIBDIR)/libscc.a
+ \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$1) -lscc -o \$@
EOF
}
--- a/cc2/main.c
+++ b/cc2/main.c
@@ -4,7 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc2.h"
#include "error.h"
--- a/cc2/node.c
+++ b/cc2/node.c
@@ -3,7 +3,7 @@
#include <stdlib.h>
#include <string.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc2.h"
--- a/cc2/optm.c
+++ b/cc2/optm.c
@@ -1,5 +1,5 @@
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc2.h"
Node *
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -6,7 +6,7 @@
#include <string.h>
#include <cstd.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc2.h"
--- a/cc2/peep.c
+++ b/cc2/peep.c
@@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
static char sccsid[] = "@(#) ./cc2/peep.c";
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc2.h"
void
--- a/cc2/symbol.c
+++ b/cc2/symbol.c
@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <string.h>
-#include "../inc/cc.h"
+#include "../inc/scc.h"
#include "cc2.h"
--- a/cc2/target/amd64-sysv/cgen.c
+++ b/cc2/target/amd64-sysv/cgen.c
@@ -2,7 +2,7 @@
static char sccsid[] = "@(#) ./cc2/arch/amd64-sysv/cgen.c";
#include "arch.h"
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
Node *
--- a/cc2/target/amd64-sysv/code.c
+++ b/cc2/target/amd64-sysv/code.c
@@ -6,7 +6,7 @@
#include <cstd.h>
#include "arch.h"
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
enum segment {
--- a/cc2/target/amd64-sysv/optm.c
+++ b/cc2/target/amd64-sysv/optm.c
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
static char sccsid[] = "@(#) ./cc2/arch/amd64-sysv/optm.c";
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
Node *
--- a/cc2/target/amd64-sysv/types.c
+++ b/cc2/target/amd64-sysv/types.c
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
static char sccsid[] = "@(#) ./cc2/arch/amd64-sysv/types.c";
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
--- a/cc2/target/i386-sysv/cgen.c
+++ b/cc2/target/i386-sysv/cgen.c
@@ -2,7 +2,7 @@
static char sccsid[] = "@(#) ./cc2/arch/i386-sysv/cgen.c";
#include "arch.h"
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
Node *
--- a/cc2/target/i386-sysv/code.c
+++ b/cc2/target/i386-sysv/code.c
@@ -5,7 +5,7 @@
#include <cstd.h>
#include "arch.h"
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
enum segment {
--- a/cc2/target/i386-sysv/optm.c
+++ b/cc2/target/i386-sysv/optm.c
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
static char sccsid[] = "@(#) ./cc2/arch/i386-sysv/optm.c";
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
Node *
--- a/cc2/target/i386-sysv/types.c
+++ b/cc2/target/i386-sysv/types.c
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
static char sccsid[] = "@(#) ./cc2/arch/i386-sysv/types.c";
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
--- a/cc2/target/qbe_amd64-sysv/cgen.c
+++ b/cc2/target/qbe_amd64-sysv/cgen.c
@@ -6,7 +6,7 @@
#include <cstd.h>
#include "arch.h"
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
enum sflags {
--- a/cc2/target/qbe_amd64-sysv/code.c
+++ b/cc2/target/qbe_amd64-sysv/code.c
@@ -7,7 +7,7 @@
#include <cstd.h>
#include "arch.h"
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
#define ADDR_LEN (INTIDENTSIZ+64)
--- a/cc2/target/qbe_amd64-sysv/optm.c
+++ b/cc2/target/qbe_amd64-sysv/optm.c
@@ -3,7 +3,7 @@
#include <stddef.h>
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
Node *
--- a/cc2/target/qbe_amd64-sysv/types.c
+++ b/cc2/target/qbe_amd64-sysv/types.c
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
static char sccsid[] = "@(#) ./cc2/arch/qbe/types.c";
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
--- a/cc2/target/z80-scc/cgen.c
+++ b/cc2/target/z80-scc/cgen.c
@@ -2,7 +2,7 @@
static char sccsid[] = "@(#) ./cc2/arch/z80/cgen.c";
#include "arch.h"
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
Node *
--- a/cc2/target/z80-scc/code.c
+++ b/cc2/target/z80-scc/code.c
@@ -6,7 +6,7 @@
#include <cstd.h>
#include "arch.h"
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
enum segment {
--- a/cc2/target/z80-scc/optm.c
+++ b/cc2/target/z80-scc/optm.c
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
static char sccsid[] = "@(#) ./cc2/arch/z80/optm.c";
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
Node *
--- a/cc2/target/z80-scc/types.c
+++ b/cc2/target/z80-scc/types.c
@@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
static char sccsid[] = "@(#) ./cc2/arch/z80/types.c";
-#include "../../../inc/cc.h"
+#include "../../../inc/scc.h"
#include "../../cc2.h"
--- a/driver/posix/Makefile
+++ b/driver/posix/Makefile
@@ -1,13 +1,13 @@
# See LICENSE file for copyright and license details.
.POSIX:
-LIBDIR = ../../lib/cc
+LIBDIR = ../../lib/scc
include ../../config.mk
include $(LIBDIR)/libdep.mk
OBJ = scc.o
HDR = config.h \
- ../../inc/cc.h \
+ ../../inc/scc.h \
../../inc/arg.h \
../../inc/syslibs.h \
../../inc/ldflags.h
@@ -22,7 +22,7 @@
$(OBJ): $(HDR)
scc: $(OBJ) $(LIBDIR)/libcc.a
- $(CC) $(SCC_LDFLAGS) $(OBJ) -lcc -o $@
+ $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
scpp: cpp.sh config.h
set -x ;\
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -16,7 +16,7 @@
#include "config.h"
#include "../../inc/arg.h"
-#include "../../inc/cc.h"
+#include "../../inc/scc.h"
#include "../../inc/syslibs.h"
#include "../../inc/ldflags.h"
--- a/inc/cc.h
+++ /dev/null
@@ -1,29 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-#include <stddef.h>
-
-extern int debug;
-
-#ifndef NDEBUG
-#define DBG(...) dbg(__VA_ARGS__)
-#define DBGON() (debug = 1)
-#else
-#define DBG(...)
-#define DBGON()
-#endif
-
-#define TINT long long
-#define TUINT unsigned long long
-#define TFLOAT double
-
-struct items {
- char **s;
- unsigned n;
-};
-
-extern void die(const char *fmt, ...);
-extern void dbg(const char *fmt, ...);
-extern void newitem(struct items *items, char *item);
-extern void *xmalloc(size_t size);
-extern void *xcalloc(size_t nmemb, size_t size);
-extern char *xstrdup(const char *s);
-extern void *xrealloc(void *buff, register size_t size);
--- /dev/null
+++ b/inc/scc.h
@@ -1,0 +1,29 @@
+/* See LICENSE file for copyright and license details. */
+#include <stddef.h>
+
+extern int debug;
+
+#ifndef NDEBUG
+#define DBG(...) dbg(__VA_ARGS__)
+#define DBGON() (debug = 1)
+#else
+#define DBG(...)
+#define DBGON()
+#endif
+
+#define TINT long long
+#define TUINT unsigned long long
+#define TFLOAT double
+
+struct items {
+ char **s;
+ unsigned n;
+};
+
+extern void die(const char *fmt, ...);
+extern void dbg(const char *fmt, ...);
+extern void newitem(struct items *items, char *item);
+extern void *xmalloc(size_t size);
+extern void *xcalloc(size_t nmemb, size_t size);
+extern char *xstrdup(const char *s);
+extern void *xrealloc(void *buff, register size_t size);
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -3,7 +3,7 @@
include ../config.mk
-DIRS = cc
+DIRS = scc
all dep clean distclean:
@pwd=$$PWD; \
--- a/lib/cc/Makefile
+++ /dev/null
@@ -1,19 +1,0 @@
-# See LICENSE file for copyright and license details.
-.POSIX:
-
-LIBDIR = ./
-include ../../config.mk
-include libdep.mk
-
-all: libcc.a
-
-libcc.a: $(LIB-OBJ)
- ar $(ARFLAGS) $@ $?
- ranlib $@
-
-dep:
-
-clean:
- rm -f *.o *.a
-
-distclean: clean
--- a/lib/cc/debug.c
+++ /dev/null
@@ -1,21 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-static char sccsid[] = "@(#) ./lib/debug.c";
-#include <stdarg.h>
-#include <stdio.h>
-
-#include "../../inc/cc.h"
-
-int debug;
-
-void
-dbg(const char *fmt, ...)
-{
- if (!debug)
- return;
- va_list va;
- va_start(va, fmt);
- vfprintf(stderr, fmt, va);
- putc('\n', stderr);
- va_end(va);
- return;
-}
--- a/lib/cc/die.c
+++ /dev/null
@@ -1,21 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-static char sccsid[] = "@(#) ./lib/die.c";
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "../../inc/cc.h"
-
-int failure;
-
-void
-die(const char *fmt, ...)
-{
- failure = 1;
- va_list va;
- va_start(va, fmt);
- vfprintf(stderr, fmt, va);
- putc('\n', stderr);
- va_end(va);
- exit(1);
-}
--- a/lib/cc/libdep.mk
+++ /dev/null
@@ -1,8 +1,0 @@
-
-LIB-OBJ = $(LIBDIR)/debug.o \
- $(LIBDIR)/die.o \
- $(LIBDIR)/newitem.o \
- $(LIBDIR)/xcalloc.o \
- $(LIBDIR)/xmalloc.o \
- $(LIBDIR)/xrealloc.o \
- $(LIBDIR)/xstrdup.o \
--- a/lib/cc/newitem.c
+++ /dev/null
@@ -1,12 +1,0 @@
-#include "../../inc/cc.h"
-
-void
-newitem(struct items *items, char *item)
-{
- if ((items->n + 1) < items->n)
- die("newitem: overflow (%u + 1)", items->n);
-
- items->s = xrealloc(items->s, (items->n + 1) * sizeof(char **));
- items->s[items->n++] = item;
-}
-
--- a/lib/cc/xcalloc.c
+++ /dev/null
@@ -1,14 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-static char sccsid[] = "@(#) ./lib/xcalloc.c";
-#include <stdlib.h>
-#include "../../inc/cc.h"
-
-void *
-xcalloc(size_t n, size_t size)
-{
- void *p = calloc(n, size);
-
- if (!p)
- die("out of memory");
- return p;
-}
--- a/lib/cc/xmalloc.c
+++ /dev/null
@@ -1,14 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-static char sccsid[] = "@(#) ./lib/xmalloc.c";
-#include <stdlib.h>
-#include "../../inc/cc.h"
-
-void *
-xmalloc(size_t size)
-{
- void *p = malloc(size);
-
- if (!p)
- die("out of memory");
- return p;
-}
--- a/lib/cc/xrealloc.c
+++ /dev/null
@@ -1,14 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-static char sccsid[] = "@(#) ./lib/xrealloc.c";
-#include <stdlib.h>
-#include "../../inc/cc.h"
-
-void *
-xrealloc(void *buff, size_t size)
-{
- void *p = realloc(buff, size);
-
- if (!p)
- die("out of memory");
- return p;
-}
--- a/lib/cc/xstrdup.c
+++ /dev/null
@@ -1,13 +1,0 @@
-/* See LICENSE file for copyright and license details. */
-static char sccsid[] = "@(#) ./lib/xstrdup.c";
-#include <string.h>
-#include "../../inc/cc.h"
-
-char *
-xstrdup(const char *s)
-{
- size_t len = strlen(s) + 1;
- char *p = xmalloc(len);
-
- return memcpy(p, s, len);
-}
--- /dev/null
+++ b/lib/scc/Makefile
@@ -1,0 +1,19 @@
+# See LICENSE file for copyright and license details.
+.POSIX:
+
+LIBDIR = ./
+include ../../config.mk
+include libdep.mk
+
+all: libscc.a
+
+libscc.a: $(LIB-OBJ)
+ ar $(ARFLAGS) $@ $?
+ ranlib $@
+
+dep:
+
+clean:
+ rm -f *.o *.a
+
+distclean: clean
--- /dev/null
+++ b/lib/scc/debug.c
@@ -1,0 +1,21 @@
+/* See LICENSE file for copyright and license details. */
+static char sccsid[] = "@(#) ./lib/debug.c";
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "../../inc/scc.h"
+
+int debug;
+
+void
+dbg(const char *fmt, ...)
+{
+ if (!debug)
+ return;
+ va_list va;
+ va_start(va, fmt);
+ vfprintf(stderr, fmt, va);
+ putc('\n', stderr);
+ va_end(va);
+ return;
+}
--- /dev/null
+++ b/lib/scc/die.c
@@ -1,0 +1,21 @@
+/* See LICENSE file for copyright and license details. */
+static char sccsid[] = "@(#) ./lib/die.c";
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "../../inc/scc.h"
+
+int failure;
+
+void
+die(const char *fmt, ...)
+{
+ failure = 1;
+ va_list va;
+ va_start(va, fmt);
+ vfprintf(stderr, fmt, va);
+ putc('\n', stderr);
+ va_end(va);
+ exit(1);
+}
--- /dev/null
+++ b/lib/scc/libdep.mk
@@ -1,0 +1,8 @@
+
+LIB-OBJ = $(LIBDIR)/debug.o \
+ $(LIBDIR)/die.o \
+ $(LIBDIR)/newitem.o \
+ $(LIBDIR)/xcalloc.o \
+ $(LIBDIR)/xmalloc.o \
+ $(LIBDIR)/xrealloc.o \
+ $(LIBDIR)/xstrdup.o \
--- /dev/null
+++ b/lib/scc/newitem.c
@@ -1,0 +1,12 @@
+#include "../../inc/scc.h"
+
+void
+newitem(struct items *items, char *item)
+{
+ if ((items->n + 1) < items->n)
+ die("newitem: overflow (%u + 1)", items->n);
+
+ items->s = xrealloc(items->s, (items->n + 1) * sizeof(char **));
+ items->s[items->n++] = item;
+}
+
--- /dev/null
+++ b/lib/scc/xcalloc.c
@@ -1,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+static char sccsid[] = "@(#) ./lib/xcalloc.c";
+#include <stdlib.h>
+#include "../../inc/scc.h"
+
+void *
+xcalloc(size_t n, size_t size)
+{
+ void *p = calloc(n, size);
+
+ if (!p)
+ die("out of memory");
+ return p;
+}
--- /dev/null
+++ b/lib/scc/xmalloc.c
@@ -1,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+static char sccsid[] = "@(#) ./lib/xmalloc.c";
+#include <stdlib.h>
+#include "../../inc/scc.h"
+
+void *
+xmalloc(size_t size)
+{
+ void *p = malloc(size);
+
+ if (!p)
+ die("out of memory");
+ return p;
+}
--- /dev/null
+++ b/lib/scc/xrealloc.c
@@ -1,0 +1,14 @@
+/* See LICENSE file for copyright and license details. */
+static char sccsid[] = "@(#) ./lib/xrealloc.c";
+#include <stdlib.h>
+#include "../../inc/scc.h"
+
+void *
+xrealloc(void *buff, size_t size)
+{
+ void *p = realloc(buff, size);
+
+ if (!p)
+ die("out of memory");
+ return p;
+}
--- /dev/null
+++ b/lib/scc/xstrdup.c
@@ -1,0 +1,13 @@
+/* See LICENSE file for copyright and license details. */
+static char sccsid[] = "@(#) ./lib/xstrdup.c";
+#include <string.h>
+#include "../../inc/scc.h"
+
+char *
+xstrdup(const char *s)
+{
+ size_t len = strlen(s) + 1;
+ char *p = xmalloc(len);
+
+ return memcpy(p, s, len);
+}