summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ebf91ae)
raw | patch | inline | side by side (parent: ebf91ae)
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Wed, 4 Jan 2012 17:33:30 +0000 (18:33 +0100) | ||
committer | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Wed, 23 May 2012 01:49:59 +0000 (03:49 +0200) |
Reduce some unneeded complexity when adding strings returned
by other libraries than glib.
by other libraries than glib.
src/screen_lyrics.c | patch | blob | history | |
src/screen_text.c | patch | blob | history | |
src/screen_text.h | patch | blob | history |
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index ef230c83a749d0ead633ed5daa19b17444205afb..604a051579ed87a982f8c15443396b92fddb011c 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
static void
screen_lyrics_set(const GString *str)
{
- screen_text_set(&text, str);
+ screen_text_set(&text, str->str);
/* paint new data */
diff --git a/src/screen_text.c b/src/screen_text.c
index 21e73aac8ad47869bcbca505b7ea924ce3eac90f..244903dd85a8645b0e05797f07a56c8eacc84d14 100644 (file)
--- a/src/screen_text.c
+++ b/src/screen_text.c
}
void
-screen_text_set(struct screen_text *text, const GString *str)
+screen_text_set(struct screen_text *text, const char *str)
{
- const char *p, *eol, *next;
+ const char *eol, *next;
assert(str != NULL);
screen_text_clear(text);
- p = str->str;
- while ((eol = strchr(p, '\n')) != NULL) {
+ while ((eol = strchr(str, '\n')) != NULL) {
char *line;
next = eol + 1;
/* strip whitespace at end */
- while (eol > p && (unsigned char)eol[-1] <= 0x20)
+ while (eol > str && (unsigned char)eol[-1] <= 0x20)
--eol;
/* create copy and append it to text->lines */
- line = g_malloc(eol - p + 1);
- memcpy(line, p, eol - p);
- line[eol - p] = 0;
+ line = g_malloc(eol - str + 1);
+ memcpy(line, str, eol - str);
+ line[eol - str] = 0;
g_ptr_array_add(text->lines, line);
/* reset control characters */
- for (eol = line + (eol - p); line < eol; ++line)
+ for (eol = line + (eol - str); line < eol; ++line)
if ((unsigned char)*line < 0x20)
*line = ' ';
- p = next;
+ str = next;
}
- if (*p != 0)
- g_ptr_array_add(text->lines, g_strdup(p));
+ if (*str != 0)
+ g_ptr_array_add(text->lines, g_strdup(str));
list_window_set_length(text->lw, text->lines->len);
}
diff --git a/src/screen_text.h b/src/screen_text.h
index 0e681dab5bd7fc6040bcbf8c1e38c2978eb82e20..3d9327c4997030717ec81a3f67e44c083bd1b008 100644 (file)
--- a/src/screen_text.h
+++ b/src/screen_text.h
}
void
-screen_text_set(struct screen_text *text, const GString *str);
+screen_text_set(struct screen_text *text, const char *str);
const char *
screen_text_list_callback(unsigned idx, void *data);