diff options
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/files.c | 17 | ||||
| -rw-r--r-- | src/stdlib/files.h | 2 | ||||
| -rw-r--r-- | src/stdlib/nums.c | 4 | ||||
| -rw-r--r-- | src/stdlib/util.h | 2 |
4 files changed, 3 insertions, 22 deletions
diff --git a/src/stdlib/files.c b/src/stdlib/files.c index 900129f8..87b0205c 100644 --- a/src/stdlib/files.c +++ b/src/stdlib/files.c @@ -79,23 +79,6 @@ public char *file_base_name(const char *path) return buf; } -public char *file_base_id(const char *path) -{ - const char *slash = strrchr(path, '/'); - if (slash) path = slash + 1; - assert(!isdigit(*path)); - const char *end = path + strcspn(path, "."); - size_t len = (size_t)(end - path); - char *buf = GC_MALLOC_ATOMIC(len+1); - strncpy(buf, path, len); - buf[len] = '\0'; - for (char *p = buf; *p; p++) { - if (!isalnum(*p)) - *p = '_'; - } - return buf; -} - static file_t *_load_file(const char* filename, FILE *file) { if (!file) return NULL; diff --git a/src/stdlib/files.h b/src/stdlib/files.h index 68827c2a..f650f78e 100644 --- a/src/stdlib/files.h +++ b/src/stdlib/files.h @@ -18,8 +18,6 @@ typedef struct { char *resolve_path(const char *path, const char *relative_to, const char *system_path); __attribute__((pure, nonnull)) char *file_base_name(const char *path); -__attribute__((pure, nonnull)) -char *file_base_id(const char *path); __attribute__((nonnull)) file_t *load_file(const char *filename); __attribute__((nonnull, returns_nonnull)) diff --git a/src/stdlib/nums.c b/src/stdlib/nums.c index 3213fd2f..34fbb162 100644 --- a/src/stdlib/nums.c +++ b/src/stdlib/nums.c @@ -105,7 +105,7 @@ public OptionalNum_t Num$parse(Text_t text) { if (end > str && end[0] == '\0') return d; else - return nan("null"); + return nan("none"); } static bool Num$is_none(const void *n, const TypeInfo_t *info) @@ -210,7 +210,7 @@ public OptionalNum32_t Num32$parse(Text_t text) { if (end > str && end[0] == '\0') return d; else - return nan("null"); + return nan("none"); } static bool Num32$is_none(const void *n, const TypeInfo_t *info) diff --git a/src/stdlib/util.h b/src/stdlib/util.h index 25cd49f9..3b00e6e9 100644 --- a/src/stdlib/util.h +++ b/src/stdlib/util.h @@ -14,7 +14,7 @@ #define new(t, ...) ((t*)memcpy(GC_MALLOC(sizeof(t)), &(t){__VA_ARGS__}, sizeof(t))) #define heap(x) (__typeof(x)*)memcpy(GC_MALLOC(sizeof(x)), (__typeof(x)[1]){x}, sizeof(x)) #define stack(x) (__typeof(x)*)((__typeof(x)[1]){x}) -#define check_initialized(var, name) *({ if (!var ## $initialized) fail("The variable " name " is being accessed before it has been initialized!"); \ +#define check_initialized(var, init_var, name) *({ if (!init_var) fail("The variable " name " is being accessed before it has been initialized!"); \ &var; }) #define IF_DECLARE(decl, expr, block) if (({ decl; expr ? ({ block; 1; }) : 0; })) {} |
