diff --git a/include/file.inc b/include/file.inc index 00ca635f..08b93f91 100644 --- a/include/file.inc +++ b/include/file.inc @@ -30,6 +30,9 @@ native File: fopen(const name[], filemode: mode = io_readwrite); native bool: fclose(File: handle); native File: ftemp(); native bool: fremove(const name[]); +native bool: fcopy(const source[], const target[]); +native bool: frename(const oldname[], const newname[]); +native bool: fcreatedir(const name[]); native fwrite(File: handle, const string[]); native fread(File: handle, string[], size = sizeof string, bool: pack = false); @@ -42,3 +45,12 @@ native fseek(File: handle, position = 0, seek_whence: whence = seek_start) native flength(File: handle); native fexist(const pattern[]); native bool: fmatch(name[], const pattern[], index = 0, size = sizeof name); +native bool: fstat(name[], &size = 0, ×tamp = 0, &mode = 0, &inode = 0); +native bool: fattrib(const name[], timestamp=0, attrib=0x0f); +native filecrc(const name[]); + +native readcfg(const filename[]="", const section[]="", const key[], value[], size=sizeof value, const defvalue[]="", bool:pack=false); +native readcfgvalue(const filename[]="", const section[]="", const key[], defvalue=0); +native bool: writecfg(const filename[]="", const section[]="", const key[], const value[]); +native bool: writecfgvalue(const filename[]="", const section[]="", const key[], value); +native bool: deletecfg(const filename[]="", const section[]="", const key[]=""); diff --git a/include/string.inc b/include/string.inc index c1814aa2..5dcba800 100644 --- a/include/string.inc +++ b/include/string.inc @@ -12,6 +12,7 @@ native strlen(const string[]); native strpack(dest[], const source[], maxlength=sizeof dest); native strunpack(dest[], const source[], maxlength=sizeof dest); +native strcopy(dest[], const source[], maxlength=sizeof dest); native strcat(dest[], const source[], maxlength=sizeof dest); native strmid(dest[], const source[], start=0, end=cellmax, maxlength=sizeof dest); @@ -32,4 +33,4 @@ native uuencode(dest[], const source[], numbytes, maxlength=sizeof dest); native memcpy(dest[], const source[], index=0, numbytes, maxlength=sizeof dest); stock bool: strequal(const string1[], const string2[], bool:ignorecase=false, length=cellmax) - return strcmp(string1, string2, ignorecase, length) == 0 + return strcmp(string1, string2, ignorecase, length) == 0; diff --git a/include/time.inc b/include/time.inc index 0dbf775c..e8ecf756 100644 --- a/include/time.inc +++ b/include/time.inc @@ -13,7 +13,9 @@ native gettime(&hour=0, &minute=0, &second=0); native settime(hour=cellmin, minute=cellmin, second=cellmin); native getdate(&year=0, &month=0, &day=0); native setdate(year=cellmin, month=cellmin, day=cellmin); + native settimestamp(seconds1970); +native cvttimestamp(seconds1970, &year=0, &month=0, &day=0, &hour=0, &minute=0, &second=0); native settimer(milliseconds, bool: singleshot=false); native tickcount(&granularity=0); diff --git a/readme.md b/readme.md index 240e2d13..64e4c849 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/source/amx/amx.c b/source/amx/amx.c index 9bfd1d48..6f5ddb8a 100644 --- a/source/amx/amx.c +++ b/source/amx/amx.c @@ -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); @@ -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; ivalue==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; diff --git a/source/amx/amxfile.c b/source/amx/amxfile.c index 5b49ba72..ef5e91ba 100644 --- a/source/amx/amxfile.c +++ b/source/amx/amxfile.c @@ -664,7 +664,7 @@ static cell AMX_NATIVE_CALL n_fwrite(AMX *amx, const cell *params) if ((ucell)*cptr>UNPACKEDMAX) { /* the string is packed, write it as an ASCII/ANSI string */ if ((str=(char*)alloca(len + 1))!=NULL) { - amx_GetString(str,cptr,0,len); + amx_GetString(str,cptr,0,len+1); r=fputs(str,f); } /* if */ } else { @@ -975,7 +975,7 @@ 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); @@ -983,7 +983,7 @@ static cell AMX_NATIVE_CALL n_flength(AMX *amx, const cell *params) _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; @@ -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; } diff --git a/source/amx/amxfloat.c b/source/amx/amxfloat.c index 1571dcf8..e246a708 100644 --- a/source/amx/amxfloat.c +++ b/source/amx/amxfloat.c @@ -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) @@ -290,7 +289,7 @@ static cell AMX_NATIVE_CALL n_floatsin(AMX *amx,const cell *params) */ REAL fA = amx_ctof(params[1]); fA = ToRadians(fA, params[2]); - fA = (float)sin(fA); + fA = (REAL)sin(fA); (void)amx; return amx_ftoc(fA); } @@ -305,7 +304,7 @@ static cell AMX_NATIVE_CALL n_floatcos(AMX *amx,const cell *params) */ REAL fA = amx_ctof(params[1]); fA = ToRadians(fA, params[2]); - fA = (float)cos(fA); + fA = (REAL)cos(fA); (void)amx; return amx_ftoc(fA); } @@ -320,7 +319,7 @@ static cell AMX_NATIVE_CALL n_floattan(AMX *amx,const cell *params) */ REAL fA = amx_ctof(params[1]); fA = ToRadians(fA, params[2]); - fA = (float)tan(fA); + fA = (REAL)tan(fA); (void)amx; return amx_ftoc(fA); } diff --git a/source/amx/amxstring.c b/source/amx/amxstring.c index d7d50b8f..19a9d910 100644 --- a/source/amx/amxstring.c +++ b/source/amx/amxstring.c @@ -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) @@ -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; }