Skip to content

Commit

Permalink
Prepare for release: fix issues found in regression testing, fix issu…
Browse files Browse the repository at this point in the history
…es found by static analysis.

Signed-off-by: Thiadmer Riemersma <thiadmer@compuphase.com>
  • Loading branch information
Thiadmer Riemersma committed Mar 23, 2024
1 parent 6310f91 commit e0cba25
Show file tree
Hide file tree
Showing 28 changed files with 681 additions and 674 deletions.
5 changes: 2 additions & 3 deletions amx/amx.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: amx.c 6973 2023-08-05 20:07:04Z thiadmer $
* Version: $Id: amx.c 7151 2024-03-23 16:08:18Z thiadmer $
*/

#define WIN32_LEAN_AND_MEAN
Expand Down Expand Up @@ -93,7 +93,7 @@
#define AMX_EXPLIT_FUNCTIONS
#endif
#if !defined AMX_EXPLIT_FUNCTIONS
/* no constant set, set them all */
/* no constant set, set them all (except amx_InitJIT() and other JIT support) */
#define AMX_ALIGN /* amx_Align16(), amx_Align32() and amx_Align64() */
#define AMX_ALLOT /* amx_Allot() and amx_Release() */
#define AMX_DEFCALLBACK /* amx_Callback() */
Expand All @@ -102,7 +102,6 @@
#define AMX_EXEC /* amx_Exec() */
#define AMX_FLAGS /* amx_Flags() */
#define AMX_INIT /* amx_Init() */
#define AMX_JIT /* amx_InitJIT() and other JIT support */
#define AMX_MEMINFO /* amx_MemInfo() */
#define AMX_NAMELENGTH /* amx_NameLength() */
#define AMX_NATIVEINFO /* amx_NativeInfo() */
Expand Down
6 changes: 3 additions & 3 deletions amx/amx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: amx.h 6965 2023-07-20 15:44:35Z thiadmer $
* Version: $Id: amx.h 7152 2024-03-23 20:47:23Z thiadmer $
*/

