Beispiel #1
0
char*	id_getline(int fd)
{
    char	c;
    char*	buf;
    int	size;
    int	ret;

    buf = 0;
    size = 0;
    ret = read(fd, &c, 1);
    if (ret <= 0)
        return(0);
    buf = malloc(sizeof(*buf));
    if (buf == 0)
        return (0);
    buf[0] = 0;
    while (ret > 0)
    {
        if ( c == '\n')
            return (buf);
        if (inc_buf(&buf, &size, c))
            return (buf);
        ret = read(fd, &c, 1);
    }
    return (buf);
}
Beispiel #2
0
/*
 * v_put -- [buffer]p
 *	Insert the contents of the buffer after the cursor.
 *
 * PUBLIC: int v_put __P((SCR *, VICMD *));
 */
int
v_put(SCR *sp, VICMD *vp)
{
	u_long cnt;

	if (F_ISSET(vp, VC_ISDOT))
		inc_buf(sp, vp);

	/*
	 * !!!
	 * Historic vi did not support a count with the 'p' and 'P'
	 * commands.  It's useful, so we do.
	 */
	for (cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1; cnt--;) {
		if (put(sp, NULL,
		    F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL,
		    &vp->m_start, &vp->m_final, 1))
			return (1);
		vp->m_start = vp->m_final;
		if (INTERRUPTED(sp))
			return (1);
	}
	return (0);
}