mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2025-06-07 08:14:48 +00:00
Added StrReplace(). Not heavily tested
This commit is contained in:
parent
ce63335991
commit
c7a04c4ee7
Binary file not shown.
@ -135,7 +135,7 @@ $FG,2$Merge(\"C:/*\",\"D:/*\",\"+r+d\");$FG$ to check my changes.
|
|||||||
|
|
||||||
* You can use $FG,2$<CTRL-SHIFT-L>$FG$ to do a check for compile errors.
|
* You can use $FG,2$<CTRL-SHIFT-L>$FG$ to do a check for compile errors.
|
||||||
|
|
||||||
* You can use $LK,"DocOpt",A="MN:DocOpt"$() to optimize links. (Mostly just removes )
|
* You can use $LK,"DocOpt",A="MN:DocOpt"$() to optimize links.
|
||||||
|
|
||||||
* With $FG,2$start$FG$/$FG,2$end$FG$, common trailing code is fast. Common leading code is slow.$FG$
|
* With $FG,2$start$FG$/$FG,2$end$FG$, common trailing code is fast. Common leading code is slow.$FG$
|
||||||
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
g
|
@ -232,30 +232,3 @@ SMBIOSInit;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
If you are sure a fun won't be called
|
If you are sure a fun won't be called before import is resolved, you can use
|
||||||
before import is resolved, you can use
|
"import". Otherwise, use a fun pointer var and check it before calling.
|
||||||
"import". Otherwise, use a fun pointer
|
|
||||||
var and check it before calling.
|
|
||||||
*/
|
*/
|
||||||
import U0 ClassRep(U8 *_d,U8 *class_name=lastclass,
|
import U0 ClassRep(U8 *_d,U8 *class_name=lastclass,
|
||||||
I64 max_depth=2,Bool u8_chars=FALSE,Bool fun=FALSE,I64 offset=0);
|
I64 max_depth=2,Bool u8_chars=FALSE,Bool fun=FALSE,I64 offset=0);
|
||||||
@ -48,6 +46,7 @@ extern Bool FAT32DirNew(CDrive *drive,U8 *cur_dir,CDirEntry *tmpde,
|
|||||||
extern Bool FAT32FileFind(CDrive *drive,I64 cur_dir_clus,U8 *name,
|
extern Bool FAT32FileFind(CDrive *drive,I64 cur_dir_clus,U8 *name,
|
||||||
CDirEntry *_res,I64 fuf_flags=0);
|
CDirEntry *_res,I64 fuf_flags=0);
|
||||||
extern U0 FAT32Init(CDrive *drive);
|
extern U0 FAT32Init(CDrive *drive);
|
||||||
|
extern U0 Free(U8 *addr);
|
||||||
extern Bool FBlkRead(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 count=1);
|
extern Bool FBlkRead(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 count=1);
|
||||||
extern Bool FBlkWrite(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 count=1);
|
extern Bool FBlkWrite(CFile *f,U8 *buf,I64 blk=FFB_NEXT_BLK,I64 count=1);
|
||||||
extern U0 FClose(CFile *f);
|
extern U0 FClose(CFile *f);
|
||||||
|
@ -1681,6 +1681,7 @@ public class CAutoCompleteDictGlobals
|
|||||||
#define OPTf_NO_BUILTIN_CONST 10 //Applied to funs, not statements
|
#define OPTf_NO_BUILTIN_CONST 10 //Applied to funs, not statements
|
||||||
#define OPTf_USE_IMM64 11 //Not completely implemented
|
#define OPTf_USE_IMM64 11 //Not completely implemented
|
||||||
#define OPTf_DECIMAL_ONLY 12 //Only allow decimal numbers (no 0x or 0b prefixed numbers)
|
#define OPTf_DECIMAL_ONLY 12 //Only allow decimal numbers (no 0x or 0b prefixed numbers)
|
||||||
|
#define OPTf_NO_FLOATS 13 //No floating point numbers allowed
|
||||||
|
|
||||||
#define OPTF_ECHO (1<<OPTf_ECHO)
|
#define OPTF_ECHO (1<<OPTf_ECHO)
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ public extern U8 *StrFirstRemove(U8 *src,U8 *marker,U8 *dst=NULL);
|
|||||||
public _extern _STRICOMPARE I64 StrICompare(U8 *st1,U8 *st2);
|
public _extern _STRICOMPARE I64 StrICompare(U8 *st1,U8 *st2);
|
||||||
public _extern _STRIMATCH U8 *StrIMatch(U8 *needle,U8 *haystack_str);
|
public _extern _STRIMATCH U8 *StrIMatch(U8 *needle,U8 *haystack_str);
|
||||||
public extern U8 *StrLastOcc(U8 *src,U8 *marker);
|
public extern U8 *StrLastOcc(U8 *src,U8 *marker);
|
||||||
|
public extern U8 *StrReplace(U8 *str, U8 *old, U8 *new, I64 sff_flags=NONE);
|
||||||
public extern U8 *StrLastRemove(U8 *src,U8 *marker,U8 *dst=NULL);
|
public extern U8 *StrLastRemove(U8 *src,U8 *marker,U8 *dst=NULL);
|
||||||
public _extern _STRMATCH U8 *StrMatch(U8 *needle,U8 *haystack_str);
|
public _extern _STRMATCH U8 *StrMatch(U8 *needle,U8 *haystack_str);
|
||||||
public _extern _STRNCOMPARE I64 StrNCompare(U8 *st1,U8 *st2,I64 n);
|
public _extern _STRNCOMPARE I64 StrNCompare(U8 *st1,U8 *st2,I64 n);
|
||||||
|
@ -641,6 +641,24 @@ U8 *StrFind(U8 *needle,U8 *haystack_str,I64 flags=0)
|
|||||||
return haystack_str;
|
return haystack_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
U8 *StrReplace(U8 *str, U8 *old, U8 *new, I64 sff_flags=NONE)
|
||||||
|
{//Replace all instances of old with new in str. New MAlloc()ed string.
|
||||||
|
if (!*old)
|
||||||
|
return new;
|
||||||
|
|
||||||
|
U8 *str_start, *str_end, *str_loc, *tmpm = NULL;
|
||||||
|
while (str_loc = str_end = StrFind(old, str, sff_flags))
|
||||||
|
{
|
||||||
|
str_start = str;
|
||||||
|
str_end += StrLen(old); //Move start marker past old str, cutting it out
|
||||||
|
str_start[StrLen(str_start) - StrLen(str_loc)] = '\0'; //End str_start right before where old was
|
||||||
|
Free(tmpm);
|
||||||
|
tmpm = MStrPrint("%s%s%s", str_start, new, str_end);
|
||||||
|
str = tmpm;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
Bool WildMatch(U8 *test_str,U8 *wild_str)
|
Bool WildMatch(U8 *test_str,U8 *wild_str)
|
||||||
{//Wildcard match with '*' and '?'.
|
{//Wildcard match with '*' and '?'.
|
||||||
I64 ch1,ch2;
|
I64 ch1,ch2;
|
||||||
|
@ -263,7 +263,7 @@ public I64 FR(U8 *text_to_replace, U8 *new_text, U8 *files_find_mask="/*",
|
|||||||
//FR("Gr", "Graphics", "/Zenith/Gr/*");
|
//FR("Gr", "Graphics", "/Zenith/Gr/*");
|
||||||
CDirEntry *files, *files_head;
|
CDirEntry *files, *files_head;
|
||||||
I64 i, count = 0, fuf_flags = 0;
|
I64 i, count = 0, fuf_flags = 0;
|
||||||
U8 *str_loc, *name_start, *tmp_name, *name_end, *new_path;
|
U8 *tmp_name, *new_path;
|
||||||
Bool all_flag = FALSE;
|
Bool all_flag = FALSE;
|
||||||
|
|
||||||
ScanFlags(&fuf_flags, Define("ST_FILE_UTIL_FLAGS"), "+r+f+F");
|
ScanFlags(&fuf_flags, Define("ST_FILE_UTIL_FLAGS"), "+r+f+F");
|
||||||
@ -273,15 +273,11 @@ public I64 FR(U8 *text_to_replace, U8 *new_text, U8 *files_find_mask="/*",
|
|||||||
|
|
||||||
while (files)
|
while (files)
|
||||||
{
|
{
|
||||||
if (name_end = str_loc = StrFind(text_to_replace, files->name, sff_flags))
|
if (StrFind(text_to_replace, files->name, sff_flags))
|
||||||
{
|
{
|
||||||
PutFileLink(files->full_name);
|
PutFileLink(files->full_name);
|
||||||
name_start = files->name;
|
|
||||||
' -> ';
|
' -> ';
|
||||||
name_end += StrLen(text_to_replace); //Cut out the old text
|
tmp_name = StrReplace(files->name, text_to_replace, new_text, sff_flags);
|
||||||
name_start[StrLen(name_start) - StrLen(str_loc)] = '\0'; //End the name_start right before where the old text was
|
|
||||||
|
|
||||||
tmp_name = MStrPrint("%s%s%s", name_start, new_text, name_end);
|
|
||||||
new_path = MStrPrint("%s/%s", DirFile(files->full_name), tmp_name);
|
new_path = MStrPrint("%s/%s", DirFile(files->full_name), tmp_name);
|
||||||
PutFileLink(new_path);
|
PutFileLink(new_path);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user