Full_Name: Thomas Cort Version: HEAD OS: 10.10.3 URL: ftp://ftp.openldap.org/incoming/ Submission from: (NULL) (96.46.34.154)
ldapsearch outputs LDAP results in a loop. The LDIF separator isn't printed after the result is printed. It's printed before the next result is printed. This subtlety causes a problem for a program consuming the output of a persistent ldapsearch (-Esync=rp). It has no way of knowing the current result has been fully output until the separator is printed (when the next result comes in), which could take a long time if there are no changes going on.
I think the newline should be printed at the end of the for-loop (after the result is printed), not at the beginning (when the next result is received).
I tried moving the putchar('\n') to the end of the for-loop. The output is the same for some simple searches I tried and the test suite passes. I'm hesitant to submit that as a patch because I think there might be some subtle edge cases I haven't hit where an extra newline would be inserted or omitted. Any ideas from someone who understands the code?