|
@@ -120,6 +120,18 @@ HL_PRIM int hl_bytes_find( vbyte *where, int pos, int len, vbyte *which, int wpo
|
|
|
return (int)(size_t)(found - where);
|
|
|
}
|
|
|
|
|
|
+HL_PRIM int hl_bytes_rfind( vbyte *where, int len, vbyte *which, int wlen ) {
|
|
|
+ if( wlen > len ) return -1;
|
|
|
+ if( wlen == 0 ) return len; // at end
|
|
|
+ int pos = len - wlen;
|
|
|
+ while( pos > 0 ) {
|
|
|
+ if( memcmp(where+pos,which,wlen) == 0 )
|
|
|
+ return pos;
|
|
|
+ pos--;
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
HL_PRIM void hl_bytes_fill( vbyte *bytes, int pos, int len, int value ) {
|
|
|
memset(bytes+pos,value,len);
|
|
|
}
|
|
@@ -226,6 +238,7 @@ DEFINE_PRIM(_VOID,bytes_blit,_BYTES _I32 _BYTES _I32 _I32);
|
|
|
DEFINE_PRIM(_I32,bytes_compare,_BYTES _I32 _BYTES _I32 _I32);
|
|
|
DEFINE_PRIM(_I32,string_compare,_BYTES _BYTES _I32);
|
|
|
DEFINE_PRIM(_I32,bytes_find,_BYTES _I32 _I32 _BYTES _I32 _I32);
|
|
|
+DEFINE_PRIM(_I32,bytes_rfind,_BYTES _I32 _BYTES _I32);
|
|
|
DEFINE_PRIM(_VOID,bytes_fill,_BYTES _I32 _I32 _I32);
|
|
|
DEFINE_PRIM(_F64, parse_float,_BYTES _I32 _I32);
|
|
|
DEFINE_PRIM(_NULL(_I32), parse_int, _BYTES _I32 _I32);
|