Strongly link tr and sed into system() and popen()

This commit is contained in:
Justine Tunney 2024-11-15 21:19:08 -08:00
parent cafdb456ed
commit 1312f60245
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
9 changed files with 51 additions and 22 deletions

View file

@ -3,6 +3,8 @@
#include "libc/limits.h"
COSMOPOLITAN_C_START_
#define next _tr_next
typedef struct {
enum { STRING1, STRING2 } which;
enum { EOS, INFINITE, NORMAL, RANGE, SEQUENCE, SET } state;

11
third_party/tr/tr.c vendored
View file

@ -42,8 +42,8 @@
#include "third_party/tr/cmd.h"
#include "third_party/tr/extern.h"
int delete[NCHARS], squeeze[NCHARS];
int translate[NCHARS] = {
static int delete[NCHARS], squeeze[NCHARS];
static int translate[NCHARS] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* ASCII */
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
@ -78,8 +78,8 @@ int translate[NCHARS] = {
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
};
STR s1 = { STRING1, NORMAL, 0, OOBCH, { 0, OOBCH }, NULL, NULL };
STR s2 = { STRING2, NORMAL, 0, OOBCH, { 0, OOBCH }, NULL, NULL };
static STR s1 = { STRING1, NORMAL, 0, OOBCH, { 0, OOBCH }, NULL, NULL };
static STR s2 = { STRING2, NORMAL, 0, OOBCH, { 0, OOBCH }, NULL, NULL };
static void setup(int *, char *, STR *, int);
static void usage(void);
@ -90,9 +90,6 @@ _tr(int argc, char *argv[])
int ch, cnt, lastch, *p;
int cflag, dflag, sflag;
if (pledge("stdio", NULL) == -1)
err(1, "pledge");
cflag = dflag = sflag = 0;
while ((ch = getopt(argc, argv, "Ccds")) != -1)
switch(ch) {