Created
November 12, 2009 19:03
-
-
Save stepancheg/233188 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t find_newline(const char* ptr, size_t len) { | |
size_t i = 0; | |
while (i < len) { | |
if (ptr[i] == '\n') | |
return i + 1; | |
if (ptr[i] == '\r') { | |
if (i + 1 < len && ptr[i + 1] == '\n') | |
return i + 2; | |
else | |
return i + 1; | |
} | |
++i; | |
} | |
return i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment