python-texttable: update to 1.3.1
[void-packages.git] / srcpkgs / nvi / patches / nvi-13-widechar_horrors.patch
blob21cdb48d138c94d1fdc2f416443fd5bb281f0cb8
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 13widechar_horrors.dpatch by <hesso@pool.math.tu-berlin.de>
3 ##
4 ## DP: This patch tries to cope with the fact that widechar support
5 ## DP: in nvi is at best rudimentary.
6 ## DP: Hunk 1)
7 ## DP: * Due to "ch = *t", this code is not wide-char aware, so
8 ## DP: cast the value to a proper type so the KEY_ macros make
9 ## DP: the right choice.
10 ## DP: Hunk 2)
11 ## DP: * Printing of the in-/decreased number back into the screen
12 ## DP: buffer is not widechar-aware, either. Add a dirty fix.
13 ## DP: Cf. #497349.
15 @DPATCH@
16 --- nvi-1.81.6.orig/vi/vs_msg.c 2007-11-18 17:41:42.000000000 +0100
17 +++ nvi-1.81.6/vi/vs_msg.c 2009-03-01 14:51:08.211414132 +0100
18 @@ -472,10 +472,10 @@
20 if (ch == '\t')
21 ch = ' ';
22 - chlen = KEY_LEN(sp, ch);
23 + chlen = KEY_LEN(sp, (unsigned char)ch);
24 if (cbp + chlen >= ecbp)
25 FLUSH;
26 - for (kp = KEY_NAME(sp, ch); chlen--;)
27 + for (kp = KEY_NAME(sp, (unsigned char)ch); chlen--;)
28 *cbp++ = *kp++;
30 if (cbp > cbuf)
31 --- nvi-1.81.6.orig/vi/v_increment.c 2007-11-18 17:41:42.000000000 +0100
32 +++ nvi-1.81.6/vi/v_increment.c 2009-03-01 15:12:50.950415874 +0100
33 @@ -57,7 +57,7 @@
34 long change, ltmp, lval;
35 size_t beg, blen, end, len, nlen, wlen;
36 int base, isempty, rval;
37 - char *ntype, nbuf[100];
38 + char *ntype, nbuf[100 * sizeof(CHAR_T)];
39 CHAR_T *bp, *p, *t;
41 /* Validate the operator. */
42 @@ -202,7 +202,7 @@
43 /* If we cross 0, signed numbers lose their sign. */
44 if (lval == 0 && ntype == fmt[SDEC])
45 ntype = fmt[DEC];
46 - nlen = snprintf(nbuf, sizeof(nbuf), ntype, lval);
47 + nlen = snprintf(nbuf, sizeof(nbuf)/sizeof(CHAR_T), ntype, lval);
48 } else {
49 if ((nret = nget_uslong(sp, &ulval, t, NULL, base)) != NUM_OK)
50 goto err;
51 @@ -224,7 +224,15 @@
52 if (base == 16)
53 wlen -= 2;
55 - nlen = snprintf(nbuf, sizeof(nbuf), ntype, wlen, ulval);
56 + nlen = snprintf(nbuf, sizeof(nbuf)/sizeof(CHAR_T), ntype, wlen, ulval);
57 + }
59 + /* Inflate the printed char buffer to CHAR_T elements if necessary */
60 + if (sizeof(CHAR_T) > sizeof(char)) {
61 + int nlen_inflate;
62 + for (nlen_inflate = nlen; nlen_inflate >= 0; nlen_inflate--) {
63 + ((CHAR_T *)nbuf)[nlen_inflate] = nbuf[nlen_inflate];
64 + }
67 /* Build the new line. */