forked from bonsai/harakit
GNUmakefile, intcmp(1), npc(1), scrut(1), str(1), strcmp(1), include/sysexits.h: added fallback header file for when systems don’t have sysexits.h(3)
This commit is contained in:
parent
74d5b65f78
commit
94ba336ee4
13
GNUmakefile
13
GNUmakefile
@ -17,22 +17,23 @@
|
|||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
|
|
||||||
CC=cc
|
CC=cc
|
||||||
CFLAGS=-O3 -Lbuild/lib
|
CFLAGS=-O3 -Lbuild/lib -idirafter include
|
||||||
|
|
||||||
RUSTC=rustc
|
RUSTC=rustc
|
||||||
RUSTCFLAGS=-C opt-level=z -C codegen-units=1 -C panic=abort -C lto=y -C strip=symbols
|
RUSTCFLAGS=-C opt-level=z -C codegen-units=1 -C panic=abort -C lto=y \
|
||||||
|
-C strip=symbols
|
||||||
|
|
||||||
ifeq ($(CC), gcc)
|
ifeq ($(CC), gcc)
|
||||||
CFLAGS=-O3 -s -Wl,-z,noseparate-code,-z,nosectionheader -flto \
|
CFLAGS=-O3 -s -Wl,-z,noseparate-code,-z,nosectionheader -flto -Lbuild/lib \
|
||||||
-Lbuild/lib
|
-idirafter include
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CC), clang)
|
ifeq ($(CC), clang)
|
||||||
CFLAGS=-O3 -Wall -Lbuild/lib
|
CFLAGS=-O3 -Wall -Lbuild/lib -idirafter include
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CC), tcc)
|
ifeq ($(CC), tcc)
|
||||||
CFLAGS=-O3 -s -Wl -flto -Lbuild/lib
|
CFLAGS=-O3 -s -Wl -flto -Lbuild/lib -idirafter include
|
||||||
endif
|
endif
|
||||||
|
|
||||||
build: build_dir false intcmp scrut str strcmp true
|
build: build_dir false intcmp scrut str strcmp true
|
||||||
|
38
include/sysexits.h
Normal file
38
include/sysexits.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023 DTB <trinity@trinity.moe>
|
||||||
|
* Copyright (c) 2023 Emma Tebibyte <emma@tebibyte.media>
|
||||||
|
* SPDX-License-Identifier: CC0
|
||||||
|
*
|
||||||
|
* This work is marked with CC0 1.0. To view a copy of this license, visit
|
||||||
|
* <http://creativecommons.org/publicdomain/zero/1.0>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SYSEXITS_H
|
||||||
|
#define _SYSEXITS_H 2
|
||||||
|
|
||||||
|
#ifndef EXIT_FAILURE
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define EX_OK EXIT_SUCCESS
|
||||||
|
|
||||||
|
#define EX__BASE EXIT_FAILURE /* base value for error messages */
|
||||||
|
#define EX_USAGE EXIT_FAILURE /* command line usage error */
|
||||||
|
#define EX_DATAERR EXIT_FAILURE /* data format error */
|
||||||
|
#define EX_NOINPUT EXIT_FAILURE /* cannot open input */
|
||||||
|
#define EX_NOUSER EXIT_FAILURE /* addressee unknown */
|
||||||
|
#define EX_NOHOST EXIT_FAILURE /* host name unknown */
|
||||||
|
#define EX_UNAVAILABLE EXIT_FAILURE /* service unavailable */
|
||||||
|
#define EX_SOFTWARE EXIT_FAILURE /* internal software error */
|
||||||
|
#define EX_OSERR EXIT_FAILURE /* system error (e.g., can't fork) */
|
||||||
|
#define EX_OSFILE EXIT_FAILURE /* critical OS file missing */
|
||||||
|
#define EX_CANTCREAT EXIT_FAILURE /* can't create (user) output file */
|
||||||
|
#define EX_IOERR EXIT_FAILURE /* input/output error */
|
||||||
|
#define EX_TEMPFAIL EXIT_FAILURE /* temp failure; user is invited to retry */
|
||||||
|
#define EX_PROTOCOL EXIT_FAILURE /* remote error in protocol */
|
||||||
|
#define EX_NOPERM EXIT_FAILURE /* permission denied */
|
||||||
|
#define EX_CONFIG EXIT_FAILURE /* configuration error */
|
||||||
|
|
||||||
|
#define EX__MAX EXIT_FAILURE /* maximum listed value */
|
||||||
|
|
||||||
|
#endif
|
@ -19,10 +19,8 @@
|
|||||||
#include <errno.h> /* errno */
|
#include <errno.h> /* errno */
|
||||||
#include <stdio.h> /* fprintf(3), stderr */
|
#include <stdio.h> /* fprintf(3), stderr */
|
||||||
#include <stdlib.h> /* strtol(3), size_t, EXIT_FAILURE */
|
#include <stdlib.h> /* strtol(3), size_t, EXIT_FAILURE */
|
||||||
#ifndef EX_USAGE
|
|
||||||
# define EX_USAGE EXIT_FAILURE
|
|
||||||
#endif
|
|
||||||
#include <unistd.h> /* getopt(3), optind */
|
#include <unistd.h> /* getopt(3), optind */
|
||||||
|
#include <sysexits.h>
|
||||||
|
|
||||||
/* 0b00? */ /* Equal | -e | 0b001 | 1 */
|
/* 0b00? */ /* Equal | -e | 0b001 | 1 */
|
||||||
#define EQUAL 0x01 /* Greater | -g | 0b010 | 2 */
|
#define EQUAL 0x01 /* Greater | -g | 0b010 | 2 */
|
||||||
|
@ -20,12 +20,7 @@
|
|||||||
* EOF */
|
* EOF */
|
||||||
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS */
|
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS */
|
||||||
#include <unistd.h> /* getopt(3) */
|
#include <unistd.h> /* getopt(3) */
|
||||||
#if !defined EX_USAGE
|
#include <sysexits.h>
|
||||||
# define EX_USAGE EXIT_FAILURE
|
|
||||||
#endif
|
|
||||||
#if !defined EX_OK
|
|
||||||
# define EX_OK EXIT_SUCCESS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
int c;
|
int c;
|
||||||
|
@ -19,13 +19,11 @@
|
|||||||
#include <stdio.h> /* fprintf(3), stderr, NULL */
|
#include <stdio.h> /* fprintf(3), stderr, NULL */
|
||||||
#include <stdlib.h> /* EXIT_FAILURE */
|
#include <stdlib.h> /* EXIT_FAILURE */
|
||||||
#include <string.h> /* strchr(3) */
|
#include <string.h> /* strchr(3) */
|
||||||
#ifndef EX_USAGE
|
|
||||||
# define EX_USAGE EXIT_FAILURE
|
|
||||||
#endif
|
|
||||||
#include <unistd.h> /* access(3), getopt(3), F_OK, R_OK, W_OK, X_OK */
|
#include <unistd.h> /* access(3), getopt(3), F_OK, R_OK, W_OK, X_OK */
|
||||||
#include <sys/stat.h> /* lstat(3), stat struct, S_ISBLK, S_ISCHR, S_ISDIR,
|
#include <sys/stat.h> /* lstat(3), stat struct, S_ISBLK, S_ISCHR, S_ISDIR,
|
||||||
* S_ISFIFO, S_ISGID, S_ISREG, S_ISLNK, S_ISSOCK,
|
* S_ISFIFO, S_ISGID, S_ISREG, S_ISLNK, S_ISSOCK,
|
||||||
* S_ISUID, S_ISVTX */
|
* S_ISUID, S_ISVTX */
|
||||||
|
#include <sysexits.h>
|
||||||
|
|
||||||
static char args[] = "bcdefghkprsuwxLS";
|
static char args[] = "bcdefghkprsuwxLS";
|
||||||
static char ops[(sizeof args) / (sizeof *args)];
|
static char ops[(sizeof args) / (sizeof *args)];
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
#include <stdio.h> /* fprintf(3) */
|
#include <stdio.h> /* fprintf(3) */
|
||||||
#include <stdlib.h> /* EXIT_FAILURE */
|
#include <stdlib.h> /* EXIT_FAILURE */
|
||||||
#include <string.h> /* strcmp(3) */
|
#include <string.h> /* strcmp(3) */
|
||||||
#if !defined EX_USAGE
|
#include <sysexits.h>
|
||||||
# define EX_USAGE EXIT_FAILURE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char *program_name = "str";
|
static char *program_name = "str";
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include <stdio.h> /* fprintf(3), stderr */
|
#include <stdio.h> /* fprintf(3), stderr */
|
||||||
#include <stdlib.h> /* EXIT_FAILURE */
|
#include <stdlib.h> /* EXIT_FAILURE */
|
||||||
#if !defined EX_USAGE
|
#include <sysexits.h>
|
||||||
# define EX_USAGE EXIT_FAILURE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static char *program_name = "strcmp";
|
static char *program_name = "strcmp";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user