Namespace fix (making sure a namespace is a prefix only)

This commit is contained in:
Edward R. Gonzalez 2023-11-17 19:24:27 -05:00
parent 6395d022f1
commit 22f74f3dc6

View File

@ -2,8 +2,6 @@
#include "IO.cpp" #include "IO.cpp"
#include "Spec.cpp" #include "Spec.cpp"
void parse_options( int num, char** arguments ) void parse_options( int num, char** arguments )
{ {
zpl_opts opts; zpl_opts opts;
@ -72,14 +70,14 @@ void parse_options( int num, char** arguments )
do do
{ {
path[length] = *opt; path[length] = *opt;
} }
while ( length++, opt++, *opt != ' ' && *opt != '\0' ); while ( length++, opt++, *opt != ' ' && *opt != '\0' );
zpl_string path_string = zpl_string_make_length( g_allocator, path, length ); zpl_string path_string = zpl_string_make_length( g_allocator, path, length );
zpl_array_append( IO::Sources, path_string ); zpl_array_append( IO::Sources, path_string );
opt++; opt++;
} }
while ( --left ); while ( --left );
} }
} }
@ -132,7 +130,7 @@ void parse_options( int num, char** arguments )
do do
{ {
zpl_array_append( IO::Destinations, IO::Sources[num - left] ); zpl_array_append( IO::Destinations, IO::Sources[num - left] );
} }
while ( --left ); while ( --left );
} }
@ -163,7 +161,7 @@ void parse_options( int num, char** arguments )
/* /*
Refactor will problably have the execution and arg parsing (main and opts) Refactor will problably have the execution and arg parsing (main and opts)
moved to a separate file. moved to a separate file.
*/ */
@ -172,7 +170,7 @@ zpl_arena Refactor_Buffer;
void refactor() void refactor()
{ {
ct static char const* include_sig = "include"; ct static char const* include_sig = "include";
struct Token struct Token
{ {
u32 Start; u32 Start;
@ -280,7 +278,7 @@ void refactor()
{ {
Spec::Entry* ignore = Spec::Ignore_Includes; Spec::Entry* ignore = Spec::Ignore_Includes;
sw ignores_left = zpl_array_count( Spec::Ignore_Includes); sw ignores_left = zpl_array_count( Spec::Ignore_Includes);
Snapshot backup = { src, left, col, line }; Snapshot backup = { src, left, col, line };
if ( '#' != src[0] ) if ( '#' != src[0] )
break; break;
@ -386,6 +384,12 @@ void refactor()
continue; continue;
} }
if (( zpl_char_is_alphanumeric( src[-1] ) || src[-1] == '_') )
{
ignore++;
continue;
}
zpl_string_clear( current ); zpl_string_clear( current );
u32 sig_length = zpl_string_length( ignore->Sig ); u32 sig_length = zpl_string_length( ignore->Sig );
@ -487,7 +491,7 @@ void refactor()
} }
restore( backup ); restore( backup );
} }
while (false); while (false);
// Words to match // Words to match
@ -549,6 +553,9 @@ void refactor()
if ( nspace->Sig[0] != src[0] ) if ( nspace->Sig[0] != src[0] )
continue; continue;
if (( zpl_char_is_alphanumeric( src[-1] ) || src[-1] == '_') )
continue;
zpl_string_clear( current ); zpl_string_clear( current );
u32 sig_length = zpl_string_length( nspace->Sig ); u32 sig_length = zpl_string_length( nspace->Sig );
@ -595,7 +602,7 @@ void refactor()
Skip: Skip:
move_forward( 1 ); move_forward( 1 );
} }
while ( left ); while ( left );
End_Search: End_Search:
@ -607,7 +614,7 @@ End_Search:
// Prep data for building the content // Prep data for building the content
left = zpl_array_count( tokens); left = zpl_array_count( tokens);
char* content = IO::Current_Content; char* content = IO::Current_Content;
zpl_string refactored = zpl_string_make_reserve( zpl_arena_allocator( & Refactor_Buffer ), buffer_size ); zpl_string refactored = zpl_string_make_reserve( zpl_arena_allocator( & Refactor_Buffer ), buffer_size );
@ -643,7 +650,7 @@ End_Search:
entry--; entry--;
if ( entry->End < IO::Current_Size ) if ( entry->End < IO::Current_Size )
{ {
refactored = zpl_string_append_length( refactored, content, IO::Current_Size - 1 - entry->End ); refactored = zpl_string_append_length( refactored, content, IO::Current_Size - 1 - entry->End );
} }
@ -676,7 +683,7 @@ int main( int num, char** arguments )
refactor(); refactor();
zpl_printf("\nRefactored: %s", IO::Sources[IO::Current]); zpl_printf("\nRefactored: %s", IO::Sources[IO::Current]);
} }
while ( --left ); while ( --left );
zpl_arena_free( & Refactor_Buffer ); zpl_arena_free( & Refactor_Buffer );