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

Vc cc improvements #16

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ case "$_os" in
OS_VERSION=cygwin
CASE_INSENSITIVE_FS=true
;;
"MINGW")
MINGW*)
OS_VERSION=mingw
OS_TYPE=winnt
BUILDINFO="Windows / MinGW"
Expand All @@ -85,7 +85,7 @@ case "$_os" in
"MSVC6")
OS_VERSION=msvc6
OS_TYPE=winnt
BUILDINFO="Windows / MS Visual C++"
BUILDINFO="Windows / MS Visual C++" dmstr2\(_MSC_FULL_VER\)
CASE_INSENSITIVE_FS=true
;;
"Darwin")
Expand Down
4 changes: 2 additions & 2 deletions dag.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,16 +643,16 @@ int no_check;
DB_PRINT( "rul", ("Defining recipe %s", rcp) );

if( !white_too ) rcp = DmStrSpn( rcp, " \t" );
if( (rcp == NIL(char)) || (*rcp == 0 && !white_too) )
if( *rcp == 0 && !white_too )
DB_RETURN( sp ); /* return last recipe when new recipe not added */

rp = no_check ? rcp : DmStrSpn( rcp, " \t@-+%" );

TALLOC(nsp, 1, STRING);
nsp->st_string = DmStrDup( rp );
/*nsp->st_next = NIL(STRING); already null*/

if( sp != NIL(STRING) ) sp->st_next = nsp;
nsp->st_next = NIL(STRING);

if( !no_check ) nsp->st_attr |= Rcp_attribute( rcp );

Expand Down
5 changes: 5 additions & 0 deletions dmake.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,10 @@
#define STOBOOL(A) (A && ((*A | 0x20) == 'y'))
#define BTOBOOL(A) (A)

/* To stringify the result of the expansion of a macro argument
* use two levels of macros. */
#define dmstr2(s) dmstr1(s)
#define dmstr1(s) #s

#endif

15 changes: 6 additions & 9 deletions dmstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ DmStrDup( str )/*
char *str;
{
char *t;
size_t len;

if( str == NIL(char) ) return( NIL(char) );

if( (t = MALLOC( strlen( str )+1, char )) == NIL(char) ) No_ram();
strcpy( t, str );
len = strlen( str )+1;
if( (t = MALLOC( len, char )) == NIL(char) ) No_ram();
t = memcpy( t, str, len );

return( t );
}
Expand Down Expand Up @@ -211,10 +212,7 @@ char *searchchars;

if( s1 == NIL(char) || searchchars == NIL(char) ) return( "" );

t = strpbrk(s1, searchchars);
if( !t )
t = s1+strlen(s1);
return( t );
return( s1+strcspn(s1, searchchars) );
}


Expand All @@ -234,8 +232,7 @@ char *s2;

if( s1 == NIL(char) || s2 == NIL(char) ) return( "" );

for( t=s1; *t && (strchr( s2, *t ) != NIL(char)); t++ );
return( t );
return( s1 + strspn(s1, s2) );
}


Expand Down
19 changes: 18 additions & 1 deletion extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@
/* For MSVC++ needs to include windows.h first to avoid problems with
* type redefinitions. Include it also for MinGW for consistency. */
#if defined(__MINGW32__) || defined(_MSC_VER)
/* silence warnings about using null term strings in >= VC 2005
sysintf.c(918) : warning C4996: 'strcat' was declared deprecated
Message: 'This function or variable may be unsafe. Consider using strcat
_s instead. To disable deprecation, use _CRT_SECURE_NO_DEPRECATE. See online hel
p for details.' */
#define _CRT_SECURE_NO_DEPRECATE
/* silence warnings about using POSIX name funcs in >= VC 2005
sysintf.c(1132) : warning C4996: 'unlink' was declared deprecated
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\stdio.h(290) : see
declaration of 'unlink'
Message: 'The POSIX name for this item is deprecated. Instead, use the I
SO C++ conformant name: _unlink. See online help for details.' */
#define _CRT_NONSTDC_NO_DEPRECATE
/* get back some of the perf loss caused by >= VC 2005 dropping single threaded
static link CRT, this macro disables multithreading locks on some stdio
functions */
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
Expand Down Expand Up @@ -169,7 +186,7 @@ char *cygdospath(char *src, int winpath);
#endif

#ifdef _WIN32
# define FileTimeTo_time_t(ft) ((time_t)((*((unsigned __int64 *)ft) - 116444736000000000ULL)/10000000ULL))
# define FileTimeTo_time_t(ft) ((time_t)((*((unsigned __int64 *)ft) - 116444736000000000)/10000000))
#endif

/* Get the working directory fall back code */
Expand Down
10 changes: 8 additions & 2 deletions function.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,14 @@ char *data;

data = Expand(data);

