comparison mcabber/mcabber/screen.c @ 1903:75a0a22bbf78

Fix issue #54 -- command line corruption Thanks to the Anonymous reporter :)
author Mikael Berthe <mikael@lilotux.net>
date Sat, 17 Apr 2010 11:21:04 +0200
parents 2b013c0f949a
children e09763e16e49
comparison
equal deleted inserted replaced
1902:51cc01a1a5ec 1903:75a0a22bbf78
3139 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match 3139 if (strncmp(cmdhisto_backup, mask, len)) return NULL; // No match
3140 cmdhisto_cur = NULL; 3140 cmdhisto_cur = NULL;
3141 return cmdhisto_backup; 3141 return cmdhisto_backup;
3142 } 3142 }
3143 3143
3144 static char *_strmove(char *dst, const char *src)
3145 {
3146 char *dest = dst;
3147 while ((*dest++ = *src++) != '\0')
3148 ;
3149 return dest;
3150 }
3151
3144 // readline_transpose_chars() 3152 // readline_transpose_chars()
3145 // Drag the character before point forward over the character at 3153 // Drag the character before point forward over the character at
3146 // point, moving point forward as well. If point is at the end of 3154 // point, moving point forward as well. If point is at the end of
3147 // the line, then this transposes the two characters before point. 3155 // the line, then this transposes the two characters before point.
3148 void readline_transpose_chars(void) 3156 void readline_transpose_chars(void)
3219 c = next_char(c); 3227 c = next_char(c);
3220 } 3228 }
3221 3229
3222 // Modify the line 3230 // Modify the line
3223 ptr_inputline = c; 3231 ptr_inputline = c;
3224 for (;;) { 3232 _strmove(ptr_inputline, old);
3225 *c = *old++;
3226 if (!*c++) break;
3227 }
3228 check_offset(-1); 3233 check_offset(-1);
3229 } 3234 }
3230 3235
3231 // readline_backward_word() 3236 // readline_backward_word()
3232 // Move back to the start of the current or previous word 3237 // Move back to the start of the current or previous word
3449 return; 3454 return;
3450 3455
3451 src = ptr_inputline; 3456 src = ptr_inputline;
3452 c = prev_char(ptr_inputline, inputLine); 3457 c = prev_char(ptr_inputline, inputLine);
3453 ptr_inputline = c; 3458 ptr_inputline = c;
3454 for ( ; *src ; ) 3459 _strmove(ptr_inputline, src);
3455 *c++ = *src++;
3456 *c = 0;
3457 check_offset(-1); 3460 check_offset(-1);
3458 } 3461 }
3459 3462
3460 void readline_forward_kill_char(void) 3463 void readline_forward_kill_char(void)
3461 { 3464 {
3462 if (!*ptr_inputline) 3465 if (!*ptr_inputline)
3463 return; 3466 return;
3464 3467
3465 strcpy(ptr_inputline, next_char(ptr_inputline)); 3468 _strmove(ptr_inputline, next_char(ptr_inputline));
3466 } 3469 }
3467 3470
3468 void readline_iline_start(void) 3471 void readline_iline_start(void)
3469 { 3472 {
3470 ptr_inputline = inputLine; 3473 ptr_inputline = inputLine;
3484 if (ptr_inputline == inputLine) return; 3487 if (ptr_inputline == inputLine) return;
3485 3488
3486 if (*dest == COMMAND_CHAR && ptr_inputline != dest+1) 3489 if (*dest == COMMAND_CHAR && ptr_inputline != dest+1)
3487 dest = next_char(dest); 3490 dest = next_char(dest);
3488 3491
3489 strcpy(dest, ptr_inputline); 3492 _strmove(dest, ptr_inputline);
3490 ptr_inputline = dest; 3493 ptr_inputline = dest;
3491 inputline_offset = 0; 3494 inputline_offset = 0;
3492 } 3495 }
3493 3496
3494 void readline_forward_kill_iline(void) 3497 void readline_forward_kill_iline(void)