- fix segmentation fault while editing non-UTF8 files (#229383)

This commit is contained in:
Jindrich Novy 2007-04-16 16:44:45 +00:00
parent e17be1ffa0
commit fccc601927
2 changed files with 107 additions and 1 deletions

View File

@ -5201,3 +5201,106 @@
if (edit->overwrite) { if (edit->overwrite) {
if (edit_get_byte (edit, edit->curs1) != '\n') if (edit_get_byte (edit, edit->curs1) != '\n')
edit_delete (edit); edit_delete (edit);
--- mc/edit/edit.c.jn 2007-04-16 18:14:22.000000000 +0200
+++ mc/edit/edit.c 2007-04-16 18:26:25.000000000 +0200
@@ -1526,7 +1526,11 @@
f = edit_eol (edit, offset) - 1;
while (s <= f) {
c = edit_get_byte (edit, s++);
+#ifndef UTF8
if (!isspace (c))
+#else
+ if (!iswspace (c))
+#endif /* UTF8 */
return 0;
}
return 1;
@@ -1781,6 +1785,7 @@
return 2;
return 0x80000000UL;
}
+#ifndef UTF8
if (isupper (c))
c = 'A';
else if (islower (c))
@@ -1791,6 +1796,18 @@
c = '0';
else if (isspace (c))
c = ' ';
+#else
+ if (iswupper (c))
+ c = 'A';
+ else if (iswlower (c))
+ c = 'a';
+ else if (iswalpha (c))
+ c = 'a';
+ else if (iswdigit (c))
+ c = '0';
+ else if (iswspace (c))
+ c = ' ';
+#endif /* UTF8 */
q = strchr (option_chars_move_whole_word, c);
if (!q)
return 0xFFFFFFFFUL;
@@ -1815,10 +1832,18 @@
c2 = edit_get_byte (edit, edit->curs1);
if (!(my_type_of (c1) & my_type_of (c2)))
break;
+#ifndef UTF8
if (isspace (c1) && !isspace (c2))
+#else
+ if (iswspace (c1) && !iswspace (c2))
+#endif /* UTF8 */
break;
if (s)
+#ifndef UTF8
if (!isspace (c1) && isspace (c2))
+#else
+ if (!iswspace (c1) && iswspace (c2))
+#endif /* UTF8 */
break;
}
}
@@ -1841,10 +1866,18 @@
c2 = edit_get_byte (edit, edit->curs1);
if (!(my_type_of (c1) & my_type_of (c2)))
break;
+#ifndef UTF8
if (isspace (c1) && !isspace (c2))
+#else
+ if (iswspace (c1) && !iswspace (c2))
+#endif /* UTF8 */
break;
if (s)
+#ifndef UTF8
if (!isspace (c1) && isspace (c2))
+#else
+ if (!iswspace (c1) && iswspace (c2))
+#endif /* UTF8 */
break;
}
}
@@ -1864,7 +1897,11 @@
break;
c1 = edit_delete (edit);
c2 = edit_get_byte (edit, edit->curs1);
+#ifndef UTF8
if ((isspace (c1) == 0) != (isspace (c2) == 0))
+#else
+ if ((iswspace (c1) == 0) != (iswspace (c2) == 0))
+#endif /* UTF8 */
break;
if (!(my_type_of (c1) & my_type_of (c2)))
break;
@@ -1879,7 +1916,11 @@
break;
c1 = edit_backspace (edit);
c2 = edit_get_byte (edit, edit->curs1 - 1);
+#ifndef UTF8
if ((isspace (c1) == 0) != (isspace (c2) == 0))
+#else
+ if ((iswspace (c1) == 0) != (iswspace (c2) == 0))
+#endif /* UTF8 */
break;
if (!(my_type_of (c1) & my_type_of (c2)))
break;

View File

@ -3,7 +3,7 @@
Summary: User-friendly text console file manager and visual shell Summary: User-friendly text console file manager and visual shell
Name: mc Name: mc
Version: 4.6.1a Version: 4.6.1a
Release: 44.20070124cvs%{?dist} Release: 45.20070124cvs%{?dist}
Epoch: 1 Epoch: 1
License: GPL License: GPL
Group: System Environment/Shells Group: System Environment/Shells
@ -192,6 +192,9 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_libexecdir}/mc %dir %{_libexecdir}/mc
%changelog %changelog
* Mon Apr 16 2007 Jindrich Novy <jnovy@redhat.com> 4.6.1a-45
- fix segmentation fault while editing non-UTF8 files (#229383)
* Mon Apr 2 2007 Jindrich Novy <jnovy@redhat.com> 4.6.1a-44 * Mon Apr 2 2007 Jindrich Novy <jnovy@redhat.com> 4.6.1a-44
- fix unowned directories (#233880) - fix unowned directories (#233880)