heirloom-ed
diff ed.c @ 4:4165f1b57d18
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 diff
1.1 --- a/ed.c Sun Apr 12 21:45:34 2015 +0200 1.2 +++ b/ed.c Mon Apr 13 17:26:51 2015 +0200 1.3 @@ -47,15 +47,7 @@ 1.4 #else 1.5 #define USED 1.6 #endif 1.7 -#if defined (SU3) 1.8 static const char sccsid[] USED = "@(#)ed_su3.sl 1.99 (gritter) 7/27/06"; 1.9 -#elif defined (SUS) 1.10 -static const char sccsid[] USED = "@(#)ed_sus.sl 1.99 (gritter) 7/27/06"; 1.11 -#elif defined (S42) 1.12 -static const char sccsid[] USED = "@(#)ed_s42.sl 1.99 (gritter) 7/27/06"; 1.13 -#else /* !SU3, !SUS, !S42 */ 1.14 -static const char sccsid[] USED = "@(#)ed.sl 1.99 (gritter) 7/27/06"; 1.15 -#endif /* !SU3, !SUS, !S42 */ 1.16 1.17 #include <sys/types.h> 1.18 #include <sys/stat.h> 1.19 @@ -238,8 +230,6 @@ 1.20 #define ERROR(c) cmplerr(c) 1.21 static wint_t GETWC(char *); 1.22 1.23 -#if defined (SUS) || defined (S42) || defined (SU3) 1.24 - 1.25 #include <regex.h> 1.26 1.27 #define NBRA 9 1.28 @@ -254,12 +244,6 @@ 1.29 static char *compile(char *, char *, const char *, int); 1.30 static int step(const char *, const char *); 1.31 1.32 -#else /* !SUS, !S42, !SU3 */ 1.33 - 1.34 -#include <regexp.h> 1.35 - 1.36 -#endif /* !SUS, !S42, !SU3 */ 1.37 - 1.38 int 1.39 main(int argc, char **argv) 1.40 { 1.41 @@ -267,9 +251,7 @@ 1.42 void (*oldintr)(int); 1.43 1.44 progname = basename(argv[0]); 1.45 -#if defined (SUS) || defined (S42) || defined (SU3) 1.46 setlocale(LC_COLLATE, ""); 1.47 -#endif 1.48 setlocale(LC_CTYPE, ""); 1.49 mb_cur_max = MB_CUR_MAX; 1.50 myuid = getuid(); 1.51 @@ -397,19 +379,15 @@ 1.52 continue; 1.53 1.54 case 'c': 1.55 -#if defined (SU3) 1.56 if (addr1 == zero && addr1+1 <= dol) { 1.57 if (addr1 == addr2) 1.58 addr2++; 1.59 addr1++; 1.60 } 1.61 -#endif /* SU3 */ 1.62 delete(); 1.63 append(gettty, addr1-1); 1.64 -#if defined (SUS) || defined (SU3) 1.65 if (dot == addr1-1 && addr1 <= dol) 1.66 dot = addr1; 1.67 -#endif /* SUS || SU3 */ 1.68 continue; 1.69 1.70 case 'd': 1.71 @@ -466,7 +444,6 @@ 1.72 1.73 case 'i': 1.74 setdot(); 1.75 -#if defined (SU3) 1.76 if (addr1 == zero) { 1.77 if (addr1 == addr2) 1.78 addr2++; 1.79 @@ -474,7 +451,6 @@ 1.80 if (dol != zero) 1.81 nonzero(); 1.82 } else 1.83 -#endif /* SU3 */ 1.84 nonzero(); 1.85 newline(); 1.86 checkpoint(); 1.87 @@ -1055,10 +1031,6 @@ 1.88 linebuf[i++] = 0; 1.89 if (linebuf[0]=='.' && linebuf[1]==0) 1.90 return(EOF); 1.91 -#if !defined (SUS) && !defined (SU3) 1.92 - if (linebuf[0]=='\\' && linebuf[1]=='.' && linebuf[2]==0) 1.93 - linebuf[0]='.', linebuf[1]=0; 1.94 -#endif 1.95 return(0); 1.96 } 1.97 1.98 @@ -1730,7 +1702,6 @@ 1.99 } 1.100 i = loc2 - linebuf; 1.101 loc2 = j + linebuf; 1.102 -#if defined (SUS) || defined (SU3) || defined (S42) 1.103 if (loc1 == &linebuf[i]) { 1.104 int n; 1.105 wchar_t wc; 1.106 @@ -1739,7 +1710,6 @@ 1.107 else 1.108 loc2++; 1.109 } 1.110 -#endif /* SUS || SU3 || S42 */ 1.111 while (genbuf[j++] = linebuf[i++]) 1.112 if (j >= LBSIZE) 1.113 growlb("line too long"); 1.114 @@ -1867,9 +1837,6 @@ 1.115 { 1.116 const char *msg; 1.117 1.118 -#if !defined (SUS) && !defined (S42) && !defined (SU3) 1.119 - expbuf[0] = 0; 1.120 -#endif 1.121 switch (c) { 1.122 case 11: 1.123 msg = "Range endpoint too large"; 1.124 @@ -1987,10 +1954,7 @@ 1.125 putchr('\\'); 1.126 putchr('\n'); 1.127 } 1.128 - if (n<0 || 1.129 -#if defined (SUS) || defined (S42) || defined (SU3) 1.130 - c == '\\' || 1.131 -#endif /* SUS || S42 || SU3 */ 1.132 + if (n<0 || c == '\\' || 1.133 !(mb_cur_max>1 ? iswprint(c) : isprint(c))) { 1.134 if (n<0) 1.135 n = 1; 1.136 @@ -2005,9 +1969,7 @@ 1.137 col++; 1.138 } 1.139 } 1.140 -#if defined (SUS) || defined (S42) || defined (SU3) 1.141 putchr('$'); 1.142 -#endif 1.143 putchr('\n'); 1.144 } 1.145 1.146 @@ -2016,24 +1978,6 @@ 1.147 { 1.148 int cad = 1, d; 1.149 1.150 -#if !defined (SUS) && !defined (S42) && !defined (SU3) 1.151 - if (c=='\t') { 1.152 - c = '>'; 1.153 - goto esc; 1.154 - } 1.155 - if (c=='\b') { 1.156 - c = '<'; 1.157 - esc: 1.158 - putchr('-'); 1.159 - putchr('\b'); 1.160 - putchr(c); 1.161 - } else if (c == '\n') { 1.162 - putchr('\\'); 1.163 - putchr('0'); 1.164 - putchr('0'); 1.165 - putchr('0'); 1.166 - cad = 4; 1.167 -#else /* !SUS, !S42, !SU3 */ 1.168 if (c == '\n') 1.169 c = '\0'; 1.170 if (c == '\\') { 1.171 @@ -2064,7 +2008,6 @@ 1.172 putchr('\\'); 1.173 putchr('v'); 1.174 cad = 2; 1.175 -#endif /* !SUS, !S42, !SU3 */ 1.176 } else { 1.177 putchr('\\'); 1.178 putchr(((c&~077)>>6)+'0'); 1.179 @@ -2281,7 +2224,6 @@ 1.180 file[0] = savedfile[0] = 0; 1.181 } 1.182 1.183 -#if defined (SUS) || defined (S42) || defined (SU3) 1.184 union ptrstore { 1.185 void *vp; 1.186 char bp[sizeof (void *)]; 1.187 @@ -2385,7 +2327,7 @@ 1.188 #ifdef REG_ANGLES 1.189 reflags |= REG_ANGLES; 1.190 #endif 1.191 -#if defined (SU3) && defined (REG_AVOIDNULL) 1.192 +#ifdef REG_AVOIDNULL 1.193 reflags |= REG_AVOIDNULL; 1.194 #endif 1.195 if (op[0]) 1.196 @@ -2453,7 +2395,6 @@ 1.197 } 1.198 return res == 0; 1.199 } 1.200 -#endif /* SUS || S42 || SU3 */ 1.201 1.202 static void 1.203 help(void)