forked from xt-sys/exectos
Add explanatory comments to string handling code
This commit is contained in:
parent
e23a4c71a2
commit
3c25934495
@ -327,27 +327,38 @@ RtlStringToWideString(OUT PWCHAR Destination,
|
|||||||
PCHAR LocalSource = *Source;
|
PCHAR LocalSource = *Source;
|
||||||
SIZE_T Count = Length;
|
SIZE_T Count = Length;
|
||||||
|
|
||||||
|
/* Check if NULL pointer passed */
|
||||||
if(Destination == NULL)
|
if(Destination == NULL)
|
||||||
{
|
{
|
||||||
|
/* No wide characters written */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Iterate through the string */
|
||||||
while(Count)
|
while(Count)
|
||||||
{
|
{
|
||||||
|
/* Copy character */
|
||||||
if((*Destination = *LocalSource) == 0)
|
if((*Destination = *LocalSource) == 0)
|
||||||
{
|
{
|
||||||
|
/* End of string reached */
|
||||||
LocalSource = NULL;
|
LocalSource = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if character is valid */
|
||||||
if(*Destination >= 0x80)
|
if(*Destination >= 0x80)
|
||||||
{
|
{
|
||||||
|
/* Invalid character, return error */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Advance pointers */
|
||||||
LocalSource++;
|
LocalSource++;
|
||||||
Destination++;
|
Destination++;
|
||||||
Count--;
|
Count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return number of wide characters written */
|
||||||
return Length - Count;
|
return Length - Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,14 +410,18 @@ RtlTokenizeString(IN PCHAR String,
|
|||||||
Span = (PCHAR)Delimiter;
|
Span = (PCHAR)Delimiter;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
/* Check if delimiter found */
|
||||||
if((SpanChar = *Span++) == Char)
|
if((SpanChar = *Span++) == Char)
|
||||||
{
|
{
|
||||||
|
/* Check if end of string reached */
|
||||||
if(Char == '\0')
|
if(Char == '\0')
|
||||||
{
|
{
|
||||||
|
/* End of string reached, no more tokens */
|
||||||
String = NULL;
|
String = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* Terminate token */
|
||||||
String[-1] = '\0';
|
String[-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user