Skip to content

Commit

Permalink
Merge pull request #749 from liz3/liz3/utf8-experiments
Browse files Browse the repository at this point in the history
utf-8 support in strings
  • Loading branch information
Jason2605 authored Nov 8, 2024
2 parents 2c18902 + 9fa46e3 commit 643f2c9
Show file tree
Hide file tree
Showing 35 changed files with 2,307 additions and 190 deletions.
4 changes: 4 additions & 0 deletions src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ add_compile_definitions(USE_UTF8)
add_executable(dictu ${DICTU_CLI_SRC})
target_include_directories(dictu PUBLIC ${INCLUDE_DIR})
target_link_libraries(dictu dictu_api_static)
if(LINUX AND CMAKE_C_COMPILER_ID STREQUAL "Clang")
# Clang needs this otherwise ld will fail on linux since the lib is build with -flto
set(CMAKE_C_FLAGS_RELEASE "-flto")
endif()
2 changes: 1 addition & 1 deletion src/optionals/sqlite/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -56382,7 +56382,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen(
const char *zUri = 0; /* URI args to copy */
int nUriByte = 1; /* Number of bytes of URI args at *zUri */
int nUri = 0; /* Number of URI parameters */

(void)nUri;
/* Figure out how much space is required for each journal file-handle
** (there are two of them, the main journal and the sub-journal). */
journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
Expand Down
10 changes: 6 additions & 4 deletions src/optionals/uuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#ifndef _WIN32
static uuid_t uuid;

#define UUID_STRING_LEN 37
#define UUID_STRING_LEN 36 // Note(Liz3): the strlen() of a UUID is 36, but the uuid_unparse_lower call expects
// a buffer with space for the null byte, but since copyString wants the strlen we
// keep the define to 36 and allocate +1.

static Value uuidGenerateNative(DictuVM *vm, int argCount, Value *args) {
UNUSED(args);
Expand All @@ -21,7 +23,7 @@ static Value uuidGenerateNative(DictuVM *vm, int argCount, Value *args) {
return newResultError(vm, "error: failed to generate uuid");
}

char out[UUID_STRING_LEN] = {};
char out[UUID_STRING_LEN+1] = {};
uuid_unparse_lower(uuid, out);

return newResultSuccess(vm, OBJ_VAL(copyString(vm, out, UUID_STRING_LEN)));
Expand All @@ -43,7 +45,7 @@ static Value uuidGenRandomNative(DictuVM *vm, int argCount, Value *args) {
return newResultError(vm, "error: failed to generate uuid");
}

char out[UUID_STRING_LEN] = {};
char out[UUID_STRING_LEN+1] = {};
uuid_unparse_lower(uuid, out);

return newResultSuccess(vm, OBJ_VAL(copyString(vm, out, UUID_STRING_LEN)));
Expand All @@ -65,7 +67,7 @@ static Value uuidGenTimeNative(DictuVM *vm, int argCount, Value *args) {
return newResultError(vm, "error: failed to generate uuid");
}

char out[UUID_STRING_LEN] = {};
char out[UUID_STRING_LEN+1] = {};
uuid_unparse_lower(uuid, out);

return newResultSuccess(vm, OBJ_VAL(copyString(vm, out, UUID_STRING_LEN)));
Expand Down
Loading

0 comments on commit 643f2c9

Please sign in to comment.