コード例 #1
0
ファイル: input.c プロジェクト: n-t-roff/9front_troff
Obj *copythru(char *s)	/* collect the macro name or body for thru */
{
	Obj *p;
	char *q;

	p = lookup(s, 0);
	if (p != NULL) {
		if (p->type == DEFNAME) {
			p->val = addnewline(p->val);
			return p;
		} else
			ERROR "%s used as define and name", s FATAL;
	}
	/* have to collect the definition */
	pbstr(s);	/* first char is the delimiter */
	q = delimstr("thru body");
	p = lookup("nameless", 1);
	if (p != NULL)
		if (p->val)
			free(p->val);
	p->type = DEFNAME;
	p->val = q;
	p->val = addnewline(p->val);
	dprintf("installing nameless as `%s'\n", p->val);
	return p;
}
コード例 #2
0
ファイル: input.c プロジェクト: aahud/harvey
struct symtab *copythru(char *s)	/* collect the macro name or body for thru */
{
	struct symtab *p;
	char *q, *addnewline(char *);

	p = lookup(s);
	if (p != NULL) {
		if (p->s_type == DEFNAME) {
			p->s_val.p = addnewline(p->s_val.p);
			return p;
		} else
			ERROR "%s used as define and name", s FATAL;
	}
	/* have to collect the definition */
	pbstr(s);	/* first char is the delimiter */
	q = delimstr("thru body");
	s = "nameless";
	p = lookup(s);
	if (p != NULL) {
		if (p->s_val.p)
			free(p->s_val.p);
		p->s_val.p = q;
	} else {
		YYSTYPE u;
		u.p = q;
		p = makevar(tostring(s), DEFNAME, u);
	}
	p->s_val.p = addnewline(p->s_val.p);
	dprintf("installing %s as `%s'\n", s, p->s_val.p);
	return p;
}
コード例 #3
0
ファイル: renderer.c プロジェクト: Orc/ndialog
/*
 * flushline() finalizes a rendered line and sets up for the next line.
 */
static int
flushline()
{
    int indent = state.indent;

    /* deal with leading indent, which is not clickable */

    if (XP > 0) {
	switch (state.align) {
	case wwRIGHT:
		if (XP < state.width)
		    indent += state.width - XP;
		break;
	case wwCENTER:
		if (XP < state.width)
		    indent += (state.width - XP) / 2;
		break;
	default:
		/* everything else is left-alignment */
		break;
	}
	setindent(indent);
	addnewline();
	return 1;
    }
    return 0;
} /* flushline */
コード例 #4
0
ファイル: renderer.c プロジェクト: Orc/ndialog
/*
 * addspace() adds space to the rendered page, breaking the line as appropriate
 */
void
addspace(char *space)
{
    switch (state.doing) {
    case D_PRE:
	    /* when doing a PRE segment, we need to catch \n's and properly
	     * expand them into \n, DLE, ' ' */
	    while (*space) {
		if (*space == '\n')
		    addnewline();
		else {
		    linestart();
		    addchar(*space);
		}
		++space;
	    }
	    break;
    case D_TITLE:
	    if (!LASTWASSPACE) {
		state.page->titlelen++;
		state.page->title = realloc(state.page->title,
					    state.page->titlelen+2);
		strcat(state.page->title, " ");
	    }
	    break;
    default:
	    if (!LASTWASSPACE) {
		if (XP >= state.width)
		    breakline();
		else if (XP > 0) {
		    linestart();
		    addchar(' ');
		    XP++;
		}
	    }
	    break;
    }
    LASTWASSPACE = 1;
} /* addspace */
コード例 #5
0
ファイル: renderer.c プロジェクト: Orc/ndialog
/*
 * newline() breaks the current line, even if there's nothing to be
 * broken on it.
 */
void
newline()
{
    if (!flushline())
	addnewline();
} /* newline */