Preprocessor added
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
19990524-10:25 CET Alexander Kressin (upload Eddie Runia)
|
||||
* source/hbpp
|
||||
added preprocessor
|
||||
|
||||
19990524-08:10 CET Les Griffiths (upload Eddie Runia)
|
||||
* source/rtl/files.c
|
||||
a step in right the direction
|
||||
|
||||
15
harbour/source/hbpp/a.prg
Normal file
15
harbour/source/hbpp/a.prg
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "example.ch"
|
||||
Private x,ar,y
|
||||
x = " /* 111 */ "
|
||||
/* comment string 1
|
||||
string 2
|
||||
string 3 */
|
||||
ar = { 1000, 2000, 3000, 4000,; && Comment
|
||||
5000, 6000, 7000 }
|
||||
#ifdef MAXPOS
|
||||
y = MAXPOS
|
||||
#else
|
||||
y = MINPOS
|
||||
#endif
|
||||
y = MAX(y,10)
|
||||
return
|
||||
1
harbour/source/hbpp/build.bat
Normal file
1
harbour/source/hbpp/build.bat
Normal file
@@ -0,0 +1 @@
|
||||
\borlandc\bin\make -fmakefile.b16
|
||||
1
harbour/source/hbpp/build32.bat
Normal file
1
harbour/source/hbpp/build32.bat
Normal file
@@ -0,0 +1 @@
|
||||
make -fmakefile.b32
|
||||
16
harbour/source/hbpp/c.prg
Normal file
16
harbour/source/hbpp/c.prg
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "std.ch"
|
||||
@ 1,1,10,10 BOX ORAMKA
|
||||
@ 2, 3 SAY "Hello,world"
|
||||
SET DATE BRITISH
|
||||
USE JOUPL SHARED INDEX JOUPI1
|
||||
SET FILTER TO
|
||||
SEEK STR(A->NOMER,10)
|
||||
go top
|
||||
DO WHILE x>1
|
||||
skip 3
|
||||
ENDDO
|
||||
LOCATE FOR Family = "Johnson"
|
||||
? "Family:", Family, "--"
|
||||
REPLACE PARAM1 WITH 3, PARAM2 WITH "Hello", PARAM3 WITH PARAM4 * 2
|
||||
STORE 10 to x,y,z
|
||||
return
|
||||
2
harbour/source/hbpp/exam2.ch
Normal file
2
harbour/source/hbpp/exam2.ch
Normal file
@@ -0,0 +1,2 @@
|
||||
#define MAX(arg1, arg2) IIF(arg1>arg2, arg1, arg2)
|
||||
#define MIN(arg1, arg2) IIF(arg1<arg2, arg1, arg2)
|
||||
3
harbour/source/hbpp/example.ch
Normal file
3
harbour/source/hbpp/example.ch
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "exam2.ch"
|
||||
#define MAXPOS 20
|
||||
#define MINPOS 5
|
||||
156
harbour/source/hbpp/harb.c
Normal file
156
harbour/source/hbpp/harb.c
Normal file
@@ -0,0 +1,156 @@
|
||||
#include <stdio.h>
|
||||
#include <mem.h>
|
||||
#include <alloc.h>
|
||||
#include "harb.h"
|
||||
/*
|
||||
* Split given filename into path, name and extension
|
||||
*/
|
||||
FILENAME *SplitFilename( char *szFilename )
|
||||
{
|
||||
FILENAME *pName =(FILENAME *)OurMalloc( sizeof(FILENAME) );
|
||||
int iLen = strlen(szFilename);
|
||||
int iSlashPos, iDotPos;
|
||||
int iPos;
|
||||
|
||||
pName->path =pName->name =pName->extension =NULL;
|
||||
|
||||
iSlashPos =iLen-1;
|
||||
iPos =0;
|
||||
while( iSlashPos >= 0 && !IS_PATH_SEP(szFilename[ iSlashPos ]) )
|
||||
--iSlashPos;
|
||||
if( iSlashPos == 0 )
|
||||
{
|
||||
/* root path -> \filename */
|
||||
pName->_buffer[ 0 ] =PATH_DELIMITER[ 0 ];
|
||||
pName->_buffer[ 1 ] ='\x0';
|
||||
pName->path =pName->_buffer;
|
||||
iPos =2; /* first free position after the slash */
|
||||
}
|
||||
else if( iSlashPos > 0 )
|
||||
{
|
||||
/* path with separator -> path\filename */
|
||||
memcpy( pName->_buffer, szFilename, iSlashPos );
|
||||
pName->_buffer[ iSlashPos ] ='\x0';
|
||||
pName->path =pName->_buffer;
|
||||
iPos =iSlashPos +1; /* first free position after the slash */
|
||||
}
|
||||
|
||||
iDotPos =iLen-1;
|
||||
while( iDotPos > iSlashPos && szFilename[ iDotPos ] != '.' )
|
||||
--iDotPos;
|
||||
if( (iDotPos-iSlashPos) > 1 )
|
||||
{
|
||||
/* the dot was found
|
||||
* and there is at least one character between a slash and a dot
|
||||
*/
|
||||
if( iDotPos == iLen-1 )
|
||||
{
|
||||
/* the dot is the last character -use it as extension name */
|
||||
pName->extension =pName->_buffer+iPos;
|
||||
pName->_buffer[ iPos++ ] ='.';
|
||||
pName->_buffer[ iPos++ ] ='\x0';
|
||||
}
|
||||
else
|
||||
{
|
||||
pName->extension =pName->_buffer+iPos;
|
||||
/* copy rest of the string with terminating ZERO character */
|
||||
memcpy( pName->extension, szFilename+iDotPos+1, iLen-iDotPos );
|
||||
iPos +=iLen-iDotPos;
|
||||
}
|
||||
}
|
||||
else
|
||||
/* there is no dot in the filename or it is '.filename' */
|
||||
iDotPos =iLen;
|
||||
|
||||
pName->name =pName->_buffer+iPos;
|
||||
memcpy( pName->name, szFilename+iSlashPos+1, iDotPos-iSlashPos-1 );
|
||||
pName->name[ iDotPos-iSlashPos-1 ] ='\x0';
|
||||
|
||||
return pName;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function joins path, name and extension into a string with a filename
|
||||
*/
|
||||
char *MakeFilename( char *szFileName, FILENAME *pFileName )
|
||||
{
|
||||
if( pFileName->path && pFileName->path[ 0 ] )
|
||||
{
|
||||
/* we have not empty path specified */
|
||||
int iLen =strlen(pFileName->path);
|
||||
strcpy( szFileName, pFileName->path );
|
||||
/* if the path is a root directory then we don't need to add path separator */
|
||||
if( !(IS_PATH_SEP(pFileName->path[ 0 ]) && pFileName->path[ 0 ] == '\x0') )
|
||||
{
|
||||
/* add the path separator only in cases:
|
||||
* when a name doesn't start with it
|
||||
* when the path doesn't end with it
|
||||
*/
|
||||
if( !( IS_PATH_SEP(pFileName->name[ 0 ]) || IS_PATH_SEP(pFileName->path[ iLen-1 ]) ) )
|
||||
{
|
||||
szFileName[ iLen++ ] =PATH_DELIMITER[ 0 ];
|
||||
szFileName[ iLen ] ='\x0';
|
||||
}
|
||||
}
|
||||
strcpy( szFileName+iLen, pFileName->name );
|
||||
}
|
||||
else
|
||||
strcpy( szFileName, pFileName->name );
|
||||
|
||||
if( pFileName->extension )
|
||||
{
|
||||
int iLen =strlen(szFileName);
|
||||
|
||||
if( !(pFileName->extension[ 0 ] == '.' || pFileName->name[ iLen-1 ] == '.') )
|
||||
{
|
||||
/* add extension separator only when extansion doesn't contain it */
|
||||
szFileName[ iLen++ ] ='.';
|
||||
szFileName[ iLen ] ='\x0';
|
||||
}
|
||||
strcpy( szFileName+iLen, pFileName->extension );
|
||||
}
|
||||
|
||||
return szFileName;
|
||||
}
|
||||
|
||||
void * OurMalloc( LONG lSize )
|
||||
{
|
||||
void * pMem = malloc( lSize );
|
||||
|
||||
if( ! pMem )
|
||||
printf( "\nCan't allocate memory!\n" );
|
||||
|
||||
return pMem;
|
||||
}
|
||||
|
||||
void * _xgrab( ULONG ulSize ) /* allocates fixed memory */
|
||||
{
|
||||
void * pMem = malloc( ulSize );
|
||||
|
||||
if( ! pMem )
|
||||
{
|
||||
printf( "\n_xgrab error: can't allocate memory!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
return pMem;
|
||||
}
|
||||
|
||||
void * _xrealloc( void * pMem, ULONG ulSize ) /* reallocates memory */
|
||||
{
|
||||
void * pResult = realloc( pMem, ulSize );
|
||||
|
||||
if( ! pResult )
|
||||
{
|
||||
printf( "\n_xrealloc error: can't reallocate memory!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
return pResult;
|
||||
}
|
||||
|
||||
void _xfree( void * pMem ) /* frees fixed memory */
|
||||
{
|
||||
if( pMem )
|
||||
free( pMem );
|
||||
}
|
||||
1135
harbour/source/hbpp/hbpp.c
Normal file
1135
harbour/source/hbpp/hbpp.c
Normal file
File diff suppressed because it is too large
Load Diff
8
harbour/source/hbpp/makefile.b16
Normal file
8
harbour/source/hbpp/makefile.b16
Normal file
@@ -0,0 +1,8 @@
|
||||
# makefile for Borland C/C++ 16 bits
|
||||
|
||||
PROJECT: hbpp.exe
|
||||
|
||||
hbpp.exe : hbpp.c harb.c
|
||||
\borlandc\bin\bcc -ml hbpp.c harb.c
|
||||
del hbpp.obj
|
||||
del harb.obj
|
||||
8
harbour/source/hbpp/makefile.b32
Normal file
8
harbour/source/hbpp/makefile.b32
Normal file
@@ -0,0 +1,8 @@
|
||||
# makefile for Borland C/C++ 32 bits
|
||||
|
||||
PROJECT: hbpp.exe
|
||||
|
||||
hbpp.exe : hbpp.c harb.c
|
||||
bcc32 -O2 -I\borland\cbuilder\include hbpp.c harb.c
|
||||
del hbpp.obj
|
||||
del harb.obj
|
||||
Reference in New Issue
Block a user