aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/po.c45
1 files changed, 14 insertions, 31 deletions
diff --git a/src/po.c b/src/po.c
index ebd4444..5ef6189 100644
--- a/src/po.c
+++ b/src/po.c
@@ -254,8 +254,8 @@ po_header (const char *name)
mu_opool_destroy (&pool);
}
-char *
-lang_lookup(char *id)
+char const *
+lang_lookup(char const *id)
{
return mu_assoc_get (lang_assoc, id);
}
@@ -434,8 +434,6 @@ parse_lang_datafile (const char *name)
mu_stream_t instream;
char *buf = NULL;
size_t bufsize = 0, n;
- int wsflags = MU_WRDSF_DEFFLAGS;
- struct mu_wordsplit ws;
if (verbose > 1)
mu_printf (_("Sourcing language table `%s'\n"), name);
@@ -459,45 +457,30 @@ parse_lang_datafile (const char *name)
mu_assoc_set_destroy_item (lang_assoc, mu_list_free_item);
}
- ws.ws_comment = "#";
- wsflags |= MU_WRDSF_COMMENT;
while (mu_stream_getline (instream, &buf, &bufsize, &n) == 0 && n > 0)
{
- char *p;
+ char *p, *q;
line++;
p = mu_str_stripws (buf);
if (*p == 0 || *p == '#')
continue;
-
- status = mu_wordsplit (p, &ws, wsflags);
- wsflags |= MU_WRDSF_REUSE;
- if (status)
+
+ q = mu_str_skip_class_comp (p, MU_CTYPE_SPACE);
+ if (*q)
{
- mu_error (_("%s:%u: cannot parse line: %s"),
- name, line, mu_strerror (status));
- exit (1);
+ *q++ = 0;
+ q = mu_str_skip_class (q, MU_CTYPE_SPACE);
}
-
- if (ws.ws_wordc > 1)
+
+ if (*q == 0)
{
- char *str;
- status = mu_argcv_string (ws.ws_wordc - 1, ws.ws_wordv + 1, &str);
- if (status)
- {
- mu_error (_("%s:%u: cannot build RHS: %s"),
- name, line, mu_strerror (status));
- exit (1);
- }
- mu_assoc_install (lang_assoc, str, ws.ws_wordv[0]);
- ws.ws_wordv[0] = NULL;
- free (str);
+ mu_error (_("%s:%u: too few fields"), name, line);
+ continue;
}
- else
- mu_error (_("%s:%u: too few fields"), name, line);
+
+ mu_assoc_install (lang_assoc, q, mu_strdup (p));
}
- if (wsflags & MU_WRDSF_REUSE)
- mu_wordsplit_free (&ws);
mu_stream_unref (instream);
return 0;
}

Return to:

Send suggestions and report system problems to the System administrator.