MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_readline

Function db_readline

freebsd/ddb/db_input.c:316–362  ·  view source on GitHub ↗
(lstart, lsize)

Source from the content-addressed store, hash-verified

314}
315
316int
317db_readline(lstart, lsize)
318 char * lstart;
319 int lsize;
320{
321
322 if (lsize < 2)
323 return (0);
324 if (lsize != db_lhistlsize) {
325 /*
326 * (Re)initialize input line history. Throw away any
327 * existing history.
328 */
329 db_lhist_nlines = sizeof(db_lhistory) / lsize;
330 db_lhistlsize = lsize;
331 db_lhistidx = -1;
332 }
333 db_lhistcur = db_lhistidx;
334
335 db_force_whitespace(); /* synch output position */
336
337 db_lbuf_start = lstart;
338 db_lbuf_end = lstart + lsize - 2; /* Will append NL and NUL. */
339 db_lc = lstart;
340 db_le = lstart;
341
342 while (!db_inputchar(cngetc()))
343 continue;
344
345 db_capture_write(lstart, db_le - db_lbuf_start);
346 db_printf("\n"); /* synch output position */
347 *db_le = 0;
348
349 if (db_le - db_lbuf_start > 1) {
350 /* Maintain input line history for non-empty lines. */
351 if (++db_lhistidx == db_lhist_nlines) {
352 /* Rotate history. */
353 bcopy(db_lhistory + db_lhistlsize, db_lhistory,
354 db_lhistlsize * (db_lhist_nlines - 1));
355 db_lhistidx--;
356 }
357 bcopy(lstart, db_lhistory + db_lhistidx * db_lhistlsize,
358 db_lhistlsize);
359 }
360
361 return (db_le - db_lbuf_start);
362}
363
364void
365db_check_interrupt(void)

Callers 1

db_read_lineFunction · 0.85

Calls 5

db_force_whitespaceFunction · 0.85
db_inputcharFunction · 0.85
cngetcFunction · 0.85
db_capture_writeFunction · 0.85
db_printfFunction · 0.85

Tested by

no test coverage detected