[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs charset.c hex.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs charset.c hex.c |
Date: |
Tue, 25 Apr 2017 12:56:26 -0400 (EDT) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 17/04/25 12:56:26
Modified files:
. : charset.c hex.c
Log message:
charset: improve eol and binary detection
- accept extra CR in badly encoded DOS files
- ignore ^Z in DOS files, do not detect them as binary
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/charset.c?cvsroot=qemacs&r1=1.51&r2=1.52
http://cvs.savannah.gnu.org/viewcvs/qemacs/hex.c?cvsroot=qemacs&r1=1.52&r2=1.53
Patches:
Index: charset.c
===================================================================
RCS file: /sources/qemacs/qemacs/charset.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- charset.c 25 Apr 2017 16:46:41 -0000 1.51
+++ charset.c 25 Apr 2017 16:56:26 -0000 1.52
@@ -138,7 +138,8 @@
{
const uint32_t magic = (1U << '\b') | (1U << '\t') | (1U << '\f') |
(1U << '\n') | (1U << '\r') | (1U << '\033') |
- (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1f);
+ (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1a) |
+ (1U << 0x1f);
const u8 *p = buf;
const u8 *p_end = p + size;
uint32_t c;
@@ -363,7 +364,8 @@
{
const uint32_t magic = (1U << '\b') | (1U << '\t') | (1U << '\f') |
(1U << '\n') | (1U << '\r') | (1U << '\033') |
- (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1f);
+ (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1a) |
+ (1U << 0x1f);
const u8 *p = buf;
const u8 *p_end = p + size;
uint32_t c;
@@ -562,7 +564,8 @@
{
const uint32_t magic = (1U << '\b') | (1U << '\t') | (1U << '\f') |
(1U << '\n') | (1U << '\r') | (1U << '\033') |
- (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1f);
+ (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1a) |
+ (1U << 0x1f);
const u8 *p = buf;
const u8 *p_end = p + (size & ~1);
uint32_t c;
@@ -693,7 +696,8 @@
{
const uint32_t magic = (1U << '\b') | (1U << '\t') | (1U << '\f') |
(1U << '\n') | (1U << '\r') | (1U << '\033') |
- (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1f);
+ (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1a) |
+ (1U << 0x1f);
const u8 *p = buf;
const u8 *p_end = p + (size & ~1);
uint32_t c;
@@ -837,7 +841,8 @@
{
const uint32_t magic = (1U << '\b') | (1U << '\t') | (1U << '\f') |
(1U << '\n') | (1U << '\r') | (1U << '\033') |
- (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1f);
+ (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1a) |
+ (1U << 0x1f);
const u8 *p = buf;
const u8 *p_end = p + (size & ~3);
uint32_t c;
@@ -967,7 +972,8 @@
{
const uint32_t magic = (1U << '\b') | (1U << '\t') | (1U << '\f') |
(1U << '\n') | (1U << '\r') | (1U << '\033') |
- (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1f);
+ (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1a) |
+ (1U << 0x1f);
const u8 *p = buf;
const u8 *p_end = p + (size & ~3);
uint32_t c;
@@ -1219,6 +1225,11 @@
while (p < p1) {
c = *p++;
if (c == '\r') {
+ if (*p == '\r') {
+ /* possibly spurious extra ^M in DOS file: ignore it,
+ * next iteration will determine if encoding is MAC or DOS
+ */
+ } else
if (*p == '\n') {
p++;
eol_bits |= 1 << EOL_DOS;
@@ -1502,7 +1513,8 @@
{
const uint32_t magic = (1U << '\b') | (1U << '\t') | (1U << '\f') |
(1U << '\n') | (1U << '\r') | (1U << '\033') |
- (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1f);
+ (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1a) |
+ (1U << 0x1f);
for (i = 0; i < size; i++) {
c = buf[i];
Index: hex.c
===================================================================
RCS file: /sources/qemacs/qemacs/hex.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- hex.c 16 Apr 2017 21:51:20 -0000 1.52
+++ hex.c 25 Apr 2017 16:56:26 -0000 1.53
@@ -197,7 +197,8 @@
{
const uint32_t magic = (1U << '\b') | (1U << '\t') | (1U << '\f') |
(1U << '\n') | (1U << '\r') | (1U << '\033') |
- (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1f);
+ (1U << 0x0e) | (1U << 0x0f) | (1U << 0x1a) |
+ (1U << 0x1f);
int i, c;
for (i = 0; i < size; i++) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs charset.c hex.c,
Charlie Gordon <=