Add explanatory comments to string handling code
All checks were successful
Builds / ExectOS (i686, debug) (push) Successful in 29s
Builds / ExectOS (amd64, release) (push) Successful in 32s
Builds / ExectOS (amd64, debug) (push) Successful in 33s
Builds / ExectOS (i686, release) (push) Successful in 32s

This commit is contained in:
Aiken Harris 2025-09-02 19:31:13 +02:00
parent e23a4c71a2
commit 3c25934495
Signed by: harraiken
GPG Key ID: C40F06CB7493C1F5

View File

@ -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';
} }