mirror of https://github.com/tildeclub/ex-vi.git
* Handle character case conversions with the '~' vi command correctly if the
length of the converted multibyte sequence is smaller than the original one.
This commit is contained in:
parent
f5b548bc9b
commit
7a66b78ed7
4
Changes
4
Changes
|
@ -1,3 +1,7 @@
|
||||||
|
Release ...
|
||||||
|
* Handle character case conversions with the '~' vi command correctly if the
|
||||||
|
length of the converted multibyte sequence is smaller than the original one.
|
||||||
|
|
||||||
Release 12/2/04
|
Release 12/2/04
|
||||||
* Support for multibyte character locales was added.
|
* Support for multibyte character locales was added.
|
||||||
* The code has been converted to ANSI C, and support for pre-POSIX systems has
|
* The code has been converted to ANSI C, and support for pre-POSIX systems has
|
||||||
|
|
|
@ -70,12 +70,12 @@
|
||||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* Sccsid @(#)ex_version.c 1.107 (gritter) 12/2/04
|
* Sccsid @(#)ex_version.c 1.108 (gritter) 1/2/05
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ex.h"
|
#include "ex.h"
|
||||||
|
|
||||||
static char *versionstring = "@(#)Version 4.0 (gritter) 12/2/04";
|
static char *versionstring = "@(#)Version 4.0 (gritter) 1/2/05";
|
||||||
|
|
||||||
void
|
void
|
||||||
printver(void)
|
printver(void)
|
||||||
|
|
37
ex_vops3.c
37
ex_vops3.c
|
@ -73,7 +73,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#ifdef DOSCCS
|
#ifdef DOSCCS
|
||||||
static char sccsid[] = "@(#)ex_vops3.c 1.18 (gritter) 11/27/04";
|
static char sccsid[] = "@(#)ex_vops3.c 1.19 (gritter) 1/2/05";
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -625,25 +625,25 @@ isa(register char *cp)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
cswitch(char *dst, const char *src)
|
cswitch(char *dst, int *dn, const char *src, int *sn)
|
||||||
{
|
{
|
||||||
int c, n;
|
int c;
|
||||||
|
|
||||||
#ifdef MB
|
#ifdef MB
|
||||||
if (mb_cur_max > 1) {
|
if (mb_cur_max > 1) {
|
||||||
nextc(c, src, n);
|
nextc(c, src, *sn);
|
||||||
if (c & INVBIT) {
|
if (c & INVBIT) {
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
n = 1;
|
*dn = *sn = 1;
|
||||||
} else {
|
} else {
|
||||||
if (iswupper(c))
|
if (iswupper(c))
|
||||||
c = towlower(c);
|
c = towlower(c);
|
||||||
else if (iswlower(c))
|
else if (iswlower(c))
|
||||||
c = towupper(c);
|
c = towupper(c);
|
||||||
if (wctomb(dst, c) != n) {
|
if ((*dn = wctomb(dst, c)) > *sn) {
|
||||||
*dst = *src;
|
*dst = *src;
|
||||||
n = 1;
|
*dn = *sn = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -656,9 +656,8 @@ cswitch(char *dst, const char *src)
|
||||||
*dst = toupper(c);
|
*dst = toupper(c);
|
||||||
else
|
else
|
||||||
*dst = c;
|
*dst = c;
|
||||||
n = 1;
|
*dn = *sn = 1;
|
||||||
}
|
}
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -666,26 +665,26 @@ vswitch(int cnt)
|
||||||
{
|
{
|
||||||
if (cnt <= 1) {
|
if (cnt <= 1) {
|
||||||
char mbuf[MB_LEN_MAX+4];
|
char mbuf[MB_LEN_MAX+4];
|
||||||
int n;
|
int n0, n1;
|
||||||
setLAST();
|
setLAST();
|
||||||
mbuf[0] = 'r';
|
mbuf[0] = 'r';
|
||||||
n = cswitch(&mbuf[1], cursor);
|
cswitch(&mbuf[1], &n1, cursor, &n0);
|
||||||
if (cursor[n] != '\0')
|
if (cursor[n1] != '\0')
|
||||||
mbuf[1+n++] = ' ';
|
mbuf[1+n1++] = ' ';
|
||||||
mbuf[1+n] = '\0';
|
mbuf[1+n1] = '\0';
|
||||||
macpush(mbuf, 1);
|
macpush(mbuf, 1);
|
||||||
} else { /* cnt > 1 */
|
} else { /* cnt > 1 */
|
||||||
char *mbuf = malloc(MAXDIGS + cnt*(mb_cur_max+1) + 5);
|
char *mbuf = malloc(MAXDIGS + cnt*(mb_cur_max+1) + 5);
|
||||||
register char *p = &mbuf[MAXDIGS + 1];
|
register char *p = &mbuf[MAXDIGS + 1];
|
||||||
register int num, n, m;
|
int num, n0, n1, m;
|
||||||
|
|
||||||
setLAST();
|
setLAST();
|
||||||
*p++ = 's';
|
*p++ = 's';
|
||||||
for (num = 0, m = 0; num < cnt && cursor[m] != '\0'; num++) {
|
for (num = 0, m = 0; num < cnt && cursor[m] != '\0'; num++) {
|
||||||
*p++ = CTRL('v');
|
*p++ = CTRL('v');
|
||||||
n = cswitch(p, &cursor[m]);
|
cswitch(p, &n1, &cursor[m], &n0);
|
||||||
p += n;
|
p += n1;
|
||||||
m += n;
|
m += n0;
|
||||||
}
|
}
|
||||||
*p++ = ESCAPE;
|
*p++ = ESCAPE;
|
||||||
if (cursor[m])
|
if (cursor[m])
|
||||||
|
|
Loading…
Reference in New Issue