This function determines ascii string length ending by space. search restricted to MaxLen, for example iStrLen("ABC ", 20) == 3 if MaxLen=0 then as usual strlen but bugless
| 231 | // iStrLen("ABC ", 20) == 3 |
| 232 | // if MaxLen=0 then as usual strlen but bugless |
| 233 | UINTN iStrLen(CONST CHAR8* String, UINTN MaxLen) |
| 234 | { |
| 235 | UINTN Len = 0; |
| 236 | CONST CHAR8* BA; |
| 237 | if(MaxLen > 0) { |
| 238 | for (Len=0; Len<MaxLen; Len++) { |
| 239 | if (String[Len] == 0) { |
| 240 | break; |
| 241 | } |
| 242 | } |
| 243 | BA = &String[Len - 1]; |
| 244 | while ((Len != 0) && ((*BA == ' ') || (*BA == 0))) { |
| 245 | BA--; Len--; |
| 246 | } |
| 247 | } else { |
| 248 | BA = String; |
| 249 | while(*BA){BA++; Len++;} |
| 250 | } |
| 251 | return Len; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | // Internal functions for flat SMBIOS |
no outgoing calls
no test coverage detected