StrUtils
Because some examples already uses this functions may be it will be useful to add them to StrUtils?
/*
/ Pads string to right with specific character
/ $src -- pointer to string
/ $len -- length of result string
/ $fil -- specified padding character
/ Copyright (c) 0CodErr, KolibriOS team
*/
#set frame off;
function RPadStr(char* src; sysword len; char fil) {
gp_ax = src; gp_ax--;
repeat {gp_ax++;} until (byte[gp_ax] == 0)
gp_cx = len; gp_cx -= gp_ax; gp_cx += src;
dl = fil;
repeat if ([sysint]gp_cx > 0) {
byte[gp_ax] = dl;
gp_ax++; gp_cx--;
} until (gp_cx == 0)
byte[gp_ax] = 0;
return src;
}
#set frame on;
/*
/ Pads string to left with specific character
/ $src -- pointer to string
/ $len -- length of result string
/ $fil -- specified padding character
/ Copyright (c) 0CodErr, KolibriOS team
*/
#set frame off;
function LPadStr(char* src; sysword len; char fil) {
gp_ax = src; gp_ax--;
repeat {gp_ax++;} until (byte[gp_ax] == 0)
gp_cx = len; gp_cx -= gp_ax; gp_cx += src;
if ([sysint]gp_cx > 0) {
using gp_cx {
gp_cx += gp_ax;
repeat {
dl = byte[gp_ax]; byte[gp_cx] = dl;
gp_ax--; gp_cx--;
} until (gp_ax < src)
}
gp_ax++;
dl = fil;
repeat {
byte[gp_ax] = dl;
gp_ax++; gp_cx--;
} until (gp_cx == 0)
}
return src;
}
#set frame on;