source:
scripts/patches/readline-5.0-fixes-1.patch@
f35399d3
Last change on this file since f35399d3 was 7f65c0e, checked in by , 19 years ago | |
---|---|
|
|
File size: 6.8 KB |
-
readline-5.0
Submitted By: Jim Gifford (patches at jg555 dot com) Date: 2004-09-29 Initial Package Version: 5.0 Origin: Various Upstream Status: Already Applied Description: This patch contains various fixes recommended by the author Chet. The original patches are avaiable at ftp://ftp.cwru.edu/pub/bash/readline-5.0-patches diff -Naur readline-5.0.orig/display.c readline-5.0/display.c
old new 201 201 int *lp, *lip, *niflp, *vlp; 202 202 { 203 203 char *r, *ret, *p; 204 int l, rl, last, ignoring, ninvis, invfl, in d, pind, physchars;204 int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars; 205 205 206 206 /* Short-circuit if we can. */ 207 207 if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0) … … 222 222 r = ret = (char *)xmalloc (l + 1); 223 223 224 224 invfl = 0; /* invisible chars in first line of prompt */ 225 invflset = 0; /* we only want to set invfl once */ 225 226 226 227 for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++) 227 228 { … … 249 250 while (l--) 250 251 *r++ = *p++; 251 252 if (!ignoring) 252 rl += ind - pind; 253 { 254 rl += ind - pind; 255 physchars += _rl_col_width (pmt, pind, ind); 256 } 253 257 else 254 258 ninvis += ind - pind; 255 259 p--; /* compensate for later increment */ … … 259 263 { 260 264 *r++ = *p; 261 265 if (!ignoring) 262 rl++; /* visible length byte counter */ 266 { 267 rl++; /* visible length byte counter */ 268 physchars++; 269 } 263 270 else 264 271 ninvis++; /* invisible chars byte counter */ 265 272 } 266 273 267 if ( rl >= _rl_screenwidth)268 invfl = ninvis;269 270 if (ignoring == 0)271 physchars++;274 if (invflset == 0 && rl >= _rl_screenwidth) 275 { 276 invfl = ninvis; 277 invflset = 1; 278 } 272 279 } 273 280 } 274 281 … … 351 358 local_prompt = expand_prompt (p, &prompt_visible_length, 352 359 &prompt_last_invisible, 353 360 (int *)NULL, 354 (int *)NULL);361 &prompt_physical_chars); 355 362 c = *t; *t = '\0'; 356 363 /* The portion of the prompt string up to and including the 357 364 final newline is now null-terminated. */ 358 365 local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length, 359 366 (int *)NULL, 360 367 &prompt_invis_chars_first_line, 361 &prompt_physical_chars);368 (int *)NULL); 362 369 *t = c; 363 370 return (prompt_prefix_length); 364 371 } … … 417 424 register int in, out, c, linenum, cursor_linenum; 418 425 register char *line; 419 426 int c_pos, inv_botlin, lb_botlin, lb_linenum; 420 int newlines, lpos, temp, modmark ;427 int newlines, lpos, temp, modmark, n0, num; 421 428 char *prompt_this_line; 422 429 #if defined (HANDLE_MULTIBYTE) 423 430 wchar_t wc; … … 573 580 574 581 #if defined (HANDLE_MULTIBYTE) 575 582 memset (_rl_wrapped_line, 0, vis_lbsize); 583 num = 0; 576 584 #endif 577 585 578 586 /* prompt_invis_chars_first_line is the number of invisible characters in … … 591 599 probably too much work for the benefit gained. How many people have 592 600 prompts that exceed two physical lines? 593 601 Additional logic fix from Edward Catmur <ed@catmur.co.uk> */ 602 #if defined (HANDLE_MULTIBYTE) 603 n0 = num; 604 temp = local_prompt ? strlen (local_prompt) : 0; 605 while (num < temp) 606 { 607 if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth) 608 { 609 num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY); 610 break; 611 } 612 num++; 613 } 614 temp = num + 615 #else 594 616 temp = ((newlines + 1) * _rl_screenwidth) + 617 #endif /* !HANDLE_MULTIBYTE */ 595 618 ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line 596 619 : ((newlines == 1) ? wrap_offset : 0)) 597 620 : ((newlines == 0) ? wrap_offset :0)); 598 621 599 622 inv_lbreaks[++newlines] = temp; 623 #if defined (HANDLE_MULTIBYTE) 624 lpos -= _rl_col_width (local_prompt, n0, num); 625 #else 600 626 lpos -= _rl_screenwidth; 627 #endif 601 628 } 602 629 603 630 prompt_last_screen_line = newlines; -
readline-5.0
diff -Naur readline-5.0.orig/mbutil.c readline-5.0/mbutil.c
old new 126 126 if (find_non_zero) 127 127 { 128 128 tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps); 129 while ( wcwidth (wc) == 0)129 while (tmp > 0 && wcwidth (wc) == 0) 130 130 { 131 131 point += tmp; 132 132 tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps); 133 if ( tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))133 if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp)) 134 134 break; 135 135 } 136 136 } -
readline-5.0
diff -Naur readline-5.0.orig/misc.c readline-5.0/misc.c
old new 276 276 _rl_saved_line_for_history->line = savestring (rl_line_buffer); 277 277 _rl_saved_line_for_history->data = (char *)rl_undo_list; 278 278 } 279 else if (STREQ (rl_line_buffer, _rl_saved_line_for_history->line) == 0)280 {281 free (_rl_saved_line_for_history->line);282 _rl_saved_line_for_history->line = savestring (rl_line_buffer);283 _rl_saved_line_for_history->data = (char *)rl_undo_list; /* XXX possible memleak */284 }285 279 286 280 return 0; 287 281 } -
readline-5.0
diff -Naur readline-5.0.orig/vi_mode.c readline-5.0/vi_mode.c
old new 272 272 switch (key) 273 273 { 274 274 case '?': 275 _rl_free_saved_history_line (); 275 276 rl_noninc_forward_search (count, key); 276 277 break; 277 278 278 279 case '/': 280 _rl_free_saved_history_line (); 279 281 rl_noninc_reverse_search (count, key); 280 282 break; 281 283 … … 690 692 { 691 693 wchar_t wc; 692 694 char mb[MB_LEN_MAX+1]; 693 int mblen ;695 int mblen, p; 694 696 mbstate_t ps; 695 697 696 698 memset (&ps, 0, sizeof (mbstate_t)); … … 713 715 /* Vi is kind of strange here. */ 714 716 if (wc) 715 717 { 718 p = rl_point; 716 719 mblen = wcrtomb (mb, wc, &ps); 717 720 if (mblen >= 0) 718 721 mb[mblen] = '\0'; 719 722 rl_begin_undo_group (); 720 rl_delete (1, 0); 723 rl_vi_delete (1, 0); 724 if (rl_point < p) /* Did we retreat at EOL? */ 725 rl_point++; /* XXX - should we advance more than 1 for mbchar? */ 721 726 rl_insert_text (mb); 722 727 rl_end_undo_group (); 723 728 rl_vi_check (); … … 1310 1315 rl_vi_delete (1, c); 1311 1316 #if defined (HANDLE_MULTIBYTE) 1312 1317 if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) 1313 while (_rl_insert_char (1, c)) 1314 { 1315 RL_SETSTATE (RL_STATE_MOREINPUT); 1316 c = rl_read_key (); 1317 RL_UNSETSTATE (RL_STATE_MOREINPUT); 1318 } 1318 { 1319 if (rl_point < p) /* Did we retreat at EOL? */ 1320 rl_point++; 1321 while (_rl_insert_char (1, c)) 1322 { 1323 RL_SETSTATE (RL_STATE_MOREINPUT); 1324 c = rl_read_key (); 1325 RL_UNSETSTATE (RL_STATE_MOREINPUT); 1326 } 1327 } 1319 1328 else 1320 1329 #endif 1321 1330 {
Note:
See TracBrowser
for help on using the repository browser.