summaryrefslogtreecommitdiff
path: root/package/bash/bash30-006
blob: fccc33b206877961170290e2a938f64d3359be0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
			     BASH PATCH REPORT
			     =================

Bash-Release: 3.0
Patch-ID: bash30-006

Bug-Reported-by: alexander@skwar.name
		 Tomohiro KUBOTA <debian@tmail.plala.or.jp>
Bug-Reference-ID: <20040801124721.C69B8A2547A@server.bei.digitalprojects.com>
		  <16688.41450.433668.480445@gargle.gargle.HOWL>
Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00006.html
		   http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=257540

Bug-Description:

Prompts with multibyte characters or invisible characters following a line
wrap are displayed incorrectly.

Patch:

*** ../bash-3.0/lib/readline/display.c	Thu May 27 22:57:51 2004
--- lib/readline/display.c	Mon Aug 30 11:55:02 2004
***************
*** 202,206 ****
  {
    char *r, *ret, *p;
!   int l, rl, last, ignoring, ninvis, invfl, ind, pind, physchars;
  
    /* Short-circuit if we can. */
--- 202,206 ----
  {
    char *r, *ret, *p;
!   int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
  
    /* Short-circuit if we can. */
***************
*** 223,226 ****
--- 223,227 ----
  
    invfl = 0;	/* invisible chars in first line of prompt */
+   invflset = 0;	/* we only want to set invfl once */
  
    for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++)
***************
*** 250,254 ****
  	        *r++ = *p++;
  	      if (!ignoring)
! 		rl += ind - pind;
  	      else
  		ninvis += ind - pind;
--- 251,258 ----
  	        *r++ = *p++;
  	      if (!ignoring)
! 		{
! 		  rl += ind - pind;
! 		  physchars += _rl_col_width (pmt, pind, ind);
! 		}
  	      else
  		ninvis += ind - pind;
***************
*** 260,273 ****
  	      *r++ = *p;
  	      if (!ignoring)
! 		rl++;			/* visible length byte counter */
  	      else
  		ninvis++;		/* invisible chars byte counter */
  	    }
  
! 	  if (rl >= _rl_screenwidth)
! 	    invfl = ninvis;
! 
! 	  if (ignoring == 0)
! 	    physchars++;
  	}
      }
--- 264,280 ----
  	      *r++ = *p;
  	      if (!ignoring)
! 		{
! 		  rl++;			/* visible length byte counter */
! 		  physchars++;
! 		}
  	      else
  		ninvis++;		/* invisible chars byte counter */
  	    }
  
! 	  if (invflset == 0 && rl >= _rl_screenwidth)
! 	    {
! 	      invfl = ninvis;
! 	      invflset = 1;
! 	    }
  	}
      }
***************
*** 418,422 ****
    register char *line;
    int c_pos, inv_botlin, lb_botlin, lb_linenum;
!   int newlines, lpos, temp, modmark;
    char *prompt_this_line;
  #if defined (HANDLE_MULTIBYTE)
--- 425,429 ----
    register char *line;
    int c_pos, inv_botlin, lb_botlin, lb_linenum;
!   int newlines, lpos, temp, modmark, n0, num;
    char *prompt_this_line;
  #if defined (HANDLE_MULTIBYTE)
***************
*** 574,577 ****
--- 581,585 ----
  #if defined (HANDLE_MULTIBYTE)
    memset (_rl_wrapped_line, 0, vis_lbsize);
+   num = 0;
  #endif
  
***************
*** 592,596 ****
--- 600,619 ----
           prompts that exceed two physical lines?
           Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
+ #if defined (HANDLE_MULTIBYTE)
+       n0 = num;
+       temp = local_prompt ? strlen (local_prompt) : 0;
+       while (num < temp)
+ 	{
+ 	  if (_rl_col_width  (local_prompt, n0, num) > _rl_screenwidth)
+ 	    {
+ 	      num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
+ 	      break;
+ 	    }
+ 	  num++;
+ 	}
+       temp = num +
+ #else
        temp = ((newlines + 1) * _rl_screenwidth) +
+ #endif /* !HANDLE_MULTIBYTE */
               ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
  							    : ((newlines == 1) ? wrap_offset : 0))
***************
*** 598,602 ****
--- 621,629 ----
               
        inv_lbreaks[++newlines] = temp;
+ #if defined (HANDLE_MULTIBYTE)
+       lpos -= _rl_col_width (local_prompt, n0, num);
+ #else
        lpos -= _rl_screenwidth;
+ #endif
      }
  

*** ../bash-3.0/patchlevel.h	Wed Aug 22 08:05:39 2001
--- patchlevel.h	Thu Sep  2 15:04:32 2004
***************
*** 26,30 ****
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 5
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
     looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 6
  
  #endif /* _PATCHLEVEL_H_ */