Esempio n. 1
0
void
worldprintentry(Entry e, int cmd)
{
	int nh, state[3];
	uchar *p, *pe;

	p = (uchar *)e.start;
	pe = (uchar *)e.end;
	nh = GSHORT(p);
	p += 6;
	if(cmd == 'h')
		pe = p+nh;
	state[0] = Utf;
	state[1] = 0;
	state[2] = 0;
	while(p < pe){
		if(cmd == 'r')
			outchar(*p++);
		else
			putchar(*p++, state);
	}
	outnl(0);
}
Esempio n. 2
0
void
pcollprintentry(Entry e, int cmd)
{
	char *p, *pe;
	long r, rprev, t, rlig;
	int saveoi;
	Rune *transtab;

	p = e.start;
	pe = e.end;
	transtab = normtab;
	rprev = NONE;
	changett(0, 0, 0);
	curentry = e;
	saveoi = 0;
	if(cmd == 'h')
		outinhibit = 1;
	while(p < pe) {
		if(cmd == 'r') {
			outchar(*p++);
			continue;
		}
		r = transtab[(*p++)&0x7F];
		if(r < NONE) {
			/* Emit the rune, but buffer in case of ligature */
			if(rprev != NONE)
				outrune(rprev);
			rprev = r;
		} else if(r == TAGS) {
			p = gettag(p, pe);
			t = lookassoc(tagtab, asize(tagtab), tag);
			if(t == -1) {
				if(debug && !outinhibit)
					err("tag %ld %d %s",
						e.doff, cursize, tag);
				continue;
			}
			if(t < NONE) {
				if(rprev != NONE)
					outrune(rprev);
				rprev = t;
			} else if(t >= LIGS && t < LIGE) {
				/* handle possible ligature */
				rlig = liglookup(t, rprev);
				if(rlig != NONE)
					rprev = rlig;	/* overwrite rprev */
				else {
					/* could print accent, but let's not */
					if(rprev != NONE) outrune(rprev);
					rprev = NONE;
				}
			} else if(t >= MULTI && t < MULTIE) {
				if(rprev != NONE) {
					outrune(rprev);
					rprev = NONE;
				}
				outrunes(multitab[t-MULTI]);
			} else {
				if(rprev != NONE) {
					outrune(rprev);
					rprev = NONE;
				}
				switch(t){
				case H:
					if(cmd == 'h')
						outinhibit = 0;
					else
						outnl(0);
					break;
				case X:
					if(cmd == 'h')
						outinhibit = 1;
					else
						outchars(".  ");
					break;
				case Ps:
					/* don't know enough of pron. key yet */
					saveoi = outinhibit;
					outinhibit = 1;
					break;
				case Pe:
					outinhibit = saveoi;
					break;
				}
			}
		}
	}
	if(cmd == 'h')
		outinhibit = 0;
	outnl(0);
}
Esempio n. 3
0
void
slangprintentry(Entry e, int cmd)
{
	char *p, *pe, *vs, *ve;
	long t;

	p = e.start;
	pe = e.end;
	if(cmd == 'h') {
		t = sget(p, pe, &vs, &ve);
		if(t == ME)
			soutpiece(vs, ve);
		outnl(0);
		return;
	}
	while(p < pe) {
		switch(sget(p, pe, &vs, &ve)) {
		case DF:
			soutpiece(vs, ve);
			outchars(".  ");
			break;
		case DX:
			soutpiece(vs, ve);
			outchars(".  ");
			break;
		case ET:
			outchars("[");
			soutpiece(vs, ve);
			outchars("] ");
			break;
		case EX:
			outchars("E.g., ");
			soutpiece(vs, ve);
			outchars(".  ");
			break;
		case LA:
			outchars("(");
			soutpiece(vs, ve);
			outchars(") ");
			break;
		case ME:
			outnl(0);
			soutpiece(vs, ve);
			outnl(0);
			break;
		case NU:
			outnl(2);
			soutpiece(vs, ve);
			outchars(".  ");
			break;
		case PR:
			outchars("[");
			soutpiece(vs, ve);
			outchars("] ");
			break;
		case PS:
			outnl(1);
			soutpiece(vs, ve);
			outchars(". ");
			break;
		case XR:
			outchars("See ");
			soutpiece(vs, ve);
			outchars(".  ");
			break;
		case XX:
			outchars("See ");
			soutpiece(vs, ve);
			outchars(".  ");
			break;
		default:
			ve = pe;	/* will end loop */
			break;
		}
		p = ve;
	}
	outnl(0);
}
Esempio n. 4
0
void
pcollgprintentry(Entry e, int cmd)
{
	uint8_t *p, *pe;
	int r, rprev = NONE, rx, over = 0, font;
	char buf[16];

	p = (uint8_t *)e.start;
	pe = (uint8_t *)e.end;
	curentry = e;
	if(cmd == 'h')
		outinhibit = 1;
	while(p < pe){
		if(cmd == 'r'){
			outchar(*p++);
			continue;
		}
		switch(r = intab[*p++]){	/* assign = */
		case TAGS:
			if(rprev != NONE){
				outrune(rprev);
				rprev = NONE;
			}
			p = reach(p, 0x06);
			font = tag[0];
			if(cmd == 'h')
				outinhibit = (font != 'h');
			break;

		case TAGE:	/* an extra one */
			break;
	
		case SPCS:
			p = reach(p, 0xba);
			r = looknassoc(numtab, asize(numtab), strtol(tag,0,0));
			if(r < 0){
				if(rprev != NONE){
					outrune(rprev);
					rprev = NONE;
				}
				sprint(buf, "\\N'%s'", tag);
				outchars(buf);
				break;
			}
			/* else fall through */

		default:
			if(over){
				rx = looknassoc(overtab, asize(overtab), r);
				if(rx > 0)
					rx = liglookup(rx, rprev);
				if(rx > 0 && rx != NONE)
					outrune(rx);
				else{
					outrune(rprev);
					if(r == ':')
						outrune(L'¨');
					else{
						outrune(L'^');
						outrune(r);
					}
				}
				over = 0;
				rprev = NONE;
			}else if(r == '^'){
				over = 1;
			}else{
				if(rprev != NONE)
					outrune(rprev);
				rprev = r;
			}
		}
		
	}
	if(rprev != NONE)
		outrune(rprev);
	if(cmd == 'h')
		outinhibit = 0;
	outnl(0);
}
Esempio n. 5
0
File: pgw.c Progetto: aberg001/plan9
/*
 * cmd is one of:
 *    'p': normal print
 *    'h': just print headwords
 *    'P': print raw
 */
