* pg_strip_crlf -- Remove any trailing newline and carriage return * * Removes any trailing newline and carriage return characters (\r on * Windows) in the input string, zero-terminating it. * * The passed in string must be zero-terminated. This function returns * the new length of the string. */
| 118 | * the new length of the string. |
| 119 | */ |
| 120 | int |
| 121 | pg_strip_crlf(char *str) |
| 122 | { |
| 123 | int len = strlen(str); |
| 124 | |
| 125 | while (len > 0 && (str[len - 1] == '\n' || |
| 126 | str[len - 1] == '\r')) |
| 127 | str[--len] = '\0'; |
| 128 | |
| 129 | return len; |
| 130 | } |
no outgoing calls
no test coverage detected