Got it to compile (without Incremental, parsing, editor, scanner)

This commit is contained in:
Edward R. Gonzalez 2023-05-07 15:03:24 -04:00
parent 74c5736f59
commit 00b4220333
6 changed files with 203 additions and 253 deletions

View File

@ -80,10 +80,10 @@ using zpl::pool_init;
using zpl::pool_free;
using zpl::process_exit;
using zpl::str_copy;
using zpl::str_fmt_va;
using zpl::str_fmt_out_va;
using zpl::str_fmt_out_err_va;
using zpl::str_compare;
using zpl::str_fmt_va;
using zpl::string_appendc;
using zpl::string_append_fmt;
using zpl::string_append_length;
@ -104,6 +104,7 @@ using zpl::str_len;
# pragma clang diagnostic ignored "-Wunused-variable"
# pragma clang diagnostic ignored "-Wunknown-pragmas"
# pragma clang diagnostic ignored "-Wvarargs"
# pragma clang diagnostic ignored "-Wunused-function"
#endif
@ -264,14 +265,12 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
if ( ! str )
mem_set( allocation, 0, alloc_size );
Header
header = { allocator, length, length };
Header header = { allocator, length, length };
String result = { rcast( char*, allocation) + header_size };
if ( length && str )
mem_copy( allocation + header_size, str, length );
mem_copy( result, str, length );
String
result = { rcast( char*, allocation + header_size) };
result[ length ] = '\0';
return result;
@ -327,8 +326,45 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
return true;
}
bool make_space_for( char const* str, sw add_len )
{
sw available = avail_space();
// NOTE: Return if there is enough space left
if ( available >= add_len )
{
return false;
}
else
{
sw new_len, old_size, new_size;
void* ptr;
void* new_ptr;
AllocatorInfo allocator = get_header().Allocator;
Header* header = nullptr;
new_len = length() + add_len;
ptr = & get_header();
old_size = size_of( Header ) + length() + 1;
new_size = size_of( Header ) + new_len + 1;
new_ptr = resize( allocator, ptr, old_size, new_size );
if ( new_ptr == nullptr )
return false;
header = zpl_cast( Header* ) new_ptr;
header->Allocator = allocator;
header->Capacity = new_len;
Data = rcast( char*, header + 1 );
return str;
}
}
bool make_space_for( char const* str, sw add_len );
bool append( char const* str )
{
@ -339,7 +375,7 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
{
Header& header = get_header();
if ( str > 0 )
if ( sptr(str) > 0 )
{
sw curr_len = header.Length;
@ -428,60 +464,12 @@ char const* Msg_Invalid_Value = "INVALID VALUE PROVIDED";
return header.Length;
}
bool make_space_for( char const* str, sw add_len )
{
sw available = avail_space();
// NOTE: Return if there is enough space left
if ( available >= add_len )
{
return false;
}
else
{
sw new_len, old_size, new_size;
void* ptr;
void* new_ptr;
AllocatorInfo allocator = get_header().Allocator;
Header* header = nullptr;
new_len = length() + add_len;
ptr = & get_header();
old_size = size_of( Header ) + length() + 1;
new_size = size_of( Header ) + new_len + 1;
new_ptr = resize( allocator, ptr, old_size, new_size );
if ( new_ptr == nullptr )
return false;
header = zpl_cast( Header* ) new_ptr;
header->Allocator = allocator;
header->Capacity = new_len;
Data = rcast( char*, header + 1 );
return str;
}
}
void trim( char const* cut_set )
{
char* start;
char* end;
char* start_pos;
char* end_pos;
sw len = 0;
start_pos = Data;
start = Data;
end_pos = Data + length() - 1;
end = Data + length() - 1;
char* start_pos = Data;
char* end_pos = Data + length() - 1;
while ( start_pos <= end_pos && char_first_occurence( cut_set, *start_pos ) )
start_pos++;
@ -606,7 +594,7 @@ sw fatal(char const* fmt, ...)
#if Build_Debug
va_start(va, fmt);
zpl::snprintf_va(buf, ZPL_PRINTF_MAXLEN, fmt, va);
str_fmt_va(buf, ZPL_PRINTF_MAXLEN, fmt, va);
va_end(va);
assert_crash(buf);

View File

@ -28,10 +28,10 @@ namespace gen
#pragma region Constants
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
Code type_ns(void);
Code type_ns(int);
Code type_ns(bool);
Code type_ns(char);
Code type_ns(char_wide);
Code type_ns(wchar_t);
Code type_ns(s8);
Code type_ns(s16);
@ -421,7 +421,8 @@ namespace gen
switch ( Type )
{
case Invalid:
break;
log_failure( "AST::duplicate: Cannot duplicate an invalid AST." );
return nullptr;
case Untyped:
case Comment:
@ -484,6 +485,9 @@ namespace gen
}
return result;
}
log_failure( "AST::duplicate: Unknown AST type %s.", type_str() );
return nullptr;
}
String AST::to_string()
@ -606,6 +610,7 @@ namespace gen
break;
case Enum:
{
result.append( indent );
ProcessModuleFlags();
@ -640,6 +645,7 @@ namespace gen
, body()->to_string()
, indent_str
);
}
break;
case Enum_Fwd:
@ -651,6 +657,7 @@ namespace gen
break;
case Enum_Class:
{
result.append( indent );
ProcessModuleFlags();
@ -685,9 +692,11 @@ namespace gen
, body()->to_string()
, indent_str
);
}
break;
case Enum_Class_Fwd:
{
result.append( indent );
ProcessModuleFlags();
@ -703,6 +712,7 @@ namespace gen
}
result.append_fmt( ": %s;\n", Name, Entries[idx]->to_string() );
}
break;
case Execution:
@ -900,7 +910,7 @@ namespace gen
ProcessModuleFlags();
s32 idx;
s32 idx = 0;
if ( Entries[idx]->Type == Specifiers )
{
@ -1022,6 +1032,7 @@ namespace gen
break;
case Typedef:
{
result.append( indent );
ProcessModuleFlags();
@ -1043,6 +1054,7 @@ namespace gen
{
result.append( ";" );
}
}
break;
case Typename:
@ -1057,6 +1069,7 @@ namespace gen
break;
case Union:
{
result.append( indent );
ProcessModuleFlags();
@ -1077,9 +1090,11 @@ namespace gen
, body()->to_string()
, indent_str
);
}
break;
case Using:
{
result.append( indent );
ProcessModuleFlags();
@ -1103,6 +1118,7 @@ namespace gen
result.append_fmt( "using %s", Name );
result.append( ";" );
}
break;
case Using_Namespace:
@ -1195,16 +1211,17 @@ namespace gen
#ifdef GEN_DEFINE_LIBRARY_CODE_CONSTANTS
Code&
t_bool_write = ccast( Code, t_void );
t_bool_write = def_type( name(void) );
t_void_write = ccast( Code, t_void );
t_void_write = def_type( name(void) );
t_void_write->Readonly = true;
# define def_constant_code_type( Type_ ) \
Code& \
t_##Type_ = def_type( name(Type_) ); \
t_##Type_->Readonly = true;
# define def_constant_code_type( Type_ ) \
Code& \
t_##Type_##write = ccast( Code, type_ns(Type_) ); \
t_##Type_##write = def_type( name(Type_) ); \
t_##Type_##write->Readonly = true;
def_constant_code_type( int );
def_constant_code_type( bool );
def_constant_code_type( char );
def_constant_code_type( wchar_t );
@ -1231,10 +1248,11 @@ namespace gen
spec_constexpr_write = ccast( Code, spec_constexpr );
spec_constexpr_write = def_specifiers( 1, ESpecifier::Constexpr );
# define def_constant_spec( Type_, ... ) \
Code& \
spec_##Type_ = def_specifiers( macro_num_args(__VA_ARGS__), __VA_ARGS__); \
spec_##Type_.lock();
# define def_constant_spec( Type_, ... ) \
Code& \
spec_##Type_##write = ccast( Code, spec_##Type_); \
spec_##Type_##write = def_specifiers( macro_num_args(__VA_ARGS__), __VA_ARGS__); \
spec_##Type_##write.lock()
def_constant_spec( const, ESpecifier::Const );
def_constant_spec( inline, ESpecifier::Inline );
@ -1855,7 +1873,7 @@ namespace gen
return Code::Invalid;
}
if ( parent && parent->Type != Class || parent->Type != Struct || parent->Type != Typename || parent->Type != Untyped )
if ( parent && (parent->Type != Class || parent->Type != Struct || parent->Type != Typename || parent->Type != Untyped) )
{
log_failure( "gen::def_class: parent provided is not type 'Class', 'Struct', 'Typeanme', or 'Untyped': %s", parent->debug_str() );
return Code::Invalid;

View File

@ -16,10 +16,10 @@
// #define GEN_DONT_USE_FATAL
#define GEN_ENFORCE_READONLY_AST
#define GEN_FEATURE_INCREMENTAL
#define GEN_FEATURE_PARSING
#define GEN_FEATURE_EDITOR
#define GEN_FEATURE_SCANNER
// #define GEN_FEATURE_INCREMENTAL
// #define GEN_FEATURE_PARSING
// #define GEN_FEATURE_EDITOR
// #define GEN_FEATURE_SCANNER
#ifdef gen_time
@ -188,9 +188,6 @@ namespace gen
inline
char const* to_str( Type op )
{
using something = u8;
typedef u8 another;
local_persist
char const* lookup[ Num_Ops ] = {
# define Entry( Type_, Token_ ) txt(Token_),
@ -312,7 +309,7 @@ namespace gen
};
if ( type > AccessSpec::Public )
return lookup[ (u32)AccessSpec::Invalid ];
return "Invalid";
return lookup[ (u32)type ];
}
@ -482,12 +479,14 @@ namespace gen
bool typename_is_ptr()
{
assert_crash("not implemented");
return false;
}
inline
bool typename_is_ref()
{
assert_crash("not implemented");
return false;
}
inline
@ -572,7 +571,7 @@ namespace gen
struct CodePOD
{
Using_Code_POD
# undef Using_CodePOD;
# undef Using_CodePOD
};
constexpr sw size_AST = sizeof(AST);
@ -667,6 +666,8 @@ namespace gen
return ast;
}
// Cannot be done unfortunately c++ sucks. (Will lose POD by doing so)
#if 0
inline
Code& operator=( Code other )
{
@ -688,6 +689,7 @@ namespace gen
return *this;
}
#endif
inline
AST* operator->()
@ -823,6 +825,7 @@ namespace gen
, ModuleFlag mflags = ModuleFlag::None );
Code def_class_body ( s32 num, ... );
Code def_class_body ( s32 num, Code* codes );
Code def_enum_body ( s32 num, ... );
Code def_enum_body ( s32 num, Code* codes );
Code def_export_body ( s32 num, ... );

