Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtins.cpp: #ifdef OS_NT...#else...#endif part is now human readable. #67

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 36 additions & 35 deletions src/engine/builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,39 @@
#include "output.h"

#include <ctype.h>
#include <stdlib.h>

#ifdef OS_NT
#include <windows.h>
#ifndef FSCTL_GET_REPARSE_POINT
/* MinGW's version of windows.h is missing this, so we need
* to include winioctl.h directly
*/
#include <winioctl.h>
#endif
#include <windows.h>
#ifndef FSCTL_GET_REPARSE_POINT
/* MinGW's version of windows.h is missing this, so we need
* to include winioctl.h directly
*/
#include <winioctl.h>
#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 <io.h>
#if !defined(__BORLANDC__)
#define dup _dup
#define dup2 _dup2
#define open _open
#define close _close
#endif
#else
#include <unistd.h>
#endif

#include <io.h>
#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 <sys/types.h>
# include <sys/wait.h>
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 ) );
Expand Down Expand Up @@ -1887,15 +1888,15 @@ 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 );
if ( len < 0 )
{
break;
}
else if ( int32_t(len) < bufsize )
else if ( size_t(len) < bufsize )
{
buf[ len ] = '\0';
result = list_new( object_new( buf ) );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down