Skip to content

Commit e0cba25

Browse files
author
Thiadmer Riemersma
committed
Prepare for release: fix issues found in regression testing, fix issues found by static analysis.
Signed-off-by: Thiadmer Riemersma <thiadmer@compuphase.com>
1 parent 6310f91 commit e0cba25

28 files changed

+681
-674
lines changed

amx/amx.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* License for the specific language governing permissions and limitations
1515
* under the License.
1616
*
17-
* Version: $Id: amx.c 6973 2023-08-05 20:07:04Z thiadmer $
17+
* Version: $Id: amx.c 7151 2024-03-23 16:08:18Z thiadmer $
1818
*/
1919

2020
#define WIN32_LEAN_AND_MEAN
@@ -93,7 +93,7 @@
9393
#define AMX_EXPLIT_FUNCTIONS
9494
#endif
9595
#if !defined AMX_EXPLIT_FUNCTIONS
96-
/* no constant set, set them all */
96+
/* no constant set, set them all (except amx_InitJIT() and other JIT support) */
9797
#define AMX_ALIGN /* amx_Align16(), amx_Align32() and amx_Align64() */
9898
#define AMX_ALLOT /* amx_Allot() and amx_Release() */
9999
#define AMX_DEFCALLBACK /* amx_Callback() */
@@ -102,7 +102,6 @@
102102
#define AMX_EXEC /* amx_Exec() */
103103
#define AMX_FLAGS /* amx_Flags() */
104104
#define AMX_INIT /* amx_Init() */
105-
#define AMX_JIT /* amx_InitJIT() and other JIT support */
106105
#define AMX_MEMINFO /* amx_MemInfo() */
107106
#define AMX_NAMELENGTH /* amx_NameLength() */
108107
#define AMX_NATIVEINFO /* amx_NativeInfo() */

amx/amx.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* License for the specific language governing permissions and limitations
1515
* under the License.
1616
*
17-
* Version: $Id: amx.h 6965 2023-07-20 15:44:35Z thiadmer $
17+
* Version: $Id: amx.h 7152 2024-03-23 20:47:23Z thiadmer $
1818
*/
1919

