Beispiel #1
0
int
db_readline(char *lstart, int lsize)
{
	db_force_whitespace();	/* synch output position */

	db_lbuf_start = lstart;
	db_lbuf_end   = lstart + lsize - 1;
	db_lc = lstart;
	db_le = lstart;

	while (!db_inputchar(cngetc()))
	    continue;

	db_putchar('\n');	/* synch output position */

	*db_le = 0;
	return (db_le - db_lbuf_start);
}
Beispiel #2
0
int
db_readline(char *lstart, int lsize)
{
    if (lsize != db_lhistlsize) {
        /*
         * (Re)initialize input line history.  Throw away any
         * existing history.
         */
        db_lhist_nlines = sizeof(db_lhistory) / lsize;
        db_lhistlsize = lsize;
        db_lhistidx = -1;
    }
    db_lhistcur = db_lhistidx;

    db_force_whitespace();	/* synch output position */

    db_lbuf_start = lstart;
    db_lbuf_end   = lstart + lsize;
    db_lc = lstart;
    db_le = lstart;

    while (!db_inputchar(cngetc()))
        continue;

    db_printf("\n");	/* synch output position */
    *db_le = 0;

    if (db_le - db_lbuf_start > 1) {
        /* Maintain input line history for non-empty lines. */
        if (++db_lhistidx == db_lhist_nlines) {
            /* Rotate history. */
            ovbcopy(db_lhistory + db_lhistlsize, db_lhistory,
                    db_lhistlsize * (db_lhist_nlines - 1));
            db_lhistidx--;
        }
        bcopy(lstart, db_lhistory + db_lhistidx * db_lhistlsize,
              db_lhistlsize);
    }

    return (db_le - db_lbuf_start);
}