#ifndef AMX_H_INCLUDED
Expand Down Expand Up @@ -158,7 +158,7 @@ extern "C" {
#define AMXAPI __stdcall
#elif defined CDECL
#define AMXAPI __cdecl
#elif defined GCC_HASCLASSVISIBILITY
#elif defined GCC_HASCLASSVISIBILITY && defined __cplusplus
#define AMXAPI __attribute__((visibility("default")))
#else
#define AMXAPI
Expand Down Expand Up @@ -263,7 +263,7 @@ typedef int (AMXAPI *AMX_IDLE)(struct tagAMX *amx, int AMXAPI Exec(struct tagAMX
#else
#pragma pack(push)
#pragma pack(1) /* structures must be packed (byte-aligned) */
#if defined __TURBOC__
#if defined __BORLANDC__
#pragma option -a- /* "pack" pragma for older Borland compilers */
#endif
#endif
Expand Down
4 changes: 2 additions & 2 deletions amx/amxdbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: amxdbg.h 6131 2020-04-29 19:47:15Z thiadmer $
* Version: $Id: amxdbg.h 7152 2024-03-23 20:47:23Z thiadmer $
*/

#ifndef AMXDBG_H_INCLUDED
Expand Down Expand Up @@ -52,7 +52,7 @@ extern "C" {
#else
#pragma pack(push)
#pragma pack(1) /* structures must be packed (byte-aligned) */
#if defined __TURBOC__
#if defined __BORLANDC__
#pragma option -a- /* "pack" pragma for older Borland compilers */
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion amx/amxfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: amxfile.c 6965 2023-07-20 15:44:35Z thiadmer $
* Version: $Id: amxfile.c 6969 2023-07-26 12:26:41Z thiadmer $
*/
#if defined _UNICODE || defined __UNICODE__ || defined UNICODE
# if !defined UNICODE /* for Windows */
Expand Down
2 changes: 1 addition & 1 deletion amx/amxtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: amxtime.c 6965 2023-07-20 15:44:35Z thiadmer $
* Version: $Id: amxtime.c 6969 2023-07-26 12:26:41Z thiadmer $
*/
#include <time.h>
#include <assert.h>
Expand Down
2 changes: 1 addition & 1 deletion amx/minIni.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: minIni.c 5691 2017-06-09 19:48:22Z thiadmer $
* Version: $Id: minIni.c 6965 2023-07-20 15:44:35Z thiadmer $
*/

#if (defined _UNICODE || defined __UNICODE__ || defined UNICODE) && !defined INI_ANSIONLY
Expand Down
10 changes: 5 additions & 5 deletions amx/osdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@
* eCos option management.
*/
#include <pkgconf/pawn.h>
#if CYGPKG_PAWN_AMX_ANSIONLY==1
#if defined CYGPKG_PAWN_AMX_ANSIONLY && CYGPKG_PAWN_AMX_ANSIONLY==1
#define AMX_ANSIONLY
#endif
#define PAWN_CELL_SIZE CYGPKG_PAWN_AMX_CELLSIZE
#if CYGPKG_PAWN_CORE_RANDOM==0
#if defined CYGPKG_PAWN_CORE_RANDOM && CYGPKG_PAWN_CORE_RANDOM==0
#define AMX_NORANDOM
#endif
#if CYGPKG_PAWN_CORE_PROPERTY==0
#if defined CYGPKG_PAWN_CORE_PROPERTY && CYGPKG_PAWN_CORE_PROPERTY==0
#define AMX_NOPROPLIST
#endif
#if CYGPKG_PAWN_AMX_CONS_FIXEDPOINT==1
#if defined CYGPKG_PAWN_AMX_CONS_FIXEDPOINT && CYGPKG_PAWN_AMX_CONS_FIXEDPOINT==1
#define FIXEDPOINT
#endif
#if CYGPKG_PAWN_AMX_CONS_FLOATPOINT==1
#if defined CYGPKG_PAWN_AMX_CONS_FLOATPOINT && CYGPKG_PAWN_AMX_CONS_FLOATPOINT==1
#define FLOATPOINT
#endif
#endif
Expand Down
6 changes: 3 additions & 3 deletions amx/pawndbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: pawndbg.c 6131 2020-04-29 19:47:15Z thiadmer $
* Version: $Id: pawndbg.c 7133 2024-03-05 10:31:12Z thiadmer $
*
*
* Command line options:
Expand Down Expand Up @@ -1228,12 +1228,12 @@ static void remote_write_rs232(AMX *amx,cell vaddr,int number)
while (number>0) {
num=(number>10) ? 10 : number;
number-=num;
sprintf(buffer,"?W%lx",(long)vaddr);
sprintf(buffer,"?W%lx",(unsigned long)vaddr);
while (num>0) {
cptr=VirtAddressToPhys(amx,vaddr);
assert(cptr!=NULL);
strcat(buffer,",");
sprintf(buffer+strlen(buffer),"%x",*cptr);
sprintf(buffer+strlen(buffer),"%lx",(unsigned long)*cptr);
num--;
vaddr+=sizeof(cell);
} /* while */
Expand Down
12 changes: 5 additions & 7 deletions compiler/libpawnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: libpawnc.c 6131 2020-04-29 19:47:15Z thiadmer $
* Version: $Id: libpawnc.c 7152 2024-03-23 20:47:23Z thiadmer $
*/
#include <assert.h>
#include <stdio.h>
Expand Down Expand Up @@ -124,12 +124,10 @@ int pc_printf(const char *message,...)
*/
int pc_error(int number,const char *message,const char *filename,int firstline,int lastline,va_list argptr)
{
static char *prefix[3]={ "error", "fatal error", "warning" };
static const char *prefix[3]={ "error", "fatal error", "warning" };

if (number!=0) {
char *pre;

pre=prefix[number/100];
const char *pre=prefix[number/100];
if (firstline>=0)
fprintf(stderr,"%s(%d -- %d) : %s %03d: ",filename,firstline,lastline,pre,number);
else
Expand Down Expand Up @@ -252,7 +250,7 @@ int pc_eofsrc(void *handle)
/* should return a pointer, which is used as a "magic cookie" to all I/O
* functions; return NULL for failure
*/
void *pc_openasm(char *filename)
void *pc_openasm(const char *filename)
{
#if defined __MSDOS__ || defined PAWN_LIGHT
return fopen(filename,"w+t");
Expand Down Expand Up @@ -309,7 +307,7 @@ char *pc_readasm(void *handle, char *string, int maxchars)
/* Should return a pointer, which is used as a "magic cookie" to all I/O
* functions; return NULL for failure.
*/
void *pc_openbin(char *filename)
void *pc_openbin(const char *filename)
{
return fopen(filename,"wb");
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/pawndisasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: pawndisasm.c 6969 2023-07-26 12:26:41Z thiadmer $
* Version: $Id: pawndisasm.c 6970 2023-07-28 20:12:00Z thiadmer $
*/
#include <assert.h>
#include <inttypes.h>
Expand Down
26 changes: 13 additions & 13 deletions compiler/sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* This version comes close to a complete rewrite.
*
* Copyright CompuPhase, 1997-2020
* Copyright CompuPhase, 1997-2024
* Copyright J.E. Hendrix, 1982, 1983
* Copyright R. Cain, 1980
*
Expand All @@ -23,7 +23,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Version: $Id: sc.h 7108 2024-02-19 22:02:45Z thiadmer $
* Version: $Id: sc.h 7152 2024-03-23 20:47:23Z thiadmer $
*/
#ifndef SC_H_INCLUDED
#define SC_H_INCLUDED
Expand Down Expand Up @@ -545,14 +545,14 @@ void pc_resetsrc(void *handle,void *position); /* reset to a position marked
int pc_eofsrc(void *handle);

/* output to intermediate (.ASM) file */
void *pc_openasm(char *filename); /* read/write */
void *pc_openasm(const char *filename); /* read/write */
void pc_closeasm(void *handle,int deletefile);
void pc_resetasm(void *handle);
int pc_writeasm(void *handle,const char *str);
char *pc_readasm(void *handle,char *target,int maxchars);

/* output to binary (.AMX) file */
void *pc_openbin(char *filename);
void *pc_openbin(const char *filename);
void pc_closebin(void *handle,int deletefile);
void pc_resetbin(void *handle,long offset);
int pc_writebin(void *handle,const void *buffer,int size);
Expand All @@ -577,13 +577,13 @@ long pc_lengthbin(void *handle); /* return the length of the file */
#endif

/* function prototypes in SC1.C */
SC_FUNC void set_extension(char *filename,char *extension,int force);
SC_FUNC void set_extension(char *filename,const char *extension,int force);
SC_FUNC symbol *fetchfunc(const char *name,int tag);
SC_FUNC char *operator_symname(char *symname,char *opername,int tag1,int tag2,int numtags,int resulttag);
SC_FUNC char *funcdisplayname(char *dest,const char *funcname);
SC_FUNC int constexpr(cell *val,int *tag,symbol **symptr);
SC_FUNC constvalue *append_constval(constvalue *table,const char *name,cell val,int index);
SC_FUNC constvalue *find_constval(constvalue *table,char *name,int index);
SC_FUNC constvalue *find_constval(constvalue *table,const char *name,int index);
SC_FUNC void delete_consttable(constvalue *table);
SC_FUNC int compare_consttable(constvalue *table1, constvalue *table2);
SC_FUNC symbol *add_constant(const char *name,cell val,int scope,int tag);
Expand All @@ -598,17 +598,17 @@ SC_FUNC void sc_attachdocumentation(symbol *sym,int onlylastblock);
SC_FUNC void pushstk(stkitem val);
SC_FUNC stkitem popstk(void);
SC_FUNC void clearstk(void);
SC_FUNC int plungequalifiedfile(char *name); /* explicit path included */
SC_FUNC int plungequalifiedfile(const char *name); /* explicit path included */
SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths); /* search through "include" paths */
SC_FUNC char *strdel(char *str,size_t len);
SC_FUNC char *strins(char *dest,char *src,size_t srclen);
SC_FUNC char *strins(char *dest,const char *src,size_t srclen);
SC_FUNC void preprocess(void);
SC_FUNC void lex_fetchindent(const unsigned char *string,const unsigned char *pos);
SC_FUNC int lex_adjusttabsize(int matchindent);
SC_FUNC int lexinit(int releaseall);
SC_FUNC int lex(cell *lexvalue,char **lexsym);
SC_FUNC void lexpush(void);
SC_FUNC int lexsettoken(int token,char *str);
SC_FUNC int lexsettoken(int token,const char *str);
SC_FUNC void lexclr(int clreol);
SC_FUNC int lexpeek(void);
SC_FUNC int matchtoken(int token);
Expand Down Expand Up @@ -650,7 +650,7 @@ SC_FUNC void writestatetables(symbol *root,int lbl_nostate,int lbl_ignorestate);
SC_FUNC void begcseg(void);
SC_FUNC void begdseg(void);
SC_FUNC void setline(int chkbounds);
SC_FUNC void setfiledirect(char *name);
SC_FUNC void setfiledirect(const char *name);
SC_FUNC void setlinedirect(int line);
SC_FUNC void setlabel(int index);
SC_FUNC void markexpr(optmark type,const char *name,cell offset);
Expand All @@ -664,7 +664,7 @@ SC_FUNC void loadreg(cell address,regid reg);
SC_FUNC void storereg(cell address,regid reg);
SC_FUNC void memcopy(cell size);
SC_FUNC void copyarray2d(int majordim,int minordim);
SC_FUNC void fillarray(symbol *sym,cell size,cell value);
SC_FUNC void fillarray(const symbol *sym,cell size,cell value);
SC_FUNC void ldconst(cell val,regid reg);
SC_FUNC void swapregs(void);
SC_FUNC void pushreg(regid reg);
Expand Down Expand Up @@ -833,7 +833,7 @@ SC_FUNC constvalue *state_add(const char *name,int fsa_id);
SC_FUNC constvalue *state_find(const char *name,int fsa_id,char *closestmatch);
SC_FUNC constvalue *state_findid(int id,int fsa_id);
SC_FUNC void state_buildlist(int **list,int *listsize,int *count,int stateid);
SC_FUNC int state_addlist(int *list,int count,int fsa_id);
SC_FUNC int state_addlist(const int *list,int count,int fsa_id);
SC_FUNC void state_deletetable(void);
SC_FUNC int state_getfsa(int listid);
SC_FUNC int state_count(int listid);
Expand All @@ -850,7 +850,7 @@ SC_VDECL symbol loctab; /* local symbol table */
SC_VDECL symbol glbtab; /* global symbol table */
SC_VDECL cell *litq; /* the literal queue */
SC_VDECL unsigned char *srcline;/* the line read from the input file */
SC_VDECL const unsigned char *lptr;/* points to the current position in "srcline" */
SC_VDECL const unsigned char *lexptr;/* points to the current position in "srcline" */
SC_VDECL constvalue tagname_tab;/* tagname table */
SC_VDECL constvalue libname_tab;/* library table (#pragma library "..." syntax) */
SC_VDECL constvalue *curlibrary;/* current library */
Expand Down
Loading

0 comments on commit e0cba25

Please sign in to comment.