<p>Neels Hofmeyr <strong>uploaded patch set #3</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/13573">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add osmo_{escape,quote}_str_buf2() for standard args ordering<br><br>To be able to append an escaped or quoted string using<br>OSMO_STRBUF_APPEND_NOLEN(), the function signature must have the buf and len as<br>first args, like most other *_buf() functions.<br><br>Add osmo_escape_str_buf2() and osmo_quote_str_buf2() to match this signature.<br><br>A recent patch [1] has changed the return value of osmo_escape_str_buf() to<br>char*, removing the const. However, the functions may return const strings,<br>hence re-add the const. The new signatures always return the non-const buffer.<br><br>To avoid code duplication, implement osmo_quote_str_buf() and<br>osmo_escape_str_buf() by calling the new functions.<br><br>I decided to allow slight changes to the behavior for current osmo_escape_str()<br>and osmo_escape_str_buf(), because impact on callers is minimal:<br><br>(1) The new implementation uses OSMO_STRBUF_*, and in consequence<br>osmo_quote_str() no longer prints an ending double quote after truncated<br>strings; Before, a truncated output was, sic:<br>  "this string is trunca"<br>and now this becomes, sic:<br>  "this string is truncat<br>I decided to not keep the old behavior because it is questionable to begin<br>with. It looks like the string actually ended at the truncation boundary<br>instead of the reason being not enough space in the output buffer.<br><br>(2) The new osmo_escape_str_buf2() function obviously cannot pass-thru an<br>unchanged char* if no escaping was needed. Sacrifice this tiny optimization<br>feature to avoid code duplication:<br>- it is an unnoticeable optimization,<br>- the caller anyway always passes a string buffer,<br>- the feature caused handling strings and buffers differently depending on<br>  their content (i.e. code that usually writes out strings in full length<br>  "suddenly" truncates because a non-printable character is contained, etc.)<br>I considered adding a skip_if_unescaped flag to the osmo_quote_str_buf2()<br>function signature, but in the end decided that the API clutter is not worth<br>having for all the above reasons.<br><br>Adjust tests to accomodate above changes.<br><br>[1] 4a62eda225ab7f3c9556990c81a6fc5e19b5eec8<br>    Ibf85f79e93244f53b2684ff6f1095c5b41203e05<br><br>Change-Id: Id748b906b0083b1f1887f2be7a53cae705a8a9ae<br>---<br>M TODO-RELEASE<br>M include/osmocom/core/utils.h<br>M src/utils.c<br>M tests/utils/utils_test.c<br>M tests/utils/utils_test.ok<br>5 files changed, 115 insertions(+), 47 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/13573/3</pre><p>To view, visit <a href="https://gerrit.osmocom.org/13573">change 13573</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13573"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>
<div style="display:none"> Gerrit-Change-Id: Id748b906b0083b1f1887f2be7a53cae705a8a9ae </div>
<div style="display:none"> Gerrit-Change-Number: 13573 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: Harald Welte <laforge@gnumonks.org> </div>