Changeset 8a68b60 in rtems


Ignore:
Timestamp:
Nov 23, 2009, 9:55:36 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, master
Children:
13c37ad
Parents:
6e701e2
Message:

2009-11-23 Joel Sherrill <joel.sherrill@…>

  • libmisc/shell/login_prompt.c: Properly process EOF and do not depend on ungetc() to propagate the status back.
Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r6e701e2 r8a68b60  
     12009-11-23      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * libmisc/shell/login_prompt.c: Properly process EOF and do not depend
     4        on ungetc() to propagate the status back.
     5
    162009-11-23      Joel Sherrill <joel.sherrill@OARcorp.com>
    27
  • cpukit/libmisc/shell/login_prompt.c

    r6e701e2 r8a68b60  
    7979}
    8080
    81 static void rtems_shell_get_text(
     81static bool rtems_shell_get_text(
    8282  FILE *in,
    8383  FILE *out,
     
    9494
    9595  if (size < 1) {
    96     return;
     96    return false;
    9797  }
    9898
     
    107107    switch (c) {
    108108      case EOF:
    109         /* Here comes an ugly hack: The Termios driver's read() handler returns
    110          * 0 to the C library's fgets() if it times out.  fgets() interprets
    111          * this (correctly) as EOF, a condition we want to undo since it's not
    112          * really true since we really have a read error (Termios bug?).
    113          *
    114          * As a workaround we push something back and read it again.  This
    115          * should simply reset the EOF condition.
    116          */
    117         if (ungetc( '?', in) == '?') {
    118           fgetc( in);
    119         }
    120         break;
     109        return false;
    121110      case '\n':
    122111      case '\r':
    123112        put( '\n', out);
    124113        line [i] = '\0';
    125         return;
     114        return true;
    126115      case  127:
    127116      case '\b':
     
    182171    fprintf( out, "%s login: ", device);
    183172    fflush( out);
    184     rtems_shell_get_text( in, out, user, sizeof( user));
     173    if ( !rtems_shell_get_text( in, out, user, sizeof( user)) )
     174      break;
    185175
    186176    fflush( in);
    187177    fprintf( out, "Password: ");
    188178    fflush( out);
    189     rtems_shell_get_text( in, NULL, passphrase, sizeof( passphrase));
     179    if ( !rtems_shell_get_text( in, NULL, passphrase, sizeof( passphrase)) )
     180      break;
    190181    fputc( '\n', out);
    191182
Note: See TracChangeset for help on using the changeset viewer.