[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs charset.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs charset.c |
Date: |
Mon, 24 Mar 2014 09:33:50 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 14/03/24 09:33:50
Modified files:
. : charset.c
Log message:
improve utf8 and ucsx probing functions
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/charset.c?cvsroot=qemacs&r1=1.34&r2=1.35
Patches:
Index: charset.c
===================================================================
RCS file: /sources/qemacs/qemacs/charset.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- charset.c 15 Mar 2014 14:55:05 -0000 1.34
+++ charset.c 24 Mar 2014 09:33:49 -0000 1.35
@@ -596,7 +596,7 @@
return 0;
}
}
- if (count_spaces | count_lines)
+ if (count_spaces + count_lines > size / 16)
return 1;
else
return 0;
@@ -732,7 +732,7 @@
return 0;
}
}
- if (count_spaces | count_lines)
+ if (count_spaces + count_lines > size / 16)
return 1;
else
return 0;
@@ -876,7 +876,7 @@
return 0;
}
}
- if (count_spaces | count_lines)
+ if (count_spaces + count_lines > size / 16)
return 1;
else
return 0;
@@ -1006,7 +1006,7 @@
return 0;
}
}
- if (count_spaces | count_lines)
+ if (count_spaces + count_lines > size / 16)
return 1;
else
return 0;
@@ -1425,8 +1425,10 @@
has_utf8 = 0;
for (i = 0; i < size;) {
c = buf[i++];
- if ((c >= 0x80 && c < 0xc0) || c >= 0xfe)
- goto no_utf8;
+ if ((c >= 0x80 && c < 0xc0) || c >= 0xfe) {
+ has_utf8 = -1;
+ goto done_utf8;
+ }
l = utf8_length[c];
while (l > 1) {
has_utf8 = 1;
@@ -1434,14 +1436,14 @@
break;
c = buf[i++];
if (!(c >= 0x80 && c < 0xc0)) {
- no_utf8:
- has_utf8 = 0;
- break;
+ has_utf8 = -1;
+ goto done_utf8;
}
l--;
}
}
- if (has_utf8) {
+done_utf8:
+ if (has_utf8 > 0) {
return detect_eol_type(buf, size, &charset_utf8, eol_typep);
}
@@ -1523,7 +1525,7 @@
detect_eol_type(buf, size, &charset_raw, eol_typep);
- if (*eol_typep == EOL_DOS) {
+ if (*eol_typep == EOL_DOS || has_utf8 < 0) {
/* XXX: default DOS files to Latin1, should be selectable */
return &charset_8859_1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs charset.c,
Charlie Gordon <=