From a9cde6d274a572a0e07abbef7833b9f30889dffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sun, 11 Nov 2007 10:29:07 +0000 Subject: [PATCH] * this should cover the case where the buffer is one byte long but is _not_ a text file git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22893 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/translators/stxt/STXTTranslator.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/add-ons/translators/stxt/STXTTranslator.cpp b/src/add-ons/translators/stxt/STXTTranslator.cpp index 96820a0419..71a1fabe52 100644 --- a/src/add-ons/translators/stxt/STXTTranslator.cpp +++ b/src/add-ons/translators/stxt/STXTTranslator.cpp @@ -218,6 +218,8 @@ file_ascmagic(const unsigned char *buf, size_t nbytes, BMimeType* mimeType, code = "ASCII"; encoding = NULL; //"us-ascii"; type = "text"; + if (nbytes == 1) + rv = 1; } else if (nbytes == 0 || looks_utf8(buf, nbytes, ubuf, &ulen)) { code = "UTF-8 Unicode"; encoding = NULL; // "UTF-8"; @@ -263,6 +265,8 @@ file_ascmagic(const unsigned char *buf, size_t nbytes, BMimeType* mimeType, } if (nbytes <= 1) { + if (rv == -1) + rv = 0; goto done; }