33 Commits

Author SHA1 Message Date
Vincent Torri
9d16636042 Windows: add str_endswithi() for compiler_cl_args_output()
also added references in meson to check if it is
compatible with meson
2024-02-02 09:49:47 -05:00
Stone Tickle
0f22851a0a
ignore leading/trailing whitespace in str.to_int()
This is what meson does and seems reasonable.
2024-01-07 13:05:05 -05:00
Stone Tickle
446122b154
add str_eql_glob 2024-01-01 21:58:12 -05:00
Stone Tickle
3ddf339d4a
remove usage of strncasecmp 2023-12-11 20:58:07 -05:00
Stone Tickle
883594c470
reuse identical strings 2023-12-04 21:17:26 -05:00
Stone Tickle
d286201f39
rename posix.h to compat.h
Currently all compat.h does is define the appropriate POSIX macro unless
you are on windows, as well as conditionally enabling
__attribute__(format...).
2023-03-10 09:35:04 -05:00
Stone Tickle
4298aa2011
make muon reuse compliant
https://reuse.software
2022-10-25 10:54:31 -04:00
Stone Tickle
5e53b2a21a
make sbuf_into_str always take ownership 2022-09-05 06:50:40 -05:00
Stone Tickle
32edd32c8b
cleanup sbuf initializations 2022-09-05 06:50:40 -05:00
Stone Tickle
9a45f9d356
finish porting path functions to sbufs 2022-09-05 06:50:40 -05:00
Stone Tickle
b6afb1f3ec
transition path_join functions to use sbufs 2022-09-05 06:50:39 -05:00
Stone Tickle
376399ea2b
start transitioning path_ functions to use sbufs 2022-09-05 06:50:39 -05:00
Stone Tickle
c86d371268
introduce sbuf a general string buffer
There are lots of places in muon where we want to manipulate strings.
In some cases it is appropriate to use the make_str() + str_app()
method.  However, in other cases, it would be better to avoid
allocation.

The solution so far has been to write specialized buffer functions that
append a buffer and check that it doesn't overflow, etc., for every
different case.  Sometimes these buffers can grow with realloc,
sometimes they are static only.

sbuf is a sort of compromise.  It starts out with a stack allocated
static array that is somewhat small, and can be configured to overflow
into either an unmanaged allocation, or into the workspace string pool.

Some other nice features include a mode that transparently writes output
to a FILE * rather than a buffer, which means that there is no longer a
limit on the length obj_fprintf can output.

The plan is to change the signature of the path_ functions to use sbuf
rather than a buffer + length.  That means we can finally get away from
PATH_MAX everywhere.
2022-09-05 06:50:38 -05:00
Stone Tickle
d573e2d381
obj_printf print \n in strings in unescaped mode 2022-08-12 19:53:26 -05:00
Stone Tickle
caab5b933b
move str_split into lang/string.c 2022-05-23 09:04:25 -05:00
Stone Tickle
b4d39614f7
small cleanups 2022-02-15 15:48:59 -06:00
Stone Tickle
111775f567
start using typechecked obj getters 2022-02-12 07:36:35 -06:00
Stone Tickle
d22f7292b4
implement more correct shell escapes 2021-11-29 06:37:35 -06:00
Stone Tickle
5addc706cb
remove wk_ prefix to string functions 2021-11-26 06:49:23 -06:00
Stone Tickle
79ff61cf07
unify strings and objects
Strings were originally indices into an array of chars.  This was
eventually refactored to an array of `str` structs to allow strings to
contain null bytes.  This intermediate array mapping objects to strings
was actually unnecessary, and this commit removes it.
2021-11-25 19:56:02 -06:00
Stone Tickle
c2bec76ce8
change c standard to c99 2021-11-16 14:56:05 -06:00
Stone Tickle
abfdf4483b
implement string endswith 2021-10-21 07:41:46 -05:00
Stone Tickle
1c1ab11310
extract string.split() 2021-10-13 09:47:52 -05:00
Stone Tickle
a9f4e72118
remove all cstr assumptions from core language 2021-09-30 13:15:32 -05:00
Stone Tickle
4bef7e5752
remove use of cstr from interpreter 2021-09-30 12:59:26 -05:00
Stone Tickle
f3600385d5
add more string functions 2021-09-30 12:12:17 -05:00
Stone Tickle
e6e29d6624
update string.strip() implementation
- works with meson strings
- accepts optional "what to strip" argument
2021-09-29 14:51:21 -05:00
Stone Tickle
474ca2e842
add wk_strcat to join two wk_strs 2021-09-29 11:39:13 -05:00
Stone Tickle
c2d6abd67e
fix serialization 2021-09-29 10:18:26 -05:00
Stone Tickle
c877ed9f9b
make return of wk_file_path const 2021-09-29 10:06:48 -05:00
Stone Tickle
bf58106e1d
make return of get_str const 2021-09-29 10:05:35 -05:00
Stone Tickle
06b00a2ea7
refactor core datastructures for strings
In muon strings were represented as C strings internally.  In Meson, strings
are python strings, which notably are allowed to contain null bytes.  In
order to be compatible string handling needed to be rewritten.  Use this
opportunity also to allow handling larger strings, and pushing strings
without invalidating others.
2021-09-28 16:13:31 -05:00
Stone Tickle
a35e36bf76
move string functions into their own file 2021-09-28 08:22:12 -05:00