X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=registry.cpp;h=2b111c346dfe7355ec7b8d4b36f77b2f7569e09b;hb=d25f6e7c829d492a1cb62a877ceb999efcd2a128;hp=1e801ee06dfd7253e7a518a80f97016b34c1208d;hpb=5380a4a53d9b34d6c56ef3e8a022fcdc184593a3;p=nssm.git diff --git a/registry.cpp b/registry.cpp index 1e801ee..2b111c3 100644 --- a/registry.cpp +++ b/registry.cpp @@ -392,6 +392,27 @@ int unformat_double_null(TCHAR *dn, unsigned long dnlen, TCHAR **unformatted, un } for (i = 0; i < dnlen; i++) if (dn[i] != _T('\r')) ++*newlen; + + /* Skip blank lines. */ + for (i = 0; i < dnlen; i++) { + if (dn[i] == _T('\r') && dn[i + 1] == _T('\n')) { + /* This is the last CRLF. */ + if (i >= dnlen - 2) break; + + /* + Strip at the start of the block or if the next characters are + CRLF too. + */ + if (! i || (dn[i + 2] == _T('\r') && dn[i + 3] == _T('\n'))) { + for (j = i + 2; j < dnlen; j++) dn[j - 2] = dn[j]; + dn[dnlen--] = _T('\0'); + dn[dnlen--] = _T('\0'); + i--; + --*newlen; + } + } + } + /* Must end with two NULLs. */ *newlen += 2;