diff options
-rw-r--r-- | filesystem-posix.c | 5 | ||||
-rw-r--r-- | math.c | 5 | ||||
-rw-r--r-- | syntax.c | 4 |
3 files changed, 10 insertions, 4 deletions
diff --git a/filesystem-posix.c b/filesystem-posix.c index 6a52732..5506278 100644 --- a/filesystem-posix.c +++ b/filesystem-posix.c @@ -22,10 +22,9 @@ FsType fs_path_type(char const *path) { } FsPermission fs_path_permission(char const *path) { - int bits = access(path, R_OK | W_OK); FsPermission perm = 0; - if (!(bits & R_OK)) perm |= FS_PERMISSION_READ; - if (!(bits & W_OK)) perm |= FS_PERMISSION_WRITE; + if (access(path, R_OK) == 0) perm |= FS_PERMISSION_READ; + if (access(path, W_OK) == 0) perm |= FS_PERMISSION_WRITE; return perm; } @@ -176,7 +176,10 @@ static inline float randf(void) { static float rand_gauss(void) { // https://en.wikipedia.org/wiki/Normal_distribution#Generating_values_from_normal_distribution - float U = randf(), V = randf(); + float U, V; + do + U = randf(), V = randf(); + while (U == 0 || V == 0); return sqrtf(-2 * logf(U)) * cosf(TAUf * V); } @@ -394,6 +394,10 @@ static void syntax_highlight_rust(SyntaxState *state, char32_t const *line, u32 if (line[char_end] == '\'' && backslashes % 2 == 0) { break; } + if (line[char_end] == '\\') + ++backslashes; + else + backslashes = 0; if (line[char_end] < CHAR_MAX && line[char_end - 1] != '\\' && !strchr("abcdefABCDEF0123456789", (char)line[char_end])) |