From 806431dcbe19ff300482f8833ca8b57c492c6fea Mon Sep 17 00:00:00 2001 From: DoctorNoobingstoneIPresume Date: Mon, 2 Aug 2021 22:52:58 +0300 Subject: [PATCH] builtins.cpp: #ifdef OS_NT...#else...#endif part is now human readable. --- src/engine/builtins.cpp | 71 +++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/engine/builtins.cpp b/src/engine/builtins.cpp index 86706a65b1..ff8050120e 100644 --- a/src/engine/builtins.cpp +++ b/src/engine/builtins.cpp @@ -30,38 +30,39 @@ #include "output.h" #include -#include #ifdef OS_NT -#include -#ifndef FSCTL_GET_REPARSE_POINT -/* MinGW's version of windows.h is missing this, so we need - * to include winioctl.h directly - */ -#include -#endif + #include + #ifndef FSCTL_GET_REPARSE_POINT + /* MinGW's version of windows.h is missing this, so we need + * to include winioctl.h directly + */ + #include + #endif -/* With VC8 (VS2005) these are not defined: - * FSCTL_GET_REPARSE_POINT (expects WINVER >= 0x0500 _WIN32_WINNT >= 0x0500 ) - * IO_REPARSE_TAG_SYMLINK (is part of a separate Driver SDK) - * So define them explicitly to their expected values. - */ -#ifndef FSCTL_GET_REPARSE_POINT -# define FSCTL_GET_REPARSE_POINT 0x000900a8 -#endif -#ifndef IO_REPARSE_TAG_SYMLINK -# define IO_REPARSE_TAG_SYMLINK (0xA000000CL) + /* With VC8 (VS2005) these are not defined: + * FSCTL_GET_REPARSE_POINT (expects WINVER >= 0x0500 _WIN32_WINNT >= 0x0500 ) + * IO_REPARSE_TAG_SYMLINK (is part of a separate Driver SDK) + * So define them explicitly to their expected values. + */ + #ifndef FSCTL_GET_REPARSE_POINT + #define FSCTL_GET_REPARSE_POINT 0x000900a8 + #endif + #ifndef IO_REPARSE_TAG_SYMLINK + #define IO_REPARSE_TAG_SYMLINK (0xA000000CL) + #endif + + #include + #if !defined(__BORLANDC__) + #define dup _dup + #define dup2 _dup2 + #define open _open + #define close _close + #endif +#else + #include #endif -#include -#if !defined(__BORLANDC__) -#define dup _dup -#define dup2 _dup2 -#define open _open -#define close _close -#endif /* __BORLANDC__ */ -#endif /* OS_NT */ - #if defined(USE_EXECUNIX) # include # include @@ -912,7 +913,7 @@ LIST * glob_recursive( char const * pattern ) { OBJECT * p; path->f_dir.ptr = object_str( list_item( iter ) ); - path->f_dir.len = int32_t(strlen( object_str( list_item( iter ) ) )); + path->f_dir.len = strlen( object_str( list_item( iter ) ) ); path_build( path, file_string ); p = object_new( file_string->value ); @@ -1750,14 +1751,14 @@ LIST * builtin_pad( FRAME * frame, int flags ) OBJECT * string = list_front( lol_get( frame->args, 0 ) ); char const * width_s = object_str( list_front( lol_get( frame->args, 1 ) ) ); - int32_t current = int32_t(strlen( object_str( string ) )); - int32_t desired = atoi( width_s ); + int current = strlen( object_str( string ) ); + int desired = atoi( width_s ); if ( current >= desired ) return list_new( object_copy( string ) ); else { char * buffer = (char *)BJAM_MALLOC( desired + 1 ); - int32_t i; + int i; LIST * result; strcpy( buffer, object_str( string ) ); @@ -1887,7 +1888,7 @@ LIST *builtin_readlink( FRAME * frame, int flags ) #else char static_buf[256]; char * buf = static_buf; - int32_t bufsize = 256; + size_t bufsize = 256; LIST * result = 0; while (1) { ssize_t len = readlink( path, buf, bufsize ); @@ -1895,7 +1896,7 @@ LIST *builtin_readlink( FRAME * frame, int flags ) { break; } - else if ( int32_t(len) < bufsize ) + else if ( size_t(len) < bufsize ) { buf[ len ] = '\0'; result = list_new( object_new( buf ) ); @@ -2401,7 +2402,7 @@ LIST * builtin_shell( FRAME * frame, int flags ) LIST * command = lol_get( frame->args, 0 ); LIST * result = L0; string s; - int32_t ret; + int ret; char buffer[ 1024 ]; FILE * p = NULL; int exit_status = -1; @@ -2436,7 +2437,7 @@ LIST * builtin_shell( FRAME * frame, int flags ) string_new( &s ); - while ( ( ret = int32_t(fread( buffer, sizeof( char ), sizeof( buffer ) - 1, p )) ) > + while ( ( ret = fread( buffer, sizeof( char ), sizeof( buffer ) - 1, p ) ) > 0 ) { buffer[ ret ] = 0;