/[dtapublic]/projs/trunk/shared_source/tcl_base/regc_color.c
ViewVC logotype

Contents of /projs/trunk/shared_source/tcl_base/regc_color.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (show annotations) (download)
Fri Oct 14 01:50:00 2016 UTC (7 years, 5 months ago) by dashley
File MIME type: text/plain
File size: 18952 byte(s)
Move shared source code to commonize.
1 /* $Header: /cvsroot/esrg/sfesrg/esrgpcpj/shared/tcl_base/regc_color.c,v 1.1.1.1 2001/06/13 04:31:42 dtashley Exp $ */
2
3 /*
4 * colorings of characters
5 * This file is #included by regcomp.c.
6 *
7 * Copyright (c) 1998, 1999 Henry Spencer. All rights reserved.
8 *
9 * Development of this software was funded, in part, by Cray Research Inc.,
10 * UUNET Communications Services Inc., Sun Microsystems Inc., and Scriptics
11 * Corporation, none of whom are responsible for the results. The author
12 * thanks all of them.
13 *
14 * Redistribution and use in source and binary forms -- with or without
15 * modification -- are permitted for any purpose, provided that
16 * redistributions in source form retain this entire copyright notice and
17 * indicate the origin and nature of any modifications.
18 *
19 * I'd appreciate being given credit for this package in the documentation
20 * of software which uses it, but that is not a requirement.
21 *
22 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
25 * HENRY SPENCER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 *
34 *
35 * Note that there are some incestuous relationships between this code and
36 * NFA arc maintenance, which perhaps ought to be cleaned up sometime.
37 */
38
39
40
41 #define CISERR() VISERR(cm->v)
42 #define CERR(e) VERR(cm->v, (e))
43
44
45
46 /*
47 - initcm - set up new colormap
48 ^ static VOID initcm(struct vars *, struct colormap *);
49 */
50 static VOID
51 initcm(v, cm)
52 struct vars *v;
53 struct colormap *cm;
54 {
55 int i;
56 int j;
57 union tree *t;
58 union tree *nextt;
59 struct colordesc *cd;
60
61 cm->magic = CMMAGIC;
62 cm->v = v;
63
64 cm->ncds = NINLINECDS;
65 cm->cd = cm->cdspace;
66 cm->max = 0;
67 cm->free = 0;
68
69 cd = cm->cd; /* cm->cd[WHITE] */
70 cd->sub = NOSUB;
71 cd->arcs = NULL;
72 cd->flags = 0;
73 cd->nchrs = CHR_MAX - CHR_MIN + 1;
74
75 /* upper levels of tree */
76 for (t = &cm->tree[0], j = NBYTS-1; j > 0; t = nextt, j--) {
77 nextt = t + 1;
78 for (i = BYTTAB-1; i >= 0; i--)
79 t->tptr[i] = nextt;
80 }
81 /* bottom level is solid white */
82 t = &cm->tree[NBYTS-1];
83 for (i = BYTTAB-1; i >= 0; i--)
84 t->tcolor[i] = WHITE;
85 cd->block = t;
86 }
87
88 /*
89 - freecm - free dynamically-allocated things in a colormap
90 ^ static VOID freecm(struct colormap *);
91 */
92 static VOID
93 freecm(cm)
94 struct colormap *cm;
95 {
96 size_t i;
97 union tree *cb;
98
99 cm->magic = 0;
100 if (NBYTS > 1)
101 cmtreefree(cm, cm->tree, 0);
102 for (i = 1; i <= cm->max; i++) /* skip WHITE */
103 if (!UNUSEDCOLOR(&cm->cd[i])) {
104 cb = cm->cd[i].block;
105 if (cb != NULL)
106 FREE(cb);
107 }
108 if (cm->cd != cm->cdspace)
109 FREE(cm->cd);
110 }
111
112 /*
113 - cmtreefree - free a non-terminal part of a colormap tree
114 ^ static VOID cmtreefree(struct colormap *, union tree *, int);
115 */
116 static VOID
117 cmtreefree(cm, tree, level)
118 struct colormap *cm;
119 union tree *tree;
120 int level; /* level number (top == 0) of this block */
121 {
122 int i;
123 union tree *t;
124 union tree *fillt = &cm->tree[level+1];
125 union tree *cb;
126
127 assert(level < NBYTS-1); /* this level has pointers */
128 for (i = BYTTAB-1; i >= 0; i--) {
129 t = tree->tptr[i];
130 assert(t != NULL);
131 if (t != fillt) {
132 if (level < NBYTS-2) { /* more pointer blocks below */
133 cmtreefree(cm, t, level+1);
134 FREE(t);
135 } else { /* color block below */
136 cb = cm->cd[t->tcolor[0]].block;
137 if (t != cb) /* not a solid block */
138 FREE(t);
139 }
140 }
141 }
142 }
143
144 /*
145 - setcolor - set the color of a character in a colormap
146 ^ static color setcolor(struct colormap *, pchr, pcolor);
147 */
148 static color /* previous color */
149 setcolor(cm, c, co)
150 struct colormap *cm;
151 pchr c;
152 pcolor co;
153 {
154 uchr uc = c;
155 int shift;
156 int level;
157 int b;
158 int bottom;
159 union tree *t;
160 union tree *newt;
161 union tree *fillt;
162 union tree *lastt;
163 union tree *cb;
164 color prev;
165
166 assert(cm->magic == CMMAGIC);
167 if (CISERR() || co == COLORLESS)
168 return COLORLESS;
169
170 t = cm->tree;
171 for (level = 0, shift = BYTBITS * (NBYTS - 1); shift > 0;
172 level++, shift -= BYTBITS) {
173 b = (uc >> shift) & BYTMASK;
174 lastt = t;
175 t = lastt->tptr[b];
176 assert(t != NULL);
177 fillt = &cm->tree[level+1];
178 bottom = (shift <= BYTBITS) ? 1 : 0;
179 cb = (bottom) ? cm->cd[t->tcolor[0]].block : fillt;
180 if (t == fillt || t == cb) { /* must allocate a new block */
181 newt = (union tree *)MALLOC((bottom) ?
182 sizeof(struct colors) : sizeof(struct ptrs));
183 if (newt == NULL) {
184 CERR(REG_ESPACE);
185 return COLORLESS;
186 }
187 if (bottom)
188 memcpy(VS(newt->tcolor), VS(t->tcolor),
189 BYTTAB*sizeof(color));
190 else
191 memcpy(VS(newt->tptr), VS(t->tptr),
192 BYTTAB*sizeof(union tree *));
193 t = newt;
194 lastt->tptr[b] = t;
195 }
196 }
197
198 b = uc & BYTMASK;
199 prev = t->tcolor[b];
200 t->tcolor[b] = (color)co;
201 return prev;
202 }
203
204 /*
205 - maxcolor - report largest color number in use
206 ^ static color maxcolor(struct colormap *);
207 */
208 static color
209 maxcolor(cm)
210 struct colormap *cm;
211 {
212 if (CISERR())
213 return COLORLESS;
214
215 return (color)cm->max;
216 }
217
218 /*
219 - newcolor - find a new color (must be subject of setcolor at once)
220 * Beware: may relocate the colordescs.
221 ^ static color newcolor(struct colormap *);
222 */
223 static color /* COLORLESS for error */
224 newcolor(cm)
225 struct colormap *cm;
226 {
227 struct colordesc *cd;
228 struct colordesc *new;
229 size_t n;
230
231 if (CISERR())
232 return COLORLESS;
233
234 if (cm->free != 0) {
235 assert(cm->free > 0);
236 assert((size_t)cm->free < cm->ncds);
237 cd = &cm->cd[cm->free];
238 assert(UNUSEDCOLOR(cd));
239 assert(cd->arcs == NULL);
240 cm->free = cd->sub;
241 } else if (cm->max < cm->ncds - 1) {
242 cm->max++;
243 cd = &cm->cd[cm->max];
244 } else {
245 /* oops, must allocate more */
246 n = cm->ncds * 2;
247 if (cm->cd == cm->cdspace) {
248 new = (struct colordesc *)MALLOC(n *
249 sizeof(struct colordesc));
250 if (new != NULL)
251 memcpy(VS(new), VS(cm->cdspace), cm->ncds *
252 sizeof(struct colordesc));
253 } else
254 new = (struct colordesc *)REALLOC(cm->cd,
255 n * sizeof(struct colordesc));
256 if (new == NULL) {
257 CERR(REG_ESPACE);
258 return COLORLESS;
259 }
260 cm->cd = new;
261 cm->ncds = n;
262 assert(cm->max < cm->ncds - 1);
263 cm->max++;
264 cd = &cm->cd[cm->max];
265 }
266
267 cd->nchrs = 0;
268 cd->sub = NOSUB;
269 cd->arcs = NULL;
270 cd->flags = 0;
271 cd->block = NULL;
272
273 return (color)(cd - cm->cd);
274 }
275
276 /*
277 - freecolor - free a color (must have no arcs or subcolor)
278 ^ static VOID freecolor(struct colormap *, pcolor);
279 */
280 static VOID
281 freecolor(cm, co)
282 struct colormap *cm;
283 pcolor co;
284 {
285 struct colordesc *cd = &cm->cd[co];
286 color pco, nco; /* for freelist scan */
287
288 assert(co >= 0);
289 if (co == WHITE)
290 return;
291
292 assert(cd->arcs == NULL);
293 assert(cd->sub == NOSUB);
294 assert(cd->nchrs == 0);
295 cd->flags = FREECOL;
296 if (cd->block != NULL) {
297 FREE(cd->block);
298 cd->block = NULL; /* just paranoia */
299 }
300
301 if ((size_t)co == cm->max) {
302 while (cm->max > WHITE && UNUSEDCOLOR(&cm->cd[cm->max]))
303 cm->max--;
304 assert(cm->free >= 0);
305 while ((size_t)cm->free > cm->max)
306 cm->free = cm->cd[cm->free].sub;
307 if (cm->free > 0) {
308 assert(cm->free < (signed int)cm->max);
309 pco = cm->free;
310 nco = cm->cd[pco].sub;
311 while (nco > 0)
312 if ((size_t)nco > cm->max) {
313 /* take this one out of freelist */
314 nco = cm->cd[nco].sub;
315 cm->cd[pco].sub = nco;
316 } else {
317 assert(nco < (signed int)cm->max);
318 pco = nco;
319 nco = cm->cd[pco].sub;
320 }
321 }
322 } else {
323 cd->sub = cm->free;
324 cm->free = (color)(cd - cm->cd);
325 }
326 }
327
328 /*
329 - pseudocolor - allocate a false color, to be managed by other means
330 ^ static color pseudocolor(struct colormap *);
331 */
332 static color
333 pseudocolor(cm)
334 struct colormap *cm;
335 {
336 color co;
337
338 co = newcolor(cm);
339 if (CISERR())
340 return COLORLESS;
341 cm->cd[co].nchrs = 1;
342 cm->cd[co].flags = PSEUDO;
343 return co;
344 }
345
346 /*
347 - subcolor - allocate a new subcolor (if necessary) to this chr
348 ^ static color subcolor(struct colormap *, pchr c);
349 */
350 static color
351 subcolor(cm, c)
352 struct colormap *cm;
353 pchr c;
354 {
355 color co; /* current color of c */
356 color sco; /* new subcolor */
357
358 co = GETCOLOR(cm, c);
359 sco = newsub(cm, co);
360 if (CISERR())
361 return COLORLESS;
362 assert(sco != COLORLESS);
363
364 if (co == sco) /* already in an open subcolor */
365 return co; /* rest is redundant */
366 cm->cd[co].nchrs--;
367 cm->cd[sco].nchrs++;
368 setcolor(cm, c, sco);
369 return sco;
370 }
371
372 /*
373 - newsub - allocate a new subcolor (if necessary) for a color
374 ^ static color newsub(struct colormap *, pcolor);
375 */
376 static color
377 newsub(cm, co)
378 struct colormap *cm;
379 pcolor co;
380 {
381 color sco; /* new subcolor */
382
383 sco = cm->cd[co].sub;
384 if (sco == NOSUB) { /* color has no open subcolor */
385 if (cm->cd[co].nchrs == 1) /* optimization */
386 return co;
387 sco = newcolor(cm); /* must create subcolor */
388 if (sco == COLORLESS) {
389 assert(CISERR());
390 return COLORLESS;
391 }
392 cm->cd[co].sub = sco;
393 cm->cd[sco].sub = sco; /* open subcolor points to self */
394 }
395 assert(sco != NOSUB);
396
397 return sco;
398 }
399
400 /*
401 - subrange - allocate new subcolors to this range of chrs, fill in arcs
402 ^ static VOID subrange(struct vars *, pchr, pchr, struct state *,
403 ^ struct state *);
404 */
405 static VOID
406 subrange(v, from, to, lp, rp)
407 struct vars *v;
408 pchr from;
409 pchr to;
410 struct state *lp;
411 struct state *rp;
412 {
413 uchr uf;
414 int i;
415
416 assert(from <= to);
417
418 /* first, align "from" on a tree-block boundary */
419 uf = (uchr)from;
420 i = (int)( ((uf + BYTTAB-1) & (uchr)~BYTMASK) - uf );
421 for (; from <= to && i > 0; i--, from++)
422 newarc(v->nfa, PLAIN, subcolor(v->cm, from), lp, rp);
423 if (from > to) /* didn't reach a boundary */
424 return;
425
426 /* deal with whole blocks */
427 for (; to - from >= BYTTAB; from += BYTTAB)
428 subblock(v, from, lp, rp);
429
430 /* clean up any remaining partial table */
431 for (; from <= to; from++)
432 newarc(v->nfa, PLAIN, subcolor(v->cm, from), lp, rp);
433 }
434
435 /*
436 - subblock - allocate new subcolors for one tree block of chrs, fill in arcs
437 ^ static VOID subblock(struct vars *, pchr, struct state *, struct state *);
438 */
439 static VOID
440 subblock(v, start, lp, rp)
441 struct vars *v;
442 pchr start; /* first of BYTTAB chrs */
443 struct state *lp;
444 struct state *rp;
445 {
446 uchr uc = start;
447 struct colormap *cm = v->cm;
448 int shift;
449 int level;
450 int i;
451 int b;
452 union tree *t;
453 union tree *cb;
454 union tree *fillt;
455 union tree *lastt;
456 int previ;
457 int ndone;
458 color co;
459 color sco;
460
461 assert((uc % BYTTAB) == 0);
462
463 /* find its color block, making new pointer blocks as needed */
464 t = cm->tree;
465 fillt = NULL;
466 for (level = 0, shift = BYTBITS * (NBYTS - 1); shift > 0;
467 level++, shift -= BYTBITS) {
468 b = (uc >> shift) & BYTMASK;
469 lastt = t;
470 t = lastt->tptr[b];
471 assert(t != NULL);
472 fillt = &cm->tree[level+1];
473 if (t == fillt && shift > BYTBITS) { /* need new ptr block */
474 t = (union tree *)MALLOC(sizeof(struct ptrs));
475 if (t == NULL) {
476 CERR(REG_ESPACE);
477 return;
478 }
479 memcpy(VS(t->tptr), VS(fillt->tptr),
480 BYTTAB*sizeof(union tree *));
481 lastt->tptr[b] = t;
482 }
483 }
484
485 /* special cases: fill block or solid block */
486 co = t->tcolor[0];
487 cb = cm->cd[co].block;
488 if (t == fillt || t == cb) {
489 /* either way, we want a subcolor solid block */
490 sco = newsub(cm, co);
491 t = cm->cd[sco].block;
492 if (t == NULL) { /* must set it up */
493 t = (union tree *)MALLOC(sizeof(struct colors));
494 if (t == NULL) {
495 CERR(REG_ESPACE);
496 return;
497 }
498 for (i = 0; i < BYTTAB; i++)
499 t->tcolor[i] = sco;
500 cm->cd[sco].block = t;
501 }
502 /* find loop must have run at least once */
503 lastt->tptr[b] = t;
504 newarc(v->nfa, PLAIN, sco, lp, rp);
505 cm->cd[co].nchrs -= BYTTAB;
506 cm->cd[sco].nchrs += BYTTAB;
507 return;
508 }
509
510 /* general case, a mixed block to be altered */
511 i = 0;
512 while (i < BYTTAB) {
513 co = t->tcolor[i];
514 sco = newsub(cm, co);
515 newarc(v->nfa, PLAIN, sco, lp, rp);
516 previ = i;
517 do {
518 t->tcolor[i++] = sco;
519 } while (i < BYTTAB && t->tcolor[i] == co);
520 ndone = i - previ;
521 cm->cd[co].nchrs -= ndone;
522 cm->cd[sco].nchrs += ndone;
523 }
524 }
525
526 /*
527 - okcolors - promote subcolors to full colors
528 ^ static VOID okcolors(struct nfa *, struct colormap *);
529 */
530 static VOID
531 okcolors(nfa, cm)
532 struct nfa *nfa;
533 struct colormap *cm;
534 {
535 struct colordesc *cd;
536 struct colordesc *end = CDEND(cm);
537 struct colordesc *scd;
538 struct arc *a;
539 color co;
540 color sco;
541
542 for (cd = cm->cd, co = 0; cd < end; cd++, co++) {
543 sco = cd->sub;
544 if (UNUSEDCOLOR(cd) || sco == NOSUB) {
545 /* has no subcolor, no further action */
546 } else if (sco == co) {
547 /* is subcolor, let parent deal with it */
548 } else if (cd->nchrs == 0) {
549 /* parent empty, its arcs change color to subcolor */
550 cd->sub = NOSUB;
551 scd = &cm->cd[sco];
552 assert(scd->nchrs > 0);
553 assert(scd->sub == sco);
554 scd->sub = NOSUB;
555 while ((a = cd->arcs) != NULL) {
556 assert(a->co == co);
557 /* uncolorchain(cm, a); */
558 cd->arcs = a->colorchain;
559 a->co = sco;
560 /* colorchain(cm, a); */
561 a->colorchain = scd->arcs;
562 scd->arcs = a;
563 }
564 freecolor(cm, co);
565 } else {
566 /* parent's arcs must gain parallel subcolor arcs */
567 cd->sub = NOSUB;
568 scd = &cm->cd[sco];
569 assert(scd->nchrs > 0);
570 assert(scd->sub == sco);
571 scd->sub = NOSUB;
572 for (a = cd->arcs; a != NULL; a = a->colorchain) {
573 assert(a->co == co);
574 newarc(nfa, a->type, sco, a->from, a->to);
575 }
576 }
577 }
578 }
579
580 /*
581 - colorchain - add this arc to the color chain of its color
582 ^ static VOID colorchain(struct colormap *, struct arc *);
583 */
584 static VOID
585 colorchain(cm, a)
586 struct colormap *cm;
587 struct arc *a;
588 {
589 struct colordesc *cd = &cm->cd[a->co];
590
591 a->colorchain = cd->arcs;
592 cd->arcs = a;
593 }
594
595 /*
596 - uncolorchain - delete this arc from the color chain of its color
597 ^ static VOID uncolorchain(struct colormap *, struct arc *);
598 */
599 static VOID
600 uncolorchain(cm, a)
601 struct colormap *cm;
602 struct arc *a;
603 {
604 struct colordesc *cd = &cm->cd[a->co];
605 struct arc *aa;
606
607 aa = cd->arcs;
608 if (aa == a) /* easy case */
609 cd->arcs = a->colorchain;
610 else {
611 for (; aa != NULL && aa->colorchain != a; aa = aa->colorchain)
612 continue;
613 assert(aa != NULL);
614 aa->colorchain = a->colorchain;
615 }
616 a->colorchain = NULL; /* paranoia */
617 }
618
619 /*
620 - singleton - is this character in its own color?
621 ^ static int singleton(struct colormap *, pchr c);
622 */
623 static int /* predicate */
624 singleton(cm, c)
625 struct colormap *cm;
626 pchr c;
627 {
628 color co; /* color of c */
629
630 co = GETCOLOR(cm, c);
631 if (cm->cd[co].nchrs == 1 && cm->cd[co].sub == NOSUB)
632 return 1;
633 return 0;
634 }
635
636 /*
637 - rainbow - add arcs of all full colors (but one) between specified states
638 ^ static VOID rainbow(struct nfa *, struct colormap *, int, pcolor,
639 ^ struct state *, struct state *);
640 */
641 static VOID
642 rainbow(nfa, cm, type, but, from, to)
643 struct nfa *nfa;
644 struct colormap *cm;
645 int type;
646 pcolor but; /* COLORLESS if no exceptions */
647 struct state *from;
648 struct state *to;
649 {
650 struct colordesc *cd;
651 struct colordesc *end = CDEND(cm);
652 color co;
653
654 for (cd = cm->cd, co = 0; cd < end && !CISERR(); cd++, co++)
655 if (!UNUSEDCOLOR(cd) && cd->sub != co && co != but &&
656 !(cd->flags&PSEUDO))
657 newarc(nfa, type, co, from, to);
658 }
659
660 /*
661 - colorcomplement - add arcs of complementary colors
662 * The calling sequence ought to be reconciled with cloneouts().
663 ^ static VOID colorcomplement(struct nfa *, struct colormap *, int,
664 ^ struct state *, struct state *, struct state *);
665 */
666 static VOID
667 colorcomplement(nfa, cm, type, of, from, to)
668 struct nfa *nfa;
669 struct colormap *cm;
670 int type;
671 struct state *of; /* complements of this guy's PLAIN outarcs */
672 struct state *from;
673 struct state *to;
674 {
675 struct colordesc *cd;
676 struct colordesc *end = CDEND(cm);
677 color co;
678
679 assert(of != from);
680 for (cd = cm->cd, co = 0; cd < end && !CISERR(); cd++, co++)
681 if (!UNUSEDCOLOR(cd) && !(cd->flags&PSEUDO))
682 if (findarc(of, PLAIN, co) == NULL)
683 newarc(nfa, type, co, from, to);
684 }
685
686
687
688 #ifdef REG_DEBUG
689 /*
690 ^ #ifdef REG_DEBUG
691 */
692
693 /*
694 - dumpcolors - debugging output
695 ^ static VOID dumpcolors(struct colormap *, FILE *);
696 */
697 static VOID
698 dumpcolors(cm, f)
699 struct colormap *cm;
700 FILE *f;
701 {
702 struct colordesc *cd;
703 struct colordesc *end;
704 color co;
705 chr c;
706 char *has;
707
708 fprintf(f, "max %ld\n", (long)cm->max);
709 if (NBYTS > 1)
710 fillcheck(cm, cm->tree, 0, f);
711 end = CDEND(cm);
712 for (cd = cm->cd + 1, co = 1; cd < end; cd++, co++) /* skip 0 */
713 if (!UNUSEDCOLOR(cd)) {
714 assert(cd->nchrs > 0);
715 has = (cd->block != NULL) ? "#" : "";
716 if (cd->flags&PSEUDO)
717 fprintf(f, "#%2ld%s(ps): ", (long)co, has);
718 else
719 fprintf(f, "#%2ld%s(%2d): ", (long)co,
720 has, cd->nchrs);
721 /* it's hard to do this more efficiently */
722 for (c = CHR_MIN; c < CHR_MAX; c++)
723 if (GETCOLOR(cm, c) == co)
724 dumpchr(c, f);
725 assert(c == CHR_MAX);
726 if (GETCOLOR(cm, c) == co)
727 dumpchr(c, f);
728 fprintf(f, "\n");
729 }
730 }
731
732 /*
733 - fillcheck - check proper filling of a tree
734 ^ static VOID fillcheck(struct colormap *, union tree *, int, FILE *);
735 */
736 static VOID
737 fillcheck(cm, tree, level, f)
738 struct colormap *cm;
739 union tree *tree;
740 int level; /* level number (top == 0) of this block */
741 FILE *f;
742 {
743 int i;
744 union tree *t;
745 union tree *fillt = &cm->tree[level+1];
746
747 assert(level < NBYTS-1); /* this level has pointers */
748 for (i = BYTTAB-1; i >= 0; i--) {
749 t = tree->tptr[i];
750 if (t == NULL)
751 fprintf(f, "NULL found in filled tree!\n");
752 else if (t == fillt)
753 {}
754 else if (level < NBYTS-2) /* more pointer blocks below */
755 fillcheck(cm, t, level+1, f);
756 }
757 }
758
759 /*
760 - dumpchr - print a chr
761 * Kind of char-centric but works well enough for debug use.
762 ^ static VOID dumpchr(pchr, FILE *);
763 */
764 static VOID
765 dumpchr(c, f)
766 pchr c;
767 FILE *f;
768 {
769 if (c == '\\')
770 fprintf(f, "\\\\");
771 else if (c > ' ' && c <= '~')
772 putc((char)c, f);
773 else
774 fprintf(f, "\\u%04lx", (long)c);
775 }
776
777 /*
778 ^ #endif
779 */
780 #endif /* ifdef REG_DEBUG */
781
782 /* $History: regc_color.c $
783 *
784 * ***************** Version 1 *****************
785 * User: Dtashley Date: 1/02/01 Time: 12:02a
786 * Created in $/IjuScripter, IjuConsole/Source/Tcl Base
787 * Initial check-in.
788 */
789
790 /* End of REGC_COLOR.C */

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25