Mercurial > heirloom-ed
diff ed.c @ 4:4165f1b57d18 default tip
Become SUSv3 compatible and thus remove own regexp code
The Heirloom tools can be compiled to comply to several standards.
This version does not need this flexibility. We can omit the
regexp code and use the system's, by using the SU3 variant of ed.
This is the latest of the supported standards.
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Mon, 13 Apr 2015 17:26:51 +0200 |
parents | ac52712b2b5e |
children |
line wrap: on
line diff
--- a/ed.c Sun Apr 12 21:45:34 2015 +0200 +++ b/ed.c Mon Apr 13 17:26:51 2015 +0200 @@ -47,15 +47,7 @@ #else #define USED #endif -#if defined (SU3) static const char sccsid[] USED = "@(#)ed_su3.sl 1.99 (gritter) 7/27/06"; -#elif defined (SUS) -static const char sccsid[] USED = "@(#)ed_sus.sl 1.99 (gritter) 7/27/06"; -#elif defined (S42) -static const char sccsid[] USED = "@(#)ed_s42.sl 1.99 (gritter) 7/27/06"; -#else /* !SU3, !SUS, !S42 */ -static const char sccsid[] USED = "@(#)ed.sl 1.99 (gritter) 7/27/06"; -#endif /* !SU3, !SUS, !S42 */ #include <sys/types.h> #include <sys/stat.h> @@ -238,8 +230,6 @@ #define ERROR(c) cmplerr(c) static wint_t GETWC(char *); -#if defined (SUS) || defined (S42) || defined (SU3) - #include <regex.h> #define NBRA 9 @@ -254,12 +244,6 @@ static char *compile(char *, char *, const char *, int); static int step(const char *, const char *); -#else /* !SUS, !S42, !SU3 */ - -#include <regexp.h> - -#endif /* !SUS, !S42, !SU3 */ - int main(int argc, char **argv) { @@ -267,9 +251,7 @@ void (*oldintr)(int); progname = basename(argv[0]); -#if defined (SUS) || defined (S42) || defined (SU3) setlocale(LC_COLLATE, ""); -#endif setlocale(LC_CTYPE, ""); mb_cur_max = MB_CUR_MAX; myuid = getuid(); @@ -397,19 +379,15 @@ continue; case 'c': -#if defined (SU3) if (addr1 == zero && addr1+1 <= dol) { if (addr1 == addr2) addr2++; addr1++; } -#endif /* SU3 */ delete(); append(gettty, addr1-1); -#if defined (SUS) || defined (SU3) if (dot == addr1-1 && addr1 <= dol) dot = addr1; -#endif /* SUS || SU3 */ continue; case 'd': @@ -466,7 +444,6 @@ case 'i': setdot(); -#if defined (SU3) if (addr1 == zero) { if (addr1 == addr2) addr2++; @@ -474,7 +451,6 @@ if (dol != zero) nonzero(); } else -#endif /* SU3 */ nonzero(); newline(); checkpoint(); @@ -1055,10 +1031,6 @@ linebuf[i++] = 0; if (linebuf[0]=='.' && linebuf[1]==0) return(EOF); -#if !defined (SUS) && !defined (SU3) - if (linebuf[0]=='\\' && linebuf[1]=='.' && linebuf[2]==0) - linebuf[0]='.', linebuf[1]=0; -#endif return(0); } @@ -1730,7 +1702,6 @@ } i = loc2 - linebuf; loc2 = j + linebuf; -#if defined (SUS) || defined (SU3) || defined (S42) if (loc1 == &linebuf[i]) { int n; wchar_t wc; @@ -1739,7 +1710,6 @@ else loc2++; } -#endif /* SUS || SU3 || S42 */ while (genbuf[j++] = linebuf[i++]) if (j >= LBSIZE) growlb("line too long"); @@ -1867,9 +1837,6 @@ { const char *msg; -#if !defined (SUS) && !defined (S42) && !defined (SU3) - expbuf[0] = 0; -#endif switch (c) { case 11: msg = "Range endpoint too large"; @@ -1987,10 +1954,7 @@ putchr('\\'); putchr('\n'); } - if (n<0 || -#if defined (SUS) || defined (S42) || defined (SU3) - c == '\\' || -#endif /* SUS || S42 || SU3 */ + if (n<0 || c == '\\' || !(mb_cur_max>1 ? iswprint(c) : isprint(c))) { if (n<0) n = 1; @@ -2005,9 +1969,7 @@ col++; } } -#if defined (SUS) || defined (S42) || defined (SU3) putchr('$'); -#endif putchr('\n'); } @@ -2016,24 +1978,6 @@ { int cad = 1, d; -#if !defined (SUS) && !defined (S42) && !defined (SU3) - if (c=='\t') { - c = '>'; - goto esc; - } - if (c=='\b') { - c = '<'; - esc: - putchr('-'); - putchr('\b'); - putchr(c); - } else if (c == '\n') { - putchr('\\'); - putchr('0'); - putchr('0'); - putchr('0'); - cad = 4; -#else /* !SUS, !S42, !SU3 */ if (c == '\n') c = '\0'; if (c == '\\') { @@ -2064,7 +2008,6 @@ putchr('\\'); putchr('v'); cad = 2; -#endif /* !SUS, !S42, !SU3 */ } else { putchr('\\'); putchr(((c&~077)>>6)+'0'); @@ -2281,7 +2224,6 @@ file[0] = savedfile[0] = 0; } -#if defined (SUS) || defined (S42) || defined (SU3) union ptrstore { void *vp; char bp[sizeof (void *)]; @@ -2385,7 +2327,7 @@ #ifdef REG_ANGLES reflags |= REG_ANGLES; #endif -#if defined (SU3) && defined (REG_AVOIDNULL) +#ifdef REG_AVOIDNULL reflags |= REG_AVOIDNULL; #endif if (op[0]) @@ -2453,7 +2395,6 @@ } return res == 0; } -#endif /* SUS || S42 || SU3 */ static void help(void)