Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ seems to be based on an older release of Pawn.
[build_win]: https://ci.appveyor.com/project/Southclaws/compiler/branch/master
[build_status_win]:
https://ci.appveyor.com/api/projects/status/k112tbr1afrkif0n?svg=true
[team]: https://github.com/pawn-lang/compiler/graphs/contributors
[team]: https://github.com/openmultiplayer/compiler/graphs/contributors
[original_readme]:
https://github.com/pawn-lang/compiler/tree/master/readme_compuphase.txt
[issues]: https://github.com/pawn-lang/compiler/issues
https://github.com/openmultiplayer/compiler/tree/master/readme_compuphase.txt
[issues]: https://github.com/openmultiplayer/compiler/issues
[bugs]: https://github.com/pawn-lang/compiler/wiki/Known-compiler-bugs
[new]: https://github.com/pawn-lang/compiler/wiki/What's-new
[releases]: https://github.com/pawn-lang/compiler/releases
[releases]: https://github.com/openmultiplayer/compiler/releases
[artifacts]:
https://ci.appveyor.com/project/Southclaws/compiler/branch/master/artifacts
[compat]: https://github.com/pawn-lang/compiler/wiki/Compatibility-mode
Expand Down
7 changes: 4 additions & 3 deletions source/amx/amx.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ static int amx_BrowseRelocate(AMX *amx)
#else
assert(sysreq_flg==0 || sysreq_flg==0x01 || sysreq_flg==0x02 || sysreq_flg==0x03);
#endif

#if defined JIT
amx->code_size = getMaxCodeSize()*opcode_count + hdr->cod
+ (hdr->stp - hdr->dat);
Expand Down Expand Up @@ -1047,7 +1048,7 @@ int AMXAPI amx_Init(AMX *amx,void *program)
hdr=(AMX_HEADER *)amx->base;
numlibraries=NUMENTRIES(hdr,libraries,pubvars);
for (i=0; i<numlibraries; i++) {
lib=(AMX_FUNCWIDE*)GETENTRY(hdr, libraries, i);
lib=(AMX_FUNCWIDE*)GETENTRY(hdr,libraries,i);
libname[0]='\0';
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
if (root!=NULL && *root!='\0') {
Expand Down Expand Up @@ -1404,7 +1405,7 @@ int AMXAPI amx_FindNative(AMX* amx, const char* name, int* index)
}

/* not found, set to an invalid index, so amx_Exec() will fail */
*index = INT_MAX;
*index=INT_MAX;
return AMX_ERR_NOTFOUND;
}
#endif /* AMX_XXXNATIVES */
Expand Down Expand Up @@ -1774,7 +1775,7 @@ int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char
assert(string!=NULL);

