thinking that a command executed successfully.
.cursor = 0,
};
int key;
- char *line = NULL;
+ char *line;
if ( prompt )
printf ( "%s", prompt );
switch ( key ) {
case 0x0d: /* Carriage return */
case 0x0a: /* Line feed */
+ putchar ( '\n' );
line = strdup ( buf );
- goto out;
+ if ( ! line )
+ printf ( "Out of memory\n" );
+ return line;
case 0x03: /* Ctrl-C */
- goto out;
+ putchar ( '\n' );
+ return NULL;
default:
/* Do nothing */
break;
}
}
-
- out:
- putchar ( '\n' );
- return line;
}