Changeset 90f11edd in rtems


Ignore:
Timestamp:
Jan 29, 2020, 8:32:05 AM (7 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
b2ddf4f
Parents:
2d07ce6
git-author:
Sebastian Huber <sebastian.huber@…> (01/29/20 08:32:05)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/10/20 08:01:10)
Message:

termios: Fix input canonical mode

Canonical input processing was broken by
667501a314ba75f80f1c13c6b43dd35d0a00efd1 as shown by test case
termios09.

Update #3800.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/termios.c

    r2d07ce6 r90f11edd  
    13381338/**
    13391339 * @brief Type returned by all input processing (iproc) methods
    1340  */ 
     1340 */
    13411341typedef enum {
    13421342  /**
    1343    * This indicates that the input character was processed
    1344    * and the results were placed into the buffer.
     1343   * This indicates that the input processing can continue.
    13451344   */
    1346   RTEMS_TERMIOS_IPROC_IN_BUFFER,
     1345  RTEMS_TERMIOS_IPROC_CONTINUE,
    13471346  /**
    1348    * This indicates that the input character was processed
    1349    * and the result did not go into the buffer.
     1347   * This indicates that the input processing is done.
    13501348   */
    1351   RTEMS_TERMIOS_IPROC_WAS_PROCESSED,
    1352   /**
    1353    * This indicates that the input character was not processed and
    1354    * subsequent processing is required.
    1355    */
    1356   RTEMS_TERMIOS_IPROC_WAS_NOT_PROCESSED,
     1349  RTEMS_TERMIOS_IPROC_DONE,
    13571350  /**
    13581351   * This indicates that the character was processed and determined
     
    13621355   * the pending read() operation should be interrupted.
    13631356   */
    1364   RTEMS_TERMIOS_IPROC_INTERRUPT_READ
     1357  RTEMS_TERMIOS_IPROC_INTERRUPT
    13651358} rtems_termios_iproc_status_code;
    13661359
     
    13801373      rc = (*termios_isig_handler)(c, tty);
    13811374      if (rc == RTEMS_TERMIOS_ISIG_INTERRUPT_READ) {
    1382          return RTEMS_TERMIOS_IPROC_INTERRUPT_READ;
    1383       }
    1384       if (rc == RTEMS_TERMIOS_ISIG_WAS_PROCESSED) {
    1385          return RTEMS_TERMIOS_IPROC_IN_BUFFER;
    1386       }
    1387       _Assert(rc == RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED);
     1375         return RTEMS_TERMIOS_IPROC_INTERRUPT;
     1376      }
     1377
     1378      return RTEMS_TERMIOS_IPROC_CONTINUE;
    13881379    }
    13891380  }
     
    13951386    if (c == tty->termios.c_cc[VERASE]) {
    13961387      erase (tty, 0);
    1397       return RTEMS_TERMIOS_IPROC_WAS_PROCESSED;
     1388      return RTEMS_TERMIOS_IPROC_CONTINUE;
    13981389    }
    13991390    else if (c == tty->termios.c_cc[VKILL]) {
    14001391      erase (tty, 1);
    1401       return RTEMS_TERMIOS_IPROC_WAS_PROCESSED;
     1392      return RTEMS_TERMIOS_IPROC_CONTINUE;
    14021393    }
    14031394    else if (c == tty->termios.c_cc[VEOF]) {
    1404       return RTEMS_TERMIOS_IPROC_IN_BUFFER;
     1395      return RTEMS_TERMIOS_IPROC_DONE;
    14051396    } else if (c == '\n') {
    14061397      if (tty->termios.c_lflag & (ECHO | ECHONL))
    14071398        echo (c, tty);
    14081399      tty->cbuf[tty->ccount++] = c;
    1409       return RTEMS_TERMIOS_IPROC_IN_BUFFER;
     1400      return RTEMS_TERMIOS_IPROC_DONE;
    14101401    } else if ((c == tty->termios.c_cc[VEOL]) ||
    14111402               (c == tty->termios.c_cc[VEOL2])) {
     
    14131404        echo (c, tty);
    14141405      tty->cbuf[tty->ccount++] = c;
    1415       return RTEMS_TERMIOS_IPROC_IN_BUFFER;
     1406      return RTEMS_TERMIOS_IPROC_DONE;
    14161407    }
    14171408  }
     
    14261417      echo (c, tty);
    14271418    tty->cbuf[tty->ccount++] = c;
    1428     return RTEMS_TERMIOS_IPROC_IN_BUFFER;
    1429   }
    1430   return RTEMS_TERMIOS_IPROC_WAS_NOT_PROCESSED;
     1419  }
     1420  return RTEMS_TERMIOS_IPROC_CONTINUE;
    14311421}
    14321422
     
    14571447{
    14581448  if (c == '\r' && (tty->termios.c_iflag & IGNCR) != 0) {
    1459     return RTEMS_TERMIOS_IPROC_WAS_NOT_PROCESSED;
     1449    return RTEMS_TERMIOS_IPROC_CONTINUE;
    14601450  }
    14611451
     
    14771467  int                             n;
    14781468  rtems_termios_iproc_status_code rc;
    1479   rtems_termios_iproc_status_code retval = RTEMS_TERMIOS_IPROC_WAS_PROCESSED;
    14801469
    14811470  if (tty->termios.c_lflag & ICANON) {
     
    14861475      } else {
    14871476        rc = siprocPoll (n, tty);
    1488         if (rc == RTEMS_TERMIOS_IPROC_IN_BUFFER) {
    1489           break;
    1490         }
    1491         if (rc == RTEMS_TERMIOS_IPROC_INTERRUPT_READ) {
    1492           retval = RTEMS_TERMIOS_IPROC_INTERRUPT_READ;
    1493           break;
     1477        if (rc != RTEMS_TERMIOS_IPROC_CONTINUE) {
     1478          return rc;
    14941479        }
    14951480      }
     
    15201505      } else {
    15211506        rc = siprocPoll (n, tty);
    1522         if (rc == RTEMS_TERMIOS_IPROC_INTERRUPT_READ) {
    1523           retval = RTEMS_TERMIOS_IPROC_INTERRUPT_READ;
    1524           break;
     1507        if (rc != RTEMS_TERMIOS_IPROC_CONTINUE) {
     1508          return rc;
    15251509        }
    15261510        if (tty->ccount >= tty->termios.c_cc[VMIN])
     
    15311515    }
    15321516  }
    1533   return retval;
     1517  return RTEMS_TERMIOS_IPROC_CONTINUE;
    15341518}
    15351519
     
    15881572      if (tty->termios.c_lflag & ICANON) {
    15891573        rc = siproc (c, tty);
    1590         /* If the read() should be interrupted, return */
    1591         if (rc == RTEMS_TERMIOS_IPROC_INTERRUPT_READ) {
    1592           return RTEMS_TERMIOS_IPROC_INTERRUPT_READ;
    1593         }
    1594         /* In canonical mode, input is made available line by line */
    1595         if (rc == RTEMS_TERMIOS_IPROC_IN_BUFFER) {
    1596           return RTEMS_TERMIOS_IPROC_IN_BUFFER;
     1574        if (rc != RTEMS_TERMIOS_IPROC_CONTINUE) {
     1575          return rc;
    15971576        }
    15981577      } else {
    15991578        rc = siproc (c, tty);
    1600         /* If the read() should be interrupted, return */
    1601         if (rc == RTEMS_TERMIOS_IPROC_INTERRUPT_READ) {
    1602           return RTEMS_TERMIOS_IPROC_INTERRUPT_READ;
     1579
     1580        /* in non-canonical mode only stop on interrupt */
     1581        if (rc == RTEMS_TERMIOS_IPROC_INTERRUPT) {
     1582          return rc;
    16031583        }
     1584
    16041585        if (tty->ccount >= tty->termios.c_cc[VMIN])
    16051586          wait = false;
     
    16361617    }
    16371618  }
    1638   return RTEMS_TERMIOS_IPROC_WAS_PROCESSED;
     1619  return RTEMS_TERMIOS_IPROC_CONTINUE;
    16391620}
    16401621
     
    16481629{
    16491630  uint32_t                         count;
    1650   rtems_termios_iproc_status_code  rc = RTEMS_TERMIOS_IPROC_WAS_PROCESSED;
     1631  rtems_termios_iproc_status_code  rc;
    16511632
    16521633  count = initial_count;
     
    16591640    else
    16601641      rc = fillBufferQueue (tty);
     1642  } else {
     1643    rc = RTEMS_TERMIOS_IPROC_CONTINUE;
    16611644  }
    16621645
     
    16761659   * and cause a signal, or a user defined action.
    16771660   */
    1678   if (rc == RTEMS_TERMIOS_IPROC_INTERRUPT_READ) {
     1661  if (rc == RTEMS_TERMIOS_IPROC_INTERRUPT) {
    16791662    return RTEMS_INTERRUPTED;
    16801663  }
Note: See TracChangeset for help on using the changeset viewer.