Idx already contains the length of the string
authorColin Finck <colin@reactos.org>
Sat, 19 Apr 2008 23:57:44 +0000 (23:57 +0000)
committerColin Finck <colin@reactos.org>
Sat, 19 Apr 2008 23:57:44 +0000 (23:57 +0000)
Just loop and remove all newline & line feed characters from the right instead of doing this with 8 strlen calls

svn path=/trunk/; revision=33042

reactos/boot/freeldr/freeldr/inifile/parse.c

index 531125a..2435713 100644 (file)
@@ -232,10 +232,8 @@ ULONG IniGetNextLine(PCHAR IniFileData, ULONG IniFileSize, PCHAR Buffer, ULONG B
        Buffer[Idx] = '\0';
 
        // Get rid of newline & linefeed characters (if any)
-       if(strlen(Buffer) && ((Buffer[strlen(Buffer)-1] == '\n') || (Buffer[strlen(Buffer)-1] == '\r')))
-               Buffer[strlen(Buffer)-1] = '\0';
-       if(strlen(Buffer) && ((Buffer[strlen(Buffer)-1] == '\n') || (Buffer[strlen(Buffer)-1] == '\r')))
-               Buffer[strlen(Buffer)-1] = '\0';
+       while(Idx && (Buffer[--Idx] == '\n' || Buffer[Idx] == '\r'))
+               Buffer[Idx] = '\0';
 
        // Send back new offset
        return CurrentOffset;