diff --git a/build.sh b/build.sh index cf0fb38..ed41a10 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ #!/bin/sh -${CC} -O3 ${CFLAGS} -o sed *.c +${CC} -O3 ${CFLAGS} -o sed *.c $(pcre2-config --libs-posix) diff --git a/compat.h b/compat.h new file mode 100644 index 0000000..2fa7c2d --- /dev/null +++ b/compat.h @@ -0,0 +1,27 @@ +#include +#include +#include + +#ifndef DEFFILEMODE +#define DEFFILEMODE 0666 +#endif + +#ifndef ALLPERMS +#define ALLPERMS 07777 +#endif + +static inline const char *getprogname() { + return "sed"; +} + +static inline void errc(int status, int code, const char *fmt, ...) { + va_list args; + + fprintf(stderr, "error: "); + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + fprintf(stderr, ": %s\n", strerror(code)); + + exit(status); +} diff --git a/compile.c b/compile.c index 47249c3..774afba 100644 --- a/compile.c +++ b/compile.c @@ -33,8 +33,6 @@ * SUCH DAMAGE. */ -#include - #include #include @@ -43,7 +41,7 @@ #include #include #include -#include +#include #include #include #include @@ -52,6 +50,7 @@ #include "defs.h" #include "extern.h" +#include "compat.h" #define LHSZ 128 #define LHMASK (LHSZ - 1) diff --git a/main.c b/main.c index 59800bd..f4b9875 100644 --- a/main.c +++ b/main.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -54,6 +54,7 @@ #include "defs.h" #include "extern.h" +#include "compat.h" /* * Linked list of units (strings and files) to be compiled @@ -108,7 +109,7 @@ u_long linenum; static void add_compunit(enum e_cut, char *); static void add_file(char *); -static void usage(void) __dead2; +static void usage(void); int main(int argc, char *argv[]) diff --git a/misc.c b/misc.c index 3a1aae7..d3dc420 100644 --- a/misc.c +++ b/misc.c @@ -33,13 +33,11 @@ * SUCH DAMAGE. */ -#include - #include #include #include -#include +#include #include #include #include diff --git a/process.c b/process.c index c177524..b9a04e7 100644 --- a/process.c +++ b/process.c @@ -33,8 +33,6 @@ * SUCH DAMAGE. */ -#include - #include #include #include @@ -45,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -55,6 +53,7 @@ #include "defs.h" #include "extern.h" +#include "compat.h" static SPACE HS, PS, SS, YS; #define pd PS.deleted diff --git a/sed b/sed new file mode 100755 index 0000000..b4388d2 Binary files /dev/null and b/sed differ