(lstart, lsize)
| 314 | } |
| 315 | |
| 316 | int |
| 317 | db_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 | |
| 364 | void |
| 365 | db_check_interrupt(void) |
no test coverage detected