diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2018-04-09 00:41:28 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2018-04-09 15:56:14 +0000 |
commit | 04eb56f146a6c0395645aa2537d7c29f1e234069 (patch) | |
tree | 6b52c23abae8096589f355e48c59e4f77577f06f /src/gsm/a5.c | |
parent | 5a9dbf81a2fdefff860657a9f131c50f9d0ce25f (diff) |
add osmo_quote_str(),osmo_quote_str_buf() and test
Rationale: with osmo_escape_str(), you get the escaped contents of the string,
but not so graceful handling of NULL strings. The caller needs to quote it, and
for NULL strings not quote it.
osmo_quote_str() is like osmo_escape_str() but always quotes a non-NULL string,
and for a NULL string returns a literal NULL, i.e. it should (tm) give the
exact C representation of a string.
That's useful in testing, to show exactly what char* situation we have, without
jumping through hoops like
if (str)
printf("\"%s\"", osmo_escape_str(str, -1));
else
printf("NULL");
Copy the unit test for osmo_escape_str() and adjust. To indicate that the
double quotes are returned by osmo_quote_str(), use single quotes in the test
printf()s.
I considered allowing to pick the quoting characters by further arguments, but
that complicates things: we'd need to escape the quoting characters. Just
hardcode double quotes like C.
Change-Id: I6f1b3709b32c23fc52f70ad9ecc9439c62b02a12
Diffstat (limited to 'src/gsm/a5.c')
0 files changed, 0 insertions, 0 deletions