mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Refactor various hex escaping code.
This commit is contained in:
parent
80d7a1482c
commit
e8a5ea8844
7 changed files with 102 additions and 60 deletions
|
@ -335,10 +335,10 @@ bool Ascii::DoWrite(int num_fields, const Field* const * fields,
|
|||
if ( strncmp(bytes, meta_prefix.data(), meta_prefix.size()) == 0 )
|
||||
{
|
||||
// It would so escape the first character.
|
||||
char buf[16];
|
||||
snprintf(buf, sizeof(buf), "\\x%02x", bytes[0]);
|
||||
char hex[4] = {'\\', 'x', '0', '0'};
|
||||
bytetohex(bytes[0], hex + 2);
|
||||
|
||||
if ( ! safe_write(fd, buf, strlen(buf)) )
|
||||
if ( ! safe_write(fd, hex, 4) )
|
||||
goto write_error;
|
||||
|
||||
++bytes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue