@ -11,7 +11,24 @@
# define FLAGSET(f, flag) (( (f) & (flag) ) == (flag))
# define DFLAGSET(f, flagname) FLAGSET(f, DISPF_SHOW_ ## flagname)
//TODO: This probably won't work. Write wrappers for strncpy(), strncat() that return number of bytes written isntead of useless pointer that we already have.
// Returns number of bytes written to `dest`. Otherwise same as `strncpy()`.
static usize strncpy_n ( char * pOUT dest , const char * restrict src , usize n )
{
usize i ;
for ( i = 0 ; i < n ; i + + )
if ( ! ( * dest + + = * src + + ) ) return i ;
dest [ i ] = 0 ;
return i ;
}
// Returns number of bytes written to (dest+strlen(dest)). Otherwise same as `strncat()`.
static inline usize strncat_n ( char * pOUT dest , const char * restrict src , usize n )
{
usize dl = strlen ( dest ) ;
return strncpy_n ( dest + dl , src , n ) ;
}
//TODO: This works, but seems inherantly unsafe. Rewrite to use the above `strn*_n()` functions for better length tracking.
static usize _display_get_fmt ( dispflags_t flags , bool matched , usize _len , char str [ pOUT _len ] )
{
register usize len = _len ;