Address various compiler warnings about precision loss
authorarr <linuxuser27@gmail.com>
Sat, 28 Apr 2018 07:02:02 +0000 (00:02 -0700)
committerarr <linuxuser27@gmail.com>
Sat, 28 Apr 2018 07:02:02 +0000 (00:02 -0700)
csrc/pf_core.c
csrc/pf_guts.h
csrc/pf_inner.c
csrc/pf_main.c
csrc/pf_save.c
csrc/pf_text.c
csrc/pf_text.h
csrc/pfcompil.c
csrc/pforth.h

index 1736aa9..a6d7c26 100644 (file)
@@ -170,9 +170,9 @@ nomem:
 ** Dictionary Management
 ***************************************************************/
 
 ** Dictionary Management
 ***************************************************************/
 
-cell_t pfExecIfDefined( const char *CString )
+ThrowCode pfExecIfDefined( const char *CString )
 {
 {
-    int result = 0;
+    ThrowCode result = 0;
     if( NAME_BASE != (cell_t)NULL)
     {
         ExecToken  XT;
     if( NAME_BASE != (cell_t)NULL)
     {
         ExecToken  XT;
@@ -427,11 +427,11 @@ void pfMessage( const char *CString )
 /**************************************************************************
 ** Main entry point for pForth.
 */
 /**************************************************************************
 ** Main entry point for pForth.
 */
-cell_t pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit )
+ThrowCode pfDoForth( const char *DicFileName, const char *SourceName, cell_t IfInit )
 {
     pfTaskData_t *cftd;
     pfDictionary_t *dic = NULL;
 {
     pfTaskData_t *cftd;
     pfDictionary_t *dic = NULL;
-    cell_t Result = 0;
+    ThrowCode Result = 0;
     ExecToken  EntryPoint = 0;
 
 #ifdef PF_USER_INIT
     ExecToken  EntryPoint = 0;
 
 #ifdef PF_USER_INIT
index 5aa4a70..a55d857 100644 (file)
@@ -462,7 +462,7 @@ typedef struct IncludeFrame
 extern "C" {
 #endif
 
 extern "C" {
 #endif
 
-int pfCatch( ExecToken XT );
+ThrowCode pfCatch( ExecToken XT );
 
 #ifdef __cplusplus
 }
 
 #ifdef __cplusplus
 }
index dffadf0..10041ba 100644 (file)
@@ -211,11 +211,11 @@ static int UdIsUint64( ucell_t Lo, ucell_t Hi )
            : Hi == 0 );
 }
 
            : Hi == 0 );
 }
 
-static const char *pfSelectFileModeCreate( int fam );
-static const char *pfSelectFileModeOpen( int fam );
+static const char *pfSelectFileModeCreate(cell_t fam );
+static const char *pfSelectFileModeOpen(cell_t fam );
 
 /**************************************************************/
 
 /**************************************************************/
-static const char *pfSelectFileModeCreate( int fam )
+static const char *pfSelectFileModeCreate( cell_t fam )
 {
     const char *famText = NULL;
     switch( fam )
 {
     const char *famText = NULL;
     switch( fam )
@@ -240,7 +240,7 @@ static const char *pfSelectFileModeCreate( int fam )
 }
 
 /**************************************************************/
 }
 
 /**************************************************************/
-static const char *pfSelectFileModeOpen( int fam )
+static const char *pfSelectFileModeOpen( cell_t fam )
 {
     const char *famText = NULL;
     switch( fam )
 {
     const char *famText = NULL;
     switch( fam )
@@ -269,7 +269,7 @@ static const char *pfSelectFileModeOpen( int fam )
 }
 
 /**************************************************************/
 }
 
 /**************************************************************/
-int pfCatch( ExecToken XT )
+ThrowCode pfCatch( ExecToken XT )
 {
     register cell_t  TopOfStack;    /* Cache for faster execution. */
     register cell_t *DataStackPtr;
 {
     register cell_t  TopOfStack;    /* Cache for faster execution. */
     register cell_t *DataStackPtr;
@@ -1089,7 +1089,7 @@ DBUG(("XX ah,m,l = 0x%8x,%8x,%8x - qh,l = 0x%8x,%8x\n", ah,am,al, qh,ql ));
                     TOS = -3; /* TODO err num? */
                     break;
                 }
                     TOS = -3; /* TODO err num? */
                     break;
                 }
-                offset = offsetLow;
+                offset = (file_offset_t)offsetLow;
                 TOS = sdSeekFile( FileID, offset, PF_SEEK_SET );
             }
             endcase;
                 TOS = sdSeekFile( FileID, offset, PF_SEEK_SET );
             }
             endcase;
index 5783f0f..1c7ef96 100644 (file)
@@ -67,7 +67,7 @@ int main( int argc, char **argv )
     char IfInit = FALSE;
     char *s;
     cell_t i;
     char IfInit = FALSE;
     char *s;
     cell_t i;
-    int Result;
+    ThrowCode Result;
 
 /* For Metroworks on Mac */
 #ifdef __MWERKS__
 
 /* For Metroworks on Mac */
 #ifdef __MWERKS__
@@ -140,7 +140,7 @@ int main( int argc, char **argv )
     Result = pfDoForth( DicName, SourceName, IfInit);
 
 on_error:
     Result = pfDoForth( DicName, SourceName, IfInit);
 
 on_error:
-    return Result;
+    return (int)Result;
 }
 
 #endif  /* PF_EMBEDDED */
 }
 
 #endif  /* PF_EMBEDDED */
