aboutsummaryrefslogtreecommitdiff
path: root/src/service.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-07-16 01:26:56 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-07-16 01:26:56 -0500
commitb2fe95c6d86114b2681763df845a2817ee0fe234 (patch)
tree22dbe171f9207c632ac541328bb2a34023b8e8d9 /src/service.c
parenta034869430082a3b10179b13071e3cc3eb6ffb97 (diff)
downloadayatana-indicator-session-b2fe95c6d86114b2681763df845a2817ee0fe234.tar.gz
ayatana-indicator-session-b2fe95c6d86114b2681763df845a2817ee0fe234.tar.bz2
ayatana-indicator-session-b2fe95c6d86114b2681763df845a2817ee0fe234.zip
make the os-release parser slightly less unreadable.
Diffstat (limited to 'src/service.c')
-rw-r--r--src/service.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/service.c b/src/service.c
index f8c375d..faff4d4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -343,7 +343,7 @@ get_os_release (void)
for (;;)
{
- char *p, *q;
+ char *in, *out;
const char *val;
GIOStatus status;
@@ -357,29 +357,28 @@ get_os_release (void)
continue;
/* split into name=value */
- p = strchr(gstr->str, '=');
- if (!p)
+ in = strchr(gstr->str, '=');
+ if (!in)
continue;
- *p++ = '\0';
+ *in++ = '\0';
/* remove quotes and newline; un-escape */
- val = p;
- q = p;
- while (*p)
+ val = out = in;
+ while (*in)
{
- if ((*p == '\'') || (*p == '"') || (*p == '\n'))
+ if ((*in=='\'') || (*in=='"') || (*in=='\n')) /* skip chars */
{
- ++p;
+ ++in;
}
else
{
- if ((*p=='\\') && !*++p)
+ if ((*in=='\\') && !*++in) /* handle an escaped char */
break;
- *q++ = *p++;
- }
- *q = '\0'; /* zero terminate */
+ *out++ = *in++;
+ }
}
+ *out = '\0'; /* zero terminate */
g_hash_table_insert (hash, g_strdup(gstr->str), g_strdup(val));
}