/* Open the input file with the name INPUT_NAME. The ending .po is added if necessary. If INPUT_NAME is not an absolute file name and the file is not found, the list of directories in "dir-list.h" is searched. The file's pathname is returned in *REAL_FILE_NAME_P, for error message purposes. */ FILE * open_catalog_file (const char *input_name, char **real_file_name_p, bool exit_on_error) { FILE *fp = try_open_catalog_file (input_name, real_file_name_p); if (fp == NULL && exit_on_error) { const char *errno_description = strerror (errno); po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, NULL, 0, 0, false, xasprintf ("%s: %s", xasprintf (_("error while opening \"%s\" for reading"), *real_file_name_p), errno_description)); } return fp; }
void po_lex_charset_set (const char *header_entry, const char *filename) { /* Verify the validity of CHARSET. It is necessary 1. for the correct treatment of multibyte characters containing 0x5C bytes in the PO lexer, 2. so that at run time, gettext() can call iconv() to convert msgstr. */ const char *charsetstr = c_strstr (header_entry, "charset="); if (charsetstr != NULL) { size_t len; char *charset; const char *canon_charset; charsetstr += strlen ("charset="); len = strcspn (charsetstr, " \t\n"); charset = (char *) xmalloca (len + 1); memcpy (charset, charsetstr, len); charset[len] = '\0'; canon_charset = po_charset_canonicalize (charset); if (canon_charset == NULL) { /* Don't warn for POT files, because POT files usually contain only ASCII msgids. */ size_t filenamelen = strlen (filename); if (!(filenamelen >= 4 && memcmp (filename + filenamelen - 4, ".pot", 4) == 0 && strcmp (charset, "CHARSET") == 0)) { char *warning_message = xasprintf (_("\ Charset \"%s\" is not a portable encoding name.\n\ Message conversion to user's charset might not work.\n"), charset); po_xerror (PO_SEVERITY_WARNING, NULL, filename, (size_t)(-1), (size_t)(-1), true, warning_message); free (warning_message); }
void catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE *fp, const char *real_filename, const char *logical_filename, catalog_input_format_ty input_syntax) { error_message_count = 0; /* Parse the stream's content. */ parse_start (pop); input_syntax->parse (pop, fp, real_filename, logical_filename); parse_end (pop); if (error_message_count > 0) po_xerror (PO_SEVERITY_FATAL_ERROR, NULL, /*real_filename*/ NULL, (size_t)(-1), (size_t)(-1), false, xasprintf (ngettext ("found %d fatal error", "found %d fatal errors", error_message_count), error_message_count)); }