libdrgn: move string_builder_line_break() to string_builder.c

This commit is contained in:
Omar Sandoval 2019-07-11 15:27:36 -07:00
parent 0ebcfc8178
commit ce808440f7
3 changed files with 17 additions and 11 deletions

View File

@ -1040,17 +1040,6 @@ open_kernel_module_debug_info(struct drgn_program *prog,
return &drgn_stop;
}
/*
* Append a newline character if the string isn't empty and doesn't already end
* in a newline.
*/
static bool string_builder_line_break(struct string_builder *sb)
{
if (!sb->len || sb->str[sb->len - 1] == '\n')
return true;
return string_builder_appendc(sb, '\n');
}
static struct drgn_error *
open_loaded_kernel_modules(struct drgn_program *prog,
struct string_builder *missing_debug_info)

View File

@ -86,3 +86,10 @@ bool string_builder_appendf(struct string_builder *sb, const char *format, ...)
va_end(ap);
return ret;
}
bool string_builder_line_break(struct string_builder *sb)
{
if (!sb->len || sb->str[sb->len - 1] == '\n')
return true;
return string_builder_appendc(sb, '\n');
}

View File

@ -144,6 +144,16 @@ bool string_builder_appendf(struct string_builder *sb, const char *format, ...)
bool string_builder_vappendf(struct string_builder *sb, const char *format,
va_list ap);
/**
* Append a newline character to a @ref string_builder if the string isn't empty
* and doesn't already end in a newline.
*
* @param[in] sb String builder.
* @return @c true on success, @c false on error (if we couldn't allocate
* memory).
*/
bool string_builder_line_break(struct string_builder *sb);
/**
* Callback to append to a string later.
*