See Changelog 19990618-07:50
This commit is contained in:
@@ -1,3 +1,51 @@
|
||||
19990618-07:50 Ryszard Glab <rglab@imid.med.pl>
|
||||
|
||||
* source/compiler/harbour.y
|
||||
+ added deallocation of used structures
|
||||
+ added yy_strupr and yy_strdup functions to make sure that memory is
|
||||
properly allocated
|
||||
|
||||
* source/compiler/harbour.l
|
||||
+ added declaration of yy_strupr and yy_strdup functions and changed
|
||||
calls for strupr and strdup to yy_strupr and yy_strdup respectively
|
||||
|
||||
* include/hbsetup.h
|
||||
+ added operating system dependand settings
|
||||
|
||||
+ config/linux/
|
||||
+ added new directory with GNU MAKE files for GCC on Linux
|
||||
You have to define:
|
||||
HB_ARCHITECTURE = linux
|
||||
HB_COMPILER = gcc
|
||||
|
||||
* source/hbpp/hbppint.c
|
||||
* added support for Watcom C/C++ compiler
|
||||
|
||||
+ source/hbpp/makefile.wat
|
||||
+ makefile for Watcom C/C++ compiler
|
||||
|
||||
+ source/compiler/makefile.wat
|
||||
* changes to link hbpp library into Harbour executable
|
||||
|
||||
* source/rtl/console.c
|
||||
* source/rtl/dir.c
|
||||
* source/rtl/files.c
|
||||
* source/rtl/set.c
|
||||
* changed files to make them compile with Watcom C/C++ and GCC on Linux
|
||||
* removed PATH_SEPARATOR and replaced it with OS_PATH_DELIMITER
|
||||
defined in hbsetup.h
|
||||
|
||||
* source/contrib/genobj.c
|
||||
* moved this file from source/tools since this is DOS specific code and
|
||||
it is not needed for Harbour
|
||||
|
||||
* source/tools/Makefile
|
||||
- removed reference to genobj.c file
|
||||
|
||||
* Harbour compiles fine on Linux now. However there is still some
|
||||
suspicious code in source/rtl/dir.c and source/rtl/files.c files.
|
||||
The runner.c is unsupported since it generates DOS specific code.
|
||||
|
||||
19990617-20:49 PST Ron Pinkas <Ron@Profit-Master.com>
|
||||
* compiler.h
|
||||
added member cType to struct VAR
|
||||
|
||||
10
harbour/config/linux/dir.cf
Normal file
10
harbour/config/linux/dir.cf
Normal file
@@ -0,0 +1,10 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
DIR_RULE =\
|
||||
@for d in $(DIRS); do \
|
||||
if [ -d $$d ]; then \
|
||||
$(MAKE) -C $$d $@; \
|
||||
fi \
|
||||
done
|
||||
29
harbour/config/linux/gcc.cf
Normal file
29
harbour/config/linux/gcc.cf
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf
|
||||
|
||||
OBJ_EXT = .o
|
||||
EXE_EXT = .exe
|
||||
LIB_PREF = lib
|
||||
LIB_EXT = .a
|
||||
|
||||
CC = gcc
|
||||
CC_OUT = -o
|
||||
CPPFLAGS = -DDEBUG -I. -I$(HB_INC_DIR)
|
||||
CFLAGS = -Wall -g
|
||||
|
||||
LD = gcc
|
||||
LD_OUT = -o
|
||||
ifdef HB_LIB_DIR
|
||||
LDFLAGS = -L$(HB_LIB_DIR)
|
||||
endif
|
||||
LINKLIBS = $(foreach lib, $(LIBS), -l$(lib))
|
||||
# LINKLIBS += -lm
|
||||
|
||||
AR = ar
|
||||
ARFLAGS =
|
||||
AR_RULE = $(AR) $(ARFLAGS) r $@ $^ || $(RM) $@
|
||||
|
||||
include $(TOP)$(ROOT)config/rules.cf
|
||||
33
harbour/config/linux/global.cf
Normal file
33
harbour/config/linux/global.cf
Normal file
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
all : first
|
||||
|
||||
|
||||
ifeq ($(HB_INC_DIR),)
|
||||
HB_INC_DIR = $(TOP)$(ROOT)include
|
||||
endif
|
||||
ifeq ($(HB_LIB_DIR),)
|
||||
HB_LIB_DIR = $(TOP)$(ROOT)libs
|
||||
endif
|
||||
ifeq ($(HB_BIN_DIR),)
|
||||
HB_BIN_DIR = $(TOP)$(ROOT)bin
|
||||
endif
|
||||
|
||||
ARCH_DIR = $(ARCH)/
|
||||
MK = $(MAKE)
|
||||
|
||||
RM = rm -f
|
||||
RD = rm -f -r
|
||||
CP = cp -f
|
||||
MV = mv -f
|
||||
MD = mkdir
|
||||
|
||||
dirbase::
|
||||
@[ -d $(HB_ARCHITECTURE) ] || $(MD) $(HB_ARCHITECTURE); \
|
||||
[ -d $(ARCH) ] || $(MD) $(ARCH)
|
||||
|
||||
clean::
|
||||
-$(RD) $(ARCH_DIR)
|
||||
|
||||
21
harbour/config/linux/install.cf
Normal file
21
harbour/config/linux/install.cf
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
INSTALL_RULE =\
|
||||
@if [ ! -d $(INSTALL_DIR) ]; \
|
||||
then \
|
||||
echo "! Can't install, path not found:" $(INSTALL_DIR); \
|
||||
else \
|
||||
for i in $(INSTALL_OBJS); \
|
||||
do \
|
||||
if [ -r $$i ]; \
|
||||
then \
|
||||
echo "! Installing $$i on $(INSTALL_DIR)"; \
|
||||
$(CP) $$i $(INSTALL_DIR); \
|
||||
else \
|
||||
echo "! Can't install $$i, not found"; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
|
||||
@@ -144,6 +144,10 @@ For MSVC on Win95/WinNT:
|
||||
HB_ARCHITECTURE win32
|
||||
HB_COMPILER msvc
|
||||
|
||||
For GCC on Linux:
|
||||
HB_ARCHITECTURE linux
|
||||
HB_COMPILER gcc
|
||||
|
||||
These are the only two supported compilers right now (guess which ones
|
||||
I own).
|
||||
|
||||
|
||||
@@ -38,6 +38,20 @@
|
||||
|
||||
/* Operating system specific definitions
|
||||
*/
|
||||
#define OS_PATH_LIST_SEPARATOR ';'
|
||||
#ifdef __GNUC__
|
||||
/* The GNU C compiler is used */
|
||||
#ifdef __DJGPP__
|
||||
/* The DJGPP port of GNU C is used - for DOS platform */
|
||||
#define OS_PATH_LIST_SEPARATOR ';'
|
||||
#define OS_PATH_DELIMITER '\\'
|
||||
#else
|
||||
#define OS_PATH_LIST_SEPARATOR ':'
|
||||
#define OS_PATH_DELIMITER '/'
|
||||
#endif
|
||||
#else
|
||||
/* we are assuming here the DOS compatible OS */
|
||||
#define OS_PATH_LIST_SEPARATOR ';'
|
||||
#define OS_PATH_DELIMITER '\\'
|
||||
#endif
|
||||
|
||||
#endif /* HBSETUP_H_ */
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "types.h"
|
||||
|
||||
void yyerror( char * );
|
||||
char *yy_strupr( char * );
|
||||
char * yy_strdup( char *p );
|
||||
static void yyunput( int, char * );
|
||||
#undef yywrap /* to implement our own yywrap() funtion to handle EOFs */
|
||||
#ifdef __cplusplus
|
||||
@@ -160,7 +162,7 @@ Separator {SpaceTab}|{Comment}
|
||||
|
||||
yyleng--;
|
||||
yytext[yyleng] = 0;
|
||||
yylval.string = strdup( yytext );
|
||||
yylval.string = yy_strdup( yytext );
|
||||
/*printf( "\nLITERAL = %s\n", yylval.string );*/
|
||||
return LITERAL;
|
||||
}
|
||||
@@ -172,7 +174,7 @@ Separator {SpaceTab}|{Comment}
|
||||
|
||||
yyleng--;
|
||||
yytext[yyleng] = 0;
|
||||
yylval.string = strdup( yytext );
|
||||
yylval.string = yy_strdup( yytext );
|
||||
/*printf( "\nLITERAL = %s\n", yylval.string );*/
|
||||
return LITERAL;
|
||||
}
|
||||
@@ -184,7 +186,7 @@ Separator {SpaceTab}|{Comment}
|
||||
|
||||
yyleng--;
|
||||
yytext[yyleng] = 0;
|
||||
yylval.string = strdup( yytext );
|
||||
yylval.string = yy_strdup( yytext );
|
||||
/*printf( "\nLITERAL = %s\n", yylval.string );*/
|
||||
return LITERAL;
|
||||
}
|
||||
@@ -226,10 +228,10 @@ Separator {SpaceTab}|{Comment}
|
||||
<DEFINE>{Identifier}/{SpaceTab}+ Define( yytext );
|
||||
<DEFINE>{Identifier}/{SpaceTab}*\n Define( yytext ); BEGIN 0;
|
||||
<DEFINE>{SpaceTab} ;
|
||||
<DEFINE>{Identifier} LastDef( pDefs )->szValue = strdup( yytext ); BEGIN 0;
|
||||
<DEFINE>{PseudoFunc} LastDef( pDefs )->szValue = strdup( yytext ); BEGIN 0;
|
||||
<DEFINE>-?{Number} LastDef( pDefs )->szValue = strdup( yytext ); BEGIN 0;
|
||||
<DEFINE>{HexNumber} LastDef( pDefs )->szValue = strdup( yytext ); BEGIN 0;
|
||||
<DEFINE>{Identifier} LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0;
|
||||
<DEFINE>{PseudoFunc} LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0;
|
||||
<DEFINE>-?{Number} LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0;
|
||||
<DEFINE>{HexNumber} LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0;
|
||||
<DEFINE>"/*".*"*/" ;
|
||||
<DEFINE>{Number}{SpaceTab}*[\(] yyerror( "Syntax error in #define" );
|
||||
|
||||
@@ -238,7 +240,7 @@ Separator {SpaceTab}|{Comment}
|
||||
<DEFINE_PARAMS>{Identifier} DefineKey( yytext );
|
||||
<DEFINE_PARAMS>[\,] ;
|
||||
<DEFINE_PARAMS>[\)] BEGIN DEFINE_EXPR;
|
||||
<DEFINE_EXPR>.*/\n LastDef( pDefs )->szValue = strdup( yytext ); BEGIN 0;
|
||||
<DEFINE_EXPR>.*/\n LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0;
|
||||
|
||||
"#"{SpaceTab}*"ifdef" BEGIN IFDEF;
|
||||
<IFDEF>{Identifier} if( FindDef( yytext ) ) BEGIN 0;
|
||||
@@ -305,7 +307,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup("BREAK");
|
||||
yylval.string = yy_strdup("BREAK");
|
||||
return IDENTIFIER;
|
||||
}
|
||||
}
|
||||
@@ -319,7 +321,7 @@ Separator {SpaceTab}|{Comment}
|
||||
<BREAK_>{Separator}*[^_a-zA-Z\[] { /* there is no identifier after "break" */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
yylval.string = strdup( "BREAK" );
|
||||
yylval.string = yy_strdup( "BREAK" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
@@ -335,7 +337,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{
|
||||
yylval.string = strdup( "BREAK" );
|
||||
yylval.string = yy_strdup( "BREAK" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -348,7 +350,7 @@ Separator {SpaceTab}|{Comment}
|
||||
<CASE_>{Separator}*[\:\=\|\$\%\*\,\/\]\)\}\^] { /* there is an operator after "case" */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
yylval.string = strdup( "CASE" );
|
||||
yylval.string = yy_strdup( "CASE" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
@@ -362,7 +364,7 @@ Separator {SpaceTab}|{Comment}
|
||||
<CASE_>{Separator}*("+="|"-="|"->") { /* operators */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
yylval.string = strdup( "CASE" );
|
||||
yylval.string = yy_strdup( "CASE" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
unput( yytext[ yyleng-2 ] );
|
||||
@@ -382,7 +384,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "CASE" );
|
||||
yylval.string = yy_strdup( "CASE" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -417,7 +419,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "DO" );
|
||||
yylval.string = yy_strdup( "DO" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -429,7 +431,7 @@ Separator {SpaceTab}|{Comment}
|
||||
if( yytext[ yyleng-1 ] == '\n' )
|
||||
--iLine;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string = strdup( "DO" );
|
||||
yylval.string = yy_strdup( "DO" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -464,7 +466,7 @@ Separator {SpaceTab}|{Comment}
|
||||
{ /* Clipper does not like end[] & end() at the begining of line */
|
||||
GenError( ERR_ENDIF, NULL, NULL );
|
||||
}
|
||||
yylval.string = strdup( "END" );
|
||||
yylval.string = yy_strdup( "END" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
@@ -476,7 +478,7 @@ Separator {SpaceTab}|{Comment}
|
||||
{ /* Clipper does not like end-> & end++ at the begining of line */
|
||||
GenError( ERR_ENDIF, NULL, NULL );
|
||||
}
|
||||
yylval.string = strdup( "END" );
|
||||
yylval.string = yy_strdup( "END" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
unput( yytext[ yyleng-2 ] );
|
||||
@@ -485,7 +487,7 @@ Separator {SpaceTab}|{Comment}
|
||||
<END_>{Separator}*[\+\-\:\=\|\$\%\*\,\/\[\]\)\}\^] { /* there is an operator after "end" */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
yylval.string = strdup( "END" );
|
||||
yylval.string = yy_strdup( "END" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
@@ -504,7 +506,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "END" );
|
||||
yylval.string = yy_strdup( "END" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -545,7 +547,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "EXIT" );
|
||||
yylval.string = yy_strdup( "EXIT" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -561,7 +563,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "EXIT" );
|
||||
yylval.string = yy_strdup( "EXIT" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -570,7 +572,7 @@ Separator {SpaceTab}|{Comment}
|
||||
<EXIT_>{Separator}*. { /* any character (not identifier) after EXIT */
|
||||
yy_lex_count_lf();
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string = strdup( "EXIT" );
|
||||
yylval.string = yy_strdup( "EXIT" );
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
@@ -579,7 +581,7 @@ Separator {SpaceTab}|{Comment}
|
||||
/* ************************************************************************ */
|
||||
%}
|
||||
"exte"|"exter"|"extern"|"externa"|"external" { BEGIN EXTERNAL_;
|
||||
yylval.string = strupr( strdup( yytext ) );
|
||||
yylval.string = yy_strupr( yy_strdup( yytext ) );
|
||||
}
|
||||
<EXTERNAL_>{Separator}+[_a-zA-Z] { /* an identifier after the EXTERNAL */
|
||||
yy_lex_count_lf();
|
||||
@@ -612,7 +614,7 @@ Separator {SpaceTab}|{Comment}
|
||||
/* ************************************************************************ */
|
||||
%}
|
||||
"fiel"|"field" { BEGIN FIELD_;
|
||||
yylval.string = strupr( strdup( yytext ) );
|
||||
yylval.string = yy_strupr( yy_strdup( yytext ) );
|
||||
}
|
||||
<FIELD_>{Separator}+[_a-zA-Z] { /* an identifier after the FIELD */
|
||||
yy_lex_count_lf();
|
||||
@@ -656,7 +658,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* for example: DO for WITH variable */
|
||||
yylval.string = strdup( "FOR" );
|
||||
yylval.string = yy_strdup( "FOR" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -668,7 +670,7 @@ Separator {SpaceTab}|{Comment}
|
||||
{ /* Clipper does not like FOR() at the begining of line */
|
||||
GenError( ERR_SYNTAX, yytext, NULL );
|
||||
}
|
||||
yylval.string = strdup( "FOR" );
|
||||
yylval.string = yy_strdup( "FOR" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
@@ -679,7 +681,7 @@ Separator {SpaceTab}|{Comment}
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
if( yytext[ yyleng-1 ] == '\n' )
|
||||
--iLine;
|
||||
yylval.string = strdup( "FOR" );
|
||||
yylval.string = yy_strdup( "FOR" );
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
@@ -776,7 +778,7 @@ Separator {SpaceTab}|{Comment}
|
||||
return IN;
|
||||
else
|
||||
{
|
||||
yylval.string =strdup( "IN" );
|
||||
yylval.string =yy_strdup( "IN" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -786,7 +788,7 @@ Separator {SpaceTab}|{Comment}
|
||||
--iLine;
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string =strdup( "IN" );
|
||||
yylval.string =yy_strdup( "IN" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -798,7 +800,7 @@ Separator {SpaceTab}|{Comment}
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string =strdup( "IN" );
|
||||
yylval.string =yy_strdup( "IN" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -820,7 +822,7 @@ Separator {SpaceTab}|{Comment}
|
||||
--iLine;
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string =strdup( "INCLUDE" );
|
||||
yylval.string =yy_strdup( "INCLUDE" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -839,7 +841,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "INIT" );
|
||||
yylval.string = yy_strdup( "INIT" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -850,7 +852,7 @@ Separator {SpaceTab}|{Comment}
|
||||
if( yytext[ yyleng-1 ] == '\n' )
|
||||
--iLine;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string = strdup( "INIT" );
|
||||
yylval.string = yy_strdup( "INIT" );
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
@@ -870,7 +872,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "LOCAL" );
|
||||
yylval.string = yy_strdup( "LOCAL" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -881,7 +883,7 @@ Separator {SpaceTab}|{Comment}
|
||||
if( yytext[ yyleng-1 ] == '\n' )
|
||||
--iLine;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string = strdup( "LOCAL" );
|
||||
yylval.string = yy_strdup( "LOCAL" );
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
@@ -904,7 +906,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "LOOP" );
|
||||
yylval.string = yy_strdup( "LOOP" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -912,7 +914,7 @@ Separator {SpaceTab}|{Comment}
|
||||
<LOOP_>{Separator}*. { /* any character (not LF) after LOOP */
|
||||
yy_lex_count_lf();
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string = strdup( "LOOP" );
|
||||
yylval.string = yy_strdup( "LOOP" );
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
@@ -940,7 +942,7 @@ Separator {SpaceTab}|{Comment}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
yylval.string = strdup( "NEXT" );
|
||||
yylval.string = yy_strdup( "NEXT" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -952,7 +954,7 @@ Separator {SpaceTab}|{Comment}
|
||||
{ /* Clipper does not like NEXT[] & NEXT() at the begining of line */
|
||||
GenError( ERR_NEXTFOR, NULL, NULL );
|
||||
}
|
||||
yylval.string = strdup( "NEXT" );
|
||||
yylval.string = yy_strdup( "NEXT" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
@@ -964,7 +966,7 @@ Separator {SpaceTab}|{Comment}
|
||||
{ /* Clipper does not like next-> & next++ at the begining of line */
|
||||
GenError( ERR_NEXTFOR, NULL, NULL );
|
||||
}
|
||||
yylval.string = strdup( "NEXT" );
|
||||
yylval.string = yy_strdup( "NEXT" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
unput( yytext[ yyleng-2 ] );
|
||||
@@ -973,7 +975,7 @@ Separator {SpaceTab}|{Comment}
|
||||
<NEXT_>{Separator}*[^_a-zA-Z] { /* there is no identifier after "next" */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
yylval.string = strdup( "NEXT" );
|
||||
yylval.string = yy_strdup( "NEXT" );
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -990,7 +992,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{
|
||||
yylval.string = strdup( "NEXT" );
|
||||
yylval.string = yy_strdup( "NEXT" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -1024,7 +1026,7 @@ Separator {SpaceTab}|{Comment}
|
||||
{ /* we have DO while - replace it with while() */
|
||||
unput( ')' ); unput( '(' );
|
||||
}
|
||||
yylval.string = strdup( "WHILE" );
|
||||
yylval.string = yy_strdup( "WHILE" );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
<WHILE_>{Separator}*[\[] { /* array */
|
||||
@@ -1036,14 +1038,14 @@ Separator {SpaceTab}|{Comment}
|
||||
<WHILE_>{Separator}*[\:\=\|\$\%\*\,\/\]\)\}\^] { /* there is an operator after "case" */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
yylval.string = strdup( "WHILE" );
|
||||
yylval.string = yy_strdup( "WHILE" );
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
<WHILE_>{Separator}*("+="|"-="|"->") { /* operators */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
yylval.string = strdup( "WHILE" );
|
||||
yylval.string = yy_strdup( "WHILE" );
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
unput( yytext[ yyleng-2 ] );
|
||||
return IDENTIFIER;
|
||||
@@ -1060,7 +1062,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = strdup( "WHILE" );
|
||||
yylval.string = yy_strdup( "WHILE" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -1074,7 +1076,7 @@ Separator {SpaceTab}|{Comment}
|
||||
--iLine;
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
unput( '\n' );
|
||||
yylval.string = strdup( "WITH" );
|
||||
yylval.string = yy_strdup( "WITH" );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
<WITH_>{Separator}*"with" {
|
||||
@@ -1084,7 +1086,7 @@ Separator {SpaceTab}|{Comment}
|
||||
if( _iState == DO )
|
||||
{ /* DO with */
|
||||
_iState =IDENTIFIER;
|
||||
yylval.string = strdup( "WITH" );
|
||||
yylval.string = yy_strdup( "WITH" );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
else
|
||||
@@ -1110,7 +1112,7 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
else
|
||||
{
|
||||
yylval.string = strdup( "WITH" );
|
||||
yylval.string = yy_strdup( "WITH" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -1239,8 +1241,8 @@ Separator {SpaceTab}|{Comment}
|
||||
yytext[ 10 ] = 0;
|
||||
yyleng = 10;
|
||||
}
|
||||
yylval.string = strupr( strdup( yytext ) );
|
||||
/*printf( "\nIdentifier = '%s'\n", strupr( strdup( yytext ) ) );*/
|
||||
yylval.string = yy_strupr( yy_strdup( yytext ) );
|
||||
/*printf( "\nIdentifier = '%s'\n", yy_strupr( yy_strdup( yytext ) ) );*/
|
||||
_iState = IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
@@ -1259,7 +1261,7 @@ Separator {SpaceTab}|{Comment}
|
||||
/*
|
||||
yyleng = 1;
|
||||
yytext[1] = 0;
|
||||
yylval.string = strdup( ")" );
|
||||
yylval.string = yy_strdup( ")" );
|
||||
*/
|
||||
_iState = OPERATOR;
|
||||
--_iOpenBracket;
|
||||
@@ -1280,7 +1282,7 @@ Separator {SpaceTab}|{Comment}
|
||||
/*
|
||||
yyleng = 1;
|
||||
yytext[1] = 0;
|
||||
yylval.string = strdup( "]" );
|
||||
yylval.string = yy_strdup( "]" );
|
||||
*/
|
||||
_iState = OPERATOR;
|
||||
return ']';
|
||||
@@ -1304,7 +1306,7 @@ Separator {SpaceTab}|{Comment}
|
||||
yytext[ 10 ] = 0;
|
||||
yyleng = 10;
|
||||
}
|
||||
yylval.string = strupr( strdup( yytext ) );
|
||||
yylval.string = yy_strupr( yy_strdup( yytext ) );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
}
|
||||
@@ -1328,7 +1330,7 @@ void Define( char * szDefine )
|
||||
else
|
||||
LastDef( pDefs )->pNext = pDef;
|
||||
|
||||
pDef->szDefine = strdup( szDefine );
|
||||
pDef->szDefine = yy_strdup( szDefine );
|
||||
pDef->szValue = 0;
|
||||
pDef->pKeys = 0;
|
||||
pDef->pNext = 0;
|
||||
@@ -1344,7 +1346,7 @@ void DefineKey( char * szKey )
|
||||
else
|
||||
pLast->pKeys = pDef;
|
||||
|
||||
pDef->szDefine = strdup( szKey );
|
||||
pDef->szDefine = yy_strdup( szKey );
|
||||
pDef->szValue = 0;
|
||||
pDef->pKeys = 0;
|
||||
pDef->pNext = 0;
|
||||
@@ -1382,13 +1384,13 @@ void AddDefine( char * szId, char * szValue )
|
||||
pDefine->szValue = 0;
|
||||
}
|
||||
if( szValue )
|
||||
pDefine->szValue = strdup( szValue );
|
||||
pDefine->szValue = yy_strdup( szValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
Define( szId );
|
||||
if( szValue )
|
||||
LastDef( pDefs )->szValue = strdup( szValue );
|
||||
LastDef( pDefs )->szValue = yy_strdup( szValue );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,20 +17,16 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <malloc.h> /* required for allocating and freeing memory */
|
||||
#include <ctype.h>
|
||||
#include "hbsetup.h" /* main configuration file */
|
||||
#include "pcode.h" /* pcode values */
|
||||
#include "types.h" /* our defined types */
|
||||
#include "compiler.h"
|
||||
#include "hberrors.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define HAVE_STRUPR
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRUPR
|
||||
#include <ctype.h>
|
||||
char *strupr( char *p );
|
||||
#endif
|
||||
#undef OurFree
|
||||
#define OurFree( p ) if( p ) free(p); else {printf( "ERROR FREE" ); exit(4);}
|
||||
|
||||
/* TODO: #define this for various platforms */
|
||||
#define PATH_DELIMITER "/\\"
|
||||
@@ -98,7 +94,7 @@ typedef struct _LOOPEXIT
|
||||
struct _LOOPEXIT *pLoopList;
|
||||
struct _LOOPEXIT *pExitList;
|
||||
struct _LOOPEXIT *pNext;
|
||||
} LOOPEXIT, * PLOOPEXIT; /* support structure for EXIT and LOOP statements */
|
||||
} LOOPEXIT, * PTR_LOOPEXIT; /* support structure for EXIT and LOOP statements */
|
||||
static void LoopStart( void );
|
||||
static void LoopEnd( void );
|
||||
static void LoopLoop( void );
|
||||
@@ -146,6 +142,9 @@ void yy_switch_to_buffer( void * ); /* yacc functions to manage multiple files *
|
||||
void yy_delete_buffer( void * ); /* yacc functions to manage multiple files */
|
||||
#endif
|
||||
|
||||
char * yy_strdup( char *p ); /* this will exit if there is not enough memory */
|
||||
char *yy_strupr( char *p );
|
||||
|
||||
#if 0
|
||||
static void __yy_memcpy( char * from, char * to, int count ); /* Bison prototype */
|
||||
#endif
|
||||
@@ -184,6 +183,8 @@ WORD JumpFalse( int iOffset ); /* generates the pcode to jump if false
|
||||
void JumpHere( int iOffset ); /* returns the pcode pos where to set a jump offset */
|
||||
void JumpThere( int iOffset, WORD wTo ); /* sets a jump offset */
|
||||
WORD JumpTrue( int iOffset ); /* generates the pcode to jump if true */
|
||||
PFUNCTION KillFunction( PFUNCTION ); /* releases all memory allocated by function and returns the next one */
|
||||
PCOMSYMBOL KillSymbol( PCOMSYMBOL ); /* releases all memory allocated by symbol and returns the next one */
|
||||
void Line( void ); /* generates the pcode with the currently compiled source code line */
|
||||
void LineBody( void ); /* generates the pcode with the currently compiled source code line */
|
||||
void Message( char * szMsgName ); /* sends a message to an object */
|
||||
@@ -401,7 +402,7 @@ int _iObj32 = 0; /* generate OBJ 32 bits */
|
||||
WORD _wStatics = 0; /* number of defined statics variables on the PRG */
|
||||
PRETURN pReturns = 0; /* list of multiple returns from a function */
|
||||
PEXTERN pExterns = 0;
|
||||
PLOOPEXIT pLoops = 0;
|
||||
PTR_LOOPEXIT pLoops = 0;
|
||||
PATHNAMES *_pIncludePath = NULL;
|
||||
|
||||
%}
|
||||
@@ -964,7 +965,7 @@ RecoverSeq : /* no recover */
|
||||
|
||||
DoProc : DO IDENTIFIER { PushSymbol( $2, 1 ); PushNil(); Do( 0 ); }
|
||||
| DO IDENTIFIER { PushSymbol( $2, 1 ); PushNil(); } WITH ArgList { Do( $5 ); }
|
||||
| WHILE { PushSymbol( "WHILE", 1 ); PushNil(); } WITH ArgList { Do( $4 ); }
|
||||
| WHILE { PushSymbol( yy_strdup("WHILE"), 1 ); PushNil(); } WITH ArgList { Do( $4 ); }
|
||||
;
|
||||
|
||||
Crlf : '\n'
|
||||
@@ -1061,7 +1062,7 @@ int harbour_main( int argc, char * argv[] )
|
||||
case 'D': /* defines a Lex #define from the command line */
|
||||
{
|
||||
unsigned int i = 0;
|
||||
char * szDefText = strdup( argv[ iArg ] + 2 );
|
||||
char * szDefText = yy_strdup( argv[ iArg ] + 2 );
|
||||
while( i < strlen( szDefText ) && szDefText[ i ] != '=' )
|
||||
i++;
|
||||
if( szDefText[ i ] != '=' )
|
||||
@@ -1078,7 +1079,7 @@ int harbour_main( int argc, char * argv[] )
|
||||
case 'f':
|
||||
case 'F':
|
||||
{
|
||||
char * szUpper = strupr( strdup( &argv[ iArg ][ 2 ] ) );
|
||||
char * szUpper = yy_strupr( yy_strdup( &argv[ iArg ][ 2 ] ) );
|
||||
if( ! strcmp( szUpper, "OBJ32" ) )
|
||||
_iObj32 = 1;
|
||||
free( szUpper );
|
||||
@@ -1233,7 +1234,7 @@ int harbour_main( int argc, char * argv[] )
|
||||
char * pPath;
|
||||
char * pDelim;
|
||||
|
||||
pPath = szInclude = strdup( szInclude );
|
||||
pPath = szInclude = yy_strdup( szInclude );
|
||||
while( (pDelim = strchr( pPath, OS_PATH_LIST_SEPARATOR )) != NULL )
|
||||
{
|
||||
*pDelim = '\0';
|
||||
@@ -1242,7 +1243,7 @@ int harbour_main( int argc, char * argv[] )
|
||||
}
|
||||
AddSearchPath( pPath, &_pIncludePath );
|
||||
}
|
||||
FunDef( strupr( strdup( pFileName->name ) ), FS_PUBLIC, FUN_PROCEDURE );
|
||||
FunDef( yy_strupr( yy_strdup( pFileName->name ) ), FS_PUBLIC, FUN_PROCEDURE );
|
||||
yyparse();
|
||||
FixReturns(); /* fix all previous function returns offsets */
|
||||
GenExterns(); /* generates EXTERN symbols names */
|
||||
@@ -1502,13 +1503,14 @@ void AddSearchPath( char *szPath, PATHNAMES * *pSearchList )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function adds the name of called function into the list
|
||||
* as they have to be placed on the symbol table later than the first
|
||||
* public symbol
|
||||
*/
|
||||
PFUNCTION AddFunCall( char * szFunctionName )
|
||||
{
|
||||
PFUNCTION pFunc = ( PFUNCTION ) OurMalloc( sizeof( _FUNC ) );
|
||||
|
||||
pFunc->szName = szFunctionName;
|
||||
pFunc->cScope = 0;
|
||||
pFunc->pNext = 0;
|
||||
PFUNCTION pFunc = FunctionNew( szFunctionName, 0 );
|
||||
|
||||
if( ! funcalls.iCount )
|
||||
{
|
||||
@@ -1525,6 +1527,11 @@ PFUNCTION AddFunCall( char * szFunctionName )
|
||||
return pFunc;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function adds the name of external symbol into the list of externals
|
||||
* as they have to be placed on the symbol table later than the first
|
||||
* public symbol
|
||||
*/
|
||||
void AddExtern( char * szExternName ) /* defines a new extern name */
|
||||
{
|
||||
PEXTERN pExtern = ( PEXTERN ) OurMalloc( sizeof( _EXTERN ) ), pLast;
|
||||
@@ -1595,7 +1602,6 @@ void AddVar( char * szVarName )
|
||||
pVar = ( PVAR ) OurMalloc( sizeof( VAR ) );
|
||||
pVar->szName = szVarName;
|
||||
pVar->szAlias = NULL;
|
||||
pVar->cType = 'U';
|
||||
pVar->iUsed = 0;
|
||||
pVar->pNext = NULL;
|
||||
|
||||
@@ -2534,10 +2540,79 @@ void GenCCode( char *szFileName, char *szName ) /* generates the C languag
|
||||
|
||||
fclose( yyc );
|
||||
|
||||
pFunc =functions.pFirst;
|
||||
while( pFunc )
|
||||
pFunc = KillFunction( pFunc );
|
||||
|
||||
pFunc =funcalls.pFirst;
|
||||
while( pFunc )
|
||||
{
|
||||
funcalls.pFirst =pFunc->pNext;
|
||||
OurFree( pFunc ); /*NOTE: szName will be released by KillSymbol() */
|
||||
pFunc =funcalls.pFirst;
|
||||
}
|
||||
|
||||
pSym =symbols.pFirst;
|
||||
while( pSym )
|
||||
pSym = KillSymbol( pSym );
|
||||
|
||||
if( ! _iQuiet )
|
||||
printf( "%s -> done!\n", szFileName );
|
||||
}
|
||||
|
||||
PFUNCTION KillFunction( PFUNCTION pFunc )
|
||||
{
|
||||
PFUNCTION pNext = pFunc->pNext;
|
||||
PVAR pVar;
|
||||
|
||||
while( pFunc->pLocals )
|
||||
{
|
||||
pVar =pFunc->pLocals;
|
||||
pFunc->pLocals =pVar->pNext;
|
||||
|
||||
OurFree( pVar->szName );
|
||||
OurFree( pVar );
|
||||
}
|
||||
|
||||
while( pFunc->pStatics )
|
||||
{
|
||||
pVar =pFunc->pStatics;
|
||||
pFunc->pStatics =pVar->pNext;
|
||||
|
||||
OurFree( pVar->szName );
|
||||
OurFree( pVar );
|
||||
}
|
||||
|
||||
while( pFunc->pFields )
|
||||
{
|
||||
pVar =pFunc->pFields;
|
||||
pFunc->pFields =pVar->pNext;
|
||||
|
||||
OurFree( pVar->szName );
|
||||
if( pVar->szAlias )
|
||||
OurFree( pVar->szAlias );
|
||||
OurFree( pVar );
|
||||
}
|
||||
|
||||
OurFree( pFunc->pCode );
|
||||
/* OurFree( pFunc->szName ); The name will be released in KillSymbol() */
|
||||
OurFree( pFunc );
|
||||
|
||||
return pNext;
|
||||
}
|
||||
|
||||
|
||||
PCOMSYMBOL KillSymbol( PCOMSYMBOL pSym )
|
||||
{
|
||||
PCOMSYMBOL pNext = pSym->pNext;
|
||||
|
||||
OurFree( pSym->szName );
|
||||
OurFree( pSym );
|
||||
|
||||
return pNext;
|
||||
}
|
||||
|
||||
|
||||
void GenExterns( void ) /* generates the symbols for the EXTERN names */
|
||||
{
|
||||
PEXTERN pDelete;
|
||||
@@ -2665,7 +2740,7 @@ int GetLocalVarPos( char * szVarName ) /* returns the order + 1 of a variable if
|
||||
{
|
||||
/* we are in a codeblock */
|
||||
if( (iVar = GetVarPos( pFunc->pLocals, szVarName ) ) )
|
||||
/* this a current codeblock parameter */
|
||||
/* this is a current codeblock parameter */
|
||||
return iVar;
|
||||
else
|
||||
{
|
||||
@@ -2703,7 +2778,6 @@ int GetLocalVarPos( char * szVarName ) /* returns the order + 1 of a variable if
|
||||
|
||||
pVar = (PVAR) OurMalloc( sizeof(VAR) );
|
||||
pVar->szName = szVarName;
|
||||
pVar->cType = 'U';
|
||||
pVar->iUsed = 0;
|
||||
pVar->pNext = NULL;
|
||||
iVar = 1; /* first variable */
|
||||
@@ -3110,8 +3184,13 @@ void PushSymbol( char * szSymbolName, int iIsFunction )
|
||||
if( iIsFunction )
|
||||
{
|
||||
char * *pName = (char * *)RESERVED_FUNC( szSymbolName );
|
||||
/* If it is reserved function name then we should truncate
|
||||
* the requested name.
|
||||
* We have to use passed szSymbolName so we can latter deallocate it
|
||||
* (pName points to static data)
|
||||
*/
|
||||
if( pName )
|
||||
szSymbolName =*pName;
|
||||
szSymbolName[ strlen( *pName ) ] ='\0';
|
||||
}
|
||||
|
||||
wSym = GetSymbolPos( szSymbolName ); /* returns 1, 2, ... */
|
||||
@@ -3227,7 +3306,7 @@ void FixReturns( void ) /* fixes all last defined function returns jumps offsets
|
||||
/* TODO: check why it triggers this error in keywords.prg
|
||||
if( pLoops )
|
||||
{
|
||||
PLOOPEXIT pLoop = pLoops;
|
||||
PTR_LOOPEXIT pLoop = pLoops;
|
||||
char cLine[ 64 ];
|
||||
|
||||
while( pLoop->pNext )
|
||||
@@ -3398,7 +3477,7 @@ void CodeBlockEnd()
|
||||
GenPCode1( HIBYTE(wPos) );
|
||||
|
||||
pFree = pVar;
|
||||
pFree->szName = NULL;
|
||||
OurFree( pFree->szName );
|
||||
pVar = pVar->pNext;
|
||||
OurFree( pFree );
|
||||
}
|
||||
@@ -3416,7 +3495,7 @@ void CodeBlockEnd()
|
||||
|
||||
/* free used variables */
|
||||
pFree = pVar;
|
||||
pFree->szName = NULL;
|
||||
OurFree( pFree->szName );
|
||||
pVar = pVar->pNext;
|
||||
OurFree( pFree );
|
||||
}
|
||||
@@ -3476,7 +3555,7 @@ void StaticDefStart( void )
|
||||
functions.pLast->bFlags |= FUN_USES_STATICS;
|
||||
if( ! _pInitFunc )
|
||||
{
|
||||
_pInitFunc =FunctionNew( "_INITSTATICS", FS_INIT );
|
||||
_pInitFunc =FunctionNew( yy_strdup("_INITSTATICS"), FS_INIT );
|
||||
_pInitFunc->pOwner =functions.pLast;
|
||||
_pInitFunc->bFlags =FUN_USES_STATICS | FUN_PROCEDURE;
|
||||
functions.pLast =_pInitFunc;
|
||||
@@ -3521,11 +3600,11 @@ void StaticAssign( void )
|
||||
*/
|
||||
static void LoopStart( void )
|
||||
{
|
||||
PLOOPEXIT pLoop = ( PLOOPEXIT ) OurMalloc( sizeof(LOOPEXIT) );
|
||||
PTR_LOOPEXIT pLoop = ( PTR_LOOPEXIT ) OurMalloc( sizeof(LOOPEXIT) );
|
||||
|
||||
if( pLoops )
|
||||
{
|
||||
PLOOPEXIT pLast =pLoops;
|
||||
PTR_LOOPEXIT pLast =pLoops;
|
||||
|
||||
while( pLast->pNext )
|
||||
pLast =pLast->pNext;
|
||||
@@ -3546,7 +3625,7 @@ static void LoopStart( void )
|
||||
*/
|
||||
static void LoopLoop( void )
|
||||
{
|
||||
PLOOPEXIT pLast, pLoop = (PLOOPEXIT) OurMalloc( sizeof( LOOPEXIT ) );
|
||||
PTR_LOOPEXIT pLast, pLoop = (PTR_LOOPEXIT) OurMalloc( sizeof( LOOPEXIT ) );
|
||||
|
||||
pLoop->pLoopList =NULL;
|
||||
pLoop->wOffset =functions.pLast->lPCodePos; /* store the position to fix */
|
||||
@@ -3568,7 +3647,7 @@ static void LoopLoop( void )
|
||||
*/
|
||||
static void LoopExit( void )
|
||||
{
|
||||
PLOOPEXIT pLast, pLoop = (PLOOPEXIT) OurMalloc( sizeof( LOOPEXIT ) );
|
||||
PTR_LOOPEXIT pLast, pLoop = (PTR_LOOPEXIT) OurMalloc( sizeof( LOOPEXIT ) );
|
||||
|
||||
pLoop->pExitList =NULL;
|
||||
pLoop->wOffset =functions.pLast->lPCodePos; /* store the position to fix */
|
||||
@@ -3590,7 +3669,7 @@ static void LoopExit( void )
|
||||
*/
|
||||
static void LoopHere( void )
|
||||
{
|
||||
PLOOPEXIT pLoop = pLoops, pFree;
|
||||
PTR_LOOPEXIT pLoop = pLoops, pFree;
|
||||
|
||||
while( pLoop->pNext )
|
||||
pLoop = pLoop->pNext;
|
||||
@@ -3610,7 +3689,7 @@ static void LoopHere( void )
|
||||
*/
|
||||
static void LoopEnd( void )
|
||||
{
|
||||
PLOOPEXIT pExit, pLoop = pLoops, pLast = pLoops, pFree;
|
||||
PTR_LOOPEXIT pExit, pLoop = pLoops, pLast = pLoops, pFree;
|
||||
|
||||
while( pLoop->pNext )
|
||||
{
|
||||
@@ -3654,8 +3733,7 @@ void * OurRealloc( void * p, LONG lSize )
|
||||
return pMem;
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRUPR
|
||||
char * strupr( char * p )
|
||||
char * yy_strupr( char * p )
|
||||
{
|
||||
char * p1;
|
||||
|
||||
@@ -3663,7 +3741,19 @@ char * strupr( char * p )
|
||||
* p1 = toupper( * p1 );
|
||||
return( p );
|
||||
}
|
||||
#endif
|
||||
|
||||
char * yy_strdup( char *p )
|
||||
{
|
||||
char *pDup;
|
||||
int iLen;
|
||||
|
||||
iLen = strlen( p ) +1;
|
||||
pDup = (char *) OurMalloc( iLen );
|
||||
memcpy( pDup, p, iLen );
|
||||
|
||||
return pDup;
|
||||
}
|
||||
|
||||
|
||||
#define SYM_NOLINK 0 /* Symbol does not have to be linked */
|
||||
#define SYM_FUNC 1 /* Defined function */
|
||||
|
||||
@@ -13,6 +13,7 @@ $(TARGET) : harboury.obj harbourl.obj harbour.obj
|
||||
%append link.tmp FI harboury
|
||||
%append link.tmp FI harbourl
|
||||
%append link.tmp FI harbour
|
||||
%append link.tmp LIB $(HARBOURDIR)\libs\hbpp
|
||||
%append link.tmp NAME $(TARGET)
|
||||
%append link.tmp $(WLOPTIONS)
|
||||
%append link.tmp $(WLSTACK)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
#if defined(__IBMCPP__)
|
||||
#if defined(__IBMCPP__) || defined(__WATCOMC__)
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#else
|
||||
|
||||
23
harbour/source/hbpp/makefile.wat
Normal file
23
harbour/source/hbpp/makefile.wat
Normal file
@@ -0,0 +1,23 @@
|
||||
# $Id$
|
||||
# Makefile for Watcom C/C++ 10.x
|
||||
#
|
||||
!include ..\..\makewat.env
|
||||
|
||||
TARGET=$(HARBOURDIR)\libs\hbpp.lib
|
||||
|
||||
OBJECTS=hbpp.obj hbppint.obj table.obj
|
||||
|
||||
all : $(TARGET)
|
||||
|
||||
.c.obj: # $< # .AUTODEPEND
|
||||
*$(WC) $(WCOPTIONS) $(WCINCLUDE) $(WCDEBUG) $(WCDEFINE) $(WCEXTRA) $<
|
||||
|
||||
$(TARGET) : $(OBJECTS)
|
||||
%create lib.tmp
|
||||
@for %i in ( $(OBJECTS) ) do @%append lib.tmp +-%i
|
||||
wlib $^@ @lib.tmp
|
||||
|
||||
clean : .SYMBOLIC
|
||||
-del *.obj
|
||||
-del *.tmp
|
||||
-del *.err
|
||||
@@ -1,7 +1,12 @@
|
||||
# $Id$
|
||||
# Makefile for Watcom C/C++
|
||||
#
|
||||
all : compiler vm rtl tools
|
||||
all : hbpp compiler vm rtl tools
|
||||
|
||||
hbpp : .SYMBOLIC
|
||||
cd hbpp
|
||||
wmake $(__MAKEOPTS__) /f makefile.wat all
|
||||
cd ..
|
||||
|
||||
compiler : .SYMBOLIC
|
||||
cd compiler
|
||||
|
||||
@@ -6,13 +6,17 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <io.h>
|
||||
#include <extend.h>
|
||||
#include <ctoharb.h>
|
||||
#include <dates.h>
|
||||
#include <set.h>
|
||||
#if defined(__DJGPP__) || defined(__GNUC__)
|
||||
#include <unistd.h>
|
||||
#if defined(__GNUC__)
|
||||
#include <unistd.h>
|
||||
#if defined(__DJGPP__)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
#ifdef USE_GTAPI
|
||||
#include <gtapi.h>
|
||||
|
||||
@@ -6,32 +6,27 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <itemapi.h>
|
||||
#include <hbsetup.h>
|
||||
|
||||
#if defined(__GNUC__) || defined(__DJGPP__)
|
||||
#if defined(__GNUC__)
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <io.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#if defined(__DJGPP__)
|
||||
#include <io.h>
|
||||
#else
|
||||
#define _chmod chmod
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
|
||||
#if !defined(FA_RDONLY)
|
||||
#define FA_RDONLY 1
|
||||
#define FA_HIDDEN 2
|
||||
#define FA_SYSTEM 4
|
||||
#define FA_LABEL 8
|
||||
#define FA_DIREC 16
|
||||
#define FA_ARCH 32
|
||||
#endif
|
||||
|
||||
#define PATH_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
@@ -41,12 +36,13 @@
|
||||
#include <io.h>
|
||||
#include <errno.h>
|
||||
#include <direct.h>
|
||||
#include <time.h>
|
||||
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#define _chmod chmod
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
@@ -77,8 +73,15 @@
|
||||
#define S_IXUSR 0x0040 /* owner may execute <directory search> */
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#if !defined(FA_RDONLY)
|
||||
#define FA_RDONLY 1
|
||||
#define FA_HIDDEN 2
|
||||
#define FA_SYSTEM 4
|
||||
#define FA_LABEL 8
|
||||
#define FA_DIREC 16
|
||||
#define FA_ARCH 32
|
||||
#endif
|
||||
|
||||
HARBOUR HB_DIRECTORY(void);
|
||||
@@ -140,8 +143,8 @@ HARBOUR HB_DIRECTORY( void )
|
||||
|
||||
if( arg1_it )
|
||||
{
|
||||
strcpy(string, hb_parc(1));
|
||||
pos = strrchr(string,PATH_SEPARATOR);
|
||||
strcpy(string, _parc(1));
|
||||
pos = strrchr(string,OS_PATH_DELIMITER);
|
||||
if( pos )
|
||||
{
|
||||
strcpy(pattern,(pos+1));
|
||||
@@ -152,7 +155,7 @@ HARBOUR HB_DIRECTORY( void )
|
||||
{
|
||||
strcpy(pattern,string);
|
||||
strcpy(dirname,".X");
|
||||
dirname[1] = PATH_SEPARATOR;
|
||||
dirname[1] = OS_PATH_DELIMITER;
|
||||
}
|
||||
}
|
||||
if (strlen(pattern) < 1)
|
||||
@@ -160,7 +163,7 @@ HARBOUR HB_DIRECTORY( void )
|
||||
if (strlen(dirname) < 1)
|
||||
{
|
||||
strcpy(dirname,".X");
|
||||
dirname[1] = PATH_SEPARATOR;
|
||||
dirname[1] = OS_PATH_DELIMITER;
|
||||
}
|
||||
|
||||
if (strlen(pattern) > 0)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <hbsetup.h>
|
||||
#include <filesys.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -19,8 +20,6 @@
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
|
||||
#define PATH_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
@@ -34,8 +33,6 @@
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) || defined(__IBMCPP__)
|
||||
@@ -52,8 +49,6 @@
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
#endif
|
||||
|
||||
#define PATH_SEPARATOR '\\'
|
||||
#endif
|
||||
|
||||
#ifndef O_BINARY
|
||||
@@ -242,7 +237,7 @@ FHANDLE hb_fsOpen ( BYTEP name, USHORT flags )
|
||||
FHANDLE handle;
|
||||
#if defined(HAVE_POSIX_IO)
|
||||
errno = 0;
|
||||
handle = open(name,convert_open_flags(flags));
|
||||
handle = open((char *)name,convert_open_flags(flags));
|
||||
last_error = errno;
|
||||
#else
|
||||
handle = FS_ERROR;
|
||||
@@ -260,7 +255,7 @@ FHANDLE hb_fsCreate ( BYTEP name, USHORT flags )
|
||||
#if defined(HAVE_POSIX_IO)
|
||||
errno = 0;
|
||||
convert_create_flags( flags, &oflag, &pmode );
|
||||
handle = open(name,oflag,pmode);
|
||||
handle = open((char *)name,oflag,pmode);
|
||||
last_error = errno;
|
||||
#else
|
||||
handle = FS_ERROR;
|
||||
@@ -328,7 +323,7 @@ void hb_fsDelete ( BYTEP name )
|
||||
{
|
||||
#if defined(HAVE_POSIX_IO)
|
||||
errno = 0;
|
||||
unlink(name);
|
||||
unlink(( char *)name );
|
||||
last_error = errno;
|
||||
return;
|
||||
#endif
|
||||
@@ -338,7 +333,7 @@ void hb_fsRename ( BYTEP older, BYTEP newer )
|
||||
{
|
||||
#if defined(HAVE_POSIX_IO)
|
||||
errno = 0;
|
||||
rename(older,newer);
|
||||
rename( (char *)older, (char *)newer );
|
||||
last_error = errno;
|
||||
return;
|
||||
#endif
|
||||
@@ -393,9 +388,9 @@ BOOL hb_fsMkDir ( BYTEP name )
|
||||
#if defined(HAVE_POSIX_IO)
|
||||
errno = 0;
|
||||
#if !defined(__WATCOMC__) && !defined(__BORLANDC__) && !defined(__IBMCPP__)
|
||||
result = mkdir(name,S_IWUSR|S_IRUSR);
|
||||
result = mkdir( (char *)name, S_IWUSR|S_IRUSR);
|
||||
#else
|
||||
result = mkdir( name );
|
||||
result = mkdir( (char *)name );
|
||||
#endif
|
||||
last_error = errno;
|
||||
#else
|
||||
@@ -410,7 +405,7 @@ BOOL hb_fsChDir ( BYTEP name )
|
||||
int result;
|
||||
#if defined(HAVE_POSIX_IO)
|
||||
errno = 0;
|
||||
result = chdir(name);
|
||||
result = chdir( (char *)name );
|
||||
last_error = errno;
|
||||
#else
|
||||
result = 1;
|
||||
@@ -424,7 +419,7 @@ BOOL hb_fsRmDir ( BYTEP name )
|
||||
int result;
|
||||
#if defined(HAVE_POSIX_IO)
|
||||
errno = 0;
|
||||
result = rmdir(name);
|
||||
result = rmdir( (char *)name );
|
||||
last_error = errno;
|
||||
#else
|
||||
result = 1;
|
||||
@@ -444,7 +439,7 @@ BYTEP hb_fsCurDir ( USHORT uiDrive )
|
||||
cwd_buff[0] = 0;
|
||||
last_error = FS_ERROR;
|
||||
#endif
|
||||
return cwd_buff;
|
||||
return (BYTEP)cwd_buff;
|
||||
}
|
||||
|
||||
USHORT hb_fsChDrv ( BYTEP nDrive )
|
||||
@@ -518,7 +513,7 @@ HARBOUR HB_FOPEN( void )
|
||||
else
|
||||
open_flags = 0;
|
||||
|
||||
file_handle = hb_fsOpen(hb_parc(1),open_flags);
|
||||
file_handle = hb_fsOpen( (BYTEP)_parc(1), open_flags );
|
||||
}
|
||||
|
||||
hb_retni(file_handle);
|
||||
@@ -540,7 +535,7 @@ HARBOUR HB_FCREATE( void )
|
||||
else
|
||||
create_flags = 0;
|
||||
|
||||
file_handle = hb_fsCreate(hb_parc(1),create_flags);
|
||||
file_handle = hb_fsCreate( (BYTEP)_parc(1), create_flags );
|
||||
}
|
||||
|
||||
hb_retni(file_handle);
|
||||
@@ -557,7 +552,7 @@ HARBOUR HB_FREAD( void )
|
||||
|
||||
if( arg1_it && arg2_it && arg3_it )
|
||||
{
|
||||
bytes = hb_fsRead(hb_parni(1),hb_parc(2),hb_parnl(3));
|
||||
bytes = hb_fsRead(_parni(1), (BYTEP)_parc(2), _parnl(3) );
|
||||
}
|
||||
|
||||
hb_retnl(bytes);
|
||||
@@ -574,8 +569,8 @@ HARBOUR HB_FWRITE( void )
|
||||
|
||||
if( arg1_it && arg2_it )
|
||||
{
|
||||
bytes = (arg3_it ? hb_parnl(3) : arg2_it->wLength );
|
||||
bytes = hb_fsWrite(hb_parni(1),hb_parc(2),bytes);
|
||||
bytes = (arg3_it ? _parnl(3) : arg2_it->wLength );
|
||||
bytes = hb_fsWrite( _parni(1), (BYTEP)_parc(2), bytes);
|
||||
}
|
||||
|
||||
hb_retnl(bytes);
|
||||
@@ -607,7 +602,7 @@ HARBOUR HB_FERASE( void )
|
||||
|
||||
if( arg1_it )
|
||||
{
|
||||
hb_fsDelete(hb_parc(1));
|
||||
hb_fsDelete( (BYTEP)_parc(1) );
|
||||
}
|
||||
|
||||
hb_retni(last_error=0);
|
||||
@@ -621,7 +616,7 @@ HARBOUR HB_FRENAME( void )
|
||||
|
||||
if( arg1_it && arg2_it )
|
||||
{
|
||||
hb_fsRename(hb_parc(1),hb_parc(2));
|
||||
hb_fsRename( (BYTEP)_parc(1), (BYTEP)_parc(2) );
|
||||
}
|
||||
|
||||
hb_retni(last_error);
|
||||
|
||||
@@ -4,13 +4,17 @@
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#include <unistd.h>
|
||||
#if defined(__DJGPP__)
|
||||
#include <io.h>
|
||||
#endif
|
||||
#else
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <extend.h>
|
||||
#include <errorapi.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <sys/stat.h>
|
||||
#include <set.h>
|
||||
#include <errno.h>
|
||||
|
||||
@@ -16,7 +16,6 @@ C_SOURCES=\
|
||||
chrtotal.c \
|
||||
datesx.c \
|
||||
debug.c \
|
||||
genobj.c \
|
||||
hb_f.c \
|
||||
io.c \
|
||||
mathx.c \
|
||||
|
||||
Reference in New Issue
Block a user