Append_line( data, TRUE, tmpfile, name, FALSE, FALSE );
Close_temp( Current_target, tmpfile );
/* Expand's decendents can change Current_target, example
"$(mktmp $(HEADER) $(shell @type text_file_on_disk) $(FOOTER))" will do it.
Is that a bug? Should Current_target be saved to a C auto? IDK. See also a
comment by the original author in Exec_commands(). "type" is a
Win32 command. ~bulk88
*/
Append_line( data, TRUE, tmpfile, FALSE, FALSE );
Close_temp( Current_target, tmpfile, name );
FREE(data);

return( text );
Expand Down
4 changes: 1 addition & 3 deletions imacs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@

#include "extern.h"

#define DM_StGiFy(a) #a
#define STRINGIFY(a) DM_StGiFy(a)
#define SET_INT_VAR_FROM_INT(name, val, flag, var) _set_int_var_from_int_and_str(name, val, STRINGIFY(val), flag, var)
#define SET_INT_VAR_FROM_INT(name, val, flag, var) _set_int_var_from_int_and_str(name, val, dmstr2(val), flag, var)

static void _set_int_var ANSI((char *, char *, int, int *));
static void _set_int_var_from_int_and_str ANSI((char *, int, char *, int, int *));
Expand Down
4 changes: 2 additions & 2 deletions mac/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int Exec_commands ANSI((CELLPTR));
void Print_cmnd ANSI((char *, int, int));
int Push_dir ANSI((char *, char *, int));
void Pop_dir ANSI((int));
void Append_line ANSI((char *, int, FILE *, char *, int, int));
void Append_line ANSI((char *, int, FILE *, int, int));
void Stat_target ANSI((CELLPTR, int, int));
char *Expand ANSI((char *));
char *Apply_edit ANSI((char *, char *, char *, int, int));
Expand Down Expand Up @@ -128,7 +128,7 @@ FILE* Get_temp ANSI((char **, char *));
FILE *Start_temp ANSI((char *, CELLPTR, char **));
void Open_temp_error ANSI((char *, char *));
void Link_temp ANSI((CELLPTR, FILE *, char *));
void Close_temp ANSI((CELLPTR, FILE *));
void Close_temp ANSI((CELLPTR, FILE *, char *));
void Unlink_temp_files ANSI((CELLPTR));
void Handle_result ANSI((int, int, int, CELLPTR));
void Update_time_stamp ANSI((CELLPTR));
Expand Down
2 changes: 1 addition & 1 deletion macparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ int flag;
cp = lp->cl_prq;
}
TALLOC(sp,1,STRING);
sp->st_string = DmStrDup(tok2);
sp->st_next = cp->ce_cond;
cp->ce_cond = sp;
sp->st_string = DmStrDup(tok2);

tok1 = NIL(char);
}
Expand Down
10 changes: 6 additions & 4 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ echo msc60 - Microsoft C 6.0 compile.
echo msc60swp - Microsoft C 6.0, MASM 5.1 compile of swapping dmake.

echo win95-bcc50 - Borland C++ 5.0 32-bit compile of dmake.
echo win95-vpp40 - Microsoft VC++ 4.0 32-bit compile of dmake.
echo win95-vpp70 - MS VC++ ^>= 2003 optimized
echo win95-vpp70 rel - MS VC++ ^>= 2003 optimized
echo win95-vpp70 dbg - MS VC++ ^>= 2003 unoptimized for debugging
echo win95-vpp40 - Microsoft VC++ 4.0-6.0 optimized
echo win95-vpp40 rel - Microsoft VC++ 4.0-6.0 optimized
echo win95-vpp40 dbg - Microsoft VC++ 4.0-6.0 unoptimized for debugging
echo win95-vpp70 - MS VC++ ^>= 2003 32 or 64 bit optimized
echo win95-vpp70 rel - MS VC++ ^>= 2003 32 or 64 bit optimized
echo win95-vpp70 dbg - MS VC++ ^>= 2003 32 or 64 bit unoptimized 4 debugging
goto end

rem This is the script that makes dmake using Microsoft C 5.1
Expand Down
22 changes: 8 additions & 14 deletions make.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef struct {
static void _drop_mac ANSI((HASHPTR));
static void _set_recipe ANSI((char*, int));
static void _set_tmd ANSI(());
static void _append_file ANSI((STRINGPTR, FILE*, char*, int));
static void _append_file ANSI((STRINGPTR, FILE*, int));
static LINKPTR _dup_prq ANSI((LINKPTR));
static LINKPTR _expand_dynamic_prq ANSI(( LINKPTR, LINKPTR, char * ));
static char* _prefix ANSI((char *, char *));
Expand Down Expand Up @@ -1316,7 +1316,7 @@ CELLPTR cp;

/* Emit group prolog */
if( attr & A_PROLOG )
_append_file( _recipes[RP_GPPROLOG], tmpfile, cp->CE_NAME, trace );
_append_file( _recipes[RP_GPPROLOG], tmpfile, trace );
}