void
pgwprintentry(Entry e, int cmd)
{
    char *p, *pe;
    int t;
    long r, rprev, rlig;
    Rune *transtab;

    p = e.start;
    pe = e.end;
    transtab = normtab;
    rprev = NONE;
    changett(0, 0, 0);
    curentry = e;
    if(cmd == 'h')
        outinhibit = 1;
    while(p < pe) {
        if(cmd == 'r') {
            outchar(*p++);
            continue;
        }
        r = transtab[(*p++)&0x7F];
        if(r < NONE) {
            /* Emit the rune, but buffer in case of ligature */
            if(rprev != NONE)
                outrune(rprev);
            rprev = r;
        } else if(r == SPCS) {
            /* Start of special character name */
            p = getspec(p, pe);
            r = lookassoc(spectab, asize(spectab), spec);
            if(r == -1) {
                if(debug)
                    err("spec %ld %d %s",
                        e.doff, cursize, spec);
                r = L'�';
            }
            if(r >= LIGS && r < LIGE) {
                /* handle possible ligature */
                rlig = liglookup(r, rprev);
                if(rlig != NONE)
                    rprev = rlig;	/* overwrite rprev */
                else {
                    /* could print accent, but let's not */
                    if(rprev != NONE) outrune(rprev);
                    rprev = NONE;
                }
            } else if(r >= MULTI && r < MULTIE) {
                if(rprev != NONE) {
                    outrune(rprev);
                    rprev = NONE;
                }
                outrunes(multitab[r-MULTI]);
            } else if(r == PAR) {
                if(rprev != NONE) {
                    outrune(rprev);
                    rprev = NONE;
                }
                outnl(1);
            } else {
                if(rprev != NONE) outrune(rprev);
                rprev = r;
            }
        } else if(r == TAGS) {
            /* Start of tag name */
            if(rprev != NONE) {
                outrune(rprev);
                rprev = NONE;
            }
            p = gettag(p, pe);
            t = lookassoc(tagtab, asize(tagtab), tag);
            if(t == -1) {
                if(debug)
                    err("tag %ld %d %s",
                        e.doff, cursize, tag);
                continue;
            }
            switch(t) {
            case Hw:
                if(cmd == 'h') {
                    if(!tagstarts)
                        outchar(' ');
                    outinhibit = !tagstarts;
                }
                break;
            case Sn:
                if(tagstarts) {
                    outnl(2);
                }
                break;
            case P:
                outnl(tagstarts);
                break;
            case Col:
            case Br:
            case Blockquote:
                if(tagstarts)
                    outnl(1);
                break;
            case U:
                outchar('/');
            }
        }
    }
    if(cmd == 'h') {
        outinhibit = 0;
        outnl(0);
    }
}