epics-modules / autosave

APS BCDA synApps module: autosave
https://epics-modules.github.io/autosave/
Other
8 stars 31 forks source link

Detect error in epicsStrPrintEscaped #52

Closed smarsching closed 1 year ago

smarsching commented 1 year ago

PR #29 introduced the use of epicsStrPrintEscaped so that line breaks in strings would be handled correctly. Unfortunately, this introduced a bug (#48) that would cause save attempts to fail when the string to be written was empty.

This bug was fixed with d1e46a23ddad4bf01281b06d65021ed4a788a409 and 3d69b3d9387bcaa4953d5a4d44bae636c5cfba46, but this introduced an issue where Autosave would assume success, even if epicsStrPrintEscaped failed to write anything, not because the string was empty, but because fprintf failed or some reason.

This commit reintroduces the check whether epicsStrPrintEscaped has written anything, but it now correctly handles the case where epicsStrPrintEscaped does not write anything because the string that it is supposed to write is empty.