From: hgn Date: Sat, 11 Nov 2023 21:35:41 +0000 (+0000) Subject: strcatch X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=cb716ecad639dda76fb8254d77889026298f87f5;hp=543f7ce8b73edfddea525406a87e416afe366bb3;p=vg.git strcatch --- diff --git a/vg_platform.h b/vg_platform.h index 8bdd099..ef3daed 100644 --- a/vg_platform.h +++ b/vg_platform.h @@ -105,6 +105,17 @@ static void vg_strcat( vg_str *str, const char *append ){ str->i = -1; } +static void vg_strcatch( vg_str *str, char c ){ + if( str->i == -1 ) return; + if( (str->i + 2) > str->len ){ + str->i = -1; + return; + } + str->buffer[ str->i ++ ] = c; + str->buffer[ str->i ] = '\0'; +} + +/* FIXME: Negative numbers */ static void vg_strcati32( vg_str *str, i32 value ){ if( value ){ char temp[32];