<p>neels <strong>uploaded patch set #4</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/16160">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add osmo_escape_cstr and osmo_quote_cstr<br><br>Provide string escaping that<br>- returns the required buffer size, so it can be used with OSMO_STRBUF_APPEND().<br>- uses C compatible string constant escaping sequences.<br><br>This is intended as a replacement for all previous osmo_escape_str* and<br>osmo_quote_str* API. It pains me that I didn't get them right the first nor the<br>second time:<br>- The buffer functions do not return the chars needed, which is required for<br>  allocating sufficient memory in the *_c versions of the functions.<br>- Because of that, these functions are accurately usable for<br>  OSMO_STRBUF_APPEND(), producing truncated strings, for example when dumping a<br>  GSUP message.<br>- They do not use the C equivalent string constant escaping: for some reason I<br>  thought "\15" would be valid, but it should be "\x0f".<br>If I could, I would completely drop those mislead implementations ... but<br>backwards compat prohibits that.<br><br>A previous patch already provided internal static functions that accurately<br>return the required buffer size. Enhance these to also support C compatible<br>string escaping, and use them as implementation of the new functions:<br><br>osmo_escape_cstr_buf()<br>osmo_escape_cstr_c()<br>osmo_quote_cstr_buf()<br>osmo_quote_cstr_c()<br><br>In the tests for these, also test C string equivalence.<br><br>Naming: from API versions, it would be kind of logical to call them<br>osmo_escape_str_buf3() and osmo_escape_str_c2(). Since these anyway return a<br>different escaping, it makes sense to me to have distinct names instead.<br><br>Quasi missing are variants of the non-C-compatible weird legacy escaping that<br>return the required buffer size, but I refrain from adding those, because we<br>have enough API cruft as it is. Just always use these new cstr variants.<br><br>Change-Id: I3dfb892036e01000033dd8e7e4a6a0c32a3caa9b<br>---<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>4 files changed, 301 insertions(+), 21 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/16160/4</pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/16160">change 16160</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/c/libosmocore/+/16160"/><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-Change-Id: I3dfb892036e01000033dd8e7e4a6a0c32a3caa9b </div>
<div style="display:none"> Gerrit-Change-Number: 16160 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>