mirror of
https://github.com/simon987/sist2.git
synced 2025-04-19 18:26:43 +00:00
Fixes #38
This commit is contained in:
parent
12d17acf4f
commit
ccccdb3b78
@ -6,7 +6,7 @@
|
|||||||
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
|
||||||
|
|
||||||
|
|
||||||
static const char *const Version = "1.3.2";
|
static const char *const Version = "1.3.3";
|
||||||
static const char *const usage[] = {
|
static const char *const usage[] = {
|
||||||
"sist2 scan [OPTION]... PATH",
|
"sist2 scan [OPTION]... PATH",
|
||||||
"sist2 index [OPTION]... INDEX",
|
"sist2 index [OPTION]... INDEX",
|
||||||
|
45
src/util.h
45
src/util.h
@ -19,7 +19,7 @@ typedef struct dyn_buffer {
|
|||||||
#include "sist.h"
|
#include "sist.h"
|
||||||
|
|
||||||
typedef struct text_buffer {
|
typedef struct text_buffer {
|
||||||
size_t max_size;
|
long max_size;
|
||||||
int last_char_was_whitespace;
|
int last_char_was_whitespace;
|
||||||
dyn_buffer_t dyn_buffer;
|
dyn_buffer_t dyn_buffer;
|
||||||
} text_buffer_t;
|
} text_buffer_t;
|
||||||
@ -235,23 +235,42 @@ static void text_buffer_terminate_string(text_buffer_t *buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__always_inline
|
#define UTF8_END_OF_STRING \
|
||||||
static int text_buffer_append_string(text_buffer_t *buf, char *str, size_t len) {
|
(ptr - str >= len || *ptr == 0 || \
|
||||||
|
(0xc0 == (0xe0 & *ptr) && ptr - str > len - 2) || \
|
||||||
|
(0xe0 == (0xf0 & *ptr) && ptr - str > len - 3) || \
|
||||||
|
(0xf0 == (0xf8 & *ptr) && ptr - str > len - 4))
|
||||||
|
|
||||||
utf8_int32_t c;
|
__always_inline
|
||||||
if (str == NULL || len < 1 ||
|
static int text_buffer_append_string(text_buffer_t *buf, const char *str, size_t len) {
|
||||||
(0xf0 == (0xf8 & str[0]) && len < 4) ||
|
|
||||||
(0xe0 == (0xf0 & str[0]) && len < 3) ||
|
char *ptr = str;
|
||||||
(0xc0 == (0xe0 & str[0]) && len == 1) ||
|
char *oldPtr = ptr;
|
||||||
*(str) == 0) {
|
|
||||||
|
if (str == NULL || UTF8_END_OF_STRING) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (void *v = utf8codepoint(str, &c); c != '\0' && ((char *) v - str + 4) < len; v = utf8codepoint(v, &c)) {
|
utf8_int32_t c;
|
||||||
if (utf8_validchr2(v)) {
|
char tmp[4];
|
||||||
text_buffer_append_char(buf, c);
|
|
||||||
|
do {
|
||||||
|
ptr = utf8codepoint(ptr, &c);
|
||||||
|
*(int *) tmp = 0x00000000;
|
||||||
|
memcpy(tmp, oldPtr, ptr - oldPtr);
|
||||||
|
oldPtr = ptr;
|
||||||
|
|
||||||
|
if (!utf8_validchr2(tmp)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
int ret = text_buffer_append_char(buf, c);
|
||||||
|
|
||||||
|
if (ret != 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
} while (!UTF8_END_OF_STRING);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<nav class="navbar navbar-expand-lg">
|
<nav class="navbar navbar-expand-lg">
|
||||||
<a class="navbar-brand" href="/">sist2</a>
|
<a class="navbar-brand" href="/">sist2</a>
|
||||||
<span class="badge badge-pill version">v1.3.2</span>
|
<span class="badge badge-pill version">v1.3.3</span>
|
||||||
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
<span class="tagline">Lightning-fast file system indexer and search tool </span>
|
||||||
<button style="margin-left: auto" class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings</button>
|
<button style="margin-left: auto" class="btn" type="button" data-toggle="modal" data-target="#settings" onclick="loadSettings()">Settings</button>
|
||||||
<a id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
|
<a id="theme" class="btn" title="Toggle theme" href="/">Theme</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user