1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtinfo: fix a highlighting issue.

This commit is contained in:
Liang Chang 2022-02-18 10:29:29 +08:00
parent b796f9fce4
commit bad30e1b1a
4 changed files with 17 additions and 15 deletions

View file

@ -256,14 +256,14 @@ DtCvStrVccToIndex(_DtCvSegment* seg, unsigned int vcc)
if (seg->type & _DtCvWIDE_CHAR) { if (seg->type & _DtCvWIDE_CHAR) {
wchar_t* seg_str = (wchar_t*)seg->handle.string.string; wchar_t* seg_str = (wchar_t*)seg->handle.string.string;
for (; *seg_str && rel_vcc > 0; seg_str++, index++) { for (; *seg_str && rel_vcc > 0; seg_str++, index++) {
if (!isspace(*seg_str)) if (!ISSPACE_C(*seg_str))
rel_vcc--; rel_vcc--;
} }
if (*seg_str == 0 && rel_vcc > 0) if (*seg_str == 0 && rel_vcc > 0)
index = (unsigned int)-1; index = (unsigned int)-1;
else { else {
for (; *seg_str; seg_str++, index++) { for (; *seg_str; seg_str++, index++) {
if (!isspace(*seg_str)) if (!ISSPACE_C(*seg_str))
break; break;
} }
} }
@ -271,7 +271,7 @@ DtCvStrVccToIndex(_DtCvSegment* seg, unsigned int vcc)
else { else {
unsigned char* seg_str = (unsigned char*)seg->handle.string.string; unsigned char* seg_str = (unsigned char*)seg->handle.string.string;
while (*seg_str && rel_vcc > 0) { while (*seg_str && rel_vcc > 0) {
if (!isspace(*seg_str)) if (!ISSPACE_C(*seg_str))
rel_vcc--; rel_vcc--;
int mbl = mblen((char *) seg_str, MB_CUR_MAX); int mbl = mblen((char *) seg_str, MB_CUR_MAX);
@ -289,7 +289,7 @@ DtCvStrVccToIndex(_DtCvSegment* seg, unsigned int vcc)
index = (unsigned int)-1; index = (unsigned int)-1;
else { else {
for (; *seg_str; seg_str++, index++) { for (; *seg_str; seg_str++, index++) {
if (!isspace(*seg_str)) if (!ISSPACE_C(*seg_str))
break; break;
} }
} }
@ -310,14 +310,14 @@ DtCvStrVcLenSync(_DtCvSegment* seg)
if (seg->type & _DtCvWIDE_CHAR) { if (seg->type & _DtCvWIDE_CHAR) {
wchar_t* seg_str = (wchar_t*)seg->handle.string.string; wchar_t* seg_str = (wchar_t*)seg->handle.string.string;
for (; *seg_str; seg_str++) { for (; *seg_str; seg_str++) {
if (!isspace(*seg_str)) if (!ISSPACE_C(*seg_str))
vclen++; vclen++;
} }
} }
else { else {
unsigned char* seg_str = (unsigned char*)seg->handle.string.string; unsigned char* seg_str = (unsigned char*)seg->handle.string.string;
while (*seg_str) { while (*seg_str) {
if (!isspace(*seg_str)) if (!ISSPACE_C(*seg_str))
vclen++; vclen++;
int mbl = mblen((char *) seg_str, MB_CUR_MAX); int mbl = mblen((char *) seg_str, MB_CUR_MAX);
@ -569,7 +569,7 @@ highlight_search_hit(_DtCvSegment* seg, unsigned int vcc, unsigned int vlen)
unsigned char *seg_str = (unsigned char*)seg->handle.string.string; unsigned char *seg_str = (unsigned char*)seg->handle.string.string;
for (int i = 0; i < rel_vcc; ++i) { for (int i = 0; i < rel_vcc; ++i) {
if (isspace(*seg_str)) { if (ISSPACE_C(*seg_str)) {
++seg_str; ++seg_str;
continue; continue;
} }
@ -581,7 +581,7 @@ highlight_search_hit(_DtCvSegment* seg, unsigned int vcc, unsigned int vlen)
} }
for (int i = 0; i < vlen; ++i) { for (int i = 0; i < vlen; ++i) {
if (isspace(*seg_str)) { if (ISSPACE_C(*seg_str)) {
++seg_str; ++seg_str;
++len; ++len;
continue; continue;

View file

@ -1282,7 +1282,7 @@ CanvasRenderer::handle_olias_attributes(ElementFeatures &features,
assert( mb_len > 0 ); assert( mb_len > 0 );
if (mb_len == 1) { if (mb_len == 1) {
const unsigned char ch = (unsigned char)*p++; const unsigned char ch = (unsigned char)*p++;
if (isspace(ch)) if (ISSPACE_C(ch))
continue; continue;
} }
else else
@ -1293,7 +1293,7 @@ CanvasRenderer::handle_olias_attributes(ElementFeatures &features,
#else #else
while (*p) while (*p)
{ {
if (!isspace(*p)) if (!ISSPACE_C(*p))
{ {
vcc++ ; vcc++ ;
} }
@ -1673,7 +1673,7 @@ CanvasRenderer::really_insert_string (_DtCvSegment *container,
if (strseg->type & _DtCvWIDE_CHAR) { if (strseg->type & _DtCvWIDE_CHAR) {
wchar_t *p; wchar_t *p;
for (p = (wchar_t*)string; *p; p++) { for (p = (wchar_t*)string; *p; p++) {
if (!isspace(*p)) if (!ISSPACE_C(*p))
scd.vclen()++; scd.vclen()++;
} }
} }
@ -1683,7 +1683,7 @@ CanvasRenderer::really_insert_string (_DtCvSegment *container,
while (*p) { while (*p) {
int mbl = mblen((char *) p, MB_CUR_MAX); int mbl = mblen((char *) p, MB_CUR_MAX);
if (!isspace(*p)) if (!ISSPACE_C(*p))
scd.vclen()++; scd.vclen()++;
if (mbl < 0) ++p; if (mbl < 0) ++p;

View file

@ -395,7 +395,7 @@ DtSR_SearchResultsEntry::create_matches()
while (off > 0) { while (off > 0) {
int scanned = 0; int scanned = 0;
if (isspace(*cursor)) { if (ISSPACE_C(*cursor)) {
scanned++; scanned++;
} }
else if (*cursor == ShiftIn || *cursor == ShiftOut) { else if (*cursor == ShiftIn || *cursor == ShiftOut) {
@ -424,11 +424,11 @@ DtSR_SearchResultsEntry::create_matches()
int len = atoi(len_str); int len = atoi(len_str);
// remove leading white-spaces // remove leading white-spaces
for (; len && isspace(*cursor); cursor++, len--); for (; len && ISSPACE_C(*cursor); cursor++, len--);
// remove trailing white-spaces // remove trailing white-spaces
if (len > 0) { if (len > 0) {
for (const char *p = cursor + len - 1; isspace(*p); p--, len--); for (const char *p = cursor + len - 1; ISSPACE_C(*p); p--, len--);
} }
if (len == 0) if (len == 0)

View file

@ -132,6 +132,8 @@ typedef unsigned char u_char;
#define ON_DEBUG(stmt) #define ON_DEBUG(stmt)
#endif #endif
#define ISSPACE_C(C) (C == ' ' || C > 0x8 && C < 0x14)
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>