index 03f4ce8..faa6d81 100644 (file)
@@ -315,7 +315,7 @@ cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize,
 /***************************************************************/
 static int Write32ToFile( FileStream *fid, uint32_t Val )
 {
 /***************************************************************/
 static int Write32ToFile( FileStream *fid, uint32_t Val )
 {
-    int numw;
+    size_t numw;
     uint8_t pad[4];
 
     Write32BigEndian(pad,Val);
     uint8_t pad[4];
 
     Write32BigEndian(pad,Val);
@@ -515,7 +515,7 @@ error:
 /***************************************************************/
 static int32_t Read32FromFile( FileStream *fid, uint32_t *ValPtr )
 {
 /***************************************************************/
 static int32_t Read32FromFile( FileStream *fid, uint32_t *ValPtr )
 {
-    int32_t numr;
+    size_t numr;
     uint8_t pad[4];
     numr = sdReadFile( pad, 1, sizeof(pad), fid );
     if( numr != sizeof(pad) ) return -1;
     uint8_t pad[4];
     numr = sdReadFile( pad, 1, sizeof(pad), fid );
     if( numr != sizeof(pad) ) return -1;
@@ -533,7 +533,7 @@ PForthDictionary pfLoadDictionary( const char *FileName, ExecToken *EntryPointPt
     uint32_t ChunkSize;
     uint32_t FormSize;
     uint32_t BytesLeft;
     uint32_t ChunkSize;
     uint32_t FormSize;
     uint32_t BytesLeft;
-    uint32_t numr;
+    size_t numr;
     int   isDicBigEndian;
 
 DBUG(("pfLoadDictionary( %s )\n", FileName ));
     int   isDicBigEndian;
 
 DBUG(("pfLoadDictionary( %s )\n", FileName ));
@@ -726,7 +726,7 @@ DBUG(("pfLoadDictionary( %s )\n", FileName ));
 /* Find special words in dictionary for global XTs. */
         if( (Result = FindSpecialXTs()) < 0 )
         {
 /* Find special words in dictionary for global XTs. */
         if( (Result = FindSpecialXTs()) < 0 )
         {
-            pfReportError("pfLoadDictionary: FindSpecialXTs", Result);
+            pfReportError("pfLoadDictionary: FindSpecialXTs", (Err)Result);
             goto error;
         }
     }
             goto error;
         }
     }
index e48e457..03430a7 100644 (file)
@@ -222,7 +222,7 @@ DBUGX(("ffCompareText: return 0x%x\n", Result ));
 ** Compare two strings, case sensitive.
 ** Return zero if they match, -1 if s1<s2, +1 is s1>s2;
 */
 ** Compare two strings, case sensitive.
 ** Return zero if they match, -1 if s1<s2, +1 is s1>s2;
 */
-cell_t ffCompare( const char *s1, cell_t len1, const char *s2, int32_t len2 )
+cell_t ffCompare( const char *s1, cell_t len1, const char *s2, cell_t len2 )
 {
     cell_t i, result, n, diff;
 
 {
     cell_t i, result, n, diff;
 
index 05431d7..fd71371 100644 (file)
@@ -54,7 +54,7 @@ void pfReportThrow( ThrowCode code );
 char  *ForthStringToC( char *dst, const char *FString, cell_t dstSize );
 char  *CStringToForth( char *dst, const char *CString, cell_t dstSize  );
 
 char  *ForthStringToC( char *dst, const char *FString, cell_t dstSize );
 char  *CStringToForth( char *dst, const char *CString, cell_t dstSize  );
 
-cell_t ffCompare( const char *s1, cell_t len1, const char *s2, int32_t len2 );
+cell_t ffCompare( const char *s1, cell_t len1, const char *s2, cell_t len2 );
 cell_t ffCompareText( const char *s1, const char *s2, cell_t len );
 cell_t ffCompareTextCaseN( const char *s1, const char *s2, cell_t len );
 
 cell_t ffCompareText( const char *s1, const char *s2, cell_t len );
 cell_t ffCompareTextCaseN( const char *s1, const char *s2, cell_t len );
 
index b618c9f..937e39e 100644 (file)
@@ -981,7 +981,7 @@ ThrowCode ffIncludeFile( FileStream *InputFile )
 ***************************************************************/
 Err ffPushInputStream( FileStream *InputFile )
 {
 ***************************************************************/
 Err ffPushInputStream( FileStream *InputFile )
 {
-    cell_t Result = 0;
+    Err Result = 0;
     IncludeFrame *inf;
 
 /* Push current input state onto special include stack. */
     IncludeFrame *inf;
 
 /* Push current input state onto special include stack. */
index cd74336..96eb93f 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
 #endif
 
 /* Main entry point to pForth. */
 #endif
 
 /* Main entry point to pForth. */
-cell_t pfDoForth( const char *DicName, const char *SourceName, cell_t IfInit );
+ThrowCode pfDoForth( const char *DicName, const char *SourceName, cell_t IfInit );
 
 /* Turn off messages. */
 void  pfSetQuiet( cell_t IfQuiet );
 
 /* Turn off messages. */
 void  pfSetQuiet( cell_t IfQuiet );
@@ -78,7 +78,7 @@ void  pfDeleteDictionary( PForthDictionary dict );
 ThrowCode pfQuit( void );
 
 /* Execute a single execution token in the current task and return 0 or an error code. */
 ThrowCode pfQuit( void );
 
 /* Execute a single execution token in the current task and return 0 or an error code. */
-int pfCatch( ExecToken XT );
+ThrowCode pfCatch( ExecToken XT );
 
 /* Include the given pForth source code file. */
 ThrowCode pfIncludeFile( const char *FileName );
 
 /* Include the given pForth source code file. */
 ThrowCode pfIncludeFile( const char *FileName );