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

Function ttydisc_write_oproc

freebsd/kern/tty_ttydisc.c:368–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368static int
369ttydisc_write_oproc(struct tty *tp, char c)
370{
371 unsigned int scnt, error;
372
373 MPASS(CMP_FLAG(o, OPOST));
374 MPASS(CTL_VALID(c));
375
376#define PRINT_NORMAL() ttyoutq_write_nofrag(&tp->t_outq, &c, 1)
377 switch (c) {
378 case CEOF:
379 /* End-of-text dropping. */
380 if (CMP_FLAG(o, ONOEOT))
381 return (0);
382 return PRINT_NORMAL();
383
384 case CERASE2:
385 /* Handle backspace to fix tab expansion. */
386 if (PRINT_NORMAL() != 0)
387 return (-1);
388 if (tp->t_column > 0)
389 tp->t_column--;
390 return (0);
391
392 case CTAB:
393 /* Tab expansion. */
394 scnt = 8 - (tp->t_column & 7);
395 if (CMP_FLAG(o, TAB3)) {
396 error = ttyoutq_write_nofrag(&tp->t_outq,
397 " ", scnt);
398 } else {
399 error = PRINT_NORMAL();
400 }
401 if (error)
402 return (-1);
403
404 tp->t_column += scnt;
405 MPASS((tp->t_column % 8) == 0);
406 return (0);
407
408 case CNL:
409 /* Newline conversion. */
410 if (CMP_FLAG(o, ONLCR)) {
411 /* Convert \n to \r\n. */
412 error = ttyoutq_write_nofrag(&tp->t_outq, "\r\n", 2);
413 } else {
414 error = PRINT_NORMAL();
415 }
416 if (error)
417 return (-1);
418
419 if (CMP_FLAG(o, ONLCR|ONLRET)) {
420 tp->t_column = tp->t_writepos = 0;
421 ttyinq_reprintpos_set(&tp->t_inq);
422 }
423 return (0);
424
425 case CCR:

Callers 2

ttydisc_writeFunction · 0.85
ttydisc_echo_forceFunction · 0.85

Calls 2

ttyoutq_write_nofragFunction · 0.85
ttyinq_reprintpos_setFunction · 0.85

Tested by

no test coverage detected