View File

@ -19,47 +19,6 @@ $path_build = Join-Path $path_root build
$path_scripts = Join-Path $path_root scripts
if ($false)
{
#region Regular Build
write-host "Building project`n"
if ( -not( Test-Path $path_build ) )
{
$args_meson = @()
$args_meson += "setup"
$args_meson += $path_build
# Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
Push-Location $path_scripts
Invoke-Expression "& meson $args_meson"
Pop-Location
}
if ( $type )
{
$args_meson = @()
$args_meson += "configure"
$args_meson += $path_build
$args_meson += "--buildtype $($type)"
# Start-Process meson $args_meson -NoNewWindow -Wait -WorkingDirectory $path_scripts
Push-Location $path_scripts
Invoke-Expression "& meson $args_meson"
Pop-Location
}
$args_ninja = @()
$args_ninja += "-C"
$args_ninja += $path_build
Push-Location $path_root
ninja $args_ninja
Pop-Location
#endregion Regular Build
}
# if ( $test -eq $true )
# {
#region Test Build
@ -98,29 +57,29 @@ Pop-Location
# Build the program depending on generated files.
if ( -not( Test-Path $path_test_build ) )
{
$args_meson = @()
$args_meson += "setup"
$args_meson += $path_test_build
# if ( -not( Test-Path $path_test_build ) )
# {
# $args_meson = @()
# $args_meson += "setup"
# $args_meson += $path_test_build
Push-Location $path_test
& meson $args_meson
Pop-Location
}
# Push-Location $path_test
# & meson $args_meson
# Pop-Location
# }
$args_ninja = @()
$args_ninja += "-C"
$args_ninja += $path_test_build
# $args_ninja = @()
# $args_ninja += "-C"
# $args_ninja += $path_test_build
Push-Location $path_root
ninja $args_ninja
Pop-Location
# Push-Location $path_root
# ninja $args_ninja
# Pop-Location
$testcpp = Join-Path $path_test_build testcpp.exe
# $testcpp = Join-Path $path_test_build testcpp.exe
Push-Location $path_test
& $testcpp
Pop-Location
# Push-Location $path_test
# & $testcpp
# Pop-Location
# endregion Test Build
# }

