diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-01-03 18:41:48 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-01-03 18:41:48 +0000 |
commit | 189731aad01e09db1807c78af421c615ed3a3242 (patch) | |
tree | 4cec623654b4e4e9da03bb00f36ea49755c8ca98 /sys/src/cmd/rc/rc.h | |
parent | c51a5cfa06dd982da839c4cfcba1610259d27e38 (diff) |
rc: make it portable (for UNIX)
Fixup remaining Plan9 dependencies (chartorune()).
Add Makefile for UNIX-like systems (tested with Linux and APE).
Make error printing consistent, use Errstr() explicitely.
Get rid of NSTATUS buffer limit, just malloc it.
Diffstat (limited to 'sys/src/cmd/rc/rc.h')
-rw-r--r-- | sys/src/cmd/rc/rc.h | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/sys/src/cmd/rc/rc.h b/sys/src/cmd/rc/rc.h index 7e0b0611c..d02c1312f 100644 --- a/sys/src/cmd/rc/rc.h +++ b/sys/src/cmd/rc/rc.h @@ -1,28 +1,29 @@ /* * Plan9 is defined for plan 9 - * V9 is defined for 9th edition - * Sun is defined for sun-os + * otherwise its UNIX. * Please don't litter the code with ifdefs. The three below (and one in * getflags) should be enough. */ -#define Plan9 -#ifdef Plan9 +#ifdef Plan9 #include <u.h> #include <libc.h> -#define NSIG 32 +#define NSIG 32 #define SIGINT 2 #define SIGQUIT 3 -#endif -#ifdef V9 +#else +#include <stdlib.h> +#include <stdarg.h> +#include <unistd.h> +#include <string.h> #include <signal.h> -#include <libc.h> +#ifndef NSIG +#define NSIG 32 #endif -#ifdef Sun -#include <signal.h> #endif + #define YYMAXDEPTH 500 #ifndef PAREN -#include "x.tab.h" +#include "y.tab.h" #endif typedef struct tree tree; typedef struct word word; @@ -143,10 +144,13 @@ int mypid; */ #define GLOB ((char)0x01) /* - * onebyte(c) - * Is c the first character of a one-byte utf sequence? + * Is c the first character of a utf sequence? */ -#define onebyte(c) ((c&0x80)==0x00) +#define onebyte(c) (((c)&0x80)==0x00) +#define twobyte(c) (((c)&0xe0)==0xc0) +#define threebyte(c) (((c)&0xf0)==0xe0) +#define fourbyte(c) (((c)&0xf8)==0xf0) +#define xbyte(c) (((c)&0xc0)==0x80) extern char **argp; extern char **args; |