]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Extract msgen's main function to a separate file, for use by msginit.
authorBruno Haible <bruno@clisp.org>
Thu, 25 Oct 2001 09:26:23 +0000 (09:26 +0000)
committerBruno Haible <bruno@clisp.org>
Thu, 25 Oct 2001 09:26:23 +0000 (09:26 +0000)
src/ChangeLog
src/Makefile.am
src/msgen.c
src/msgl-english.c [new file with mode: 0644]
src/msgl-english.h [new file with mode: 0644]

index 12e02d22b5285a21b726bd7356160d04e10273ff..61dff26ccb1ac3f215abd6dbe06192a2a8a06026 100644 (file)
@@ -1,3 +1,13 @@
+2001-10-08  Bruno Haible  <haible@clisp.cons.org>
+
+       * 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  <haible@clisp.cons.org>
 
        * po-time.h: New file.
index a7f17cc37ce57fabe1bd5dd7b4c5e98397b667c7..347ef1b88df81c49ae2bee263dcad6e33c982ab2 100644 (file)
@@ -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
index 05df1cfca7da1b73bd59266544d1c17bd2e1e633..fad5003e534a888111947ef201145b99a6ce3442 100644 (file)
@@ -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 (file)
index 0000000..9a07071
--- /dev/null
@@ -0,0 +1,72 @@
+/* Message translation initialization for English.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   Written by Bruno Haible <haible@clisp.cons.org>, 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 <string.h>
+
+#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 (file)
index 0000000..dec6948
--- /dev/null
@@ -0,0 +1,27 @@
+/* Message translation initialization for English.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   Written by Bruno Haible <haible@clisp.cons.org>, 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 */