Commit Graph

152 Commits

Author SHA1 Message Date
be47176524 object: dict: use b_strings as keys rather than plain c-strings.
now that strings can contain UTF-8 codepoints and null chars, the b_dict
api has been enhanced to accept keys as b_strings as well as regular c-strings.

keys are now stored as b_strings internally, to allow a wider range of
keys to be used.
2025-09-22 10:50:07 +01:00
b7da91ac93 object: hashmap: implement integer-based hashmap keys
rather than always interpreting a b_hashmap_key as a buffer to be hashed,
b_hashmap can now be told to consider the value of the key_data pointer itself
as the key, treating it as a buffer of size sizeof(void*).
2025-09-22 10:48:05 +01:00
d9041cda3f object: to_string() now takes a const object pointer 2025-09-22 10:47:33 +01:00
16b68b6fba object: add a type for storing, parsing, and stringifying date/time values 2025-09-22 10:44:56 +01:00
2fcadf7f39 core: string: add UTF-8 and null-char support; and some new string functions
b_string now uses UTF-8 internally, and can correctly manipulate strings
that contain non-ASCII and multi-byte codepoints.

b_string now tracks the length of a string in both bytes and unicode codepoints.

string insertion functions have been updated to correctly handle strings with
multi-byte codepoints, so the index parameter of each function now refers to codepoints
rather than bytes. inserting single-byte chars into a string with no multi-byte codepoints
is still optimised to used array indexing and memmove.

a b_string_iterator has been added to simplify iterating through a UTF-8 string, without
having to use a charAt()-style interface that would incur performance penalties.

strings can now also contain null bytes.

new functions include:
  - b_string_tokenise: a b_iterator interface for iterating through tokens
    in a string. similar to strtok except that:
    * it is re-entrant, and uses no global state.
    * it supports delimiters that are longer than one character and/or contain
      multi-byte UTF-8 codepoints.
    * it doesn't modify the string that is being iterated over.
    * it correctly handles strings with multi-byte UTF-8 codepoints and null chars.
  - b_string_compare: for comparing strings. necessary to use this rather than strcpy
    as b_strings can now contain null chars.
2025-09-22 10:36:26 +01:00
cbaeb002f8 core: stream: b_stream_read_line_s now includes linefeed in output and correctly reports EOF condition 2025-09-22 10:32:37 +01:00
bc5986150c core: stream: fix buffer overflow in stream indentation stack 2025-09-22 10:31:53 +01:00
4ab524a66b core: hash: rename b_hash_string to avoid conflict with b_string 2025-09-22 10:31:30 +01:00
d52992c8ba core: printf: switch to an enhanced version of embedded printf 2025-09-22 10:30:40 +01:00
072903f896 core: error: fix b_error_caused_by_code calling an undefined function 2025-09-22 10:29:48 +01:00
0a2a1c695a core: error: add function to test if an error has a particular vendor/code 2025-09-22 10:29:01 +01:00
db3d1e3183 core: add a type to store unicode characters, as well as functions to query them 2025-09-22 10:28:03 +01:00
bdf201dedc TEMP: add toml parser 2025-09-19 15:47:59 +01:00
a5e3e06306 core: add basic mutex and per-thread data support 2025-08-09 19:49:06 +01:00
ee2611c678 core: error: fix double free of errors released with b_error_release 2025-08-09 19:48:40 +01:00
ed8e51ed5e core: bitop: add atomic compare-exchange 2025-08-09 19:48:01 +01:00
a1c1fee301 compress: cstream: add skip() and reset() functions 2025-08-09 19:45:34 +01:00
13cb866892 test: io: add directory deletion test 2025-08-09 19:41:57 +01:00
8bdb770ae5 io: directory: implement temporary directories and delete-on-close 2025-08-09 19:40:11 +01:00
655d8b1881 io: path: implement deleting (empty) directories 2025-08-09 19:40:02 +01:00
bcbd85372e cmd: improve command usage strings
the command usage strings now use the actual argument values provided by the user, in particular for the names of relevant commands
2025-08-09 19:36:46 +01:00
fae8ffe4f8 test: compress: report total bytes transacted in mix-(de)compress 2025-07-31 11:28:57 +01:00
17b6a02a4f compress: cstream: record the total number of bytes that pass through the endpoint across all (un)compressed sections 2025-07-31 11:28:28 +01:00
ede5e72fc2 compress: cstream: add support for temporarily moving the cursor and performing limited i/o operations
the cursor can only be moved during uncompressed i/o, and any read/write operations are performed directly on the underlying endpoint with no buffering, and don't count towards the transacted byte statistics.

the cursor can only be moved once, after which it's position must be restored.
2025-07-31 11:18:10 +01:00
10dfa54d5c compress: zstd: fix f_ctx_size not being set correctly 2025-07-31 11:15:28 +01:00
5e6a4d0aa6 compress: compressor: check that function ctx size is >0 before returning a pointer to it 2025-07-31 11:14:59 +01:00
67392d12e6 core: stream: replaced cached cursor counter with a tell() function callback 2025-07-31 11:13:40 +01:00
771044a95a core: stream: add seek support to stdio streams 2025-07-31 11:13:18 +01:00
918bdad153 test: compress: add mixed compressed/uncompressed data test 2025-07-30 18:33:53 +01:00
f877be66ee test: compress: add simple compression stream test 2025-07-30 18:33:33 +01:00
4aaeb46d11 test: compress: update simple1 compression api usage 2025-07-30 18:32:51 +01:00
73675f1e4d compress: add byte-wise (de)compression stream data structure 2025-07-30 18:32:17 +01:00
8410841b87 compress: zstd: update ringbuffer api usage to use const buffer pointer 2025-07-30 18:31:54 +01:00
5a7f0b8535 compress: compressor: merge compress and decompress functions into a single step function 2025-07-30 18:31:28 +01:00
051d371eb5 compress: move compression mode enum to function.h 2025-07-30 18:30:31 +01:00
e4c4de94b8 core: ringbuffer: reset read and write pointers to 0 when a read buffer consumes all available data 2025-07-30 18:25:17 +01:00
2f874ff11a core: ringbuffer: make open_read_buffer pointer parameter const-correct 2025-07-30 18:24:45 +01:00
b5c07c2390 core: stream: make b_stream_write_bytes buffer pointer const 2025-07-30 18:23:33 +01:00
514b9f1c5f core: stream: add function to open a b_stream from a FILE pointer 2025-07-30 17:49:56 +01:00
56d300f2cf cmake: add compress module to FindBluelib 2025-07-28 22:29:13 +01:00
3e41f51ccf test: compress: add simple (de)compression test using b_compressor 2025-07-28 22:28:59 +01:00
56399b07d8 meta: add compress module for (de)compressing data 2025-07-28 22:27:24 +01:00
65ee2a91b8 build: add new parameters to module template 2025-07-28 22:25:42 +01:00
ff71d94e5d build: set language standard to C99 without extensions 2025-07-28 22:24:46 +01:00
c14d0b717e test: update i/o api usage re: b_error 2025-07-28 22:23:57 +01:00
666b315086 test: term: add enhanced error reporting tests 2025-07-28 22:23:16 +01:00
0e0c95900c test: core: add error and ringbuffer tests 2025-07-28 22:22:38 +01:00
ad4eba6cc1 test: io: update i/o api usage re: b_error 2025-07-28 22:22:14 +01:00
0ab1855105 term: add an enhanced error reporting function 2025-07-28 22:21:13 +01:00
663df15289 io: implement b_error support for file/directory operations 2025-07-28 22:20:20 +01:00