Compare commits
No commits in common. "ae0fa95d6aee2a7427c3e3575d74af1ed360e6e5" and "adaf5cc31199b8b70404f30b51a0e4ef822d6fab" have entirely different histories.
ae0fa95d6a
...
adaf5cc311
@ -7,23 +7,21 @@ extern "C" {
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
|
||||
typedef int8_t i8;
|
||||
typedef int16_t i16;
|
||||
typedef int32_t i32;
|
||||
typedef int64_t i64;
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
typedef const char* cstr;
|
||||
typedef int8_t i8;
|
||||
typedef uint8_t u8;
|
||||
typedef int16_t i16;
|
||||
typedef uint16_t u16;
|
||||
typedef int32_t i32;
|
||||
typedef uint32_t u32;
|
||||
typedef int64_t i64;
|
||||
typedef uint64_t u64;
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
|
||||
#if !__cplusplus && !defined(bool)
|
||||
typedef u8 bool;
|
||||
@ -31,29 +29,7 @@ typedef u8 bool;
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
|
||||
#define FMT_i8 "%"PRIi8
|
||||
#define FMT_i16 "%"PRIi16
|
||||
#define FMT_i32 "%"PRIi32
|
||||
#define FMT_i64 "%"PRIi64
|
||||
#define FMT_u8 "%"PRIu8
|
||||
#define FMT_u16 "%"PRIu16
|
||||
#define FMT_u32 "%"PRIu32
|
||||
#define FMT_u64 "%"PRIu64
|
||||
#define FMT_x8 "%"PRIx8
|
||||
#define FMT_x16 "%"PRIx16
|
||||
#define FMT_x32 "%"PRIx32
|
||||
#define FMT_x64 "%"PRIx64
|
||||
#define FMT_X8 "%"PRIX8
|
||||
#define FMT_X16 "%"PRIX16
|
||||
#define FMT_X32 "%"PRIX32
|
||||
#define FMT_X64 "%"PRIX64
|
||||
#define FMT_o8 "%"PRIo8
|
||||
#define FMT_o16 "%"PRIo16
|
||||
#define FMT_o32 "%"PRIo32
|
||||
#define FMT_o64 "%"PRIo64
|
||||
#define FMT_f32 "%f"
|
||||
#define FMT_f64 "%lf"
|
||||
typedef const char* cstr;
|
||||
|
||||
#define dbg(N) printf("\e[95m%d\n",N)
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ void StringBuilder_append_cstr(StringBuilder* b, cstr s);
|
||||
void StringBuilder_append_str(StringBuilder* b, str s);
|
||||
void StringBuilder_append_i64(StringBuilder* b, i64 a);
|
||||
void StringBuilder_append_u64(StringBuilder* b, u64 a);
|
||||
void StringBuilder_append_f32(StringBuilder* b, f32 n);
|
||||
void StringBuilder_append_f64(StringBuilder* b, f64 a);
|
||||
void StringBuilder_append_memory(StringBuilder* b, Array(u8) mem, bool uppercase);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "../std.h"
|
||||
|
||||
static inline bool char_isLatinLower(char c) { return 'a' <= c && c <= 'z'; }
|
||||
static inline bool char_isLatinUpper(char c) { return 'A' <= c && c <= 'Z'; }
|
||||
static inline bool char_isDigit(char c) { return '0' <= c && c <= '9'; }
|
||||
static inline bool isAlphabeticalLower(char c) { return 'a' <= c && c <= 'z'; }
|
||||
static inline bool isAlphabeticalUpper(char c) { return 'A' <= c && c <= 'Z'; }
|
||||
static inline bool isDigit(char c) { return '0' <= c && c <= '9'; }
|
||||
@ -11,8 +11,6 @@ typedef struct str {
|
||||
bool isZeroTerminated;
|
||||
} str;
|
||||
|
||||
#define FMT_str "%.*s"
|
||||
|
||||
/// creates str from a string literal
|
||||
#define STR(LITERAL) str_construct(LITERAL, ARRAY_LEN(LITERAL) - 1, true)
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ Result(i64) file_tellPos(FILE* f){
|
||||
Result(void) file_seek(FILE* f, i64 offset, SeekOrigin origin){
|
||||
if(IFWIN(_fseeki64, fseeko64)(f, offset, (int)origin) != 0){
|
||||
return RESULT_ERROR_FMT(
|
||||
"Can't seek (offset: "FMT_i64", origin: %i) in file: %s",
|
||||
"Can't seek (offset: " IFWIN("%lli", "%li") ", origin: %i) in file: %s",
|
||||
offset, origin, strerror(errno));
|
||||
}
|
||||
return RESULT_VOID;
|
||||
@ -119,7 +119,7 @@ Result(void) file_readStructsExactly(FILE* f, void* dst, u64 struct_size, u64 ex
|
||||
}
|
||||
if(r != exact_count){
|
||||
return RESULT_ERROR_FMT(
|
||||
"read "FMT_u64" structures out of "FMT_u64,
|
||||
"read " IFWIN("%llu", "%lu") " structures out of " IFWIN("%llu", "%lu"),
|
||||
r, exact_count);
|
||||
}
|
||||
return RESULT_VOID;
|
||||
|
||||
@ -51,25 +51,19 @@ void StringBuilder_append_cstr(StringBuilder* b, cstr s){
|
||||
|
||||
void StringBuilder_append_i64(StringBuilder* b, i64 n){
|
||||
char buf[32];
|
||||
sprintf(buf, FMT_i64, n);
|
||||
sprintf(buf, IFWIN("%lli", "%li"), n);
|
||||
StringBuilder_append_cstr(b, buf);
|
||||
}
|
||||
|
||||
void StringBuilder_append_u64(StringBuilder* b, u64 n){
|
||||
char buf[32];
|
||||
sprintf(buf, FMT_u64, n);
|
||||
StringBuilder_append_cstr(b, buf);
|
||||
}
|
||||
|
||||
void StringBuilder_append_f32(StringBuilder* b, f32 n){
|
||||
char buf[32];
|
||||
sprintf(buf, FMT_f32, n);
|
||||
sprintf(buf, IFWIN("%llu", "%lu"), n);
|
||||
StringBuilder_append_cstr(b, buf);
|
||||
}
|
||||
|
||||
void StringBuilder_append_f64(StringBuilder* b, f64 n){
|
||||
char buf[32];
|
||||
sprintf(buf, FMT_f64, n);
|
||||
sprintf(buf, "%lf", n);
|
||||
StringBuilder_append_cstr(b, buf);
|
||||
}
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ u32 str_hash32(const str s){
|
||||
str str_toUpper(const str src){
|
||||
str r = str_copy(src);
|
||||
for (u32 i = 0; i < r.size; i++){
|
||||
if(char_isLatinLower(r.data[i]))
|
||||
if(isAlphabeticalLower(r.data[i]))
|
||||
r.data[i] = r.data[i] - 'a' + 'A';
|
||||
}
|
||||
return r;
|
||||
@ -126,7 +126,7 @@ str str_toUpper(const str src){
|
||||
str str_toLower(const str src){
|
||||
str r = str_copy(src);
|
||||
for (u32 i = 0; i < r.size; i++){
|
||||
if(char_isLatinUpper(r.data[i]))
|
||||
if(isAlphabeticalUpper(r.data[i]))
|
||||
r.data[i] = r.data[i] - 'A' + 'a';
|
||||
}
|
||||
return r;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user