Package: most
Version: 4.10.2-2.0.1
Followup-For: Bug #211217
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi guys,
I fixed a misshandling of tab characters that made them take no width when the
cursor was over them.
This patch should be used instead of the previous one. Only a couple lines were
changed.
- -- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.14-ck5
Locale: LANG=es_AR.UTF-8, LC_CTYPE=es_AR.UTF-8 (charmap=UTF-8)
Versions of packages most depends on:
ii libc6 2.3.5-8 GNU C Library: Shared libraries an
ii libslang2 2.0.5-1 The S-Lang programming library - r
most recommends no packages.
- -- no debconf information
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFDmy70823633cP2P8RAq1CAKCRqJnTWv1E91aG9hygkJFCYQZV1ACgkGAu
zqQQXZ+Hj+F9Arec3ewo6IM=
=kec1
-----END PGP SIGNATURE-----
Sólo en most-4.10.2: build-stamp
Sólo en most-4.10.2: config.log
Sólo en most-4.10.2: config.status
diff -ur most-4.10.2-2.debian-orig/debian/changelog most-4.10.2/debian/changelog
--- most-4.10.2-2.debian-orig/debian/changelog 2005-12-05 21:51:17.000000000 -0300
+++ most-4.10.2/debian/changelog 2005-12-06 04:57:47.000000000 -0300
@@ -1,3 +1,10 @@
+most (4.10.2-2.0.1) unstable; urgency=low
+
+ * Fixed minor glitches when displaying multi-byte characters.
+ * Fixed wrapped mode when using formatted output.
+
+ -- Javier Kohen <[EMAIL PROTECTED]> Tue, 6 Dec 2005 04:57:01 -0300
+
most (4.10.2-2) unstable; urgency=low
* Patch from Javier Kohen to rework (and fix) RegExp searches, so they now
Sólo en most-4.10.2/debian: files
Sólo en most-4.10.2/debian: most
Sólo en most-4.10.2/debian: most.postinst.debhelper
Sólo en most-4.10.2/debian: most.postrm.debhelper
Sólo en most-4.10.2/debian: most.substvars
Sólo en most-4.10.2: Makefile
diff -ur most-4.10.2-2.debian-orig/src/buffer.c most-4.10.2/src/buffer.c
--- most-4.10.2-2.debian-orig/src/buffer.c 2005-12-05 21:51:17.000000000 -0300
+++ most-4.10.2/src/buffer.c 2005-12-06 04:48:06.000000000 -0300
@@ -62,11 +62,13 @@
if (*pos == '\n')
{
pos--; /* Skip back the new-line. */
- while ((pos > Most_Beg)
- && (*pos != '\n'))
- pos = SLutf8_bskip_char(Most_Beg, pos);
+ /* This block is UTF-8 safe, because it only scans the
+ buffer for a new-line, and doesn't count
+ characters. */
+ while ((pos > Most_Beg) && (*pos != '\n'))
+ pos--;
- if (*pos != '\n') return pos;
+ if (*pos != '\n') return Most_Beg;
/* from here on *pos == '\n' */
if (pos + 1 != cpos)
return pos + 1;
@@ -77,9 +79,9 @@
if (*pos != '\n')
{
- while ((pos > Most_Beg)
- && (*pos != '\n'))
- pos = SLutf8_bskip_char(Most_Beg, pos);
+ /* This block is UTF-8 safe. See comment above. */
+ while ((pos > Most_Beg) && (*pos != '\n'))
+ pos--;
if (*pos != '\n') return Most_Beg;
/* from here on *pos == '\n' */
return pos + 1;
@@ -96,58 +98,6 @@
return pos;
}
-
-static unsigned char *forward_columns (unsigned char *b, unsigned char *e, unsigned int num_cols)
-{
- unsigned int col = 0;
-
- if (Most_UTF8_Mode)
- return SLutf8_skip_chars(b, e, num_cols, &col, 0);
-
- while ((b < e)
- && (col < num_cols))
- {
- unsigned char ch = *b++;
-
- if (most_isprint(ch))
- {
- col++;
- continue;
- }
-
- if ((ch == '\b') || (ch == '\t') || (ch == '\r'))
- switch (ch)
- {
- case '\b':
- if (Most_V_Opt == 0)
- {
- if (col > 0) col--;
- }
- else col += 2;
- break;
-
- case '\r':
- if (Most_V_Opt == 0)
- col = 0;
- else
- col += 2;
- break;
-
- case '\t':
- if (Most_T_Opt == 0)
- col = Most_Tab_Width * (col/Most_Tab_Width + 1);
- else
- col += 2;
- break;
- }
- else if (ch & 0x80)
- col += 3;
- else
- col += 2;
- }
- return b;
-}
-
/* does not move point */
static unsigned char *end_of_line1(void)
{
@@ -170,6 +120,9 @@
if (*pos != '\n')
{
+ /* This block is UTF-8 safe, because it only scans the buffer
+ for a new-line, and doesn't count characters. */
+
n = pmax - pos;
n2 = n % 8;
pmax = pos + (n - 8);
@@ -221,7 +174,7 @@
ncols = SLtt_Screen_Cols-1;
while (1)
{
- unsigned char *next_b = forward_columns (b, e, ncols);
+ unsigned char *next_b = most_forward_columns (b, e, ncols, 1);
if ((next_b == e) || (next_b == b))
break;
@@ -243,11 +196,12 @@
return e;
if (b == NULL) b = most_beg_of_line ();
- b = forward_columns (b, e, SLtt_Screen_Cols-1);
+ b = most_forward_columns (b, e, SLtt_Screen_Cols-1, 1);
/* Do not wrap the line if the last character falls on the last column
* of the display.
*/
+ /* FIXME potential bug if dealing with multi-byte char. */
if ((b + 1 <= e)
&& (b + 1 < Most_Eob)
&& (b[1] == '\n'))
Sólo en most-4.10.2/src: config.h
diff -ur most-4.10.2-2.debian-orig/src/line.c most-4.10.2/src/line.c
--- most-4.10.2-2.debian-orig/src/line.c 2005-12-05 21:51:17.000000000 -0300
+++ most-4.10.2/src/line.c 2005-12-10 16:34:01.000000000 -0300
@@ -119,19 +119,17 @@
return (ch >= ' ' && ch < 0x7F) || ch >= SLsmg_Display_Eight_Bit;
}
-static int most_analyse_line(unsigned char *begg, unsigned char *endd,
- unsigned char *out, char *attributes)
+static void most_analyse_line(unsigned char *beg, unsigned char *end,
+ unsigned char *out, char *attributes)
{
- unsigned char *beg, *end, *pout;
- unsigned int min_col, max_col;
+ unsigned char *pout;
+ char* pattributes;
unsigned int i, i_max;
- beg = begg;
- end = endd;
+ beg = most_forward_columns(beg, end, Most_Column - 1, 0);
pout = out;
+ pattributes = attributes;
i = i_max = 0;
- min_col = Most_Column - 1;
- max_col = min_col + SLtt_Screen_Cols;
while (beg < end)
{
@@ -154,9 +152,19 @@
if (i > 0)
{
if (Most_UTF8_Mode)
- pout = SLutf8_bskip_char(out, pout);
+ {
+ SLwchar_Type wc;
+ pout = SLutf8_bskip_char(out, pout);
+ if (SLutf8_decode(pout, pout + SLUTF8_MAX_MBLEN, &wc, NULL))
+ {
+ unsigned int char_len = SLwchar_wcwidth(wc);
+ if (char_len > 1)
+ i -= char_len - 1;
+ }
+ }
else
pout--;
+ pattributes--;
i--;
}
continue;
@@ -165,7 +173,7 @@
if (i < i_max) /* overstrike */
{
attr = 'b';
- if ((i >= min_col) && (i < max_col))
+ if (i < SLtt_Screen_Cols)
{
if (*pout == '_')
attr = 'u';
@@ -185,16 +193,26 @@
if (Most_UTF8_Mode) {
unsigned char *prev = --beg;
- int len;
+ SLwchar_Type wc;
+ unsigned int len;
+
+ if (SLutf8_decode(beg, end, &wc, NULL))
+ {
+ unsigned int char_len = SLwchar_wcwidth(wc);
+ if (char_len > 1)
+ i += char_len - 1;
+ }
+
beg = SLutf8_skip_char(beg, end);
len = beg - prev;
+
if (len > 1) {
/* Non-ASCII char, display it. */
- if ((i >= min_col) && (i < max_col))
+ if (i < SLtt_Screen_Cols)
{
memcpy(pout, prev, len);
pout += len;
- attributes[i-min_col] = attr;
+ *pattributes++ = attr;
}
i++;
continue;
@@ -203,10 +221,10 @@
if (most_isprint(ch))
{
- if ((i >= min_col) && (i < max_col))
+ if (i < SLtt_Screen_Cols)
{
*pout++ = ch;
- attributes[i-min_col] = attr;
+ *pattributes++ = attr;
}
i++;
continue;
@@ -215,13 +233,13 @@
if ((ch == '\t') && (Most_T_Opt == 0) && (Most_Tab_Width))
{
- int nspaces = Most_Tab_Width * (i/Most_Tab_Width + 1) - i;
+ int nspaces = Most_Tab_Width - (i % Most_Tab_Width);
while (nspaces > 0)
{
- if ((i >= min_col) && (i < max_col))
+ if (i < SLtt_Screen_Cols)
{
*pout++ = ' ';
- attributes[i-min_col] = attr;
+ *pattributes++ = attr;
}
i++;
nspaces--;
@@ -231,30 +249,30 @@
if (ch & 0x80)
{
- if ((i >= min_col) && (i < max_col))
+ if (i < SLtt_Screen_Cols)
{
*pout++ = '~';
- attributes[i-min_col] = attr;
+ *pattributes++ = attr;
}
i++;
ch &= 0x7F;
/* drop */
}
- if ((i >= min_col) && (i < max_col))
+ if (i < SLtt_Screen_Cols)
{
*pout++ = '^';
- attributes[i-min_col] = attr;
+ *pattributes++ = attr;
}
i++;
if (ch == 0x7F) ch = '?';
else ch += '@';
- if ((i >= min_col) && (i < max_col))
+ if (i < SLtt_Screen_Cols)
{
*pout++ = ch;
- attributes[i-min_col] = attr;
+ *pattributes++ = attr;
}
i++;
}
@@ -268,7 +286,7 @@
if (Most_Selective_Display
&& (Most_W_Opt == 0)
&& (beg < Most_Eob)
- && ((i >= min_col) && (i < max_col)))
+ && (i < SLtt_Screen_Cols))
{
if (*beg == '\n') beg++;
@@ -282,31 +300,21 @@
i_max = i + 3;
while (i < i_max)
{
- if (i < max_col)
+ if (i < SLtt_Screen_Cols)
{
*pout++ = '.';
- attributes[i] = ' ';
+ *pattributes++ = ' ';
}
i++;
}
}
}
-
- i_max = i;
-
- if (i < min_col)
- i = min_col;
- else if (i >= max_col)
- i = max_col;
-
- i -= min_col;
*pout = 0;
- attributes[i] = 0;
- return i_max;
+ *pattributes = 0;
}
-static void output_with_attr (unsigned char *out, unsigned char *attr)
+static void output_with_attr (unsigned char *out, char *attr)
{
unsigned char at, lat;
unsigned char *p = out;
@@ -360,9 +368,11 @@
void most_display_line (void)
{
unsigned char *beg, *end;
- unsigned int len;
+#if 0
+ unsigned char dollar;
+#endif
static unsigned char *line;
- static unsigned char *attr;
+ static char *attr;
static unsigned int line_len;
if (Most_B_Opt)
@@ -376,18 +386,42 @@
if (line_len < (unsigned int)(SLtt_Screen_Cols + 1) * SLUTF8_MAX_MBLEN)
{
SLfree ((char *) line);
- SLfree ((char *) attr);
+ SLfree (attr);
line_len = (SLtt_Screen_Cols + 1) * SLUTF8_MAX_MBLEN;
if ((NULL == (line = (unsigned char *) SLmalloc (line_len)))
- || (NULL == (attr = (unsigned char *) SLmalloc (line_len))))
+ || (NULL == (attr = SLmalloc (line_len))))
most_exit_error ("Out of memory");
}
(void) most_extract_line (&beg, &end);
- len = most_analyse_line(beg, end, line, (char *) attr);
+ most_analyse_line(beg, end, line, attr);
+
+#if 0
+ /* Currently the dollar sign is not always being written at the
+ rightmost column when displaying multi-byte characters. */
+ dollar = 0;
+ if (Most_W_Opt)
+ {
+ if ((end < Most_Eob)
+ && (*end != '\n'))
+ dollar = '\\';
+ }
+ else if (len > (unsigned int) SLtt_Screen_Cols + (Most_Column - 1))
+ dollar = '$';
+
+ if (dollar)
+ {
+ unsigned char *pline =
+ most_forward_columns(line, line + line_len, SLtt_Screen_Cols-1, 1);
+ *pline = dollar;
+ *(pline+1) = 0;
+ attr[SLtt_Screen_Cols-1] = ' ';
+ attr[SLtt_Screen_Cols] = 0;
+ }
+#endif
output_with_attr (line, attr);
SLsmg_erase_eol ();
@@ -459,3 +493,95 @@
}
return i;
}
+
+/*
+ * Returns a pointer to the num_cols'th character after the one
+ * pointed at b. Invisible character runs are not counted toward this
+ * limit, i.e. strings that represent attributes, such as "_\b" for
+ * underlines.
+ *
+ * If multi_column is non-zero, characters spanning more than one
+ * column will add their extra width to the column count.
+ *
+ * If there the end of the buffer is reached, as delimited by argument
+ * e, then e is returned.
+ */
+unsigned char *most_forward_columns (unsigned char *beg, unsigned char *e, unsigned int num_cols, int multi_column)
+{
+ unsigned int col = 0;
+ unsigned int prev_width = 1;
+ unsigned char* b = beg;
+
+ while ((b < e)
+ && ((col < num_cols)
+ || (*b == '\b')
+ || (*b == '\r')))
+ {
+ unsigned char ch = *b;
+
+ if (Most_UTF8_Mode)
+ {
+ unsigned char *prev = b;
+ int len;
+ b = SLutf8_skip_char(b, e);
+ len = b - prev;
+ if (len > 1)
+ {
+ if (multi_column)
+ {
+ SLwchar_Type wc;
+ if (SLutf8_decode(prev, e, &wc, NULL))
+ col += prev_width = SLwchar_wcwidth(wc);
+ }
+ else
+ col++;
+ continue;
+ }
+ }
+ else
+ b++;
+
+ if (most_isprint(ch))
+ {
+ col++;
+ prev_width = 1;
+ continue;
+ }
+
+ if ((ch == '\b') || (ch == '\t') || (ch == '\r'))
+ switch (ch)
+ {
+ case '\b':
+ if (Most_V_Opt == 0)
+ {
+ if (col > 0) col -= prev_width;
+ }
+ else col += 2;
+ break;
+
+ case '\r':
+ if (Most_V_Opt == 0)
+ col = 0;
+ else
+ col += 2;
+ break;
+
+ case '\t':
+ if (Most_T_Opt == 0)
+ col = Most_Tab_Width * (col/Most_Tab_Width + 1);
+ else
+ col += 2;
+ break;
+ }
+ else if (ch & 0x80)
+ col += 3;
+ else
+ col += 2;
+ }
+
+ /* Last character was too wide. Backstep it. */
+ if (col > num_cols)
+ b = SLutf8_bskip_char(beg, b);
+
+ return b;
+}
Sólo en most-4.10.2/src: line.c~
diff -ur most-4.10.2-2.debian-orig/src/line.h most-4.10.2/src/line.h
--- most-4.10.2-2.debian-orig/src/line.h 2005-12-05 21:51:17.000000000 -0300
+++ most-4.10.2/src/line.h 2005-12-06 04:20:05.000000000 -0300
@@ -7,6 +7,7 @@
extern void most_display_line(void);
extern int most_apparant_distance(unsigned char *);
-extern int most_isprint(unsigned char ch);
+extern int most_isprint(unsigned char);
+extern unsigned char *most_forward_columns (unsigned char *, unsigned char *, unsigned int, int);
#endif
Sólo en most-4.10.2/src: Makefile
Sólo en most-4.10.2/src: objs
Sólo en most-4.10.2/src: TAGS
diff -ur most-4.10.2-2.debian-orig/src/window.c most-4.10.2/src/window.c
--- most-4.10.2-2.debian-orig/src/window.c 2005-12-05 21:51:17.000000000 -0300
+++ most-4.10.2/src/window.c 2005-12-06 03:01:05.000000000 -0300
@@ -51,6 +51,7 @@
long long Most_Top_Line; /* row number of top window */
long long Most_Curs_Row;
long long Most_Curs_Col;
+/* The leftmost visible column. */
long long Most_Column = 1;
int Most_Restore_Width_To = 0;
char Most_Mini_Buf[256];