if( !useshell )
Expand Down Expand Up @@ -1420,7 +1420,7 @@ CELLPTR cp;

if( group )
/* Append_line() calls Print_cmnd(). */
Append_line( cmnd, TRUE, tmpfile, cp->CE_NAME, trace, 0 );
Append_line( cmnd, TRUE, tmpfile, trace, 0 );
else {
/* Don't print empty recipe lines. .ROOT and .TARGETS
* deliberately might have empty "" recipes and we don't want
Expand All @@ -1440,14 +1440,14 @@ CELLPTR cp;
* execute the command */
if( group && !(cp->ce_attr & A_ERROR) ) {
if( attr & A_EPILOG ) /* emit epilog */
_append_file( _recipes[RP_GPEPILOG], tmpfile, cp->CE_NAME, trace );
_append_file( _recipes[RP_GPEPILOG], tmpfile, trace );

if( trace ) fputs("]\n", stdout);

do_it = !Trace;
if( do_it )
{
Close_temp( cp, tmpfile );
Close_temp( cp, tmpfile, cp->CE_NAME );
#if defined(UNIX)

chmod(groupfile,0700);
Expand Down Expand Up @@ -1656,11 +1656,10 @@ int ind;


PUBLIC void
Append_line( cmnd, newline, tmpfile, name, printit, map )
Append_line( cmnd, newline, tmpfile, printit, map )
char *cmnd;
int newline;
FILE *tmpfile;
char *name;
int printit;
int map;
{
Expand All @@ -1670,25 +1669,20 @@ int map;

fputs(cmnd, tmpfile);
if( newline ) fputc('\n', tmpfile);
fflush(tmpfile);

if( ferror(tmpfile) )
Fatal("Write error on temporary file, while processing `%s'", name);
}



static void
_append_file( rp, tmpfile, name, printit )
_append_file( rp, tmpfile, printit )
register STRINGPTR rp;
FILE *tmpfile;
char *name;
int printit;
{
char *cmnd;

while( rp != NIL(STRING) ) {
Append_line(cmnd = Expand(rp->st_string), TRUE, tmpfile, name, printit,0);
Append_line(cmnd = Expand(rp->st_string), TRUE, tmpfile, printit,0);
FREE(cmnd);
rp = rp->st_next;
}
Expand Down
4 changes: 2 additions & 2 deletions msdos/borland/bcc30/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int Exec_commands ANSI((CELLPTR));
void Print_cmnd ANSI((char *, int, int));
int Push_dir ANSI((char *, char *, int));
void Pop_dir ANSI((int));
void Append_line ANSI((char *, int, FILE *, char *, int, int));
void Append_line ANSI((char *, int, FILE *, int, int));
void Stat_target ANSI((CELLPTR, int, int));
char *Expand ANSI((char *));
char *Apply_edit ANSI((char *, char *, char *, int, int));
Expand Down Expand Up @@ -128,7 +128,7 @@ FILE* Get_temp ANSI((char **, char *));
FILE *Start_temp ANSI((char *, CELLPTR, char **));
void Open_temp_error ANSI((char *, char *));
void Link_temp ANSI((CELLPTR, FILE *, char *));
void Close_temp ANSI((CELLPTR, FILE *));
void Close_temp ANSI((CELLPTR, FILE *, char *));
void Unlink_temp_files ANSI((CELLPTR));
void Handle_result ANSI((int, int, int, CELLPTR));
void Update_time_stamp ANSI((CELLPTR));
Expand Down
4 changes: 2 additions & 2 deletions msdos/borland/bcc40/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int Exec_commands ANSI((CELLPTR));
void Print_cmnd ANSI((char *, int, int));
int Push_dir ANSI((char *, char *, int));
void Pop_dir ANSI((int));
void Append_line ANSI((char *, int, FILE *, char *, int, int));
void Append_line ANSI((char *, int, FILE *, int, int));
void Stat_target ANSI((CELLPTR, int, int));
char *Expand ANSI((char *));
char *Apply_edit ANSI((char *, char *, char *, int, int));
Expand Down Expand Up @@ -128,7 +128,7 @@ FILE* Get_temp ANSI((char **, char *));
FILE *Start_temp ANSI((char *, CELLPTR, char **));
void Open_temp_error ANSI((char *, char *));
void Link_temp ANSI((CELLPTR, FILE *, char *));
void Close_temp ANSI((CELLPTR, FILE *));
void Close_temp ANSI((CELLPTR, FILE *, char *));
void Unlink_temp_files ANSI((CELLPTR));
void Handle_result ANSI((int, int, int, CELLPTR));
void Update_time_stamp ANSI((CELLPTR));
Expand Down
4 changes: 2 additions & 2 deletions msdos/borland/bcc45/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int Exec_commands ANSI((CELLPTR));
void Print_cmnd ANSI((char *, int, int));
int Push_dir ANSI((char *, char *, int));
void Pop_dir ANSI((int));
void Append_line ANSI((char *, int, FILE *, char *, int, int));
void Append_line ANSI((char *, int, FILE *, int, int));
void Stat_target ANSI((CELLPTR, int, int));
char *Expand ANSI((char *));
char *Apply_edit ANSI((char *, char *, char *, int, int));
Expand Down Expand Up @@ -128,7 +128,7 @@ FILE* Get_temp ANSI((char **, char *));
FILE *Start_temp ANSI((char *, CELLPTR, char **));
void Open_temp_error ANSI((char *, char *));
void Link_temp ANSI((CELLPTR, FILE *, char *));
void Close_temp ANSI((CELLPTR, FILE *));
void Close_temp ANSI((CELLPTR, FILE *, char *));
void Unlink_temp_files ANSI((CELLPTR));
void Handle_result ANSI((int, int, int, CELLPTR));
void Update_time_stamp ANSI((CELLPTR));
Expand Down
4 changes: 2 additions & 2 deletions msdos/borland/bcc50/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int Exec_commands ANSI((CELLPTR));
void Print_cmnd ANSI((char *, int, int));
int Push_dir ANSI((char *, char *, int));
void Pop_dir ANSI((int));
void Append_line ANSI((char *, int, FILE *, char *, int, int));
void Append_line ANSI((char *, int, FILE *, int, int));
void Stat_target ANSI((CELLPTR, int, int));
char *Expand ANSI((char *));
char *Apply_edit ANSI((char *, char *, char *, int, int));
Expand Down Expand Up @@ -128,7 +128,7 @@ FILE* Get_temp ANSI((char **, char *));
FILE *Start_temp ANSI((char *, CELLPTR, char **));
void Open_temp_error ANSI((char *, char *));
void Link_temp ANSI((CELLPTR, FILE *, char *));
void Close_temp ANSI((CELLPTR, FILE *));
void Close_temp ANSI((CELLPTR, FILE *, char *));
void Unlink_temp_files ANSI((CELLPTR));
void Handle_result ANSI((int, int, int, CELLPTR));
void Update_time_stamp ANSI((CELLPTR));
Expand Down
4 changes: 2 additions & 2 deletions msdos/borland/tcc20/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int Exec_commands ANSI((CELLPTR));
void Print_cmnd ANSI((char *, int, int));
int Push_dir ANSI((char *, char *, int));
void Pop_dir ANSI((int));
void Append_line ANSI((char *, int, FILE *, char *, int, int));
void Append_line ANSI((char *, int, FILE *, int, int));
void Stat_target ANSI((CELLPTR, int, int));
char *Expand ANSI((char *));
char *Apply_edit ANSI((char *, char *, char *, int, int));
Expand Down Expand Up @@ -128,7 +128,7 @@ FILE* Get_temp ANSI((char **, char *));
FILE *Start_temp ANSI((char *, CELLPTR, char **));
void Open_temp_error ANSI((char *, char *));
void Link_temp ANSI((CELLPTR, FILE *, char *));
void Close_temp ANSI((CELLPTR, FILE *));
void Close_temp ANSI((CELLPTR, FILE *, char *));
void Unlink_temp_files ANSI((CELLPTR));
void Handle_result ANSI((int, int, int, CELLPTR));
void Update_time_stamp ANSI((CELLPTR));
Expand Down
4 changes: 2 additions & 2 deletions msdos/microsft/msc51/public.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int Exec_commands ANSI((CELLPTR));
void Print_cmnd ANSI((char *, int, int));
int Push_dir ANSI((char *, char *, int));
void Pop_dir ANSI((int));
void Append_line ANSI((char *, int, FILE *, char *, int, int));
void Append_line ANSI((char *, int, FILE *, int, int));
void Stat_target ANSI((CELLPTR, int, int));
char *Expand ANSI((char *));
char *Apply_edit ANSI((char *, char *, char *, int, int));
Expand Down Expand Up @@ -128,7 +128,7 @@ FILE* Get_temp ANSI((char **, char *));
FILE *Start_temp ANSI((char *, CELLPTR, char **));
void Open_temp_error ANSI((char *, char *));
void Link_temp ANSI((CELLPTR, FILE *, char *));
void Close_temp ANSI((CELLPTR, FILE *));
void Close_temp ANSI((CELLPTR, FILE *, char *));
void Unlink_temp_files ANSI((CELLPTR));
void Handle_result ANSI((int, int, int, CELLPTR));
void Update_time_stamp ANSI((CELLPTR));
Expand Down
Loading