From: Bruno Haible Date: Thu, 25 Oct 2001 09:26:23 +0000 (+0000) Subject: Extract msgen's main function to a separate file, for use by msginit. X-Git-Tag: v0.11~414 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a19cdcb1ecd905cd1925f1f2cb7f856b2c3fd511;p=thirdparty%2Fgettext.git Extract msgen's main function to a separate file, for use by msginit. --- diff --git a/src/ChangeLog b/src/ChangeLog index 12e02d22b..61dff26cc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2001-10-08 Bruno Haible + + * msgl-english.h: New file. + * msgl-english.c: New file, extracted from msgen.c. + * msgen.c: Include msgl-english.h. + (english): Move to msgl-english.c. + (main): Update accordingly. + * Makefile.am (noinst_HEADERS): Add msgl-english.h. + (msgen_SOURCES): Add msgl-english.c. + 2001-10-08 Bruno Haible * po-time.h: New file. diff --git a/src/Makefile.am b/src/Makefile.am index a7f17cc37..347ef1b88 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,8 +28,8 @@ noinst_PROGRAMS = hostname noinst_HEADERS = pos.h message.h po-gram.h po-hash.h po-charset.h po-lex.h \ po.h open-po.h read-po.h str-list.h write-po.h dir-list.h file-list.h \ po-gram-gen.h po-hash-gen.h msgl-charset.h msgl-equal.h msgl-iconv.h \ -msgl-ascii.h msgl-cat.h msgfmt.h read-mo.h write-mo.h po-time.h xgettext.h \ -x-c.h x-po.h x-java.h x-ycp.h x-rst.h +msgl-ascii.h msgl-cat.h msgl-english.h msgfmt.h read-mo.h write-mo.h \ +po-time.h xgettext.h x-c.h x-po.h x-java.h x-ycp.h x-rst.h EXTRA_DIST = FILES @@ -76,7 +76,7 @@ msgattrib_SOURCES = msgattrib.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po msgcat_SOURCES = msgcat.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-iconv.c msgl-cat.c file-list.c msgcomm_SOURCES = msgcomm.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-iconv.c msgl-cat.c file-list.c msgconv_SOURCES = msgconv.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-iconv.c -msgen_SOURCES = msgen.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c +msgen_SOURCES = msgen.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-english.c msgexec_SOURCES = msgexec.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-charset.c msggrep_SOURCES = msggrep.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-charset.c msguniq_SOURCES = msguniq.c $(COMMON_SOURCE) msgl-ascii.c write-po.c read-po.c msgl-iconv.c msgl-cat.c diff --git a/src/msgen.c b/src/msgen.c index 05df1cfca..fad5003e5 100644 --- a/src/msgen.c +++ b/src/msgen.c @@ -32,6 +32,7 @@ #include "basename.h" #include "message.h" #include "read-po.h" +#include "msgl-english.h" #include "write-po.h" #include "xmalloc.h" #include "system.h" @@ -67,7 +68,6 @@ static const struct option long_options[] = /* Prototypes for local functions. Needed to ensure compiler checking of function argument counts despite of K&R C function definition syntax. */ static void usage PARAMS ((int status)); -static msgdomain_list_ty *english PARAMS ((msgdomain_list_ty *mdlp)); int @@ -203,7 +203,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "--sort-output", "--sort-by-file"); /* Read input file and add English translations. */ - result = english (read_po_file (argv[optind])); + result = msgdomain_list_english (read_po_file (argv[optind])); /* Sort the results. */ if (sort_by_filepos) @@ -290,46 +290,3 @@ Informative output:\n\ exit (status); } - - -static msgdomain_list_ty * -english (mdlp) - msgdomain_list_ty *mdlp; -{ - size_t j, k; - - for (k = 0; k < mdlp->nitems; k++) - { - message_list_ty *mlp = mdlp->item[k]->messages; - - for (j = 0; j < mlp->nitems; j++) - { - message_ty *mp = mlp->item[j]; - - if (mp->msgid_plural == NULL) - { - if (mp->msgstr_len == 1 && mp->msgstr[0] == '\0') - { - mp->msgstr = mp->msgid; /* no need for xstrdup */ - mp->msgstr_len = strlen (mp->msgid) + 1; - } - } - else - { - if (mp->msgstr_len == 2 - && mp->msgstr[0] == '\0' && mp->msgstr[1] == '\0') - { - size_t len0 = strlen (mp->msgid) + 1; - size_t len1 = strlen (mp->msgid_plural) + 1; - char *cp = (char *) xmalloc (len0 + len1); - memcpy (cp, mp->msgid, len0); - memcpy (cp + len0, mp->msgid_plural, len1); - mp->msgstr = cp; - mp->msgstr_len = len0 + len1; - } - } - } - } - - return mdlp; -} diff --git a/src/msgl-english.c b/src/msgl-english.c new file mode 100644 index 000000000..9a07071f9 --- /dev/null +++ b/src/msgl-english.c @@ -0,0 +1,72 @@ +/* Message translation initialization for English. + Copyright (C) 2001 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +/* Specification. */ +#include "msgl-english.h" + +#include + +#include "xmalloc.h" + + +msgdomain_list_ty * +msgdomain_list_english (mdlp) + msgdomain_list_ty *mdlp; +{ + size_t j, k; + + for (k = 0; k < mdlp->nitems; k++) + { + message_list_ty *mlp = mdlp->item[k]->messages; + + for (j = 0; j < mlp->nitems; j++) + { + message_ty *mp = mlp->item[j]; + + if (mp->msgid_plural == NULL) + { + if (mp->msgstr_len == 1 && mp->msgstr[0] == '\0') + { + mp->msgstr = mp->msgid; /* no need for xstrdup */ + mp->msgstr_len = strlen (mp->msgid) + 1; + } + } + else + { + if (mp->msgstr_len == 2 + && mp->msgstr[0] == '\0' && mp->msgstr[1] == '\0') + { + size_t len0 = strlen (mp->msgid) + 1; + size_t len1 = strlen (mp->msgid_plural) + 1; + char *cp = (char *) xmalloc (len0 + len1); + memcpy (cp, mp->msgid, len0); + memcpy (cp + len0, mp->msgid_plural, len1); + mp->msgstr = cp; + mp->msgstr_len = len0 + len1; + } + } + } + } + + return mdlp; +} diff --git a/src/msgl-english.h b/src/msgl-english.h new file mode 100644 index 000000000..dec694825 --- /dev/null +++ b/src/msgl-english.h @@ -0,0 +1,27 @@ +/* Message translation initialization for English. + Copyright (C) 2001 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _MSGL_ENGLISH_H +#define _MSGL_ENGLISH_H + +#include "message.h" + +extern msgdomain_list_ty * + msgdomain_list_english PARAMS ((msgdomain_list_ty *mdlp)); + +#endif /* _MSGL_ENGLISH_H */