Print this page
9083 replace regex implementation with tre
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libc/port/locale/collate.c
+++ new/usr/src/lib/libc/port/locale/collate.c
1 1 /*
2 2 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
3 3 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
4 4 * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
5 5 * at Electronni Visti IA, Kiev, Ukraine.
6 6 * All rights reserved.
7 7 *
8 8 * Redistribution and use in source and binary forms, with or without
9 9 * modification, are permitted provided that the following conditions
10 10 * are met:
11 11 * 1. Redistributions of source code must retain the above copyright
12 12 * notice, this list of conditions and the following disclaimer.
13 13 * 2. Redistributions in binary form must reproduce the above copyright
14 14 * notice, this list of conditions and the following disclaimer in the
15 15 * documentation and/or other materials provided with the distribution.
16 16 *
17 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
18 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
21 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 27 * SUCH DAMAGE.
28 28 */
29 29
30 30 #include "lint.h"
31 31 #include "file64.h"
32 32 #include <stdio.h>
33 33 #include <stdlib.h>
34 34 #include <stddef.h>
35 35 #include <string.h>
36 36 #include <wchar.h>
37 37 #include <errno.h>
38 38 #include <unistd.h>
39 39 #include <ctype.h>
40 40 #include <unistd.h>
41 41 #include <fcntl.h>
42 42 #include <assert.h>
43 43 #include <sys/stat.h>
44 44 #include <sys/mman.h>
45 45
46 46 #include "collate.h"
47 47 #include "localeimpl.h"
48 48
49 49 /* Check file format vs libc runtime. (See collatefile.h) */
50 50 #if COLL_WEIGHTS_MAX != COLLATE_WEIGHTS_MAX
51 51 #error "COLL_WEIGHTS_MAX != COLLATE_WEIGHTS_MAX"
52 52 #endif
53 53
54 54 /*
55 55 * See the comments in usr/src/cmd/localedef/collate.c for further
56 56 * information. It would also be very helpful to have a copy of the
57 57 * POSIX standard for collation (in the locale format manual page)
58 58 * handy (www.opengroup.org).
59 59 */
60 60
61 61 /*
62 62 * POSIX uses empty tables and falls down to strcmp.
63 63 */
64 64 struct lc_collate lc_collate_posix = {
65 65 .lc_is_posix = 1,
66 66 };
67 67
68 68 struct locdata __posix_collate_locdata = {
69 69 .l_lname = "C",
70 70 .l_data = { &lc_collate_posix }
71 71 };
72 72
73 73
74 74 struct locdata *
75 75 __lc_collate_load(const char *locname)
76 76 {
77 77 int i, chains, z;
78 78 char buf[PATH_MAX];
79 79 char *TMP;
80 80 char *map;
81 81 collate_info_t *info;
82 82 struct stat sbuf;
83 83 int fd;
84 84 struct locdata *ldata;
85 85 struct lc_collate *lcc;
86 86
87 87 /*
88 88 * Slurp the locale file into the cache.
89 89 */
90 90
91 91 (void) snprintf(buf, sizeof (buf), "%s/%s/LC_COLLATE/LCL_DATA",
92 92 _PathLocale, locname);
93 93
94 94 if ((fd = open(buf, O_RDONLY)) < 0) {
95 95 errno = EINVAL;
96 96 return (NULL);
97 97 }
98 98 if (fstat(fd, &sbuf) < 0) {
99 99 (void) close(fd);
100 100 errno = EINVAL;
101 101 return (NULL);
102 102 }
103 103 if (sbuf.st_size < (COLLATE_STR_LEN + sizeof (info))) {
104 104 (void) close(fd);
105 105 errno = EINVAL;
106 106 return (NULL);
107 107 }
108 108 map = mmap(NULL, sbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
109 109 (void) close(fd);
110 110 if ((TMP = map) == NULL) {
111 111 errno = EINVAL;
112 112 return (NULL);
113 113 }
114 114
115 115 if (strncmp(TMP, COLLATE_VERSION, COLLATE_STR_LEN) != 0) {
116 116 (void) munmap(map, sbuf.st_size);
117 117 errno = EINVAL;
118 118 return (NULL);
119 119 }
120 120 TMP += COLLATE_STR_LEN;
121 121
122 122 info = (void *)TMP;
123 123 TMP += sizeof (*info);
124 124
125 125 if ((info->directive_count < 1) ||
126 126 (info->directive_count >= COLL_WEIGHTS_MAX) ||
127 127 ((chains = info->chain_count) < 0)) {
128 128 (void) munmap(map, sbuf.st_size);
129 129 errno = EINVAL;
130 130 return (NULL);
131 131 }
132 132
133 133 i = (sizeof (collate_char_t) * (UCHAR_MAX + 1)) +
134 134 (sizeof (collate_chain_t) * chains) +
135 135 (sizeof (collate_large_t) * info->large_count);
136 136 for (z = 0; z < info->directive_count; z++) {
137 137 i += sizeof (collate_subst_t) * info->subst_count[z];
138 138 }
139 139 if (i != (sbuf.st_size - (TMP - map))) {
140 140 (void) munmap(map, sbuf.st_size);
141 141 errno = EINVAL;
142 142 return (NULL);
143 143 }
144 144
145 145
146 146 if ((ldata = __locdata_alloc(locname, sizeof (*lcc))) == NULL) {
147 147 (void) munmap(map, sbuf.st_size);
148 148 return (NULL);
149 149 }
150 150 lcc = ldata->l_data[0];
151 151 ldata->l_map = map;
152 152 ldata->l_map_len = sbuf.st_size;
153 153
154 154 lcc->lc_info = info;
155 155 lcc->lc_directive_count = info->directive_count;
156 156 lcc->lc_large_count = info->large_count;
157 157
158 158 for (z = 0; z < COLL_WEIGHTS_MAX; z++) {
159 159 lcc->lc_directive[z] = info->directive[z];
160 160 lcc->lc_subst_count[z] = info->subst_count[z];
161 161 lcc->lc_pri_count[z] = info->pri_count[z];
162 162 lcc->lc_undef_pri[z] = info->undef_pri[z];
163 163 }
164 164
165 165 lcc->lc_char_table = (void *)TMP;
166 166 TMP += sizeof (collate_char_t) * (UCHAR_MAX + 1);
167 167
168 168 for (z = 0; z < lcc->lc_directive_count; z++) {
169 169 int count;
170 170 if ((count = lcc->lc_subst_count[z]) > 0) {
171 171 lcc->lc_subst_table[z] = (void *)TMP;
172 172 TMP += count * sizeof (collate_subst_t);
173 173 } else {
174 174 lcc->lc_subst_table[z] = NULL;
175 175 }
176 176 }
177 177
178 178 if (chains > 0) {
179 179 lcc->lc_chain_table = (void *)TMP;
180 180 TMP += chains * sizeof (collate_chain_t);
181 181 } else
182 182 lcc->lc_chain_table = NULL;
183 183 lcc->lc_chain_count = chains;
184 184 if (lcc->lc_large_count > 0)
185 185 lcc->lc_large_table = (void *)TMP;
186 186 else
187 187 lcc->lc_large_table = NULL;
188 188
189 189 return (ldata);
190 190 }
191 191
192 192 static const int32_t *
193 193 substsearch(const struct lc_collate *lcc, const wchar_t key, int pass)
194 194 {
195 195 const collate_subst_t *p;
196 196 int n = lcc->lc_subst_count[pass];
197 197
198 198 if (n == 0)
199 199 return (NULL);
200 200
201 201 if (pass >= lcc->lc_directive_count)
202 202 return (NULL);
203 203
204 204 if (!(key & COLLATE_SUBST_PRIORITY))
205 205 return (NULL);
206 206
207 207 p = lcc->lc_subst_table[pass] + (key & ~COLLATE_SUBST_PRIORITY);
208 208 assert(p->key == key);
209 209 return (p->pri);
210 210 }
211 211
212 212 static collate_chain_t *
213 213 chainsearch(const struct lc_collate *lcc, const wchar_t *key, int *len)
214 214 {
215 215 int low = 0;
216 216 int high = lcc->lc_info->chain_count - 1;
217 217 int next, compar, l;
218 218 collate_chain_t *p;
219 219 collate_chain_t *tab = lcc->lc_chain_table;
220 220
221 221 if (high < 0)
222 222 return (NULL);
223 223
224 224 while (low <= high) {
225 225 next = (low + high) / 2;
226 226 p = tab + next;
227 227 compar = *key - *p->str;
228 228 if (compar == 0) {
229 229 l = wcsnlen(p->str, COLLATE_STR_LEN);
230 230 compar = wcsncmp(key, p->str, l);
231 231 if (compar == 0) {
232 232 *len = l;
233 233 return (p);
234 234 }
235 235 }
236 236 if (compar > 0)
237 237 low = next + 1;
238 238 else
239 239 high = next - 1;
240 240 }
241 241 return (NULL);
242 242 }
243 243
244 244 static collate_large_t *
245 245 largesearch(const struct lc_collate *lcc, const wchar_t key)
246 246 {
247 247 int low = 0;
248 248 int high = lcc->lc_info->large_count - 1;
249 249 int next, compar;
250 250 collate_large_t *p;
251 251 collate_large_t *tab = lcc->lc_large_table;
252 252
253 253 if (high < 0)
254 254 return (NULL);
255 255
256 256 while (low <= high) {
257 257 next = (low + high) / 2;
258 258 p = tab + next;
259 259 compar = key - p->val;
260 260 if (compar == 0)
261 261 return (p);
262 262 if (compar > 0)
263 263 low = next + 1;
264 264 else
265 265 high = next - 1;
266 266 }
267 267 return (NULL);
268 268 }
269 269
270 270 void
271 271 _collate_lookup(const struct lc_collate *lcc, const wchar_t *t,
272 272 int *len, int *pri, int which, const int **state)
273 273 {
274 274 collate_chain_t *p2;
275 275 collate_large_t *match;
276 276 int p, l;
277 277 const int *sptr;
278 278
279 279 /*
280 280 * If this is the "last" pass for the UNDEFINED, then
281 281 * we just return the priority itself.
282 282 */
283 283 if (which >= lcc->lc_directive_count) {
284 284 *pri = *t;
285 285 *len = 1;
286 286 *state = NULL;
287 287 return;
288 288 }
289 289
290 290 /*
291 291 * If we have remaining substitution data from a previous
292 292 * call, consume it first.
293 293 */
294 294 if ((sptr = *state) != NULL) {
295 295 *pri = *sptr;
296 296 sptr++;
297 297 if ((sptr == *state) || (sptr == NULL))
298 298 *state = NULL;
299 299 else
300 300 *state = sptr;
301 301 *len = 0;
302 302 return;
303 303 }
304 304
305 305 /* No active substitutions */
306 306 *len = 1;
307 307
308 308 /*
309 309 * Check for composites such as dipthongs that collate as a
310 310 * single element (aka chains or collating-elements).
311 311 */
312 312 if (((p2 = chainsearch(lcc, t, &l)) != NULL) &&
313 313 ((p = p2->pri[which]) >= 0)) {
314 314
315 315 *len = l;
316 316 *pri = p;
317 317
318 318 } else if (*t <= UCHAR_MAX) {
319 319
320 320 /*
321 321 * Character is a small (8-bit) character.
322 322 * We just look these up directly for speed.
323 323 */
324 324 *pri = lcc->lc_char_table[*t].pri[which];
325 325
326 326 } else if ((lcc->lc_info->large_count > 0) &&
327 327 ((match = largesearch(lcc, *t)) != NULL)) {
328 328
329 329 /*
330 330 * Character was found in the extended table.
331 331 */
332 332 *pri = match->pri.pri[which];
333 333
334 334 } else {
335 335 /*
336 336 * Character lacks a specific definition.
337 337 */
338 338 if (lcc->lc_directive[which] & DIRECTIVE_UNDEFINED) {
339 339 /* Mask off sign bit to prevent ordering confusion. */
340 340 *pri = (*t & COLLATE_MAX_PRIORITY);
341 341 } else {
342 342 *pri = lcc->lc_undef_pri[which];
343 343 }
344 344 /* No substitutions for undefined characters! */
345 345 return;
346 346 }
347 347
348 348 /*
349 349 * Try substituting (expanding) the character. We are
350 350 * currently doing this *after* the chain compression. I
351 351 * think it should not matter, but this way might be slightly
352 352 * faster.
353 353 *
354 354 * We do this after the priority search, as this will help us
355 355 * to identify a single key value. In order for this to work,
356 356 * its important that the priority assigned to a given element
357 357 * to be substituted be unique for that level. The localedef
358 358 * code ensures this for us.
359 359 */
360 360 if ((sptr = substsearch(lcc, *pri, which)) != NULL) {
361 361 if ((*pri = *sptr) > 0) {
362 362 sptr++;
363 363 *state = *sptr ? sptr : NULL;
364 364 }
365 365 }
366 366
367 367 }
368 368
369 369 /*
370 370 * This is the meaty part of wcsxfrm & strxfrm. Note that it does
371 371 * NOT NULL terminate. That is left to the caller.
372 372 */
373 373 size_t
374 374 _collate_wxfrm(const struct lc_collate *lcc, const wchar_t *src, wchar_t *xf,
375 375 size_t room)
376 376 {
377 377 int pri;
378 378 int len;
379 379 const wchar_t *t;
380 380 wchar_t *tr = NULL;
381 381 int direc;
382 382 int pass;
383 383 const int32_t *state;
384 384 size_t want = 0;
385 385 size_t need = 0;
386 386 int ndir = lcc->lc_directive_count;
387 387
388 388 assert(src);
389 389
390 390 for (pass = 0; pass <= ndir; pass++) {
391 391
392 392 state = NULL;
393 393
394 394 if (pass != 0) {
395 395 /* insert level separator from the previous pass */
396 396 if (room) {
397 397 *xf++ = 1;
398 398 room--;
399 399 }
400 400 want++;
401 401 }
402 402
403 403 /* special pass for undefined */
404 404 if (pass == ndir) {
405 405 direc = DIRECTIVE_FORWARD | DIRECTIVE_UNDEFINED;
406 406 } else {
407 407 direc = lcc->lc_directive[pass];
408 408 }
409 409
410 410 t = src;
411 411
412 412 if (direc & DIRECTIVE_BACKWARD) {
413 413 wchar_t *bp, *fp, c;
414 414 if (tr)
415 415 free(tr);
416 416 if ((tr = wcsdup(t)) == NULL) {
417 417 errno = ENOMEM;
418 418 goto fail;
419 419 }
420 420 bp = tr;
421 421 fp = tr + wcslen(tr) - 1;
422 422 while (bp < fp) {
423 423 c = *bp;
424 424 *bp++ = *fp;
425 425 *fp-- = c;
426 426 }
427 427 t = (const wchar_t *)tr;
428 428 }
429 429
430 430 if (direc & DIRECTIVE_POSITION) {
431 431 while (*t || state) {
432 432 _collate_lookup(lcc, t, &len, &pri, pass,
433 433 &state);
434 434 t += len;
435 435 if (pri <= 0) {
436 436 if (pri < 0) {
437 437 errno = EINVAL;
438 438 goto fail;
439 439 }
440 440 state = NULL;
441 441 pri = COLLATE_MAX_PRIORITY;
442 442 }
443 443 if (room) {
444 444 *xf++ = pri;
445 445 room--;
446 446 }
447 447 want++;
448 448 need = want;
449 449 }
450 450 } else {
451 451 while (*t || state) {
452 452 _collate_lookup(lcc, t, &len, &pri, pass,
453 453 &state);
454 454 t += len;
455 455 if (pri <= 0) {
456 456 if (pri < 0) {
457 457 errno = EINVAL;
458 458 goto fail;
459 459 }
460 460 state = NULL;
461 461 continue;
462 462 }
463 463 if (room) {
464 464 *xf++ = pri;
465 465 room--;
466 466 }
467 467 want++;
468 468 need = want;
469 469 }
470 470 }
471 471 }
472 472
473 473 end:
474 474 if (tr)
475 475 free(tr);
476 476 return (need);
477 477
478 478 fail:
479 479 if (tr)
480 480 free(tr);
481 481 return ((size_t)(-1));
482 482 }
483 483
484 484 /*
485 485 * In the non-POSIX case, we transform each character into a string of
486 486 * characters representing the character's priority. Since char is usually
487 487 * signed, we are limited by 7 bits per byte. To avoid zero, we need to add
488 488 * XFRM_OFFSET, so we can't use a full 7 bits. For simplicity, we choose 6
489 489 * bits per byte.
490 490 *
491 491 * It turns out that we sometimes have real priorities that are
492 492 * 31-bits wide. (But: be careful using priorities where the high
493 493 * order bit is set -- i.e. the priority is negative. The sort order
494 494 * may be surprising!)
495 495 *
496 496 * TODO: This would be a good area to optimize somewhat. It turns out
497 497 * that real prioririties *except for the last UNDEFINED pass* are generally
498 498 * very small. We need the localedef code to precalculate the max
499 499 * priority for us, and ideally also give us a mask, and then we could
500 500 * severely limit what we expand to.
501 501 */
502 502 #define XFRM_BYTES 6
503 503 #define XFRM_OFFSET ('0') /* make all printable characters */
504 504 #define XFRM_SHIFT 6
505 505 #define XFRM_MASK ((1 << XFRM_SHIFT) - 1)
506 506 #define XFRM_SEP ('.') /* chosen to be less than XFRM_OFFSET */
507 507
508 508 static int
509 509 xfrm(locale_t loc, unsigned char *p, int pri, int pass)
510 510 {
511 511 /* we use unsigned to ensure zero fill on right shift */
512 512 uint32_t val = (uint32_t)loc->collate->lc_pri_count[pass];
513 513 int nc = 0;
514 514
515 515 while (val) {
516 516 *p = (pri & XFRM_MASK) + XFRM_OFFSET;
517 517 pri >>= XFRM_SHIFT;
518 518 val >>= XFRM_SHIFT;
519 519 p++;
520 520 nc++;
521 521 }
522 522 return (nc);
523 523 }
524 524
525 525 size_t
526 526 _collate_sxfrm(const wchar_t *src, char *xf, size_t room, locale_t loc)
527 527 {
528 528 int pri;
529 529 int len;
530 530 const wchar_t *t;
531 531 wchar_t *tr = NULL;
532 532 int direc;
533 533 int pass;
534 534 const int32_t *state;
535 535 size_t want = 0;
536 536 size_t need = 0;
537 537 int b;
538 538 uint8_t buf[XFRM_BYTES];
539 539 const struct lc_collate *lcc = loc->collate;
540 540 int ndir = lcc->lc_directive_count;
541 541
542 542 assert(src);
543 543
544 544 for (pass = 0; pass <= ndir; pass++) {
545 545
546 546 state = NULL;
547 547
548 548 if (pass != 0) {
549 549 /* insert level separator from the previous pass */
550 550 if (room) {
551 551 *xf++ = XFRM_SEP;
552 552 room--;
553 553 }
554 554 want++;
555 555 }
556 556
557 557 /* special pass for undefined */
558 558 if (pass == ndir) {
559 559 direc = DIRECTIVE_FORWARD | DIRECTIVE_UNDEFINED;
560 560 } else {
561 561 direc = lcc->lc_directive[pass];
562 562 }
563 563
564 564 t = src;
565 565
566 566 if (direc & DIRECTIVE_BACKWARD) {
567 567 wchar_t *bp, *fp, c;
568 568 if (tr)
569 569 free(tr);
570 570 if ((tr = wcsdup(t)) == NULL) {
571 571 errno = ENOMEM;
572 572 goto fail;
573 573 }
574 574 bp = tr;
575 575 fp = tr + wcslen(tr) - 1;
576 576 while (bp < fp) {
577 577 c = *bp;
578 578 *bp++ = *fp;
579 579 *fp-- = c;
580 580 }
581 581 t = (const wchar_t *)tr;
582 582 }
583 583
584 584 if (direc & DIRECTIVE_POSITION) {
585 585 while (*t || state) {
586 586
587 587 _collate_lookup(lcc, t, &len, &pri, pass,
588 588 &state);
589 589 t += len;
590 590 if (pri <= 0) {
591 591 if (pri < 0) {
592 592 errno = EINVAL;
593 593 goto fail;
594 594 }
595 595 state = NULL;
596 596 pri = COLLATE_MAX_PRIORITY;
597 597 }
598 598
599 599 b = xfrm(loc, buf, pri, pass);
600 600 want += b;
601 601 if (room) {
602 602 while (b) {
603 603 b--;
604 604 if (room) {
605 605 *xf++ = buf[b];
606 606 room--;
607 607 }
608 608 }
609 609 }
610 610 need = want;
611 611 }
612 612 } else {
613 613 while (*t || state) {
614 614 _collate_lookup(lcc, t, &len, &pri, pass,
615 615 &state);
616 616 t += len;
617 617 if (pri <= 0) {
618 618 if (pri < 0) {
619 619 errno = EINVAL;
620 620 goto fail;
621 621 }
622 622 state = NULL;
623 623 continue;
624 624 }
625 625
626 626 b = xfrm(loc, buf, pri, pass);
627 627 want += b;
628 628 if (room) {
629 629
630 630 while (b) {
631 631 b--;
632 632 if (room) {
633 633 *xf++ = buf[b];
634 634 room--;
635 635 }
636 636 }
637 637 }
638 638 need = want;
639 639 }
640 640 }
641 641 }
642 642
↓ open down ↓ |
642 lines elided |
↑ open up ↑ |
643 643 end:
644 644 if (tr)
645 645 free(tr);
646 646 return (need);
647 647
648 648 fail:
649 649 if (tr)
650 650 free(tr);
651 651 return ((size_t)(-1));
652 652 }
653 +
654 +/*
655 + * __collate_equiv_value returns the primary collation value for the given
656 + * collating symbol specified by str and len. Zero or negative is returned
657 + * if the collating symbol was not found.
658 + */
659 +int
660 +__collate_equiv_value(locale_t loc, const wchar_t *str, size_t len)
661 +{
662 + const struct lc_collate *lcc = loc->collate;
663 + int32_t e;
664 +
665 + if (len < 1 || len >= COLLATE_STR_LEN)
666 + return (-1);
667 +
668 + if (lcc->lc_is_posix)
669 + return ((len == 1 && *str <= UCHAR_MAX) ? *str : -1);
670 +
671 + if (len == 1) {
672 + e = -1;
673 + if (*str <= UCHAR_MAX)
674 + e = lcc->lc_char_table[*str].pri[0];
675 + else if (lcc->lc_large_count > 0) {
676 + collate_large_t *match_large;
677 +
678 + match_large = largesearch(lcc, *str);
679 + if (match_large != NULL)
680 + e = match_large->pri.pri[0];
681 + }
682 + if (e == 0)
683 + return (1);
684 + return (e > 0 ? e : 0);
685 + }
686 + if (lcc->lc_chain_count > 0) {
687 + wchar_t name[COLLATE_STR_LEN];
688 + collate_chain_t *match_chain;
689 + int clen;
690 +
691 + wcsncpy(name, str, len);
692 + name[len] = 0;
693 + match_chain = chainsearch(lcc, name, &clen);
694 + if (match_chain != NULL) {
695 + e = match_chain->pri[0];
696 + if (e == 0)
697 + return (1);
698 + return (e < 0 ? -e : e);
699 + }
700 + }
701 +
702 + return (0);
703 +}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX