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:
Emma Tebibyte 2023-12-25 20:49:29 -07:00
parent 74d5b65f78
commit 94ba336ee4
Signed by untrusted user: emma
GPG Key ID: 06FA419A1698C270
7 changed files with 50 additions and 24 deletions

View File

@ -17,22 +17,23 @@
PREFIX=/usr/local
CC=cc
CFLAGS=-O3 -Lbuild/lib
CFLAGS=-O3 -Lbuild/lib -idirafter include
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)
CFLAGS=-O3 -s -Wl,-z,noseparate-code,-z,nosectionheader -flto \
-Lbuild/lib
CFLAGS=-O3 -s -Wl,-z,noseparate-code,-z,nosectionheader -flto -Lbuild/lib \
-idirafter include
endif
ifeq ($(CC), clang)
CFLAGS=-O3 -Wall -Lbuild/lib
CFLAGS=-O3 -Wall -Lbuild/lib -idirafter include
endif
ifeq ($(CC), tcc)
CFLAGS=-O3 -s -Wl -flto -Lbuild/lib
CFLAGS=-O3 -s -Wl -flto -Lbuild/lib -idirafter include
endif
build: build_dir false intcmp scrut str strcmp true

38
include/sysexits.h Normal file
View 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

View File

@ -19,10 +19,8 @@
#include <errno.h> /* errno */
#include <stdio.h> /* fprintf(3), stderr */
#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 <sysexits.h>
/* 0b00? */ /* Equal | -e | 0b001 | 1 */
#define EQUAL 0x01 /* Greater | -g | 0b010 | 2 */

View File

@ -20,12 +20,7 @@
* EOF */
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS */
#include <unistd.h> /* getopt(3) */
#if !defined EX_USAGE
# define EX_USAGE EXIT_FAILURE
#endif
#if !defined EX_OK
# define EX_OK EXIT_SUCCESS
#endif
#include <sysexits.h>
int main(int argc, char *argv[]){
int c;

View File

@ -19,13 +19,11 @@
#include <stdio.h> /* fprintf(3), stderr, NULL */
#include <stdlib.h> /* EXIT_FAILURE */
#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 <sys/stat.h> /* lstat(3), stat struct, S_ISBLK, S_ISCHR, S_ISDIR,
* S_ISFIFO, S_ISGID, S_ISREG, S_ISLNK, S_ISSOCK,
* S_ISUID, S_ISVTX */
#include <sysexits.h>
static char args[] = "bcdefghkprsuwxLS";
static char ops[(sizeof args) / (sizeof *args)];

View File

@ -22,9 +22,7 @@
#include <stdio.h> /* fprintf(3) */
#include <stdlib.h> /* EXIT_FAILURE */
#include <string.h> /* strcmp(3) */
#if !defined EX_USAGE
# define EX_USAGE EXIT_FAILURE
#endif
#include <sysexits.h>
static char *program_name = "str";

View File

@ -1,8 +1,6 @@
#include <stdio.h> /* fprintf(3), stderr */
#include <stdlib.h> /* EXIT_FAILURE */
#if !defined EX_USAGE
# define EX_USAGE EXIT_FAILURE
#endif
#include <sysexits.h>
static char *program_name = "strcmp";