str.c (3f330d7d1a3fe98c53faf01d0f30c0a9fbb37c41) | str.c (85f6c317eaba505a515597b930b9e87a13ab81c3) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 202 unchanged lines hidden (view full) --- 211 212static int 213c_class(a, b) 214 const void *a, *b; 215{ 216 return (strcmp(((const CLASS *)a)->name, ((const CLASS *)b)->name)); 217} 218 | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 202 unchanged lines hidden (view full) --- 211 212static int 213c_class(a, b) 214 const void *a, *b; 215{ 216 return (strcmp(((const CLASS *)a)->name, ((const CLASS *)b)->name)); 217} 218 |
219/* 220 * English doesn't have any equivalence classes, so for now 221 * we just syntax check and grab the character. 222 */ | |
223static void 224genequiv(s) 225 STR *s; 226{ | 219static void 220genequiv(s) 221 STR *s; 222{ |
223 int i, p, pri; 224 char src[2], dst[3]; 225 |
|
227 if (*s->str == '\\') { 228 s->equiv[0] = backslash(s); 229 if (*s->str != '=') 230 errx(1, "misplaced equivalence equals sign"); 231 } else { 232 s->equiv[0] = s->str[0]; 233 if (s->str[1] != '=') 234 errx(1, "misplaced equivalence equals sign"); 235 } | 226 if (*s->str == '\\') { 227 s->equiv[0] = backslash(s); 228 if (*s->str != '=') 229 errx(1, "misplaced equivalence equals sign"); 230 } else { 231 s->equiv[0] = s->str[0]; 232 if (s->str[1] != '=') 233 errx(1, "misplaced equivalence equals sign"); 234 } |
235 236 /* 237 * Calculate the set of all characters in the same equivalence class 238 * as the specified character (they will have the same primary 239 * collation weights). 240 * XXX Knows too much about how strxfrm() is implemented. Assumes 241 * it fills the string with primary collation weight bytes. Only one- 242 * to-one mappings are supported. 243 */ 244 src[0] = s->equiv[0]; 245 src[1] = '\0'; 246 if (strxfrm(dst, src, sizeof(dst)) == 1) { 247 pri = (unsigned char)*dst; 248 for (p = 1, i = 1; i < NCHARS; i++) { 249 *src = i; 250 if (strxfrm(dst, src, sizeof(dst)) == 1 && pri && 251 pri == (unsigned char)*dst) 252 s->equiv[p++] = i; 253 } 254 s->equiv[p] = OOBCH; 255 } 256 |
|
236 s->str += 2; 237 s->cnt = 0; 238 s->state = SET; 239 s->set = s->equiv; 240} 241 242static int 243genrange(s) --- 102 unchanged lines hidden --- | 257 s->str += 2; 258 s->cnt = 0; 259 s->state = SET; 260 s->set = s->equiv; 261} 262 263static int 264genrange(s) --- 102 unchanged lines hidden --- |