db_updater: Put parentheses back
[merlin.git] / string_utils.c
blob20778048b70400f40c62602937e163abcd41ded6
1 #include <stddef.h>
3 int unescape_newlines(char *dest, const char *src, size_t n) {
4 int i = 0, j = 0;
5 while (i < n) {
6 if (i == n - 1) {
7 /* last byte is \, next invalid read contains n -> don't read the n */
8 dest[j] = src[i];
10 else if (src[i] == '\\' && src[i+1] == 'n' ) {
11 ++i;
12 dest[j] = '\n';
14 else if (src[i] == '\\' && src[i+1] == '\\') {
15 dest[j] = src[++i];
17 else {
18 dest[j] = src[i];
20 ++j;
21 ++i;
23 return j;