8sa1-gcc/gcc/fortran/misc.c
Francois-Xavier Coudert 31043f6cfc re PR fortran/15586 (gfortran should support i18n in its compiler messages)
PR fortran/15586

	* arith.c (gfc_arith_error): Add translation support
	for error messages.
	* array.c (gfc_match_array_ref): Likewise.
	(gfc_match_array_spec): Likewise.
	* check.c (must_be): Add msgid convention to third argument.
	(same_type_check): Add translation support for error message.
	(rank_check): Likewise.
	(kind_value_check): Likewise.
	(gfc_check_associated): Correct typo.
	(gfc_check_reshape): Add translation support for error message.
	(gfc_check_spread): Likewise.
	* error.c (error_printf): Add nocmsgid convention to argument.
	(gfc_warning, gfc_notify_std, gfc_warning_now, gfc_warning_check)
	(gfc_error, gfc_error_now): Likewise.
	(gfc_status): Add cmsgid convention to argument.
	* expr.c (gfc_extract_int): Add translation support
        for error messages.
	(gfc_check_conformance): Add msgid convention to argument.
	(gfc_check_pointer_assign): Correct tabbing.
	* gfortran.h: Include intl.h header. Remove prototype
	for gfc_article.
	* gfortranspec.c: Include intl.h header.
	(lang_specific_driver): Add translation support for --version.
	* io.c (check_format): Add translation support for
	error message.
	(format_item_1): Likewise.
	(data_desc): Likewise.
	* matchexp.c: Likewise.
	* misc.c (gfc_article): Remove function.
	* module.c (bad_module): Use msgid convention. Add
	translation support for error messages.
	(require_atom): Add translation support for error messages.
	* parse.c (gfc_ascii_statement): Likewise.
	(gfc_state_name): Likewise.
	* primary.c (match_boz_constant): Reorganise error
	messages for translations.
	* resolve.c (resolve_entries): Likewise.
	(resolve_operator): Add translation support for error messages.
	(gfc_resolve_expr): Use msgid convention. Reorganise error
        messages for translations.
	(resolve_symbol): Add translation support for error messages.
	* symbol.c (gfc_add_procedure): Remove use of gfc_article function.
	* trans-const.c (gfc_build_string_const): Use msgid convention.

	* exgettext: Add a new nocmsgid convention for arguments
	that should be marked as no-c-format.
	* gcc.pot: Regenerate.

From-SVN: r104372
2005-09-17 18:58:01 +00:00

297 lines
5.3 KiB
C

/* Miscellaneous stuff that doesn't fit anywhere else.
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of GCC.
GCC 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.
GCC 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 GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
#include "config.h"
#include "system.h"
#include "gfortran.h"
/* Get a block of memory. Many callers assume that the memory we
return is zeroed. */
void *
gfc_getmem (size_t n)
{
void *p;
if (n == 0)
return NULL;
p = xmalloc (n);
if (p == NULL)
gfc_fatal_error ("Out of memory-- malloc() failed");
memset (p, 0, n);
return p;
}
/* gfortran.h defines free to something that triggers a syntax error,
but we need free() here. */
#define temp free
#undef free
void
gfc_free (void *p)
{
if (p != NULL)
free (p);
}
#define free temp
#undef temp
/* Get terminal width */
int
gfc_terminal_width(void)
{
return 80;
}
/* Initialize a typespec to unknown. */
void
gfc_clear_ts (gfc_typespec * ts)
{
ts->type = BT_UNKNOWN;
ts->kind = 0;
ts->derived = NULL;
ts->cl = NULL;
}
/* Open a file for reading. */
FILE *
gfc_open_file (const char *name)
{
struct stat statbuf;
if (!*name)
return stdin;
if (stat (name, &statbuf) < 0)
return NULL;
if (!S_ISREG (statbuf.st_mode))
return NULL;
return fopen (name, "r");
}
/* Return a string for each type. */
const char *
gfc_basic_typename (bt type)
{
const char *p;
switch (type)
{
case BT_INTEGER:
p = "INTEGER";
break;
case BT_REAL:
p = "REAL";
break;
case BT_COMPLEX:
p = "COMPLEX";
break;
case BT_LOGICAL:
p = "LOGICAL";
break;
case BT_CHARACTER:
p = "CHARACTER";
break;
case BT_HOLLERITH:
p = "HOLLERITH";
break;
case BT_DERIVED:
p = "DERIVED";
break;
case BT_PROCEDURE:
p = "PROCEDURE";
break;
case BT_UNKNOWN:
p = "UNKNOWN";
break;
default:
gfc_internal_error ("gfc_basic_typename(): Undefined type");
}
return p;
}
/* Return a string describing the type and kind of a typespec. Because
we return alternating buffers, this subroutine can appear twice in
the argument list of a single statement. */
const char *
gfc_typename (gfc_typespec * ts)
{
static char buffer1[60], buffer2[60];
static int flag = 0;
char *buffer;
buffer = flag ? buffer1 : buffer2;
flag = !flag;
switch (ts->type)
{
case BT_INTEGER:
sprintf (buffer, "INTEGER(%d)", ts->kind);
break;
case BT_REAL:
sprintf (buffer, "REAL(%d)", ts->kind);
break;
case BT_COMPLEX:
sprintf (buffer, "COMPLEX(%d)", ts->kind);
break;
case BT_LOGICAL:
sprintf (buffer, "LOGICAL(%d)", ts->kind);
break;
case BT_CHARACTER:
sprintf (buffer, "CHARACTER(%d)", ts->kind);
break;
case BT_HOLLERITH:
sprintf (buffer, "HOLLERITH");
break;
case BT_DERIVED:
sprintf (buffer, "TYPE(%s)", ts->derived->name);
break;
case BT_PROCEDURE:
strcpy (buffer, "PROCEDURE");
break;
case BT_UNKNOWN:
strcpy (buffer, "UNKNOWN");
break;
default:
gfc_internal_error ("gfc_typespec(): Undefined type");
}
return buffer;
}
/* Given an mstring array and a code, locate the code in the table,
returning a pointer to the string. */
const char *
gfc_code2string (const mstring * m, int code)
{
while (m->string != NULL)
{
if (m->tag == code)
return m->string;
m++;
}
gfc_internal_error ("gfc_code2string(): Bad code");
/* Not reached */
}
/* Given an mstring array and a string, returns the value of the tag
field. Returns the final tag if no matches to the string are
found. */
int
gfc_string2code (const mstring * m, const char *string)
{
for (; m->string != NULL; m++)
if (strcmp (m->string, string) == 0)
return m->tag;
return m->tag;
}
/* Convert an intent code to a string. */
/* TODO: move to gfortran.h as define. */
const char *
gfc_intent_string (sym_intent i)
{
return gfc_code2string (intents, i);
}
/***************** Initialization functions ****************/
/* Top level initialization. */
void
gfc_init_1 (void)
{
gfc_error_init_1 ();
gfc_scanner_init_1 ();
gfc_arith_init_1 ();
gfc_intrinsic_init_1 ();
gfc_simplify_init_1 ();
}
/* Per program unit initialization. */
void
gfc_init_2 (void)
{
gfc_symbol_init_2 ();
gfc_module_init_2 ();
}
/******************* Destructor functions ******************/
/* Call all of the top level destructors. */
void
gfc_done_1 (void)
{
gfc_scanner_done_1 ();
gfc_intrinsic_done_1 ();
gfc_arith_done_1 ();
}
/* Per program unit destructors. */
void
gfc_done_2 (void)
{
gfc_symbol_done_2 ();
gfc_module_done_2 ();
}