feat: add linux compatibility

Signed-off-by: sisungo <[email protected]>
This commit is contained in:
2026-07-06 19:08:36 +08:00
parent b4bcbdc85d
commit 326583d266
7 changed files with 36 additions and 12 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
${CC} -O3 ${CFLAGS} -o sed *.c ${CC} -O3 ${CFLAGS} -o sed *.c $(pcre2-config --libs-posix)
+27
View File
@@ -0,0 +1,27 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#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);
}
+2 -3
View File
@@ -33,8 +33,6 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -43,7 +41,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <regex.h> #include <pcre2posix.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -52,6 +50,7 @@
#include "defs.h" #include "defs.h"
#include "extern.h" #include "extern.h"
#include "compat.h"
#define LHSZ 128 #define LHSZ 128
#define LHMASK (LHSZ - 1) #define LHMASK (LHSZ - 1)
+3 -2
View File
@@ -45,7 +45,7 @@
#include <libgen.h> #include <libgen.h>
#include <limits.h> #include <limits.h>
#include <locale.h> #include <locale.h>
#include <regex.h> #include <pcre2posix.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -54,6 +54,7 @@
#include "defs.h" #include "defs.h"
#include "extern.h" #include "extern.h"
#include "compat.h"
/* /*
* Linked list of units (strings and files) to be compiled * 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_compunit(enum e_cut, char *);
static void add_file(char *); static void add_file(char *);
static void usage(void) __dead2; static void usage(void);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
+1 -3
View File
@@ -33,13 +33,11 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#include <sys/types.h> #include <sys/types.h>
#include <err.h> #include <err.h>
#include <limits.h> #include <limits.h>
#include <regex.h> #include <pcre2posix.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
+2 -3
View File
@@ -33,8 +33,6 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
@@ -45,7 +43,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <regex.h> #include <pcre2posix.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -55,6 +53,7 @@
#include "defs.h" #include "defs.h"
#include "extern.h" #include "extern.h"
#include "compat.h"
static SPACE HS, PS, SS, YS; static SPACE HS, PS, SS, YS;
#define pd PS.deleted #define pd PS.deleted
Executable
BIN
View File
Binary file not shown.