mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-18 08:30:30 +00:00
Strongly link tr and sed into system() and popen()
This commit is contained in:
parent
cafdb456ed
commit
1312f60245
9 changed files with 51 additions and 22 deletions
1
third_party/sed/defs.h
vendored
1
third_party/sed/defs.h
vendored
|
@ -3,6 +3,7 @@
|
|||
#include "libc/calls/typedef/u.h"
|
||||
#include "libc/limits.h"
|
||||
#include "third_party/regex/regex.h"
|
||||
#include "third_party/sed/shade.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
/*
|
||||
|
|
1
third_party/sed/extern.h
vendored
1
third_party/sed/extern.h
vendored
|
@ -4,6 +4,7 @@
|
|||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/regex/regex.h"
|
||||
#include "third_party/sed/defs.h"
|
||||
#include "third_party/sed/shade.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern struct s_command *prog;
|
||||
|
|
31
third_party/sed/shade.h
vendored
Normal file
31
third_party/sed/shade.h
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef COSMOPOLITAN_THIRD_PARTY_SED_SHADE_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_SED_SHADE_H_
|
||||
|
||||
#define prog _sed_prog
|
||||
#define appends_ _sed_appends_
|
||||
#define g_match _sed_g_match
|
||||
#define maxnsub _sed_maxnsub
|
||||
#define linenum _sed_linenum
|
||||
#define appendnum _sed_appendnum
|
||||
#define aflag _sed_aflag
|
||||
#define eflag _sed_eflag
|
||||
#define nflag _sed_nflag
|
||||
#define fname _sed_fname
|
||||
#define outfname _sed_outfname
|
||||
#define infile _sed_infile
|
||||
#define outfile _sed_outfile
|
||||
#define rflags _sed_rflags
|
||||
#define cfclose _sed_cfclose
|
||||
#define compile _sed_compile
|
||||
#define cspace _sed_cspace
|
||||
#define cu_fgets _sed_cu_fgets
|
||||
#define mf_fgets _sed_mf_fgets
|
||||
#define lastline _sed_lastline
|
||||
#define process _sed_process
|
||||
#define resetstate _sed_resetstate
|
||||
#define strregerror _sed_strregerror
|
||||
#define xmalloc _sed_xmalloc
|
||||
#define xrealloc _sed_xrealloc
|
||||
#define xcalloc _sed_xcalloc
|
||||
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_SED_SHADE_H_ */
|
2
third_party/tr/extern.h
vendored
2
third_party/tr/extern.h
vendored
|
@ -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
11
third_party/tr/tr.c
vendored
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue