Changeset 1554 for zzuf/trunk/src/libzzuf.c
- Timestamp:
- 01/04/07 02:09:04 (6 years ago)
- File:
-
- 1 edited
-
zzuf/trunk/src/libzzuf.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
zzuf/trunk/src/libzzuf.c
r1553 r1554 28 28 #include <unistd.h> 29 29 #include <stdlib.h> 30 #include <string.h> 30 31 #include <fcntl.h> 31 32 #include <regex.h> … … 46 47 int _zz_signal = 0; 47 48 49 /* Global tables */ 50 int _zz_protect[256]; 51 48 52 /* Local variables */ 49 53 static regex_t * re_include = NULL; … … 51 55 52 56 /* Local prototypes */ 57 static void _zz_protect_init(char const *); 53 58 static void _zz_fd_init(void); 54 59 static void _zz_fd_fini(void); … … 75 80 _zz_ratio = 5.0f; 76 81 82 tmp = getenv("ZZUF_PROTECT"); 83 if(tmp && *tmp) 84 _zz_protect_init(tmp); 85 77 86 tmp = getenv("ZZUF_INCLUDE"); 78 87 if(tmp && *tmp) … … 112 121 { 113 122 _zz_fd_fini(); 123 } 124 125 /* Byte list stuff */ 126 static void _zz_protect_init(char const *list) 127 { 128 static char const hex[] = "0123456789abcdef0123456789ABCDEF"; 129 char const *tmp; 130 int a, b; 131 132 memset(_zz_protect, 0, 256 * sizeof(int)); 133 134 for(tmp = list, a = b = -1; *tmp; tmp++) 135 { 136 int new; 137 138 if(*tmp == '\\' && tmp[1] == '\0') 139 new = '\\'; 140 else if(*tmp == '\\') 141 { 142 tmp++; 143 if(*tmp == 'n') 144 new = '\n'; 145 else if(*tmp == 'r') 146 new = '\r'; 147 else if(*tmp == 't') 148 new = '\t'; 149 else if(*tmp == '0') 150 new = '\0'; 151 else if((*tmp == 'x' || *tmp == 'X') 152 && tmp[1] && strchr(hex, tmp[1]) 153 && tmp[2] && strchr(hex, tmp[2])) 154 { 155 new = ((strchr(hex, tmp[1]) - hex) & 0xf) << 4; 156 new |= (strchr(hex, tmp[2]) - hex) & 0xf; 157 tmp += 2; 158 } 159 else 160 new = (unsigned char)*tmp; /* XXX: OK for \\, but what else? */ 161 } 162 else 163 new = (unsigned char)*tmp; 164 165 if(a != -1 && b == '-' && a <= new) 166 { 167 while(a <= new) 168 _zz_protect[a++] = 1; 169 a = b = -1; 170 } 171 else 172 { 173 if(a != -1) 174 _zz_protect[a] = 1; 175 a = b; 176 b = new; 177 } 178 } 179 180 if(a != -1) 181 _zz_protect[a] = 1; 182 if(b != -1) 183 _zz_protect[b] = 1; 114 184 } 115 185
Note: See TracChangeset
for help on using the changeset viewer.
