@@ -32,9 +32,9 @@ static char * real = NULL; /* real name */
32
32
static char * olog = NULL ; /* chat log path*/
33
33
static char * inic = NULL ; /* additional server command */
34
34
35
- static struct termios orig ; /* In order to restore at exit.*/
36
- static int rawmode = 0 ; /* For atexit() function to check if restore is needed*/
37
- static int atexit_registered = 0 ; /* Register atexit just 1 time. */
35
+ static struct termios orig ; /* restore at exit. */
36
+ static int rawmode = 0 ; /* check if restore is needed */
37
+ static int atexit_registered = 0 ; /* register atexit() */
38
38
39
39
struct State {
40
40
char * buf ; /* Edited line buffer. */
@@ -109,10 +109,10 @@ static int getColumns(int ifd, int ofd) {
109
109
if (ioctl (1 , TIOCGWINSZ , & ws ) == -1 || ws .ws_col == 0 ) {
110
110
int start , cols ;
111
111
start = getCursorPosition (ifd ,ofd );
112
- if (start == -1 ) goto failed ;
113
- if (write (ofd ,"\x1b[999C" ,6 ) != 6 ) goto failed ;
112
+ if (start == -1 ) return 80 ;
113
+ if (write (ofd ,"\x1b[999C" ,6 ) != 6 ) return 80 ;
114
114
cols = getCursorPosition (ifd ,ofd );
115
- if (cols == -1 ) goto failed ;
115
+ if (cols == -1 ) return 80 ;
116
116
if (cols > start ) {
117
117
char seq [32 ];
118
118
snprintf (seq , sizeof (seq ), "\x1b[%dD" ,cols - start );
@@ -122,9 +122,6 @@ static int getColumns(int ifd, int ofd) {
122
122
} else {
123
123
return ws .ws_col ;
124
124
}
125
-
126
- failed :
127
- return 80 ;
128
125
}
129
126
130
127
static void abInit (struct abuf * ab ) {
@@ -330,8 +327,7 @@ static int edit(struct State *l, const char *prompt) {
330
327
case 27 : /* escape sequence */
331
328
if (read (STDIN_FILENO , seq , 1 ) == -1 ) break ;
332
329
if (read (STDIN_FILENO , seq + 1 , 1 ) == -1 ) break ;
333
- /* ESC [ sequences. */
334
- if (seq [0 ] == '[' ) {
330
+ if (seq [0 ] == '[' ) { /* ESC [ sequences. */
335
331
if (seq [1 ] >= '0' && seq [1 ] <= '9' ) {
336
332
/* Extended escape, read additional byte. */
337
333
if (read (STDIN_FILENO , seq + 2 , 1 ) == -1 ) break ;
@@ -347,8 +343,7 @@ static int edit(struct State *l, const char *prompt) {
347
343
}
348
344
}
349
345
}
350
- /* ESC O sequences. */
351
- else if (seq [0 ] == 'O' ) {
346
+ else if (seq [0 ] == 'O' ) { /* ESC O sequences. */
352
347
switch (seq [1 ]) {
353
348
case 'H' : editMoveHome (l ); break ; /* Home */
354
349
case 'F' : editMoveEnd (l ); break ; /* End*/
@@ -470,7 +465,7 @@ static void rawParser(char *string) {
470
465
471
466
if (string [0 ] != ':' ) return ;
472
467
473
- printf ("\r" );
468
+ printf ("\r\x1b[0K " );
474
469
475
470
if (verb ) printf (">> %s" , string );
476
471
if (olog ) logAppend (string , olog );
@@ -638,7 +633,6 @@ int main(int argc, char **argv) {
638
633
}
639
634
if (pass ) raw ("PASS %s\r\n" , pass );
640
635
if (inic ) raw ("%s\r\n" , inic );
641
- if (cdef [0 ] == '\0' ) strcpy (cdef , "?" );
642
636
643
637
struct pollfd fds [2 ];
644
638
fds [0 ].fd = STDIN_FILENO ;
@@ -649,7 +643,7 @@ int main(int argc, char **argv) {
649
643
char usrin [MSG_MAX ], promptc [CHA_MAX ];
650
644
651
645
struct State l ;
652
-
646
+
653
647
l .buf = usrin ;
654
648
l .buflen = MSG_MAX ;
655
649
l .prompt = promptc ;
0 commit comments