[gitg] Improved format patch name mimicking git
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Improved format patch name mimicking git
- Date: Sat, 6 Aug 2011 14:31:23 +0000 (UTC)
commit e633e1b76861ab184a1d001303da083b91c7d373
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Sat Aug 6 13:10:14 2011 +0200
Improved format patch name mimicking git
Multiple spaces are now only replaced with one hyphen.
Forward slashes are also replaced by hyphens now.
libgitg/gitg-revision.c | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/libgitg/gitg-revision.c b/libgitg/gitg-revision.c
index 94b05ec..579c878 100644
--- a/libgitg/gitg-revision.c
+++ b/libgitg/gitg-revision.c
@@ -354,18 +354,34 @@ gitg_revision_get_lane (GitgRevision *revision)
gchar *
gitg_revision_get_format_patch_name (GitgRevision *revision)
{
- gchar *ret = g_strdup (revision->subject);
- gchar *ptr = ret;
+ GString *ret;
+ gboolean lastisspace = FALSE;
+ gchar const *ptr;
+
+ ret = g_string_new ("");
+ ptr = revision->subject;
do
{
- if (g_utf8_get_char (ptr) == ' ')
+ gunichar c;
+
+ c = g_utf8_get_char (ptr);
+
+ if (c == ' ' || c == '/')
{
- *ptr = '-';
+ if (!lastisspace)
+ {
+ g_string_append_c (ret, '-');
+ lastisspace = TRUE;
+ }
}
- } while (* (ptr = g_utf8_next_char (ptr)));
+ else
+ {
+ g_string_append_unichar (ret, c);
+ }
+ } while (*(ptr = g_utf8_next_char (ptr)));
- return ret;
+ return g_string_free (ret, FALSE);
}
static gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]