[ostree] admin: Extract ot_admin_join_config_lines() helper function
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] admin: Extract ot_admin_join_config_lines() helper function
- Date: Tue, 20 Aug 2013 17:05:06 +0000 (UTC)
commit cf14b398da3a28eb8d13d5fb1ca88a489a5df000
Author: Javier Martinez Canillas <javier martinez collabora co uk>
Date: Tue Aug 20 17:54:59 2013 +0200
admin: Extract ot_admin_join_config_lines() helper function
ot-bootloader-syslinux.c has a join_lines() function that is rather
generic and can be used in other places. Let's add it as a helper
function.
Signed-off-by: Javier Martinez Canillas <javier martinez collabora co uk>
https://bugzilla.gnome.org/show_bug.cgi?id=706370
src/ostree/ot-admin-functions.h | 2 ++
src/ostree/ot-admin-util.c | 24 ++++++++++++++++++++++++
src/ostree/ot-bootloader-syslinux.c | 26 +-------------------------
3 files changed, 27 insertions(+), 25 deletions(-)
---
diff --git a/src/ostree/ot-admin-functions.h b/src/ostree/ot-admin-functions.h
index a771472..61f8b23 100644
--- a/src/ostree/ot-admin-functions.h
+++ b/src/ostree/ot-admin-functions.h
@@ -38,6 +38,8 @@ gboolean ot_admin_util_get_devino (GFile *path,
GCancellable *cancellable,
GError **error);
+char *ot_admin_join_lines (GPtrArray *lines);
+
gboolean ot_admin_parse_deploy_path_name (const char *name,
char **out_csum,
int *out_serial,
diff --git a/src/ostree/ot-admin-util.c b/src/ostree/ot-admin-util.c
index affe6db..4a05578 100644
--- a/src/ostree/ot-admin-util.c
+++ b/src/ostree/ot-admin-util.c
@@ -75,3 +75,27 @@ ot_admin_util_get_devino (GFile *path,
out:
return ret;
}
+
+char *
+ot_admin_join_lines (GPtrArray *lines)
+{
+ GString *buf = g_string_new ("");
+ guint i;
+ gboolean prev_was_empty = FALSE;
+
+ for (i = 0; i < lines->len; i++)
+ {
+ const char *line = lines->pdata[i];
+ /* Special bit to remove extraneous empty lines */
+ if (*line == '\0')
+ {
+ if (prev_was_empty || i == 0)
+ continue;
+ else
+ prev_was_empty = TRUE;
+ }
+ g_string_append (buf, line);
+ g_string_append_c (buf, '\n');
+ }
+ return g_string_free (buf, FALSE);
+}
diff --git a/src/ostree/ot-bootloader-syslinux.c b/src/ostree/ot-bootloader-syslinux.c
index 27eae45..790db09 100644
--- a/src/ostree/ot-bootloader-syslinux.c
+++ b/src/ostree/ot-bootloader-syslinux.c
@@ -104,30 +104,6 @@ append_config_from_boot_loader_entries (OtBootloaderSyslinux *self,
return ret;
}
-static char *
-join_lines (GPtrArray *lines)
-{
- GString *buf = g_string_new ("");
- guint i;
- gboolean prev_was_empty = FALSE;
-
- for (i = 0; i < lines->len; i++)
- {
- const char *line = lines->pdata[i];
- /* Special bit to remove extraneous empty lines */
- if (*line == '\0')
- {
- if (prev_was_empty || i == 0)
- continue;
- else
- prev_was_empty = TRUE;
- }
- g_string_append (buf, line);
- g_string_append_c (buf, '\n');
- }
- return g_string_free (buf, FALSE);
-}
-
static gboolean
ot_bootloader_syslinux_write_config (OtBootloader *bootloader,
int bootversion,
@@ -253,7 +229,7 @@ ot_bootloader_syslinux_write_config (OtBootloader *bootloader,
cancellable, error))
goto out;
- new_config_contents = join_lines (new_lines);
+ new_config_contents = ot_admin_join_lines (new_lines);
if (strcmp (new_config_contents, config_contents) != 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]