#if defined AMX_ANSIONLY
length = strlen(string) + 1;
length = strlen(string);
#else
length = (use_wchar ? wcslen((const wchar_t*)string) : strlen(string));
#endif
Expand Down
5 changes: 2 additions & 3 deletions source/amx/amx.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ extern "C" {

#if !defined PAWN_CELL_SIZE
#if defined __64BIT__
#define PAWN_CELL_SIZE 64 /* by default, use 32-bit cells */
#define PAWN_CELL_SIZE 64 /* use 64-bit cells for 64-bit systems */
#else
#define PAWN_CELL_SIZE 32 /* by default, use 32-bit cells */
#endif
Expand Down Expand Up @@ -244,9 +244,8 @@ typedef int (AMXAPI *AMX_IDLE)(struct tagAMX *amx, int AMXAPI Exec(struct tagAMX
#endif

#if defined _MSC_VER
#pragma warning(disable:4103) /* disable warning message 4103 that complains
* about pragma pack in a header file */
#pragma warning(disable:4100) /* "'%$S' : unreferenced formal parameter" */
#pragma warning(disable:4103) /* disable warning message 4103 that complains about pragma pack in a header file */
#pragma warning(disable:4127) /* "conditional expression is constant" (needed for static_assert) */
#pragma warning(disable:4996) /* POSIX name is deprecated */
#elif defined __GNUC__
Expand Down
4 changes: 2 additions & 2 deletions source/amx/amxcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static cell AMX_NATIVE_CALL core_tolower(AMX *amx,const cell *params)
#endif
}

static cell AMX_NATIVE_CALL core_toupper(AMX *amx, const cell *params)
static cell AMX_NATIVE_CALL core_toupper(AMX *amx,const cell *params)
{
(void)amx;
#if (defined __WIN32__ || defined _WIN32 || defined WIN32) && !defined _WIN64
Expand Down Expand Up @@ -347,7 +347,7 @@ static cell AMX_NATIVE_CALL getproperty(AMX *amx,const cell *params)
/* if list_finditem() found the value, store the name */
if (item!=NULL && item->value==params[3] && strlen(name)==0) {
amx_GetAddr(amx,params[4],&cstr);
amx_SetString(cstr,item->name,1,0, UNLIMITED);
amx_SetString(cstr,item->name,1,0,UNLIMITED);
} /* if */
free(name);
return (item!=NULL) ? item->value : 0;
Expand Down
6 changes: 3 additions & 3 deletions source/amx/amxfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,15 +975,15 @@ static cell AMX_NATIVE_CALL n_flength(AMX *amx, const cell *params)
}

long l,c;
int fn = fileno(f);
int fn=fileno(f);
if (params[1]&FILE_WRITEABLE_BIT) {
/* writable, flush */
fflush(f);
#if defined __WIN32__
_commit(fn);
#endif
}
c=lseek(fn,0,SEEK_CUR);
c=lseek(fn,0,SEEK_CUR); /* save the current position */
l=lseek(fn,0,SEEK_END); /* return the file position at its end */
fseek(f,c,SEEK_SET); /* restore the file pointer */
(void)amx;
Expand Down Expand Up @@ -1073,7 +1073,7 @@ static cell AMX_NATIVE_CALL n_fexist(AMX *amx, const cell *params)
(void)amx;
amx_StrParam(amx,params[1],name);
if (name!=NULL && completename(fullname,name,sizearray(fullname))!=NULL)
r = !access(fullname, 0);
r = !access(fullname, 0);
return r;
}

Expand Down
1 change: 0 additions & 1 deletion source/amx/amxfloat.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ static cell AMX_NATIVE_CALL n_floatfract(AMX *amx,const cell *params)
* params[0] = number of bytes
* params[1] = float operand
*/

REAL fA = amx_ctof(params[1]);

if (fA >= 0.0)
Expand Down
165 changes: 83 additions & 82 deletions source/amx/amxstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,102 +515,103 @@ static cell AMX_NATIVE_CALL n_strdel(AMX *amx,const cell *params)
*/
static cell AMX_NATIVE_CALL n_strins(AMX* amx, const cell* params)
{
cell *cstr, *csub;
int index, lenstr, lensub, maxlen, count;
unsigned char* ptr;
cell c;
cell *cstr, *csub;
int index, lenstr, lensub, maxlen, count;
unsigned char* ptr;
cell c;

/* calculate number of cells needed for (packed) destination */
/* calculate number of cells needed for (packed) destination */

amx_GetAddr(amx, params[1],&cstr);
amx_GetAddr(amx, params[2],&csub);
amx_GetAddr(amx, params[1],&cstr);
amx_GetAddr(amx, params[2],&csub);

amx_StrLen(cstr, &lenstr);
amx_StrLen(csub, &lensub);
amx_StrLen(cstr, &lenstr);
amx_StrLen(csub, &lensub);

index = (int)params[3];
maxlen = (int)params[4];
index = (int)params[3];
maxlen = (int)params[4];

if ((ucell)*cstr > UNPACKEDMAX)
maxlen *= sizeof(cell);
if ((ucell)*cstr > UNPACKEDMAX)
maxlen *= sizeof(cell);

maxlen -= 1;
maxlen -= 1;

if (index < 0)
index = 0;
if (index < 0)
index = 0;

if (index > lenstr || index > maxlen)
return amx_RaiseError(amx, AMX_ERR_NATIVE);
if (index > lenstr || index > maxlen)
return amx_RaiseError(amx, AMX_ERR_NATIVE);

if (lenstr == 0) {
/* current string is empty (and the insertion point is zero), just make a copy */
if (lenstr == 0) {
assert(index == 0);
assert(index == 0);

if (lensub > maxlen)
lensub = maxlen;
if (lensub > maxlen)
lensub = maxlen;

if ((ucell)*csub > UNPACKEDMAX)
amx_StrPack(cstr, csub, lensub, 0);
else
amx_StrUnpack(cstr, csub, lensub);
return 1;
}

if (lenstr + lensub >= maxlen && index + lensub >= maxlen) {
int max_substr = maxlen - index;

if ((ucell)*cstr > UNPACKEDMAX) {
for (count = 0; count < max_substr; count++) {
c = extractchar(csub, count, 0);
ptr = packedptr(cstr, index + count);
*ptr = (unsigned char)c;
}
*(packedptr(cstr, maxlen)) = 0;
} else {
for (count = 0; count < max_substr; count++) {
c = extractchar(csub, count, 0);
cstr[index + count] = c;
}
cstr[maxlen] = 0;
}

return 1;
}

int final_len = lenstr + lensub; /* length after insertion */

if (final_len >= maxlen)
final_len = maxlen - 1;
if ((ucell)*csub > UNPACKEDMAX)
amx_StrPack(cstr, csub, lensub, 0);
else
amx_StrUnpack(cstr, csub, lensub);
return 1;
} /* if */

if (lenstr + lensub >= maxlen && index + lensub >= maxlen) {
int max_substr = maxlen - index;

if ((ucell)*cstr > UNPACKEDMAX) {
/* make room for the new characters */
for (count = final_len; count > index; count--) {
ptr = packedptr(cstr, count - lensub);
c = *ptr;
ptr = packedptr(cstr, count);
*ptr = (unsigned char)c;
}

/* copy in the new characters */
for (count = 0; count < lensub; count++) {
c = extractchar(csub, count, 0);
ptr = packedptr(cstr, index + count);
*ptr = (unsigned char)c;
}
*(packedptr(cstr, maxlen)) = 0;
for (count = 0; count < max_substr; count++) {
c = extractchar(csub, count, 0);
ptr = packedptr(cstr, index + count);
*ptr = (unsigned char)c;
} /* for */
*(packedptr(cstr, maxlen)) = 0;
} else {
/* make room for the new characters */
for (count = final_len; count > index; count--)
cstr[count] = cstr[count - lensub];

/* copy in the new characters */
for (count = 0; count < lensub; count++) {
c = extractchar(csub, count, 0);
cstr[index + count] = c;
}
cstr[maxlen] = 0;
}
for (count = 0; count < max_substr; count++) {
c = extractchar(csub, count, 0);
cstr[index + count] = c;
} /* for */
cstr[maxlen] = 0;
} /* if */

return 1;
} /* if */

int final_len = lenstr + lensub; /* length after insertion */

if (final_len >= maxlen)
final_len = maxlen - 1;

if ((ucell)*cstr > UNPACKEDMAX) {
/* make room for the new characters */
for (count = final_len; count > index; count--) {
ptr = packedptr(cstr, count - lensub);
c = *ptr;
ptr = packedptr(cstr, count);
*ptr = (unsigned char)c;
} /* for */

/* copy in the new characters */
for (count = 0; count < lensub; count++) {
c = extractchar(csub, count, 0);
ptr = packedptr(cstr, index + count);
*ptr = (unsigned char)c;
} /* for */
*(packedptr(cstr, maxlen)) = 0;
} else {
/* make room for the new characters */
for (count = final_len; count > index; count--)
cstr[count] = cstr[count - lensub];

/* copy in the new characters */
for (count = 0; count < lensub; count++) {
c = extractchar(csub, count, 0);
cstr[index + count] = c;
} /* for */
cstr[maxlen] = 0;
} /* if */

return 1;
}

/* strval(const string[], index=0)
Expand Down Expand Up @@ -997,8 +998,8 @@ static cell AMX_NATIVE_CALL n_memcpy(AMX *amx,const cell *params)
return 0;
amx_GetAddr(amx,params[1],&cdest);
amx_GetAddr(amx,params[2],&csrc);
pdest=(unsigned char*)cdest;
psrc=(unsigned char*)csrc+params[3];
pdest=(unsigned char*)cdest+params[3];
psrc=(unsigned char*)csrc;
memmove(pdest,psrc,params[4]);
return 1;
}
Expand Down