From: "Juan Manuel Guerrero" Organization: Darmstadt University of Technology To: djgpp-workers AT delorie DOT com Date: Wed, 21 Feb 2001 20:01:50 +0200 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: gettext pretest available CC: Eli Zaretskii , Bruno Haible In-reply-to: <29F40F30739@HRZ1.hrz.tu-darmstadt.de> X-mailer: Pegasus Mail for Windows (v2.54DE) Message-ID: <2A2A62E7333@HRZ1.hrz.tu-darmstadt.de> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Patch 3/3 diff -acprNC5 gettext-2001-02-05.orig/src/message.c gettext-2001-02-05/src/message.c *** gettext-2001-02-05.orig/src/message.c Sun Jan 21 16:08:46 2001 --- gettext-2001-02-05/src/message.c Wed Feb 21 18:31:06 2001 *************** message_list_print (mlp, filename, force *** 1378,1388 **** /* Open the output file. */ if (filename != NULL && strcmp (filename, "-") != 0 && strcmp (filename, "/dev/stdout") != 0) { ! fp = fopen (filename, "w"); if (fp == NULL) error (EXIT_FAILURE, errno, _("cannot create output file \"%s\""), filename); } else --- 1378,1388 ---- /* Open the output file. */ if (filename != NULL && strcmp (filename, "-") != 0 && strcmp (filename, "/dev/stdout") != 0) { ! fp = fopen (filename, WRITE); if (fp == NULL) error (EXIT_FAILURE, errno, _("cannot create output file \"%s\""), filename); } else diff -acprNC5 gettext-2001-02-05.orig/src/msgcomm.c gettext-2001-02-05/src/msgcomm.c *** gettext-2001-02-05.orig/src/msgcomm.c Thu Jan 25 14:20:58 2001 --- gettext-2001-02-05/src/msgcomm.c Wed Feb 21 18:31:06 2001 *************** warranty; not even for MERCHANTABILITY o *** 298,308 **** /* Construct the name of the ouput file. If the default domain has the special name "-" we write to stdout. */ if (output_file) { ! if (output_file[0] == '/' || strcmp(output_dir, ".") == 0 || strcmp(output_file, "-") == 0 ) file_name = xstrdup (output_file); else --- 298,308 ---- /* Construct the name of the ouput file. If the default domain has the special name "-" we write to stdout. */ if (output_file) { ! if (IS_ABSOLUTE_PATH(output_file) || strcmp(output_dir, ".") == 0 || strcmp(output_file, "-") == 0 ) file_name = xstrdup (output_file); else *************** read_name_from_file (file_name) *** 465,475 **** if (strcmp (file_name, "-") == 0) fp = stdin; else { ! fp = fopen (file_name, "r"); if (fp == NULL) error (EXIT_FAILURE, errno, _("error while opening \"%s\" for reading"), file_name); } --- 465,475 ---- if (strcmp (file_name, "-") == 0) fp = stdin; else { ! fp = fopen (file_name, READ); if (fp == NULL) error (EXIT_FAILURE, errno, _("error while opening \"%s\" for reading"), file_name); } *************** read_name_from_file (file_name) *** 483,492 **** --- 483,500 ---- /* In case of an error leave loop. */ if (len < 0) break; /* Remove trailing '\n'. */ + #if OPENED_IN_BINARY_MODE + /* Check for DOS-style EOL (CRLF) and remove it. */ + if (len > 0 && line_buf[len - 2] == '\r' && line_buf[len - 1] == '\n') + { + --len; + line_buf[--len] = '\0'; + } + #endif if (len > 0 && line_buf[len - 1] == '\n') line_buf[--len] = '\0'; /* Test if we have to ignore the line. */ if (*line_buf == '\0' || *line_buf == '#') diff -acprNC5 gettext-2001-02-05.orig/src/msgfmt.c gettext-2001-02-05/src/msgfmt.c *** gettext-2001-02-05.orig/src/msgfmt.c Mon Feb 5 18:38:02 2001 --- gettext-2001-02-05/src/msgfmt.c Wed Feb 21 18:31:06 2001 *************** warranty; not even for MERCHANTABILITY o *** 318,329 **** /* If no entry for this domain don't even create the file. */ if (domain->symbol_tab.filled != 0) { if (strcmp (domain->domain_name, "-") == 0) { output_file = stdout; ! setmode (fileno (output_file), O_BINARY); } else { const char *fname; --- 318,332 ---- /* If no entry for this domain don't even create the file. */ if (domain->symbol_tab.filled != 0) { if (strcmp (domain->domain_name, "-") == 0) { + /* On WinDos never switch stdout + to binary mode unconditionally. */ output_file = stdout; ! if (!isatty (fileno (output_file))) ! setmode (fileno (output_file), O_BINARY); } else { const char *fname; diff -acprNC5 gettext-2001-02-05.orig/src/msgunfmt.c gettext-2001-02-05/src/msgunfmt.c *** gettext-2001-02-05.orig/src/msgunfmt.c Mon Feb 5 18:38:02 2001 --- gettext-2001-02-05/src/msgunfmt.c Wed Feb 21 18:31:06 2001 *************** read_mo_file (mlp, fn) *** 347,358 **** struct mo_file_header header; int j; if (strcmp (fn, "-") == 0 || strcmp (fn, "/dev/stdin") == 0) { fp = stdin; ! setmode (fileno (fp), O_BINARY); } else { fp = fopen (fn, "rb"); if (fp == NULL) --- 347,361 ---- struct mo_file_header header; int j; if (strcmp (fn, "-") == 0 || strcmp (fn, "/dev/stdin") == 0) { + /* On WinDos never switch stdin to binary mode + unconditionally if connected to console. */ fp = stdin; ! if (!isatty (fileno (fp))) ! setmode (fileno (fp), O_BINARY); } else { fp = fopen (fn, "rb"); if (fp == NULL) diff -acprNC5 gettext-2001-02-05.orig/src/open-po.c gettext-2001-02-05/src/open-po.c *** gettext-2001-02-05.orig/src/open-po.c Mon Jan 22 12:48:00 2001 --- gettext-2001-02-05/src/open-po.c Wed Feb 21 18:31:06 2001 *************** open_po_file (input_name, file_name) *** 66,84 **** return stdin; } /* We have a real name for the input file. If the name is absolute, try the various extensions, but ignore the directory search list. */ ! if (*input_name == '/') { for (k = 0; k < SIZEOF (extension); ++k) { ext = extension[k]; *file_name = xmalloc (strlen (input_name) + strlen (ext) + 1); stpcpy (stpcpy (*file_name, input_name), ext); ! ret_val = fopen (*file_name, "r"); if (ret_val != NULL || errno != ENOENT) /* We found the file. */ return ret_val; free (*file_name); --- 66,84 ---- return stdin; } /* We have a real name for the input file. If the name is absolute, try the various extensions, but ignore the directory search list. */ ! if (IS_ABSOLUTE_PATH(input_name)) { for (k = 0; k < SIZEOF (extension); ++k) { ext = extension[k]; *file_name = xmalloc (strlen (input_name) + strlen (ext) + 1); stpcpy (stpcpy (*file_name, input_name), ext); ! ret_val = fopen (*file_name, READ); if (ret_val != NULL || errno != ENOENT) /* We found the file. */ return ret_val; free (*file_name); *************** open_po_file (input_name, file_name) *** 105,115 **** stpcpy (stpcpy (stpcpy (stpcpy (*file_name, dir), "/"), input_name), ext); } ! ret_val = fopen (*file_name, "r"); if (ret_val != NULL || errno != ENOENT) return ret_val; free (*file_name); } --- 105,115 ---- stpcpy (stpcpy (stpcpy (stpcpy (*file_name, dir), "/"), input_name), ext); } ! ret_val = fopen (*file_name, READ); if (ret_val != NULL || errno != ENOENT) return ret_val; free (*file_name); } diff -acprNC5 gettext-2001-02-05.orig/src/po-lex.c gettext-2001-02-05/src/po-lex.c *** gettext-2001-02-05.orig/src/po-lex.c Mon Jan 22 12:48:00 2001 --- gettext-2001-02-05/src/po-lex.c Wed Feb 21 18:31:06 2001 *************** lex_getc () *** 197,206 **** --- 197,220 ---- case '\n': ++gram_pos.line_number; return '\n'; + #if OPENED_IN_BINARY_MODE + case '\r': + /* Check for DOS-style EOL (CRLF) too. */ + c = getc (fp); + if (c != '\n') + { + if (c != EOF) + ungetc (c, fp); + return '\r'; + } + ++gram_pos.line_number; + return '\n'; + #endif + case '\\': c = getc (fp); if (c != '\n') { if (c != EOF) diff -acprNC5 gettext-2001-02-05.orig/src/xget-lex.c gettext-2001-02-05/src/xget-lex.c *** gettext-2001-02-05.orig/src/xget-lex.c Sun Jan 21 16:08:46 2001 --- gettext-2001-02-05/src/xget-lex.c Wed Feb 21 18:31:08 2001 *************** xgettext_lex_open (fn) *** 147,160 **** { new_name = xstrdup (_("standard input")); logical_file_name = xstrdup (new_name); fp = stdin; } ! else if (*fn == '/') { new_name = xstrdup (fn); ! fp = fopen (fn, "r"); if (fp == NULL) error (EXIT_FAILURE, errno, _("\ error while opening \"%s\" for reading"), fn); logical_file_name = xstrdup (new_name); } --- 147,160 ---- { new_name = xstrdup (_("standard input")); logical_file_name = xstrdup (new_name); fp = stdin; } ! else if (IS_ABSOLUTE_PATH(fn)) { new_name = xstrdup (fn); ! fp = fopen (fn, READ); if (fp == NULL) error (EXIT_FAILURE, errno, _("\ error while opening \"%s\" for reading"), fn); logical_file_name = xstrdup (new_name); } *************** error while opening \"%s\" for reading") *** 179,189 **** len1 = strlen (dir); new_name = xmalloc (len1 + len2 + 2); stpcpy (stpcpy (stpcpy (new_name, dir), "/"), fn); } ! fp = fopen (new_name, "r"); if (fp != NULL) break; if (errno != ENOENT) error (EXIT_FAILURE, errno, _("\ --- 179,189 ---- len1 = strlen (dir); new_name = xmalloc (len1 + len2 + 2); stpcpy (stpcpy (stpcpy (new_name, dir), "/"), fn); } ! fp = fopen (new_name, READ); if (fp != NULL) break; if (errno != ENOENT) error (EXIT_FAILURE, errno, _("\ *************** error while reading \"%s\""), file_name) *** 256,265 **** --- 256,284 ---- case '\n': ++line_number; return '\n'; + #if OPENED_IN_BINARY_MODE + case '\r': + /* Check for DOS-style EOL (CRLF) too. */ + c = getc (fp); + if (c == EOF) + { + if (ferror (fp)) + goto bomb; + return '\r'; + } + if (c != '\n') + { + ungetc (c, fp); + return '\r'; + } + ++line_number; + return '\n'; + #endif + case '\\': c = getc (fp); if (c == EOF) { if (ferror (fp)) diff -acprNC5 gettext-2001-02-05.orig/src/xgettext.c gettext-2001-02-05/src/xgettext.c *** gettext-2001-02-05.orig/src/xgettext.c Mon Jan 22 12:48:00 2001 --- gettext-2001-02-05/src/xgettext.c Wed Feb 21 18:31:08 2001 *************** warranty; not even for MERCHANTABILITY o *** 426,436 **** /* Construct the name of the ouput file. If the default domain has the special name "-" we write to stdout. */ if (output_file) { ! if (output_file[0] == '/' || strcmp(output_dir, ".") == 0 || strcmp(output_file, "-") == 0) file_name = xstrdup (output_file); else { /* Please do NOT add a .po suffix! */ --- 426,436 ---- /* Construct the name of the ouput file. If the default domain has the special name "-" we write to stdout. */ if (output_file) { ! if (IS_ABSOLUTE_PATH(output_file) || strcmp(output_dir, ".") == 0 || strcmp(output_file, "-") == 0) file_name = xstrdup (output_file); else { /* Please do NOT add a .po suffix! */ *************** read_name_from_file (file_name) *** 613,623 **** if (strcmp (file_name, "-") == 0) fp = stdin; else { ! fp = fopen (file_name, "r"); if (fp == NULL) error (EXIT_FAILURE, errno, _("error while opening \"%s\" for reading"), file_name); } --- 613,623 ---- if (strcmp (file_name, "-") == 0) fp = stdin; else { ! fp = fopen (file_name, READ); if (fp == NULL) error (EXIT_FAILURE, errno, _("error while opening \"%s\" for reading"), file_name); } *************** read_name_from_file (file_name) *** 631,640 **** --- 631,648 ---- /* In case of an error leave loop. */ if (len < 0) break; /* Remove trailing '\n'. */ + #if OPENED_IN_BINARY_MODE + /* Check for DOS-style EOL (CRLF) and remove it. */ + if (len > 0 && line_buf[len - 2] == '\r' && line_buf[len - 1] == '\n') + { + --len; + line_buf[--len] = '\0'; + } + #endif if (len > 0 && line_buf[len - 1] == '\n') line_buf[--len] = '\0'; /* Test if we have to ignore the line. */ if (*line_buf == '\0' || *line_buf == '#') diff -acprNC5 gettext-2001-02-05.orig/tests/Makefile.am gettext-2001-02-05/tests/Makefile.am *** gettext-2001-02-05.orig/tests/Makefile.am Fri Jan 26 13:51:40 2001 --- gettext-2001-02-05/tests/Makefile.am Wed Feb 21 18:31:08 2001 *************** xg-test1.ok.po: $(top_srcdir)/src/xgette *** 44,54 **** $(top_srcdir)/src/gettext.c # Two auxiliary programs used by the tests. INCLUDES = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/intl DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ ! LDADD = ../intl/libintl.la EXTRA_PROGRAMS = tstgettext cake tstgettext_SOURCES = tstgettext.c setlocale.c tstgettext_LDADD = ../lib/libnlsut.a $(LDADD) cake_SOURCES = plural-1-prg.c setlocale.c all-local: $(EXTRA_PROGRAMS) --- 44,54 ---- $(top_srcdir)/src/gettext.c # Two auxiliary programs used by the tests. INCLUDES = -I.. -I$(top_srcdir)/lib -I$(top_srcdir)/intl DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ ! LDADD = ../intl/libintl.la @LIBICONV@ EXTRA_PROGRAMS = tstgettext cake tstgettext_SOURCES = tstgettext.c setlocale.c tstgettext_LDADD = ../lib/libnlsut.a $(LDADD) cake_SOURCES = plural-1-prg.c setlocale.c all-local: $(EXTRA_PROGRAMS)