2020
#ifndef AMX_H_INCLUDED
@@ -158,7 +158,7 @@ extern "C" {
158158
#define AMXAPI __stdcall
159159
#elif defined CDECL
160160
#define AMXAPI __cdecl
161-
#elif defined GCC_HASCLASSVISIBILITY
161+
#elif defined GCC_HASCLASSVISIBILITY && defined __cplusplus
162162
#define AMXAPI __attribute__((visibility("default")))
163163
#else
164164
#define AMXAPI
@@ -263,7 +263,7 @@ typedef int (AMXAPI *AMX_IDLE)(struct tagAMX *amx, int AMXAPI Exec(struct tagAMX
263263
#else
264264
#pragma pack(push)
265265
#pragma pack(1) /* structures must be packed (byte-aligned) */
266-
#if defined __TURBOC__
266+
#if defined __BORLANDC__
267267
#pragma option -a- /* "pack" pragma for older Borland compilers */
268268
#endif
269269
#endif

amx/amxdbg.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* License for the specific language governing permissions and limitations
1818
* under the License.
1919
*
20-
* Version: $Id: amxdbg.h 6131 2020-04-29 19:47:15Z thiadmer $
20+
* Version: $Id: amxdbg.h 7152 2024-03-23 20:47:23Z thiadmer $
2121
*/
2222

2323
#ifndef AMXDBG_H_INCLUDED
@@ -52,7 +52,7 @@ extern "C" {
5252
#else
5353
#pragma pack(push)
5454
#pragma pack(1) /* structures must be packed (byte-aligned) */
55-
#if defined __TURBOC__
55+
#if defined __BORLANDC__
5656
#pragma option -a- /* "pack" pragma for older Borland compilers */
5757
#endif
5858
#endif

amx/amxfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* License for the specific language governing permissions and limitations
1515
* under the License.
1616
*
17-
* Version: $Id: amxfile.c 6965 2023-07-20 15:44:35Z thiadmer $
17+
* Version: $Id: amxfile.c 6969 2023-07-26 12:26:41Z thiadmer $
1818
*/
1919
#if defined _UNICODE || defined __UNICODE__ || defined UNICODE
2020
# if !defined UNICODE /* for Windows */

amx/amxtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* License for the specific language governing permissions and limitations
1515
* under the License.
1616
*
17-
* Version: $Id: amxtime.c 6965 2023-07-20 15:44:35Z thiadmer $
17+
* Version: $Id: amxtime.c 6969 2023-07-26 12:26:41Z thiadmer $
1818
*/
1919
#include <time.h>
2020
#include <assert.h>

amx/minIni.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* License for the specific language governing permissions and limitations
1818
* under the License.
1919
*
20-
* Version: $Id: minIni.c 5691 2017-06-09 19:48:22Z thiadmer $
20+
* Version: $Id: minIni.c 6965 2023-07-20 15:44:35Z thiadmer $
2121
*/
2222

2323
#if (defined _UNICODE || defined __UNICODE__ || defined UNICODE) && !defined INI_ANSIONLY

amx/osdefs.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,20 @@
8484
* eCos option management.
8585
*/
8686
#include <pkgconf/pawn.h>
87-
#if CYGPKG_PAWN_AMX_ANSIONLY==1
87+
#if defined CYGPKG_PAWN_AMX_ANSIONLY && CYGPKG_PAWN_AMX_ANSIONLY==1
8888
#define AMX_ANSIONLY
8989
#endif
9090
#define PAWN_CELL_SIZE CYGPKG_PAWN_AMX_CELLSIZE
91-
#if CYGPKG_PAWN_CORE_RANDOM==0
91+
#if defined CYGPKG_PAWN_CORE_RANDOM && CYGPKG_PAWN_CORE_RANDOM==0
9292
#define AMX_NORANDOM
9393
#endif
94-
#if CYGPKG_PAWN_CORE_PROPERTY==0
94+
#if defined CYGPKG_PAWN_CORE_PROPERTY && CYGPKG_PAWN_CORE_PROPERTY==0
9595
#define AMX_NOPROPLIST
9696
#endif
97-
#if CYGPKG_PAWN_AMX_CONS_FIXEDPOINT==1
97+
#if defined CYGPKG_PAWN_AMX_CONS_FIXEDPOINT && CYGPKG_PAWN_AMX_CONS_FIXEDPOINT==1
9898
#define FIXEDPOINT
9999
#endif
100-
#if CYGPKG_PAWN_AMX_CONS_FLOATPOINT==1
100+
#if defined CYGPKG_PAWN_AMX_CONS_FLOATPOINT && CYGPKG_PAWN_AMX_CONS_FLOATPOINT==1
101101
#define FLOATPOINT
102102
#endif
103103
#endif

amx/pawndbg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* License for the specific language governing permissions and limitations
2929
* under the License.
3030
*
31-
* Version: $Id: pawndbg.c 6131 2020-04-29 19:47:15Z thiadmer $
31+
* Version: $Id: pawndbg.c 7133 2024-03-05 10:31:12Z thiadmer $
3232
*
3333
*
3434
* Command line options:
@@ -1228,12 +1228,12 @@ static void remote_write_rs232(AMX *amx,cell vaddr,int number)
12281228
while (number>0) {
12291229
num=(number>10) ? 10 : number;
12301230
number-=num;
1231-
sprintf(buffer,"?W%lx",(long)vaddr);
1231+
sprintf(buffer,"?W%lx",(unsigned long)vaddr);
12321232
while (num>0) {
12331233
cptr=VirtAddressToPhys(amx,vaddr);
12341234
assert(cptr!=NULL);
12351235
strcat(buffer,",");
1236-
sprintf(buffer+strlen(buffer),"%x",*cptr);
1236+
sprintf(buffer+strlen(buffer),"%lx",(unsigned long)*cptr);
12371237
num--;
12381238
vaddr+=sizeof(cell);
12391239
} /* while */

compiler/libpawnc.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* License for the specific language governing permissions and limitations
1717
* under the License.
1818
*
19-
* Version: $Id: libpawnc.c 6131 2020-04-29 19:47:15Z thiadmer $
19+
* Version: $Id: libpawnc.c 7152 2024-03-23 20:47:23Z thiadmer $
2020
*/
2121
#include <assert.h>
2222
#include <stdio.h>
@@ -124,12 +124,10 @@ int pc_printf(const char *message,...)
124124
*/
125125
int pc_error(int number,const char *message,const char *filename,int firstline,int lastline,va_list argptr)
126126
{
127-
static char *prefix[3]={ "error", "fatal error", "warning" };
127+
static const char *prefix[3]={ "error", "fatal error", "warning" };
128128

129129
if (number!=0) {
130-
char *pre;
131-
132-
pre=prefix[number/100];
130+
const char *pre=prefix[number/100];
133131
if (firstline>=0)
134132
fprintf(stderr,"%s(%d -- %d) : %s %03d: ",filename,firstline,lastline,pre,number);
135133
else
@@ -252,7 +250,7 @@ int pc_eofsrc(void *handle)
252250
/* should return a pointer, which is used as a "magic cookie" to all I/O
253251
* functions; return NULL for failure
254252
*/
255-
void *pc_openasm(char *filename)
253+
void *pc_openasm(const char *filename)
256254
{
257255
#if defined __MSDOS__ || defined PAWN_LIGHT
258256
return fopen(filename,"w+t");
@@ -309,7 +307,7 @@ char *pc_readasm(void *handle, char *string, int maxchars)
309307
/* Should return a pointer, which is used as a "magic cookie" to all I/O
310308
* functions; return NULL for failure.
311309
*/
312-
void *pc_openbin(char *filename)
310+
void *pc_openbin(const char *filename)
313311
{
314312
return fopen(filename,"wb");
315313
}

compiler/pawndisasm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* License for the specific language governing permissions and limitations
1515
* under the License.
1616
*
17-
* Version: $Id: pawndisasm.c 6969 2023-07-26 12:26:41Z thiadmer $
17+
* Version: $Id: pawndisasm.c 6970 2023-07-28 20:12:00Z thiadmer $
1818
*/
1919
#include <assert.h>
2020
#include <inttypes.h>

compiler/sc.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* This version comes close to a complete rewrite.
99
*
10-
* Copyright CompuPhase, 1997-2020
10+
* Copyright CompuPhase, 1997-2024
1111
* Copyright J.E. Hendrix, 1982, 1983
1212
* Copyright R. Cain, 1980
1313
*
@@ -23,7 +23,7 @@
2323
* License for the specific language governing permissions and limitations
2424
* under the License.
2525
*
26-
* Version: $Id: sc.h 7108 2024-02-19 22:02:45Z thiadmer $
26+
* Version: $Id: sc.h 7152 2024-03-23 20:47:23Z thiadmer $
2727
*/
2828
#ifndef SC_H_INCLUDED
2929
#define SC_H_INCLUDED
@@ -545,14 +545,14 @@ void pc_resetsrc(void *handle,void *position); /* reset to a position marked
545545
int pc_eofsrc(void *handle);
546546

547547
/* output to intermediate (.ASM) file */
548-
void *pc_openasm(char *filename); /* read/write */
548+
void *pc_openasm(const char *filename); /* read/write */
549549
void pc_closeasm(void *handle,int deletefile);
550550
void pc_resetasm(void *handle);
551551
int pc_writeasm(void *handle,const char *str);
552552
char *pc_readasm(void *handle,char *target,int maxchars);
553553

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

579579
/* function prototypes in SC1.C */
580-
SC_FUNC void set_extension(char *filename,char *extension,int force);
580+
SC_FUNC void set_extension(char *filename,const char *extension,int force);
581581
SC_FUNC symbol *fetchfunc(const char *name,int tag);
582582
SC_FUNC char *operator_symname(char *symname,char *opername,int tag1,int tag2,int numtags,int resulttag);
583583
SC_FUNC char *funcdisplayname(char *dest,const char *funcname);
584584
SC_FUNC int constexpr(cell *val,int *tag,symbol **symptr);
585585
SC_FUNC constvalue *append_constval(constvalue *table,const char *name,cell val,int index);
586-
SC_FUNC constvalue *find_constval(constvalue *table,char *name,int index);
586+
SC_FUNC constvalue *find_constval(constvalue *table,const char *name,int index);
587587
SC_FUNC void delete_consttable(constvalue *table);
588588
SC_FUNC int compare_consttable(constvalue *table1, constvalue *table2);
589589
SC_FUNC symbol *add_constant(const char *name,cell val,int scope,int tag);
@@ -598,17 +598,17 @@ SC_FUNC void sc_attachdocumentation(symbol *sym,int onlylastblock);
598598
SC_FUNC void pushstk(stkitem val);
599599
SC_FUNC stkitem popstk(void);
600600
SC_FUNC void clearstk(void);
601-
SC_FUNC int plungequalifiedfile(char *name); /* explicit path included */
601+
SC_FUNC int plungequalifiedfile(const char *name); /* explicit path included */
602602
SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths); /* search through "include" paths */
603603
SC_FUNC char *strdel(char *str,size_t len);
604-
SC_FUNC char *strins(char *dest,char *src,size_t srclen);
604+
SC_FUNC char *strins(char *dest,const char *src,size_t srclen);
605605
SC_FUNC void preprocess(void);
606606
SC_FUNC void lex_fetchindent(const unsigned char *string,const unsigned char *pos);
607607
SC_FUNC int lex_adjusttabsize(int matchindent);
608608
SC_FUNC int lexinit(int releaseall);
609609
SC_FUNC int lex(cell *lexvalue,char **lexsym);
610610
SC_FUNC void lexpush(void);
611-
SC_FUNC int lexsettoken(int token,char *str);
611+
SC_FUNC int lexsettoken(int token,const char *str);
612612
SC_FUNC void lexclr(int clreol);
613613
SC_FUNC int lexpeek(void);
614614
SC_FUNC int matchtoken(int token);
@@ -650,7 +650,7 @@ SC_FUNC void writestatetables(symbol *root,int lbl_nostate,int lbl_ignorestate);
650650
SC_FUNC void begcseg(void);
651651
SC_FUNC void begdseg(void);
652652
SC_FUNC void setline(int chkbounds);
653-
SC_FUNC void setfiledirect(char *name);
653+
SC_FUNC void setfiledirect(const char *name);
654654
SC_FUNC void setlinedirect(int line);
655655
SC_FUNC void setlabel(int index);
656656
SC_FUNC void markexpr(optmark type,const char *name,cell offset);
@@ -664,7 +664,7 @@ SC_FUNC void loadreg(cell address,regid reg);
664664
SC_FUNC void storereg(cell address,regid reg);
665665
SC_FUNC void memcopy(cell size);
666666
SC_FUNC void copyarray2d(int majordim,int minordim);
667-
SC_FUNC void fillarray(symbol *sym,cell size,cell value);
667+
SC_FUNC void fillarray(const symbol *sym,cell size,cell value);
668668
SC_FUNC void ldconst(cell val,regid reg);
669669
SC_FUNC void swapregs(void);
670670
SC_FUNC void pushreg(regid reg);
@@ -833,7 +833,7 @@ SC_FUNC constvalue *state_add(const char *name,int fsa_id);
833833
SC_FUNC constvalue *state_find(const char *name,int fsa_id,char *closestmatch);
834834
SC_FUNC constvalue *state_findid(int id,int fsa_id);
835835
SC_FUNC void state_buildlist(int **list,int *listsize,int *count,int stateid);
836-
SC_FUNC int state_addlist(int *list,int count,int fsa_id);
836+
SC_FUNC int state_addlist(const int *list,int count,int fsa_id);
837837
SC_FUNC void state_deletetable(void);
838838
SC_FUNC int state_getfsa(int listid);
839839
SC_FUNC int state_count(int listid);
@@ -850,7 +850,7 @@ SC_VDECL symbol loctab; /* local symbol table */
850850
SC_VDECL symbol glbtab; /* global symbol table */
851851
SC_VDECL cell *litq; /* the literal queue */
852852
SC_VDECL unsigned char *srcline;/* the line read from the input file */
853-
SC_VDECL const unsigned char *lptr;/* points to the current position in "srcline" */
853+
SC_VDECL const unsigned char *lexptr;/* points to the current position in "srcline" */
854854
SC_VDECL constvalue tagname_tab;/* tagname table */
855855
SC_VDECL constvalue libname_tab;/* library table (#pragma library "..." syntax) */
856856
SC_VDECL constvalue *curlibrary;/* current library */

0 commit comments

Comments
 (0)