View File

@ -1,19 +0,0 @@
project( 'refactor', 'c', 'cpp', default_options : ['buildtype=release'] )
# add_global_arguments('-E', language : 'cpp')
includes = include_directories(
[ '../project'
, '../thirdparty'
])
get_sources = files('./get_sources.ps1')
sources = files(run_command('powershell', get_sources, check: true).stdout().strip().split('\n'))
if get_option('buildtype').startswith('debug')
add_project_arguments('-DBuild_Debug', language : ['c', 'cpp'])
endif
executable( 'refactor', sources, include_directories : includes )

125
thirdparty/zpl.h vendored
View File

@ -34,6 +34,7 @@ GitHub:
https://github.com/zpl-c/zpl
Version History:
19.0.1 - Fixed zpl_array_fill ZPL_ASSERT off-by-one error
19.0.0 - Check all results of zpl_alloc() when using JSON parser/writer (rheatley-pervasid)
18.1.5 - set parent to parsed JSON nodes (fixed)
@ -414,7 +415,7 @@ License:
# define ZPL_VERSION_MAJOR 19
# define ZPL_VERSION_MINOR 0
# define ZPL_VERSION_PATCH 0
# define ZPL_VERSION_PATCH 1
# define ZPL_VERSION_PRE ""
// file: zpl_hedley.h
@ -2044,7 +2045,7 @@ ZPL_DIAGNOSTIC_POP
namespace zpl \
{
# define ZPL_END_NAMESPACE }
# define ZPL_NS( Identifier ) zpl::##Identifier // Used in macros, properly exposes symbol anywhere
# define ZPL_NS( Identifier ) zpl::Identifier // Used in macros, properly exposes symbol anywhere
# else
# define ZPL_BEGIN_NAMESPACE
# define ZPL_END_NAMESPACE
@ -3885,15 +3886,15 @@ ZPL_IMPL_INLINE b8 _array_appendv_at( void** x, void* items, sw item_size, sw it
#define array_appendv_at( x, items, item_count, ind ) ZPL_NS( _array_appendv_at )( zpl_cast( void** ) & ( x ), ( items ), size_of( ( items )[ 0 ] ), ( item_count ), ( ind ) )
#define array_fill( x, begin, end, value ) \
do \
{ \
ZPL_ASSERT( ( begin ) >= 0 && ( end ) < array_count( x ) ); \
ZPL_ASSERT( size_of( value ) == size_of( ( x )[ 0 ] ) ); \
for ( ZPL_NS( sw ) i = ( begin ); i < ( end ); i++ ) \
{ \
x[ i ] = value; \
} \
#define array_fill( x, begin, end, value ) \
do \
{ \
ZPL_ASSERT( ( begin ) >= 0 && ( end ) <= array_count( x ) ); \
ZPL_ASSERT( size_of( value ) == size_of( ( x )[ 0 ] ) ); \
for ( ZPL_NS( sw ) i = ( begin ); i < ( end ); i++ ) \
{ \
x[ i ] = value; \
} \
} while ( 0 )
#define array_remove_at( x, index ) \
@ -4645,7 +4646,7 @@ ZPL_DEF_INLINE const char* str_tok( char* output, const char* src, const char* d
ZPL_DEF_INLINE const char* strntok( char* output, sw len, const char* src, const char* delimit );
ZPL_DEF_INLINE char* str_dup( AllocatorInfo a, char* src, sw max_len );
ZPL_DEF_INLINE char** str_split_lines( AllocatorInfo alloc, char* source, b32 strip_whitespace );
ZPL_DEF_INLINE char** str_split_lines( AllocatorInfo allocator, char* source, b32 strip_whitespace );
#define str_expand( str ) str, ZPL_NS( str_len )( str )
#define str_advance_while( str, cond ) \
@ -5126,10 +5127,10 @@ ZPL_IMPL_INLINE char* str_dup( AllocatorInfo a, char* src, sw max_len )
return dest;
}
ZPL_IMPL_INLINE char** str_split_lines( AllocatorInfo alloc, char* source, b32 strip_whitespace )
ZPL_IMPL_INLINE char** str_split_lines( AllocatorInfo allocator, char* source, b32 strip_whitespace )
{
char **lines = NULL, *p = source, *pd = p;
array_init( lines, alloc );
array_init( lines, allocator );
while ( *p )
{
@ -5601,7 +5602,7 @@ ZPL_DEF b32 file_write_contents( char const* filepath, void const* buffer, sw si
* @param strip_whitespace Strip whitespace when we split to lines?
* @return File content we've read itself
*/
ZPL_DEF char* file_read_lines( AllocatorInfo alloc, Array( char* ) * lines, char const* filename, b32 strip_whitespace );
ZPL_DEF char* file_read_lines( AllocatorInfo allocator, Array( char* ) * lines, char const* filename, b32 strip_whitespace );
//! @}
@ -5828,7 +5829,7 @@ ZPL_DEF char* path_get_full_name( AllocatorInfo a, char const* path );
* @param recurse [description]
* @return [description]
*/
ZPL_DEF /*zpl_string*/ char* path_dirlist( AllocatorInfo alloc, char const* dirname, b32 recurse );
ZPL_DEF /*zpl_string*/ char* path_dirlist( AllocatorInfo allocator, char const* dirname, b32 recurse );
/**
* Initialize dirinfo from specified path
@ -5966,7 +5967,7 @@ ZPL_DEF sw tar_pack( FileInfo* archive, char const** paths, sw paths_len );
* @param alloc memory allocator to use (ex. zpl_heap())
* @return error
*/
ZPL_DEF sw tar_pack_dir( FileInfo* archive, char const* path, AllocatorInfo alloc );
ZPL_DEF sw tar_pack_dir( FileInfo* archive, char const* path, AllocatorInfo allocator );
/**
* @brief Unpacks an existing archive
@ -6584,7 +6585,7 @@ typedef struct
typedef struct
{
AllocatorInfo alloc;
AllocatorInfo allocator;
OptsEntry* entries; ///< zpl_array
OptsError* errors; ///< zpl_array
OptsEntry** positioned; ///< zpl_array
@ -8761,7 +8762,7 @@ typedef struct
typedef struct
{
AllocatorInfo alloc;
AllocatorInfo allocator;
u32 max_threads, max_jobs, counter;
ThreadWorker* workers; ///< zpl_buffer
ThreadQueue queues[ ZPL_JOBS_MAX_PRIORITIES ];
@ -11248,16 +11249,16 @@ FileContents file_read_contents( AllocatorInfo a, b32 zero_terminate, char const
if ( file_open( &file, filepath ) == EFileError_NONE )
{
sw file_size = zpl_cast( sw ) file_size( &file );
if ( file_size > 0 )
sw fsize = zpl_cast( sw ) file_size( &file );
if ( fsize > 0 )
{
result.data = alloc( a, zero_terminate ? file_size + 1 : file_size );
result.size = file_size;
result.data = alloc( a, zero_terminate ? fsize + 1 : fsize );
result.size = fsize;
file_read_at( &file, result.data, result.size, 0 );
if ( zero_terminate )
{
u8* str = zpl_cast( u8* ) result.data;
str[ file_size ] = '\0';
u8* str = zpl_cast( u8* ) result.data;
str[ fsize ] = '\0';
}
}
file_close( &file );
@ -11294,16 +11295,16 @@ b32 file_write_contents( char const* filepath, void const* buffer, sw size, File
return write_ok;
}
char* file_read_lines( AllocatorInfo alloc, Array( char* ) * lines, char const* filename, b32 strip_whitespace )
char* file_read_lines( AllocatorInfo allocator, Array( char* ) * lines, char const* filename, b32 strip_whitespace )
{
FileInfo f = { 0 };
file_open( &f, filename );
sw fsize = ( sw )file_size( &f );
char* contents = ( char* )alloc( alloc, fsize + 1 );
char* contents = ( char* )alloc( allocator, fsize + 1 );
file_read( &f, contents, fsize );
contents[ fsize ] = 0;
*lines = str_split_lines( alloc, contents, strip_whitespace );
*lines = str_split_lines( allocator, contents, strip_whitespace );
file_close( &f );
return contents;
@ -11334,7 +11335,7 @@ typedef struct
u8 magic;
u8* buf; //< zpl_array OR plain buffer if we can't write
sw cursor;
AllocatorInfo alloc;
AllocatorInfo allocator;
FileStreamFlags flags;
sw cap;
@ -11366,10 +11367,10 @@ b8 file_stream_new( FileInfo* file, AllocatorInfo allocator )
if ( ! d )
return false;
zero_item( file );
d->magic = ZPL__FILE_STREAM_FD_MAGIC;
d->alloc = allocator;
d->flags = EFileStream_CLONE_WRITABLE;
d->cap = 0;
d->magic = ZPL__FILE_STREAM_FD_MAGIC;
d->allocator = allocator;
d->flags = EFileStream_CLONE_WRITABLE;
d->cap = 0;
if ( ! array_init( d->buf, allocator ) )
return false;
file->ops = memory_file_operations;
@ -11388,9 +11389,9 @@ b8 file_stream_open( FileInfo* file, AllocatorInfo allocator, u8* buffer, sw siz
if ( ! d )
return false;
zero_item( file );
d->magic = ZPL__FILE_STREAM_FD_MAGIC;
d->alloc = allocator;
d->flags = flags;
d->magic = ZPL__FILE_STREAM_FD_MAGIC;
d->allocator = allocator;
d->flags = flags;
if ( d->flags & EFileStream_CLONE_WRITABLE )
{
if ( ! array_init_reserve( d->buf, allocator, size ) )
@ -11483,11 +11484,11 @@ internal ZPL_FILE_WRITE_AT_PROC( _memory_file_write )
internal ZPL_FILE_CLOSE_PROC( _memory_file_close )
{
_memory_fd* d = _file_stream_from_fd( fd );
AllocatorInfo alloc = d->alloc;
_memory_fd* d = _file_stream_from_fd( fd );
AllocatorInfo allocator = d->allocator;
if ( d->flags & EFileStream_CLONE_WRITABLE )
array_free( d->buf );
free( alloc, d );
free( allocator, d );
}
FileOperations const memory_file_operations = { _memory_file_read, _memory_file_write, _memory_file_seek, _memory_file_close };
@ -11830,7 +11831,7 @@ FileError path_rmdir( char const* path )
return EFileError_UNKNOWN;
}
void _file_direntry( AllocatorInfo alloc, char const* dirname, String* output, b32 recurse )
void _file_direntry( AllocatorInfo allocator, char const* dirname, String* output, b32 recurse )
{
#if defined( ZPL_SYSTEM_UNIX ) || defined( ZPL_SYSTEM_OSX )
DIR * d, *cd;
@ -11848,7 +11849,7 @@ void _file_direntry( AllocatorInfo alloc, char const* dirname, String* output, b
if ( dir->d_name[ 0 ] == '.' && dir->d_name[ 1 ] == 0 )
continue;
String dirpath = string_make( alloc, dirname );
String dirpath = string_make( allocator, dirname );
dirpath = string_appendc( dirpath, "/" );
dirpath = string_appendc( dirpath, dir->d_name );
@ -11857,7 +11858,7 @@ void _file_direntry( AllocatorInfo alloc, char const* dirname, String* output, b
if ( recurse && ( cd = opendir( dirpath ) ) != NULL && dir->d_type == DT_DIR )
{
_file_direntry( alloc, dirpath, output, recurse );
_file_direntry( allocator, dirpath, output, recurse );
}
string_free( dirpath );
}
@ -11884,7 +11885,7 @@ void _file_direntry( AllocatorInfo alloc, char const* dirname, String* output, b
}
// attach search pattern
String findpath = string_make( alloc, directory );
String findpath = string_make( allocator, directory );
findpath = string_appendc( findpath, "\\" );
findpath = string_appendc( findpath, "*" );
@ -11901,7 +11902,7 @@ void _file_direntry( AllocatorInfo alloc, char const* dirname, String* output, b
if ( filename[ 0 ] == '.' && filename[ 1 ] == 0 )
continue;
String dirpath = string_make( alloc, directory );
String dirpath = string_make( allocator, directory );
dirpath = string_appendc( dirpath, "\\" );
dirpath = string_appendc( dirpath, filename );
DWORD attrs = GetFileAttributesW( ( const wchar_t* )utf8_to_ucs2_buf( ( const u8* )dirpath ) );
@ -11911,7 +11912,7 @@ void _file_direntry( AllocatorInfo alloc, char const* dirname, String* output, b
if ( recurse && ( data.attrib & _A_SUBDIR ) && ! ( attrs & FILE_ATTRIBUTE_REPARSE_POINT ) )
{
_file_direntry( alloc, dirpath, output, recurse );
_file_direntry( allocator, dirpath, output, recurse );
}
string_free( dirpath );
@ -11923,10 +11924,10 @@ void _file_direntry( AllocatorInfo alloc, char const* dirname, String* output, b
#endif
}
String path_dirlist( AllocatorInfo alloc, char const* dirname, b32 recurse )
String path_dirlist( AllocatorInfo allocator, char const* dirname, b32 recurse )
{
String buf = string_make_reserve( alloc, 4 );
_file_direntry( alloc, dirname, &buf, recurse );
String buf = string_make_reserve( allocator, 4 );
_file_direntry( allocator, dirname, &buf, recurse );
return buf;
}
@ -12136,9 +12137,9 @@ sw tar_pack( FileInfo* archive, char const** paths, sw paths_len )
return -( ZPL_TAR_ERROR_IO_ERROR );
}
s64 file_size = file_size( &file );
s64 fsize = file_size( &file );
str_fmt( hr.name, 12, "%s", paths[ i ] );
str_fmt( hr.size, 12, "%o", file_size );
str_fmt( hr.size, 12, "%o", fsize );
str_fmt( hr.mode, 8, "%o", 0664 );
str_fmt( hr.mtime, 12, "%o", fs_last_write_time( paths[ i ] ) );
hr.type = ZPL_TAR_TYPE_REGULAR;
@ -12148,9 +12149,9 @@ sw tar_pack( FileInfo* archive, char const** paths, sw paths_len )
// write data
{
s64 remaining_data = file_size;
s64 remaining_data = fsize;
s64 total_data = align_forward_i64( remaining_data, 512 );
s64 padding = ( total_data - file_size );
s64 padding = ( total_data - fsize );
char buf[ 4096 ] = { 0 };
s64 pos = 0;
sw bytes_read = 0;
@ -12192,10 +12193,10 @@ sw tar_pack( FileInfo* archive, char const** paths, sw paths_len )
return 0;
}
sw tar_pack_dir( FileInfo* archive, char const* path, AllocatorInfo alloc )
sw tar_pack_dir( FileInfo* archive, char const* path, AllocatorInfo allocator )
{
String filelst = path_dirlist( alloc, path, true );
char const** files = zpl_cast( char const** ) str_split_lines( alloc, filelst, false );
String filelst = path_dirlist( allocator, path, true );
char const** files = zpl_cast( char const** ) str_split_lines( allocator, filelst, false );
sw err = tar_pack( archive, files, array_count( files ) );
string_free( filelst );
array_free( files );
@ -15248,10 +15249,10 @@ ZPL_BEGIN_C_DECLS
void opts_init( Opts* opts, AllocatorInfo a, char const* app )
{
Opts opts_ = { 0 };
*opts = opts_;
opts->alloc = a;
opts->appname = app;
Opts opts_ = { 0 };
*opts = opts_;
opts->allocator = a;
opts->appname = app;
array_init( opts->entries, a );
array_init( opts->positioned, a );
@ -15353,7 +15354,7 @@ void _opts_set_value( Opts* opts, OptsEntry* t, char* b )
{
case EOpts_STRING :
{
t->text = string_make( opts->alloc, b );
t->text = string_make( opts->allocator, b );
}
break;
@ -19747,7 +19748,7 @@ void jobs_init_with_limit( JobsSystem* pool, AllocatorInfo a, u32 max_threads, u
JobsSystem pool_ = { 0 };
*pool = pool_;
pool->alloc = a;
pool->allocator = a;
pool->max_threads = max_threads;
pool->max_jobs = max_jobs;
pool->counter = 0;
@ -21643,7 +21644,7 @@ typedef uptr uintptr;
typedef sptr intptr;
# endif // ZPL_EXPOSE_TYPES
#endif // ZPL_H
#endif // ZPL_H
// TOC:
// zpl.h