Fixes and improvements to serialization.

There were multiple issues with comment and newline lexing.

Extended printing functions to support Strings with %S flag (captial 'S').
Allows for length detection. Also made it so that precision for strings is the string length.
This commit is contained in:
2023-08-08 22:14:58 -04:00
parent bb35444be9
commit b5fa864318
9 changed files with 223 additions and 224 deletions

View File

@ -47,7 +47,8 @@ internal sw _print_string( char* text, sw max_len, _format_info* info, char cons
}
if ( info && info->precision >= 0 )
len = str_len( str, info->precision );
// Made the design decision for this library that precision is the length of the string.
len = info->precision;
else
len = str_len( str );
@ -410,6 +411,15 @@ neverinline sw str_fmt_va( char* text, sw max_len, char const* fmt, va_list va )
len = _print_string( text, remaining, &info, va_arg( va, char* ) );
break;
case 'S':
{
String gen_str = String { va_arg( va, char*) };
info.precision = gen_str.length();
len = _print_string( text, remaining, &info, gen_str );
}
break;
case 'r' :
len = _print_repeated_char( text, remaining, &info, va_arg( va, int ) );
break;

View File

@ -226,6 +226,11 @@ struct String
return header.Capacity - header.Length;
}
char& back()
{
return Data[ length() - 1 ];
}
sw capacity() const
{
Header const&