summaryrefslogtreecommitdiff
path: root/src/symblcmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/symblcmp.c')
-rw-r--r--src/symblcmp.c110
1 files changed, 66 insertions, 44 deletions
diff --git a/src/symblcmp.c b/src/symblcmp.c
index b5a4fd3..2622807 100644
--- a/src/symblcmp.c
+++ b/src/symblcmp.c
@@ -1,7 +1,7 @@
/*******************************************************/
/* "C" Language Integrated Production System */
/* */
- /* CLIPS Version 6.24 06/05/06 */
+ /* CLIPS Version 6.30 08/16/14 */
/* */
/* SYMBOL CONSTRUCT COMPILER MODULE */
/*******************************************************/
@@ -16,7 +16,7 @@
/* Barry Cameron */
/* */
/* Contributing Programmer(s): */
-/* Brian L. Donnell */
+/* Brian L. Dantes */
/* */
/* Revision History: */
/* */
@@ -24,6 +24,14 @@
/* */
/* Corrected code to remove compiler warnings. */
/* */
+/* 6.30: Added support for path name argument to */
+/* constructs-to-c. */
+/* */
+/* Support for long long integers. */
+/* */
+/* Added const qualifiers to remove C++ */
+/* deprecation warnings. */
+/* */
/*************************************************************/
#define _SYMBLCMP_SOURCE_
@@ -56,13 +64,13 @@
/* LOCAL INTERNAL FUNCTION DEFINITIONS */
/***************************************/
- static int SymbolHashNodesToCode(void *,char *,int);
- static int BitMapHashNodesToCode(void *,char *,int);
- static int BitMapValuesToCode(void *,char *,int);
- static int FloatHashNodesToCode(void *,char *,int);
- static int IntegerHashNodesToCode(void *,char *,int);
- static int HashTablesToCode(void *,char *);
- static void PrintCString(FILE *,char *);
+ static int SymbolHashNodesToCode(void *,const char *,const char *,char *,int);
+ static int BitMapHashNodesToCode(void *,const char *,const char *,char *,int);
+ static int BitMapValuesToCode(void *,const char *,const char *, char *,int);
+ static int FloatHashNodesToCode(void *,const char *,const char *,char *,int);
+ static int IntegerHashNodesToCode(void *,const char *,const char *,char *,int);
+ static int HashTablesToCode(void *,const char *,const char *,char *);
+ static void PrintCString(FILE *,const char *);
/**************************************************************/
/* AtomicValuesToCode: Driver routine for generating the code */
@@ -70,19 +78,21 @@
/**************************************************************/
globle void AtomicValuesToCode(
void *theEnv,
- char *fileName)
+ const char *fileName,
+ const char *pathName,
+ char *fileNameBuffer)
{
- int version;
+ int version; // TBD Necessary?
SetAtomicValueIndices(theEnv,TRUE);
- HashTablesToCode(theEnv,fileName);
+ HashTablesToCode(theEnv,fileName,pathName,fileNameBuffer);
- version = SymbolHashNodesToCode(theEnv,fileName,5);
- version = FloatHashNodesToCode(theEnv,fileName,version);
- version = IntegerHashNodesToCode(theEnv,fileName,version);
- version = BitMapHashNodesToCode(theEnv,fileName,version);
- BitMapValuesToCode(theEnv,fileName,version);
+ version = SymbolHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,5);
+ version = FloatHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
+ version = IntegerHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
+ version = BitMapHashNodesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
+ BitMapValuesToCode(theEnv,fileName,pathName,fileNameBuffer,version);
}
/*****************************************************/
@@ -92,7 +102,9 @@ globle void AtomicValuesToCode(
/*****************************************************/
static int SymbolHashNodesToCode(
void *theEnv,
- char *fileName,
+ const char *fileName,
+ const char *pathName,
+ char *fileNameBuffer,
int version)
{
unsigned long i, j;
@@ -128,7 +140,7 @@ static int SymbolHashNodesToCode(
/* Create the file. */
/*==================*/
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(-1);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(-1);
/*===================*/
/* List the entries. */
@@ -158,7 +170,7 @@ static int SymbolHashNodesToCode(
{ fprintf(fp,"{&S%d_%d[%ld],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); }
}
- fprintf(fp,"%ld,0,1,0,0,%ld,",hashPtr->count + 1,i);
+ fprintf(fp,"%ld,1,0,0,%ld,",hashPtr->count + 1,i);
PrintCString(fp,hashPtr->contents);
count++;
@@ -173,7 +185,7 @@ static int SymbolHashNodesToCode(
version++;
if (count < numberOfEntries)
{
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(0);
newHeader = TRUE;
}
}
@@ -192,7 +204,9 @@ static int SymbolHashNodesToCode(
/******************************************************/
static int BitMapHashNodesToCode(
void *theEnv,
- char *fileName,
+ const char *fileName,
+ const char *pathName,
+ char *fileNameBuffer,
int version)
{
int i, j;
@@ -229,7 +243,7 @@ static int BitMapHashNodesToCode(
/* Create the file. */
/*==================*/
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(-1);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(-1);
/*===================*/
/* List the entries. */
@@ -259,7 +273,7 @@ static int BitMapHashNodesToCode(
{ fprintf(fp,"{&B%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); }
}
- fprintf(fp,"%ld,0,1,0,0,%d,(char *) &L%d_%d[%d],%d",
+ fprintf(fp,"%ld,1,0,0,%d,(char *) &L%d_%d[%d],%d",
hashPtr->count + 1,i,
ConstructCompilerData(theEnv)->ImageID,longsReqdPartition,longsReqdPartitionCount,
hashPtr->size);
@@ -285,7 +299,7 @@ static int BitMapHashNodesToCode(
version++;
if (count < numberOfEntries)
{
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(0);
newHeader = TRUE;
}
}
@@ -304,7 +318,9 @@ static int BitMapHashNodesToCode(
/*****************************************************/
static int BitMapValuesToCode(
void *theEnv,
- char *fileName,
+ const char *fileName,
+ const char *pathName,
+ char *fileNameBuffer,
int version)
{
int i, j, k;
@@ -347,7 +363,7 @@ static int BitMapValuesToCode(
/* Create the file. */
/*==================*/
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(-1);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(-1);
/*===================*/
/* List the entries. */
@@ -378,7 +394,7 @@ static int BitMapValuesToCode(
tmpLong = 0L;
for (l = 0 ;
((l < sizeof(unsigned long)) &&
- (((k * sizeof(unsigned long)) + l) < hashPtr->size)) ;
+ (((k * sizeof(unsigned long)) + l) < (size_t) hashPtr->size)) ;
l++)
((char *) &tmpLong)[l] = hashPtr->contents[(k * sizeof(unsigned long)) + l];
fprintf(fp,"0x%lxL",tmpLong);
@@ -396,7 +412,7 @@ static int BitMapValuesToCode(
version++;
if (count < numberOfEntries)
{
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(0);
newHeader = TRUE;
}
}
@@ -415,7 +431,9 @@ static int BitMapValuesToCode(
/****************************************************/
static int FloatHashNodesToCode(
void *theEnv,
- char *fileName,
+ const char *fileName,
+ const char *pathName,
+ char *fileNameBuffer,
int version)
{
int i, j;
@@ -451,7 +469,7 @@ static int FloatHashNodesToCode(
/* Create the file. */
/*==================*/
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(-1);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(-1);
/*===================*/
/* List the entries. */
@@ -481,7 +499,7 @@ static int FloatHashNodesToCode(
{ fprintf(fp,"{&F%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); }
}
- fprintf(fp,"%ld,0,1,0,0,%d,",hashPtr->count + 1,i);
+ fprintf(fp,"%ld,1,0,0,%d,",hashPtr->count + 1,i);
fprintf(fp,"%s",FloatToString(theEnv,hashPtr->contents));
count++;
@@ -496,7 +514,7 @@ static int FloatHashNodesToCode(
arrayVersion++;
if (count < numberOfEntries)
{
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(0);
newHeader = TRUE;
}
}
@@ -515,7 +533,9 @@ static int FloatHashNodesToCode(
/******************************************************/
static int IntegerHashNodesToCode(
void *theEnv,
- char *fileName,
+ const char *fileName,
+ const char *pathName,
+ char *fileNameBuffer,
int version)
{
int i, j;
@@ -551,7 +571,7 @@ static int IntegerHashNodesToCode(
/* Create the file. */
/*==================*/
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(-1);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(-1);
/*===================*/
/* List the entries. */
@@ -581,8 +601,8 @@ static int IntegerHashNodesToCode(
{ fprintf(fp,"{&I%d_%d[%d],",ConstructCompilerData(theEnv)->ImageID,arrayVersion,j + 1); }
}
- fprintf(fp,"%ld,0,1,0,0,%d,",hashPtr->count + 1,i);
- fprintf(fp,"%ld",hashPtr->contents);
+ fprintf(fp,"%ld,1,0,0,%d,",hashPtr->count + 1,i);
+ fprintf(fp,"%lldLL",hashPtr->contents);
count++;
j++;
@@ -596,7 +616,7 @@ static int IntegerHashNodesToCode(
arrayVersion++;
if (count < numberOfEntries)
{
- if ((fp = NewCFile(theEnv,fileName,1,version,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,version,FALSE)) == NULL) return(0);
newHeader = TRUE;
}
}
@@ -615,7 +635,9 @@ static int IntegerHashNodesToCode(
/****************************************************************/
static int HashTablesToCode(
void *theEnv,
- char *fileName)
+ const char *fileName,
+ const char *pathName,
+ char *fileNameBuffer)
{
unsigned long i;
FILE *fp;
@@ -630,7 +652,7 @@ static int HashTablesToCode(
symbolTable = GetSymbolTable(theEnv);
- if ((fp = NewCFile(theEnv,fileName,1,1,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,1,FALSE)) == NULL) return(0);
fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct symbolHashNode *sht%d[];\n",ConstructCompilerData(theEnv)->ImageID);
fprintf(fp,"struct symbolHashNode *sht%d[%ld] = {\n",ConstructCompilerData(theEnv)->ImageID,SYMBOL_HASH_SIZE);
@@ -652,7 +674,7 @@ static int HashTablesToCode(
floatTable = GetFloatTable(theEnv);
- if ((fp = NewCFile(theEnv,fileName,1,2,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,2,FALSE)) == NULL) return(0);
fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct floatHashNode *fht%d[];\n",ConstructCompilerData(theEnv)->ImageID);
fprintf(fp,"struct floatHashNode *fht%d[%d] = {\n",ConstructCompilerData(theEnv)->ImageID,FLOAT_HASH_SIZE);
@@ -675,7 +697,7 @@ static int HashTablesToCode(
integerTable = GetIntegerTable(theEnv);
- if ((fp = NewCFile(theEnv,fileName,1,3,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,3,FALSE)) == NULL) return(0);
fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct integerHashNode *iht%d[];\n",ConstructCompilerData(theEnv)->ImageID);
fprintf(fp,"struct integerHashNode *iht%d[%d] = {\n",ConstructCompilerData(theEnv)->ImageID,INTEGER_HASH_SIZE);
@@ -698,7 +720,7 @@ static int HashTablesToCode(
bitMapTable = GetBitMapTable(theEnv);
- if ((fp = NewCFile(theEnv,fileName,1,4,FALSE)) == NULL) return(0);
+ if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,1,4,FALSE)) == NULL) return(0);
fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct bitMapHashNode *bmht%d[];\n",ConstructCompilerData(theEnv)->ImageID);
fprintf(fp,"struct bitMapHashNode *bmht%d[%d] = {\n",ConstructCompilerData(theEnv)->ImageID,BITMAP_HASH_SIZE);
@@ -787,7 +809,7 @@ globle void PrintBitMapReference(
/*********************************************************/
static void PrintCString(
FILE *theFile,
- char *str)
+ const char *str)
{
unsigned i;
size_t slen;