]> granicus.if.org Git - yasm/commitdiff
Convert to using gettext instead of the ugly errwarn constant strings.
authorPeter Johnson <peter@tortall.net>
Thu, 30 Aug 2001 03:45:26 +0000 (03:45 -0000)
committerPeter Johnson <peter@tortall.net>
Thu, 30 Aug 2001 03:45:26 +0000 (03:45 -0000)
NOTE: gettextize now needs to be run before building.

svn path=/trunk/yasm/; revision=153

36 files changed:
.cvsignore
Makefile.am
acconfig.h
acinclude.m4 [new file with mode: 0644]
configure.ac
configure.in
libyasm/bytecode.c
libyasm/errwarn.c
libyasm/errwarn.h
libyasm/symrec.c
modules/objfmts/dbg/Makefile.am
modules/parsers/nasm/Makefile.am
modules/parsers/nasm/bison.y.in
modules/parsers/nasm/gen_instr.pl
modules/parsers/nasm/nasm-bison.y
modules/parsers/nasm/token.l.in
modules/preprocs/raw/Makefile.am
modules/preprocs/raw/preproc.c
modules/preprocs/raw/raw-preproc.c
po/.cvsignore [new file with mode: 0644]
po/ChangeLog [new file with mode: 0644]
po/POTFILES.in [new file with mode: 0644]
src/Makefile.am
src/bytecode.c
src/errwarn.c
src/errwarn.h
src/objfmts/dbg/Makefile.am
src/parsers/nasm/Makefile.am
src/parsers/nasm/bison.y.in
src/parsers/nasm/gen_instr.pl
src/parsers/nasm/nasm-bison.y
src/parsers/nasm/token.l.in
src/preprocs/raw/Makefile.am
src/preprocs/raw/preproc.c
src/preprocs/raw/raw-preproc.c
src/symrec.c

index cb425235298d0a289926d71d80f831ad7c299b74..b10159897323178cc737b6968cefd33694eb45cd 100644 (file)
@@ -4,3 +4,5 @@ Makefile
 config.*
 stamp-h*
 aclocal.m4
+intl
+ABOUT-NLS
index 59deea704a4baa466fff1e96d573b2bc8f10484b..e63c1c665bad6a526e2475d48bbe44f5b9e9f73d 100644 (file)
@@ -1,2 +1,2 @@
-SUBDIRS = src
+SUBDIRS = intl src po
 EXTRA_DIST = config/install-sh config/missing config/mkinstalldirs
index a2e1ad77ea60f456283af2491f7a30e25c77567b..5e9306672123bd63e572e37829b5bbaa52743665 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: acconfig.h,v 1.1 2001/08/19 04:25:18 peter Exp $ */
+/* $Id: acconfig.h,v 1.2 2001/08/30 03:45:16 peter Exp $ */
 
 #ifndef YASM_CONFIG_H
 #define YASM_CONFIG_H
 /* Workaround for bad <sys/queue.h> implementations. */
 #undef HAVE_BOGUS_SYS_QUEUE_H
 
+/* gettext tests */
+#undef ENABLE_NLS
+#undef HAVE_CATGETS
+#undef HAVE_GETTEXT
+#undef HAVE_LC_MESSAGES
+#undef HAVE_STPCPY
+
 @BOTTOM@
 
 #endif /* YASM_CONFIG_H */
diff --git a/acinclude.m4 b/acinclude.m4
new file mode 100644 (file)
index 0000000..21ccf80
--- /dev/null
@@ -0,0 +1,18 @@
+# $Id: acinclude.m4,v 1.1 2001/08/30 03:45:16 peter Exp $
+
+# This test replaces the one in autoconf.
+# Currently this macro should have the same name as the autoconf macro
+# because gettext's gettext.m4 (distributed in the automake package)
+# still uses it.  Otherwise, the use in gettext.m4 makes autoheader
+# give these diagnostics:
+#   configure.in:##: AC_TRY_COMPILE was called before AC_ISC_POSIX
+
+undefine([AC_ISC_POSIX])
+
+AC_DEFUN([AC_ISC_POSIX],
+  [
+    dnl This test replaces the obsolescent AC_ISC_POSIX kludge.
+    AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"])
+  ]
+)
+
index 763f343f304c669bb8cfed852bfd48eac54946d1..8d77c738800acab43dd860f01dc22901f9342589 100644 (file)
@@ -17,6 +17,9 @@ AC_PATH_PROGS(PERL, perl perl5.004 perl5.003 perl5.002 perl5.001 perl5)
 
 AM_PROG_CC_STDC
 
+ALL_LINGUAS=""
+AM_GNU_GETTEXT
+
 AM_PROG_LEX
 AC_PROG_YACC
 AC_PROG_INSTALL
@@ -49,4 +52,4 @@ case "$host" in
        ;;
 esac
 
-AC_OUTPUT(Makefile src/Makefile src/parsers/Makefile src/parsers/nasm/Makefile src/preprocs/Makefile src/preprocs/raw/Makefile src/outfmts/Makefile src/outfmts/dbg/Makefile)
+AC_OUTPUT(Makefile intl/Makefile po/Makefile.in src/Makefile src/parsers/Makefile src/parsers/nasm/Makefile src/preprocs/Makefile src/preprocs/raw/Makefile src/outfmts/Makefile src/outfmts/dbg/Makefile)
index 763f343f304c669bb8cfed852bfd48eac54946d1..8d77c738800acab43dd860f01dc22901f9342589 100644 (file)
@@ -17,6 +17,9 @@ AC_PATH_PROGS(PERL, perl perl5.004 perl5.003 perl5.002 perl5.001 perl5)
 
 AM_PROG_CC_STDC
 
+ALL_LINGUAS=""
+AM_GNU_GETTEXT
+
 AM_PROG_LEX
 AC_PROG_YACC
 AC_PROG_INSTALL
@@ -49,4 +52,4 @@ case "$host" in
        ;;
 esac
 
-AC_OUTPUT(Makefile src/Makefile src/parsers/Makefile src/parsers/nasm/Makefile src/preprocs/Makefile src/preprocs/raw/Makefile src/outfmts/Makefile src/outfmts/dbg/Makefile)
+AC_OUTPUT(Makefile intl/Makefile po/Makefile.in src/Makefile src/parsers/Makefile src/parsers/nasm/Makefile src/preprocs/Makefile src/preprocs/raw/Makefile src/outfmts/Makefile src/outfmts/dbg/Makefile)
index 347a45eb81d5a3bf6f1473a8dfa654200f47cc02..2765a25147e7e3b6865dc90b891482afe53f9043 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bytecode.c,v 1.19 2001/08/19 07:46:52 peter Exp $
+/* $Id: bytecode.c,v 1.20 2001/08/30 03:45:26 peter Exp $
  * Bytecode utility functions
  *
  *  Copyright (C) 2001  Peter Johnson
 # include <string.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "globals.h"
 #include "errwarn.h"
 #include "expr.h"
 
 #include "bytecode.h"
 
-RCSID("$Id: bytecode.c,v 1.19 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: bytecode.c,v 1.20 2001/08/30 03:45:26 peter Exp $");
 
 /* Static structures for when NULL is passed to conversion functions. */
 /*  for Convert*ToEA() */
@@ -95,7 +98,7 @@ ConvertImmToEA(effaddr *ptr, immval *im_ptr, unsigned char im_len)
 
     ptr->disp = im_ptr->val;
     if (im_ptr->len > im_len)
-       Warning(WARN_VALUE_EXCEEDS_BOUNDS, (char *)NULL, "word");
+       Warning(_("%s value exceeds bounds"), "word");
     ptr->len = im_len;
     ptr->segment = 0;
     ptr->valid_modrm = 0;
@@ -147,7 +150,7 @@ SetEASegment(effaddr *ptr, unsigned char segment)
        return;
 
     if (ptr->segment != 0)
-       Warning(WARN_MULT_SEG_OVERRIDE, (char *)NULL);
+       Warning(_("multiple segment overrides, using leftmost"));
 
     ptr->segment = segment;
 }
@@ -180,7 +183,7 @@ SetInsnOperSizeOverride(bytecode *bc, unsigned char opersize)
            break;
        default:
            InternalError(__LINE__, __FILE__,
-                         "OperSize override applied to non-instruction");
+                         _("OperSize override applied to non-instruction"));
            return;
     }
 }
@@ -200,7 +203,7 @@ SetInsnAddrSizeOverride(bytecode *bc, unsigned char addrsize)
            break;
        default:
            InternalError(__LINE__, __FILE__,
-                         "AddrSize override applied to non-instruction");
+                         _("AddrSize override applied to non-instruction"));
            return;
     }
 }
@@ -222,12 +225,12 @@ SetInsnLockRepPrefix(bytecode *bc, unsigned char prefix)
            break;
        default:
            InternalError(__LINE__, __FILE__,
-                         "LockRep prefix applied to non-instruction");
+                         _("LockRep prefix applied to non-instruction"));
            return;
     }
 
     if (*lockrep_pre != 0)
-       Warning(WARN_MULT_LOCKREP_PREFIX, (char *)NULL);
+       Warning(_("multiple LOCK or REP prefixes, using leftmost"));
 
     *lockrep_pre = prefix;
 }
@@ -239,7 +242,7 @@ SetOpcodeSel(jmprel_opcode_sel *old_sel, jmprel_opcode_sel new_sel)
        return;
 
     if ((*old_sel == JR_SHORT_FORCED) || (*old_sel == JR_NEAR_FORCED))
-       Warning(WARN_MULT_SHORTNEAR, (char *)NULL);
+       Warning(_("multiple SHORT or NEAR specifiers, using leftmost"));
     *old_sel = new_sel;
 }
 
@@ -324,9 +327,9 @@ BuildBC_JmpRel(bytecode      *bc,
     bc->data.jmprel.op_sel = target->op_sel;
 
     if ((target->op_sel == JR_SHORT_FORCED) && (!short_valid))
-       Error(ERR_NO_JMPREL_FORM, (char *)NULL, "SHORT");
+       Error(_("no SHORT form of that jump instruction exists"));
     if ((target->op_sel == JR_NEAR_FORCED) && (!near_valid))
-       Error(ERR_NO_JMPREL_FORM, (char *)NULL, "NEAR");
+       Error(_("no NEAR form of that jump instruction exists"));
 
     bc->data.jmprel.shortop.valid = short_valid;
     if (short_valid) {
@@ -378,13 +381,16 @@ BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size)
                break;
            case DV_FLOAT:
                if (size == 1)
-                   Error(ERR_DECLDATA_FLOAT, (char *)NULL, "DB");
+                   Error(_("floating-point constant encountered in `%s'"),
+                         "DB");
                else if (size == 2)
-                   Error(ERR_DECLDATA_FLOAT, (char *)NULL, "DW");
+                   Error(_("floating-point constant encountered in `%s'"),
+                         "DW");
                break;
            case DV_EXPR:
                if (size == 10)
-                   Error(ERR_DECLDATA_EXPR, (char *)NULL, "DT");
+                   Error(_("non-floating-point value encountered in `%s'"),
+                         "DT");
                break;
        }
     }
index c802a9a4d83d437e2cef45c8f99834aff9b701cc..63f25929e1ba47d3cdae86174dd77f343e71eb28 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.c,v 1.22 2001/08/19 07:46:52 peter Exp $
+/* $Id: errwarn.c,v 1.23 2001/08/30 03:45:26 peter Exp $
  * Error and warning reporting and related functions.
  *
  *  Copyright (C) 2001  Peter Johnson
 # include <string.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+#ifdef gettext_noop
+#define N_(String)     gettext_noop(String)
+#else
+#define N_(String)     (String)
+#endif
+
 #include "globals.h"
 #include "errwarn.h"
 
-RCSID("$Id: errwarn.c,v 1.22 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: errwarn.c,v 1.23 2001/08/30 03:45:26 peter Exp $");
 
 /* Total error count for entire assembler run.
  * Assembler should exit with EXIT_FAILURE if this is >= 0 on finish. */
@@ -52,42 +60,8 @@ unsigned int warning_count = 0;
 
 /* Fatal error messages.  Match up with fatal_num enum in errwarn.h. */
 static char *fatal_msgs[] = {
-    "unknown",
-    "out of memory"
-};
-
-/* Error messages.  Match up with err_num enum in errwarn.h. */
-static char *err_msgs[] = {
-    "",
-    "parser error: %s",
-    "missing '%1'",
-    "missing argument to %s",
-    "invalid argument to %s",
-    "invalid effective address",
-    "label or instruction expected at start of line",
-    "expression syntax error",
-    "duplicate definition of `%1'; previously defined line %2",
-    "mismatch in operand sizes",
-    "no %s form of that jump instruction exists",
-    "unterminated string",
-    "unexpected end of file in string",
-    "expression syntax error",
-    "floating-point constant encountered in `%s'",
-    "non-floating-point value encountered in `%s'",
-    "could not open file `%s'",
-    "error when reading from file"
-};
-
-/* Warning messages.  Match up with warn_num enum in errwarn.h. */
-static char *warn_msgs[] = {
-    "",
-    "ignoring unrecognized character '%s'",
-    "%s value exceeds bounds",
-    "multiple segment overrides, using leftmost",
-    "multiple LOCK or REP prefixes, using leftmost",
-    "no non-local label before '%s'",
-    "multiple SHORT or NEAR specifiers, using leftmost",
-    "character constant too large, ignoring trailing characters"
+    N_("unknown"),
+    N_("out of memory")
 };
 
 /* I hate to define these strings as static buffers; a better solution would be
@@ -100,12 +74,17 @@ static char last_err[1024];
 /* Last warning message string.  Set by Warning(), read by OutputWarning(). */
 static char last_warn[1024];
 
-/* Last error number.  Set by Error(), read and reset by OutputError(). */
-static err_num last_err_num = ERR_NONE;
+/* Has there been an error since the last time we output one?  Set by Error(),
+ * read and reset by OutputError(). */
+static int new_error = 0;
+
+/* Is the last error a parser error?  Error() lets other errors override parser
+ * errors. Set by yyerror(), read and reset by Error(). */
+static int parser_error = 0;
 
-/* Last warning number.  Set by Warning(), read and reset by
- * OutputWarning(). */
-static warn_num last_warn_num = WARN_NONE;
+/* Has there been a warning since the last time we output one?  Set by
+ * Warning(), read and reset by OutputWarning(). */
+static int new_warning = 0;
 
 /* Static buffer for use by conv_unprint(). */
 static char unprint[5];
@@ -134,9 +113,10 @@ conv_unprint(char ch)
 
 /* Parser error handler.  Moves error into our error handling system. */
 void
-yyerror(char *s)
+ParserError(char *s)
 {
-    Error(ERR_PARSER, (char *)NULL, s);
+    Error("%s %s", _("parser error:"), s);
+    parser_error = 1;
 }
 
 /* Report an internal error.  Essentially a fatal error with trace info.
@@ -144,7 +124,7 @@ yyerror(char *s)
 void
 InternalError(unsigned int line, char *file, char *message)
 {
-    fprintf(stderr, "INTERNAL ERROR at %s, line %d: %s\n", file, line,
+    fprintf(stderr, _("INTERNAL ERROR at %s, line %d: %s\n"), file, line,
            message);
     exit(EXIT_FAILURE);
 }
@@ -154,97 +134,28 @@ InternalError(unsigned int line, char *file, char *message)
 void
 Fatal(fatal_num num)
 {
-    fprintf(stderr, "FATAL: %s\n", fatal_msgs[num]);
+    fprintf(stderr, "%s %s\n", _("FATAL:"), gettext(fatal_msgs[num]));
     exit(EXIT_FAILURE);
 }
 
-/* Argument replacement function for use in error messages.
- * Replaces %1, %2, etc in src with %c, %s, etc. in argtypes.
- * Currently limits maximum number of args to 9 (%1-%9).
- *
- * We need this because messages that take multiple arguments become dependent
- * on the order and type of the arguments passed to Error()/Warning().
- *
- * i.e. an error string "'%d' is not a valid specifier for '%s'" would require
- * that the arguments passed to Error() always be an int and a char *, in that
- * order.  If the string was changed to be "'%s': invalid specifier '%d'", all
- * the times Error() was called for that string would need to be changed to
- * reorder the arguments.  Or if the %d was not right in some circumstances,
- * we'd have to add another string for that type.
- *
- * This function fixes this problem by allowing the string to be specified as
- * "'%1' is not a valid specifier for '%2'" and then specifying at the time of
- * the Error() call what the types of %1 and %2 are by passing a argtype string
- * "%d%s" (to emulate the first behavior).  If the string was changed to be
- * "'%2': invalid specifier '%1'", no change would need to be made to the
- * Error calls using that string.  And as the type is specified with the
- * argument list, mismatches are far less likely.
- *
- * For strings that only have one argument of a fixed type, it can be directly
- * specified and NULL passed for the argtypes parameter when Error() is
- * called. */
-static char *
-process_argtypes(char *src, char *argtypes)
-{
-    char *dest;
-    char *argtype[9];
-    int at_num;
-    char *destp, *srcp, *argtypep;
-
-    if (argtypes) {
-       dest = malloc(strlen(src) + strlen(argtypes));
-       if (!dest)
-           Fatal(FATAL_NOMEM);
-       /* split argtypes by % */
-       at_num = 0;
-       while ((argtypes = strchr(argtypes, '%')) && at_num < 9)
-           argtype[at_num++] = ++argtypes;
-       /* search through src for %, copying as we go */
-       destp = dest;
-       srcp = src;
-       while (*srcp != '\0') {
-           *(destp++) = *srcp;
-           if (*(srcp++) == '%') {
-               if (isdigit(*srcp)) {
-                   /* %1, %2, etc */
-                   argtypep = argtype[*srcp - '1'];
-                   while ((*argtypep != '%') && (*argtypep != '\0'))
-                       *(destp++) = *(argtypep++);
-               } else
-                   *(destp++) = *srcp;
-               srcp++;
-           }
-       }
-    } else {
-       dest = strdup(src);
-       if (!dest)
-           Fatal(FATAL_NOMEM);
-    }
-    return dest;
-}
-
 /* Register an error.  Uses argtypes as described above to specify the
  * argument types.  Does not print the error, only stores it for
  * OutputError() to print. */
 void
-Error(err_num num, char *argtypes, ...)
+Error(char *fmt, ...)
 {
     va_list ap;
-    char *printf_str;
 
-    if ((last_err_num != ERR_NONE) && (last_err_num != ERR_PARSER))
+    if (new_error && !parser_error)
        return;
 
-    last_err_num = num;
+    new_error = 1;
+    parser_error = 0;
 
-    printf_str = process_argtypes(err_msgs[num], argtypes);
-
-    va_start(ap, argtypes);
-    vsprintf(last_err, printf_str, ap);
+    va_start(ap, fmt);
+    vsprintf(last_err, fmt, ap);
     va_end(ap);
 
-    free(printf_str);
-
     error_count++;
 }
 
@@ -252,24 +163,19 @@ Error(err_num num, char *argtypes, ...)
  * argument types.  Does not print the warning, only stores it for
  * OutputWarning() to print. */
 void
-Warning(warn_num num, char *argtypes, ...)
+Warning(char *fmt, ...)
 {
     va_list ap;
-    char *printf_str;
 
-    if (last_warn_num != WARN_NONE)
+    if (new_warning)
        return;
 
-    last_warn_num = num;
+    new_warning = 1;
 
-    printf_str = process_argtypes(warn_msgs[num], argtypes);
-
-    va_start(ap, argtypes);
-    vsprintf(last_warn, printf_str, ap);
+    va_start(ap, fmt);
+    vsprintf(last_warn, fmt, ap);
     va_end(ap);
 
-    free(printf_str);
-
     warning_count++;
 }
 
@@ -277,17 +183,17 @@ Warning(warn_num num, char *argtypes, ...)
 void
 OutputError(void)
 {
-    if (last_err_num != ERR_NONE)
+    if (new_error)
        fprintf(stderr, "%s:%u: %s\n", filename, line_number, last_err);
-    last_err_num = ERR_NONE;
+    new_error = 0;
 }
 
 /* Output a previously stored warning (if any) to stderr. */
 void
 OutputWarning(void)
 {
-    if (last_warn_num != WARN_NONE)
-       fprintf(stderr, "%s:%u: warning: %s\n", filename, line_number,
-               last_warn);
-    last_warn_num = WARN_NONE;
+    if (new_warning)
+       fprintf(stderr, "%s:%u: %s %s\n", filename, line_number,
+               _("warning:"), last_warn);
+    new_warning = 0;
 }
index 13a2d75163056a644af101194bb791a5f570508a..bd9e41ede3cbfada22003fe43111d7e755880ec8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.h,v 1.13 2001/08/18 23:05:37 peter Exp $
+/* $Id: errwarn.h,v 1.14 2001/08/30 03:45:26 peter Exp $
  * Error and warning reporting and related functions header file.
  *
  *  Copyright (C) 2001  Peter Johnson
 #ifndef YASM_ERRWARN_H
 #define YASM_ERRWARN_H
 
-/* See errwarn.c for strings that match up to these constants.
+/* Fatal error constants.
+ * See fatal_msgs in errwarn.c for strings that match up to these constants.
  * When adding a constant here, keep errwarn.c in sync! */
-
-/* Fatal error constants.  Match up with fatal_msgs in errwarn.c. */
 typedef enum {
     FATAL_UNKNOWN = 0,
     FATAL_NOMEM
 } fatal_num;
 
-/* Error constants.  Match up with err_msgs in errwarn.c. */
-/* FIXME: These shouldn't be ERR_* because they'll violate namespace
- * constraints if errno.h is included. */
-typedef enum {
-    ERR_NONE = 0,
-    ERR_PARSER,
-    ERR_MISSING,
-    ERR_MISSING_ARG,
-    ERR_INVALID_ARG,
-    ERR_INVALID_EA,
-    ERR_INVALID_LINE,
-    ERR_EXP_SYNTAX,
-    ERR_DUPLICATE_DEF,
-    ERR_OP_SIZE_MISMATCH,
-    ERR_NO_JMPREL_FORM,
-    ERR_STRING_UNTERM,
-    ERR_STRING_EOF,
-    ERR_EXPR_SYNTAX,
-    ERR_DECLDATA_FLOAT,
-    ERR_DECLDATA_EXPR,
-    ERR_FILE_OPEN,
-    ERR_FILE_READ
-} err_num;
-
-/* Warning constants.  Match up with warn_msgs in errwarn.c. */
-typedef enum {
-    WARN_NONE = 0,
-    WARN_UNREC_CHAR,
-    WARN_VALUE_EXCEEDS_BOUNDS,
-    WARN_MULT_SEG_OVERRIDE,
-    WARN_MULT_LOCKREP_PREFIX,
-    WARN_NO_BASE_LABEL,
-    WARN_MULT_SHORTNEAR,
-    WARN_CHAR_CONST_TOO_BIG
-} warn_num;
-
 char *conv_unprint(char ch);
 
+void ParserError(char *);
+
 void InternalError(unsigned int line, char *file, char *message);
 
 void Fatal(fatal_num);
-void Error(err_num, char *, ...);
-void Warning(warn_num, char *, ...);
+void Error(char *, ...);
+void Warning(char *, ...);
 
 void OutputError(void);
 void OutputWarning(void);
index 153607bda117b9eebba3ae638d3db1fc57dc257e..d1ccf8389a603681c184f725667bebeb98d152e0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: symrec.c,v 1.8 2001/08/19 07:46:52 peter Exp $
+/* $Id: symrec.c,v 1.9 2001/08/30 03:45:26 peter Exp $
  * Symbol table handling
  *
  *  Copyright (C) 2001  Michael Urman
 # include <string.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "globals.h"
 #include "errwarn.h"
 #include "symrec.h"
 
-RCSID("$Id: symrec.c,v 1.8 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: symrec.c,v 1.9 2001/08/30 03:45:26 peter Exp $");
 
 /* private functions */
 static symtab *symtab_get(char *);
@@ -134,7 +137,8 @@ sym_def_get(char *name, SymType type)
 
     tab = symtab_get_or_new(name, type);
     if (tab->rec.status & SYM_DECLARED)
-       Error(ERR_DUPLICATE_DEF, "%s%d", tab->rec.name, tab->rec.line);
+       Error(_("duplicate definition of `%s'; previously defined on line %d"),
+             tab->rec.name, tab->rec.line);
     tab->rec.status |= SYM_DECLARED;
     return &(tab->rec);
 }
index 43e24e638b0d7d674376d1c364ea9642baaa7ce0..0ab845cbba2c038e83013164b44e7595f32d04df 100644 (file)
@@ -3,7 +3,9 @@ noinst_LIBRARIES = liboutfmt.a
 liboutfmt_a_SOURCES = \
        outfmt.c
 
-INCLUDES=-I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/src     \
+       -I$(top_srcdir)/intl
 
 if DEV
 CFLAGS = -ansi -pedantic -Wall -g
index 77519bc81a64c8e113905f5a5c059886dc1b4cfe..82bc7fb7df108348c6d0fe1877ed3cb7fb180729 100644 (file)
@@ -10,7 +10,9 @@ noinst_SCRIPTS = gen_instr.pl
 AM_YFLAGS = -d --name-prefix=nasm_parser_
 AM_LFLAGS = -Pnasm_parser_ -olex.yy.c
 
-INCLUDES=-I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/src     \
+       -I$(top_srcdir)/intl
 
 if DEV
 CFLAGS = -ansi -pedantic -Wall -g
index 7c6667b8311d1772e146737808938194886f6d34..c1cab314668c8fe8b7fc8d151db6f8ad74efb320 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.27 2001/08/19 07:46:52 peter Exp $
+/* $Id: bison.y.in,v 1.28 2001/08/30 03:45:26 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -31,6 +31,9 @@
 # include <math.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "globals.h"
 #include "errwarn.h"
 #include "expr.h"
 
 #include "bytecode.h"
 
-RCSID("$Id: bison.y.in,v 1.27 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: bison.y.in,v 1.28 2001/08/30 03:45:26 peter Exp $");
 
 #define YYDEBUG 1
 
 void init_table(void);
 extern int nasm_parser_lex(void);
-extern void yyerror(char *);
 static unsigned long ConvertCharConstToInt(char *);
 void nasm_parser_error(char *);
 
@@ -126,7 +128,7 @@ line: '\n'  { $$.type = BC_EMPTY; }
     | exp '\n' { DebugPrintBC(&$1); $$ = $1; }
     | directive '\n' { $$.type = BC_EMPTY; }
     | error '\n' {
-       Error(ERR_INVALID_LINE, (char *)NULL);
+       Error(_("label or instruction expected at start of line"));
        $$.type = BC_EMPTY;
        yyerrok;
     }
@@ -153,7 +155,7 @@ dataval: expr_no_string             { $$ = dataval_new_expr($1); }
     | FLTNUM                   { $$ = dataval_new_float($1); }
     | STRING                   { $$ = dataval_new_string($1); }
     | error                    {
-       Error(ERR_EXPR_SYNTAX, (char *)NULL);
+       Error(_("expression syntax error"));
        $$ = (dataval *)NULL;
     }
 ;
@@ -172,10 +174,10 @@ directive: '[' DIRECTIVE_NAME DIRECTIVE_VAL ']' {
        printf("Directive: Name='%s' Value='%s'\n", $2, $3);
     }
     | '[' DIRECTIVE_NAME DIRECTIVE_VAL error {
-       Error(ERR_MISSING, "%c", ']');
+       Error(_("missing `%c'"), ']');
     }
     | '[' DIRECTIVE_NAME error {
-       Error(ERR_MISSING_ARG, (char *)NULL, $2);
+       Error(_("missing argument to `%s'"), $2);
     }
 ;
 
@@ -415,7 +417,7 @@ ConvertCharConstToInt(char *cc)
     size_t len = strlen(cc);
 
     if(len > 4)
-       Warning(WARN_CHAR_CONST_TOO_BIG, (char *)NULL);
+       Warning(_("character constant too large, ignoring trailing characters"));
 
     switch(len) {
        case 4:
@@ -437,6 +439,6 @@ ConvertCharConstToInt(char *cc)
 void
 nasm_parser_error(char *s)
 {
-    yyerror(s);
+    ParserError(s);
 }
 
index a122e084d27cfe8095cd2a021ff66fd4652e15f6..1428393c0e0e03945ed876d8f4c1f547808d7b1e 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# $Id: gen_instr.pl,v 1.18 2001/07/11 04:07:11 peter Exp $
+# $Id: gen_instr.pl,v 1.19 2001/08/30 03:45:26 peter Exp $
 # Generates bison.y and token.l from instrs.dat for YASM
 #
 #    Copyright (C) 2001  Michael Urman
@@ -802,7 +802,7 @@ sub output_yacc ($@)
                # print error action
                # ASSUMES: at least one previous action exists
                print GRAMMAR "    | \Ugrp_$group\E error {\n";
-               print GRAMMAR "        Error (ERR_EXP_SYNTAX, (char *)NULL);\n";
+               print GRAMMAR "        Error (_(\"expression syntax error\"));\n";
                print GRAMMAR "    }\n";
 
                # terminate the rule
index 26aac799b99f1c8aa153f46a9d347b3cc4d0c210..84720ffb600c5e6f768a7137db5849d4765d01f2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-bison.y,v 1.27 2001/08/19 07:46:52 peter Exp $
+/* $Id: nasm-bison.y,v 1.28 2001/08/30 03:45:26 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -31,6 +31,9 @@
 # include <math.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "globals.h"
 #include "errwarn.h"
 #include "expr.h"
 
 #include "bytecode.h"
 
-RCSID("$Id: nasm-bison.y,v 1.27 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: nasm-bison.y,v 1.28 2001/08/30 03:45:26 peter Exp $");
 
 #define YYDEBUG 1
 
 void init_table(void);
 extern int nasm_parser_lex(void);
-extern void yyerror(char *);
 static unsigned long ConvertCharConstToInt(char *);
 void nasm_parser_error(char *);
 
@@ -126,7 +128,7 @@ line: '\n'  { $$.type = BC_EMPTY; }
     | exp '\n' { DebugPrintBC(&$1); $$ = $1; }
     | directive '\n' { $$.type = BC_EMPTY; }
     | error '\n' {
-       Error(ERR_INVALID_LINE, (char *)NULL);
+       Error(_("label or instruction expected at start of line"));
        $$.type = BC_EMPTY;
        yyerrok;
     }
@@ -153,7 +155,7 @@ dataval: expr_no_string             { $$ = dataval_new_expr($1); }
     | FLTNUM                   { $$ = dataval_new_float($1); }
     | STRING                   { $$ = dataval_new_string($1); }
     | error                    {
-       Error(ERR_EXPR_SYNTAX, (char *)NULL);
+       Error(_("expression syntax error"));
        $$ = (dataval *)NULL;
     }
 ;
@@ -172,10 +174,10 @@ directive: '[' DIRECTIVE_NAME DIRECTIVE_VAL ']' {
        printf("Directive: Name='%s' Value='%s'\n", $2, $3);
     }
     | '[' DIRECTIVE_NAME DIRECTIVE_VAL error {
-       Error(ERR_MISSING, "%c", ']');
+       Error(_("missing `%c'"), ']');
     }
     | '[' DIRECTIVE_NAME error {
-       Error(ERR_MISSING_ARG, (char *)NULL, $2);
+       Error(_("missing argument to `%s'"), $2);
     }
 ;
 
@@ -415,7 +417,7 @@ ConvertCharConstToInt(char *cc)
     size_t len = strlen(cc);
 
     if(len > 4)
-       Warning(WARN_CHAR_CONST_TOO_BIG, (char *)NULL);
+       Warning(_("character constant too large, ignoring trailing characters"));
 
     switch(len) {
        case 4:
@@ -437,6 +439,6 @@ ConvertCharConstToInt(char *cc)
 void
 nasm_parser_error(char *s)
 {
-    yyerror(s);
+    ParserError(s);
 }
 
index 5cc850a53df28c26f0dd7771ac9502cda092d660..137c596eaebda22a6d63c7dfd586201ab8cca2b5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: token.l.in,v 1.15 2001/08/19 07:46:52 peter Exp $
+/* $Id: token.l.in,v 1.16 2001/08/30 03:45:26 peter Exp $
  * Main lexer
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -31,6 +31,9 @@
 # include <string.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "errwarn.h"
 #include "expr.h"
 #include "symrec.h"
@@ -39,7 +42,7 @@
 
 #include "bison.h"
 
-RCSID("$Id: token.l.in,v 1.15 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: token.l.in,v 1.16 2001/08/30 03:45:26 peter Exp $");
 
 #define yylval nasm_parser_lval
 
@@ -133,9 +136,9 @@ WS       [ \t\r]
     }
 
     if(inch == '\n')
-       Error(ERR_STRING_UNTERM, (char *)NULL);
+       Error(_("unterminated string"));
     else if(inch == EOF)
-       Error(ERR_STRING_EOF, (char *)NULL);
+       Error(_("unexpected end of file in string"));
 
     strbuf[count] = '\0';
 
@@ -166,10 +169,12 @@ WS       [ \t\r]
     return DIRECTIVE_VAL;
 }
 <DIRECTIVE>. {
-    Warning(WARN_UNREC_CHAR, (char *)NULL, conv_unprint(yytext[0]));
+    Warning(_("ignoring unrecognized character `%s'"),
+           conv_unprint(yytext[0]));
 }
 <DIRECTIVE2>. {
-    Warning(WARN_UNREC_CHAR, (char *)NULL, conv_unprint(yytext[0]));
+    Warning(_("ignoring unrecognized character `%s'"),
+           conv_unprint(yytext[0]));
 }
 
     /* size specifiers */
@@ -293,7 +298,7 @@ $$|$|\.\.[a-z0-9_$#@~.?]+ {
 \.[a-z0-9_$#@~?][a-z0-9_$#@~.?]* {
     if (locallabel_base == NULL) 
     {
-       Warning (WARN_NO_BASE_LABEL, (char *)NULL, yytext);
+       Warning (_("no non-local label before `%s'"), yytext);
        yylval.syminfo.name = strdup (yytext);
        if (yylval.syminfo.name == NULL) Fatal (FATAL_NOMEM);
     }
@@ -329,5 +334,8 @@ $$|$|\.\.[a-z0-9_$#@~.?]+ {
 
 \n     return '\n';
 
-.      { Warning(WARN_UNREC_CHAR, (char *)NULL, conv_unprint(yytext[0])); }
+.      {
+    Warning(_("ignoring unrecognized character `%s'"),
+           conv_unprint(yytext[0]));
+}
 
index 9e956333176750914ffc31e2068d67a0a254c536..5a55488038e01dcc79538c687d129610f1bc810c 100644 (file)
@@ -3,7 +3,9 @@ noinst_LIBRARIES = libpreproc.a
 libpreproc_a_SOURCES = \
        preproc.c
 
-INCLUDES=-I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/src     \
+       -I$(top_srcdir)/intl
 
 if DEV
 CFLAGS = -ansi -pedantic -Wall -g
index c21980f4db656f579c7dd8734487aeef852e0376..f93d3b3d5149a1802a69d86f908cf0c0ae096dc3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: preproc.c,v 1.5 2001/08/19 07:46:52 peter Exp $
+/* $Id: preproc.c,v 1.6 2001/08/30 03:45:26 peter Exp $
  * Raw preprocessor (preforms NO preprocessing)
  *
  *  Copyright (C) 2001  Peter Johnson
 
 #include <stdio.h>
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "errwarn.h"
 
 #include "outfmt.h"
 #include "preproc.h"
 
-RCSID("$Id: preproc.c,v 1.5 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: preproc.c,v 1.6 2001/08/30 03:45:26 peter Exp $");
 
 static int is_interactive;
 static FILE *in;
@@ -57,9 +60,9 @@ input(char *buf, int max_size)
        if (c == '\n')
            buf[n++] = (char)c;
        if (c == EOF && ferror(in))
-           Error(ERR_FILE_READ, (char *)NULL);
+           Error(_("error when reading from file"));
     } else if (((n = fread(buf, 1, max_size, in)) == 0) && ferror(in))
-       Error(ERR_FILE_READ, (char *)NULL);
+       Error(_("error when reading from file"));
 
     return n;
 }
index 319a4343edcc5420bba0155aaed7228161980a46..1bb5dc4c5ef0900f5d5bf2ef103739de4f8bf396 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: raw-preproc.c,v 1.5 2001/08/19 07:46:52 peter Exp $
+/* $Id: raw-preproc.c,v 1.6 2001/08/30 03:45:26 peter Exp $
  * Raw preprocessor (preforms NO preprocessing)
  *
  *  Copyright (C) 2001  Peter Johnson
 
 #include <stdio.h>
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "errwarn.h"
 
 #include "outfmt.h"
 #include "preproc.h"
 
-RCSID("$Id: raw-preproc.c,v 1.5 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: raw-preproc.c,v 1.6 2001/08/30 03:45:26 peter Exp $");
 
 static int is_interactive;
 static FILE *in;
@@ -57,9 +60,9 @@ input(char *buf, int max_size)
        if (c == '\n')
            buf[n++] = (char)c;
        if (c == EOF && ferror(in))
-           Error(ERR_FILE_READ, (char *)NULL);
+           Error(_("error when reading from file"));
     } else if (((n = fread(buf, 1, max_size, in)) == 0) && ferror(in))
-       Error(ERR_FILE_READ, (char *)NULL);
+       Error(_("error when reading from file"));
 
     return n;
 }
diff --git a/po/.cvsignore b/po/.cvsignore
new file mode 100644 (file)
index 0000000..5473340
--- /dev/null
@@ -0,0 +1,7 @@
+Makefile
+Makefile.in
+Makefile.in.in
+POTFILES
+cat-id-tbl.c
+yasm.pot
+stamp-cat-id
diff --git a/po/ChangeLog b/po/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644 (file)
index 0000000..a19b1a4
--- /dev/null
@@ -0,0 +1,11 @@
+# List of source files containing translatable strings.
+# Copyright (c) 2001  Peter Johnson
+#
+# $Id: POTFILES.in,v 1.1 2001/08/30 03:45:16 peter Exp $
+
+src/errwarn.c
+src/bytecode.c
+src/symrec.c
+src/parsers/nasm/bison.c
+src/parsers/nasm/token.c
+src/preprocs/raw/preproc.c
index 54886725f520ff887a07aac2fcfa5ac5cbf3438d..56433ef04148c6e23f007700af968af564046f98 100644 (file)
@@ -1,5 +1,7 @@
 SUBDIRS = parsers preprocs outfmts
 
+INCLUDES = -I$(top_srcdir)/intl
+
 bin_PROGRAMS = yasm
 
 yasm_SOURCES = \
@@ -22,7 +24,8 @@ yasm_SOURCES = \
 yasm_LDADD = \
        parsers/nasm/libparser.a        \
        preprocs/raw/libpreproc.a       \
-       outfmts/dbg/liboutfmt.a
+       outfmts/dbg/liboutfmt.a         \
+       $(INTLLIBS)
 
 if DEV
 CFLAGS = -ansi -pedantic -Wall -g
index 347a45eb81d5a3bf6f1473a8dfa654200f47cc02..2765a25147e7e3b6865dc90b891482afe53f9043 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bytecode.c,v 1.19 2001/08/19 07:46:52 peter Exp $
+/* $Id: bytecode.c,v 1.20 2001/08/30 03:45:26 peter Exp $
  * Bytecode utility functions
  *
  *  Copyright (C) 2001  Peter Johnson
 # include <string.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "globals.h"
 #include "errwarn.h"
 #include "expr.h"
 
 #include "bytecode.h"
 
-RCSID("$Id: bytecode.c,v 1.19 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: bytecode.c,v 1.20 2001/08/30 03:45:26 peter Exp $");
 
 /* Static structures for when NULL is passed to conversion functions. */
 /*  for Convert*ToEA() */
@@ -95,7 +98,7 @@ ConvertImmToEA(effaddr *ptr, immval *im_ptr, unsigned char im_len)
 
     ptr->disp = im_ptr->val;
     if (im_ptr->len > im_len)
-       Warning(WARN_VALUE_EXCEEDS_BOUNDS, (char *)NULL, "word");
+       Warning(_("%s value exceeds bounds"), "word");
     ptr->len = im_len;
     ptr->segment = 0;
     ptr->valid_modrm = 0;
@@ -147,7 +150,7 @@ SetEASegment(effaddr *ptr, unsigned char segment)
        return;
 
     if (ptr->segment != 0)
-       Warning(WARN_MULT_SEG_OVERRIDE, (char *)NULL);
+       Warning(_("multiple segment overrides, using leftmost"));
 
     ptr->segment = segment;
 }
@@ -180,7 +183,7 @@ SetInsnOperSizeOverride(bytecode *bc, unsigned char opersize)
            break;
        default:
            InternalError(__LINE__, __FILE__,
-                         "OperSize override applied to non-instruction");
+                         _("OperSize override applied to non-instruction"));
            return;
     }
 }
@@ -200,7 +203,7 @@ SetInsnAddrSizeOverride(bytecode *bc, unsigned char addrsize)
            break;
        default:
            InternalError(__LINE__, __FILE__,
-                         "AddrSize override applied to non-instruction");
+                         _("AddrSize override applied to non-instruction"));
            return;
     }
 }
@@ -222,12 +225,12 @@ SetInsnLockRepPrefix(bytecode *bc, unsigned char prefix)
            break;
        default:
            InternalError(__LINE__, __FILE__,
-                         "LockRep prefix applied to non-instruction");
+                         _("LockRep prefix applied to non-instruction"));
            return;
     }
 
     if (*lockrep_pre != 0)
-       Warning(WARN_MULT_LOCKREP_PREFIX, (char *)NULL);
+       Warning(_("multiple LOCK or REP prefixes, using leftmost"));
 
     *lockrep_pre = prefix;
 }
@@ -239,7 +242,7 @@ SetOpcodeSel(jmprel_opcode_sel *old_sel, jmprel_opcode_sel new_sel)
        return;
 
     if ((*old_sel == JR_SHORT_FORCED) || (*old_sel == JR_NEAR_FORCED))
-       Warning(WARN_MULT_SHORTNEAR, (char *)NULL);
+       Warning(_("multiple SHORT or NEAR specifiers, using leftmost"));
     *old_sel = new_sel;
 }
 
@@ -324,9 +327,9 @@ BuildBC_JmpRel(bytecode      *bc,
     bc->data.jmprel.op_sel = target->op_sel;
 
     if ((target->op_sel == JR_SHORT_FORCED) && (!short_valid))
-       Error(ERR_NO_JMPREL_FORM, (char *)NULL, "SHORT");
+       Error(_("no SHORT form of that jump instruction exists"));
     if ((target->op_sel == JR_NEAR_FORCED) && (!near_valid))
-       Error(ERR_NO_JMPREL_FORM, (char *)NULL, "NEAR");
+       Error(_("no NEAR form of that jump instruction exists"));
 
     bc->data.jmprel.shortop.valid = short_valid;
     if (short_valid) {
@@ -378,13 +381,16 @@ BuildBC_Data(bytecode *bc, datavalhead *datahead, unsigned long size)
                break;
            case DV_FLOAT:
                if (size == 1)
-                   Error(ERR_DECLDATA_FLOAT, (char *)NULL, "DB");
+                   Error(_("floating-point constant encountered in `%s'"),
+                         "DB");
                else if (size == 2)
-                   Error(ERR_DECLDATA_FLOAT, (char *)NULL, "DW");
+                   Error(_("floating-point constant encountered in `%s'"),
+                         "DW");
                break;
            case DV_EXPR:
                if (size == 10)
-                   Error(ERR_DECLDATA_EXPR, (char *)NULL, "DT");
+                   Error(_("non-floating-point value encountered in `%s'"),
+                         "DT");
                break;
        }
     }
index c802a9a4d83d437e2cef45c8f99834aff9b701cc..63f25929e1ba47d3cdae86174dd77f343e71eb28 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.c,v 1.22 2001/08/19 07:46:52 peter Exp $
+/* $Id: errwarn.c,v 1.23 2001/08/30 03:45:26 peter Exp $
  * Error and warning reporting and related functions.
  *
  *  Copyright (C) 2001  Peter Johnson
 # include <string.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+#ifdef gettext_noop
+#define N_(String)     gettext_noop(String)
+#else
+#define N_(String)     (String)
+#endif
+
 #include "globals.h"
 #include "errwarn.h"
 
-RCSID("$Id: errwarn.c,v 1.22 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: errwarn.c,v 1.23 2001/08/30 03:45:26 peter Exp $");
 
 /* Total error count for entire assembler run.
  * Assembler should exit with EXIT_FAILURE if this is >= 0 on finish. */
@@ -52,42 +60,8 @@ unsigned int warning_count = 0;
 
 /* Fatal error messages.  Match up with fatal_num enum in errwarn.h. */
 static char *fatal_msgs[] = {
-    "unknown",
-    "out of memory"
-};
-
-/* Error messages.  Match up with err_num enum in errwarn.h. */
-static char *err_msgs[] = {
-    "",
-    "parser error: %s",
-    "missing '%1'",
-    "missing argument to %s",
-    "invalid argument to %s",
-    "invalid effective address",
-    "label or instruction expected at start of line",
-    "expression syntax error",
-    "duplicate definition of `%1'; previously defined line %2",
-    "mismatch in operand sizes",
-    "no %s form of that jump instruction exists",
-    "unterminated string",
-    "unexpected end of file in string",
-    "expression syntax error",
-    "floating-point constant encountered in `%s'",
-    "non-floating-point value encountered in `%s'",
-    "could not open file `%s'",
-    "error when reading from file"
-};
-
-/* Warning messages.  Match up with warn_num enum in errwarn.h. */
-static char *warn_msgs[] = {
-    "",
-    "ignoring unrecognized character '%s'",
-    "%s value exceeds bounds",
-    "multiple segment overrides, using leftmost",
-    "multiple LOCK or REP prefixes, using leftmost",
-    "no non-local label before '%s'",
-    "multiple SHORT or NEAR specifiers, using leftmost",
-    "character constant too large, ignoring trailing characters"
+    N_("unknown"),
+    N_("out of memory")
 };
 
 /* I hate to define these strings as static buffers; a better solution would be
@@ -100,12 +74,17 @@ static char last_err[1024];
 /* Last warning message string.  Set by Warning(), read by OutputWarning(). */
 static char last_warn[1024];
 
-/* Last error number.  Set by Error(), read and reset by OutputError(). */
-static err_num last_err_num = ERR_NONE;
+/* Has there been an error since the last time we output one?  Set by Error(),
+ * read and reset by OutputError(). */
+static int new_error = 0;
+
+/* Is the last error a parser error?  Error() lets other errors override parser
+ * errors. Set by yyerror(), read and reset by Error(). */
+static int parser_error = 0;
 
-/* Last warning number.  Set by Warning(), read and reset by
- * OutputWarning(). */
-static warn_num last_warn_num = WARN_NONE;
+/* Has there been a warning since the last time we output one?  Set by
+ * Warning(), read and reset by OutputWarning(). */
+static int new_warning = 0;
 
 /* Static buffer for use by conv_unprint(). */
 static char unprint[5];
@@ -134,9 +113,10 @@ conv_unprint(char ch)
 
 /* Parser error handler.  Moves error into our error handling system. */
 void
-yyerror(char *s)
+ParserError(char *s)
 {
-    Error(ERR_PARSER, (char *)NULL, s);
+    Error("%s %s", _("parser error:"), s);
+    parser_error = 1;
 }
 
 /* Report an internal error.  Essentially a fatal error with trace info.
@@ -144,7 +124,7 @@ yyerror(char *s)
 void
 InternalError(unsigned int line, char *file, char *message)
 {
-    fprintf(stderr, "INTERNAL ERROR at %s, line %d: %s\n", file, line,
+    fprintf(stderr, _("INTERNAL ERROR at %s, line %d: %s\n"), file, line,
            message);
     exit(EXIT_FAILURE);
 }
@@ -154,97 +134,28 @@ InternalError(unsigned int line, char *file, char *message)
 void
 Fatal(fatal_num num)
 {
-    fprintf(stderr, "FATAL: %s\n", fatal_msgs[num]);
+    fprintf(stderr, "%s %s\n", _("FATAL:"), gettext(fatal_msgs[num]));
     exit(EXIT_FAILURE);
 }
 
-/* Argument replacement function for use in error messages.
- * Replaces %1, %2, etc in src with %c, %s, etc. in argtypes.
- * Currently limits maximum number of args to 9 (%1-%9).
- *
- * We need this because messages that take multiple arguments become dependent
- * on the order and type of the arguments passed to Error()/Warning().
- *
- * i.e. an error string "'%d' is not a valid specifier for '%s'" would require
- * that the arguments passed to Error() always be an int and a char *, in that
- * order.  If the string was changed to be "'%s': invalid specifier '%d'", all
- * the times Error() was called for that string would need to be changed to
- * reorder the arguments.  Or if the %d was not right in some circumstances,
- * we'd have to add another string for that type.
- *
- * This function fixes this problem by allowing the string to be specified as
- * "'%1' is not a valid specifier for '%2'" and then specifying at the time of
- * the Error() call what the types of %1 and %2 are by passing a argtype string
- * "%d%s" (to emulate the first behavior).  If the string was changed to be
- * "'%2': invalid specifier '%1'", no change would need to be made to the
- * Error calls using that string.  And as the type is specified with the
- * argument list, mismatches are far less likely.
- *
- * For strings that only have one argument of a fixed type, it can be directly
- * specified and NULL passed for the argtypes parameter when Error() is
- * called. */
-static char *
-process_argtypes(char *src, char *argtypes)
-{
-    char *dest;
-    char *argtype[9];
-    int at_num;
-    char *destp, *srcp, *argtypep;
-
-    if (argtypes) {
-       dest = malloc(strlen(src) + strlen(argtypes));
-       if (!dest)
-           Fatal(FATAL_NOMEM);
-       /* split argtypes by % */
-       at_num = 0;
-       while ((argtypes = strchr(argtypes, '%')) && at_num < 9)
-           argtype[at_num++] = ++argtypes;
-       /* search through src for %, copying as we go */
-       destp = dest;
-       srcp = src;
-       while (*srcp != '\0') {
-           *(destp++) = *srcp;
-           if (*(srcp++) == '%') {
-               if (isdigit(*srcp)) {
-                   /* %1, %2, etc */
-                   argtypep = argtype[*srcp - '1'];
-                   while ((*argtypep != '%') && (*argtypep != '\0'))
-                       *(destp++) = *(argtypep++);
-               } else
-                   *(destp++) = *srcp;
-               srcp++;
-           }
-       }
-    } else {
-       dest = strdup(src);
-       if (!dest)
-           Fatal(FATAL_NOMEM);
-    }
-    return dest;
-}
-
 /* Register an error.  Uses argtypes as described above to specify the
  * argument types.  Does not print the error, only stores it for
  * OutputError() to print. */
 void
-Error(err_num num, char *argtypes, ...)
+Error(char *fmt, ...)
 {
     va_list ap;
-    char *printf_str;
 
-    if ((last_err_num != ERR_NONE) && (last_err_num != ERR_PARSER))
+    if (new_error && !parser_error)
        return;
 
-    last_err_num = num;
+    new_error = 1;
+    parser_error = 0;
 
-    printf_str = process_argtypes(err_msgs[num], argtypes);
-
-    va_start(ap, argtypes);
-    vsprintf(last_err, printf_str, ap);
+    va_start(ap, fmt);
+    vsprintf(last_err, fmt, ap);
     va_end(ap);
 
-    free(printf_str);
-
     error_count++;
 }
 
@@ -252,24 +163,19 @@ Error(err_num num, char *argtypes, ...)
  * argument types.  Does not print the warning, only stores it for
  * OutputWarning() to print. */
 void
-Warning(warn_num num, char *argtypes, ...)
+Warning(char *fmt, ...)
 {
     va_list ap;
-    char *printf_str;
 
-    if (last_warn_num != WARN_NONE)
+    if (new_warning)
        return;
 
-    last_warn_num = num;
+    new_warning = 1;
 
-    printf_str = process_argtypes(warn_msgs[num], argtypes);
-
-    va_start(ap, argtypes);
-    vsprintf(last_warn, printf_str, ap);
+    va_start(ap, fmt);
+    vsprintf(last_warn, fmt, ap);
     va_end(ap);
 
-    free(printf_str);
-
     warning_count++;
 }
 
@@ -277,17 +183,17 @@ Warning(warn_num num, char *argtypes, ...)
 void
 OutputError(void)
 {
-    if (last_err_num != ERR_NONE)
+    if (new_error)
        fprintf(stderr, "%s:%u: %s\n", filename, line_number, last_err);
-    last_err_num = ERR_NONE;
+    new_error = 0;
 }
 
 /* Output a previously stored warning (if any) to stderr. */
 void
 OutputWarning(void)
 {
-    if (last_warn_num != WARN_NONE)
-       fprintf(stderr, "%s:%u: warning: %s\n", filename, line_number,
-               last_warn);
-    last_warn_num = WARN_NONE;
+    if (new_warning)
+       fprintf(stderr, "%s:%u: %s %s\n", filename, line_number,
+               _("warning:"), last_warn);
+    new_warning = 0;
 }
index 13a2d75163056a644af101194bb791a5f570508a..bd9e41ede3cbfada22003fe43111d7e755880ec8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: errwarn.h,v 1.13 2001/08/18 23:05:37 peter Exp $
+/* $Id: errwarn.h,v 1.14 2001/08/30 03:45:26 peter Exp $
  * Error and warning reporting and related functions header file.
  *
  *  Copyright (C) 2001  Peter Johnson
 #ifndef YASM_ERRWARN_H
 #define YASM_ERRWARN_H
 
-/* See errwarn.c for strings that match up to these constants.
+/* Fatal error constants.
+ * See fatal_msgs in errwarn.c for strings that match up to these constants.
  * When adding a constant here, keep errwarn.c in sync! */
-
-/* Fatal error constants.  Match up with fatal_msgs in errwarn.c. */
 typedef enum {
     FATAL_UNKNOWN = 0,
     FATAL_NOMEM
 } fatal_num;
 
-/* Error constants.  Match up with err_msgs in errwarn.c. */
-/* FIXME: These shouldn't be ERR_* because they'll violate namespace
- * constraints if errno.h is included. */
-typedef enum {
-    ERR_NONE = 0,
-    ERR_PARSER,
-    ERR_MISSING,
-    ERR_MISSING_ARG,
-    ERR_INVALID_ARG,
-    ERR_INVALID_EA,
-    ERR_INVALID_LINE,
-    ERR_EXP_SYNTAX,
-    ERR_DUPLICATE_DEF,
-    ERR_OP_SIZE_MISMATCH,
-    ERR_NO_JMPREL_FORM,
-    ERR_STRING_UNTERM,
-    ERR_STRING_EOF,
-    ERR_EXPR_SYNTAX,
-    ERR_DECLDATA_FLOAT,
-    ERR_DECLDATA_EXPR,
-    ERR_FILE_OPEN,
-    ERR_FILE_READ
-} err_num;
-
-/* Warning constants.  Match up with warn_msgs in errwarn.c. */
-typedef enum {
-    WARN_NONE = 0,
-    WARN_UNREC_CHAR,
-    WARN_VALUE_EXCEEDS_BOUNDS,
-    WARN_MULT_SEG_OVERRIDE,
-    WARN_MULT_LOCKREP_PREFIX,
-    WARN_NO_BASE_LABEL,
-    WARN_MULT_SHORTNEAR,
-    WARN_CHAR_CONST_TOO_BIG
-} warn_num;
-
 char *conv_unprint(char ch);
 
+void ParserError(char *);
+
 void InternalError(unsigned int line, char *file, char *message);
 
 void Fatal(fatal_num);
-void Error(err_num, char *, ...);
-void Warning(warn_num, char *, ...);
+void Error(char *, ...);
+void Warning(char *, ...);
 
 void OutputError(void);
 void OutputWarning(void);
index 43e24e638b0d7d674376d1c364ea9642baaa7ce0..0ab845cbba2c038e83013164b44e7595f32d04df 100644 (file)
@@ -3,7 +3,9 @@ noinst_LIBRARIES = liboutfmt.a
 liboutfmt_a_SOURCES = \
        outfmt.c
 
-INCLUDES=-I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/src     \
+       -I$(top_srcdir)/intl
 
 if DEV
 CFLAGS = -ansi -pedantic -Wall -g
index 77519bc81a64c8e113905f5a5c059886dc1b4cfe..82bc7fb7df108348c6d0fe1877ed3cb7fb180729 100644 (file)
@@ -10,7 +10,9 @@ noinst_SCRIPTS = gen_instr.pl
 AM_YFLAGS = -d --name-prefix=nasm_parser_
 AM_LFLAGS = -Pnasm_parser_ -olex.yy.c
 
-INCLUDES=-I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/src     \
+       -I$(top_srcdir)/intl
 
 if DEV
 CFLAGS = -ansi -pedantic -Wall -g
index 7c6667b8311d1772e146737808938194886f6d34..c1cab314668c8fe8b7fc8d151db6f8ad74efb320 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.27 2001/08/19 07:46:52 peter Exp $
+/* $Id: bison.y.in,v 1.28 2001/08/30 03:45:26 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -31,6 +31,9 @@
 # include <math.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "globals.h"
 #include "errwarn.h"
 #include "expr.h"
 
 #include "bytecode.h"
 
-RCSID("$Id: bison.y.in,v 1.27 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: bison.y.in,v 1.28 2001/08/30 03:45:26 peter Exp $");
 
 #define YYDEBUG 1
 
 void init_table(void);
 extern int nasm_parser_lex(void);
-extern void yyerror(char *);
 static unsigned long ConvertCharConstToInt(char *);
 void nasm_parser_error(char *);
 
@@ -126,7 +128,7 @@ line: '\n'  { $$.type = BC_EMPTY; }
     | exp '\n' { DebugPrintBC(&$1); $$ = $1; }
     | directive '\n' { $$.type = BC_EMPTY; }
     | error '\n' {
-       Error(ERR_INVALID_LINE, (char *)NULL);
+       Error(_("label or instruction expected at start of line"));
        $$.type = BC_EMPTY;
        yyerrok;
     }
@@ -153,7 +155,7 @@ dataval: expr_no_string             { $$ = dataval_new_expr($1); }
     | FLTNUM                   { $$ = dataval_new_float($1); }
     | STRING                   { $$ = dataval_new_string($1); }
     | error                    {
-       Error(ERR_EXPR_SYNTAX, (char *)NULL);
+       Error(_("expression syntax error"));
        $$ = (dataval *)NULL;
     }
 ;
@@ -172,10 +174,10 @@ directive: '[' DIRECTIVE_NAME DIRECTIVE_VAL ']' {
        printf("Directive: Name='%s' Value='%s'\n", $2, $3);
     }
     | '[' DIRECTIVE_NAME DIRECTIVE_VAL error {
-       Error(ERR_MISSING, "%c", ']');
+       Error(_("missing `%c'"), ']');
     }
     | '[' DIRECTIVE_NAME error {
-       Error(ERR_MISSING_ARG, (char *)NULL, $2);
+       Error(_("missing argument to `%s'"), $2);
     }
 ;
 
@@ -415,7 +417,7 @@ ConvertCharConstToInt(char *cc)
     size_t len = strlen(cc);
 
     if(len > 4)
-       Warning(WARN_CHAR_CONST_TOO_BIG, (char *)NULL);
+       Warning(_("character constant too large, ignoring trailing characters"));
 
     switch(len) {
        case 4:
@@ -437,6 +439,6 @@ ConvertCharConstToInt(char *cc)
 void
 nasm_parser_error(char *s)
 {
-    yyerror(s);
+    ParserError(s);
 }
 
index a122e084d27cfe8095cd2a021ff66fd4652e15f6..1428393c0e0e03945ed876d8f4c1f547808d7b1e 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# $Id: gen_instr.pl,v 1.18 2001/07/11 04:07:11 peter Exp $
+# $Id: gen_instr.pl,v 1.19 2001/08/30 03:45:26 peter Exp $
 # Generates bison.y and token.l from instrs.dat for YASM
 #
 #    Copyright (C) 2001  Michael Urman
@@ -802,7 +802,7 @@ sub output_yacc ($@)
                # print error action
                # ASSUMES: at least one previous action exists
                print GRAMMAR "    | \Ugrp_$group\E error {\n";
-               print GRAMMAR "        Error (ERR_EXP_SYNTAX, (char *)NULL);\n";
+               print GRAMMAR "        Error (_(\"expression syntax error\"));\n";
                print GRAMMAR "    }\n";
 
                # terminate the rule
index 26aac799b99f1c8aa153f46a9d347b3cc4d0c210..84720ffb600c5e6f768a7137db5849d4765d01f2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-bison.y,v 1.27 2001/08/19 07:46:52 peter Exp $
+/* $Id: nasm-bison.y,v 1.28 2001/08/30 03:45:26 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -31,6 +31,9 @@
 # include <math.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "globals.h"
 #include "errwarn.h"
 #include "expr.h"
 
 #include "bytecode.h"
 
-RCSID("$Id: nasm-bison.y,v 1.27 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: nasm-bison.y,v 1.28 2001/08/30 03:45:26 peter Exp $");
 
 #define YYDEBUG 1
 
 void init_table(void);
 extern int nasm_parser_lex(void);
-extern void yyerror(char *);
 static unsigned long ConvertCharConstToInt(char *);
 void nasm_parser_error(char *);
 
@@ -126,7 +128,7 @@ line: '\n'  { $$.type = BC_EMPTY; }
     | exp '\n' { DebugPrintBC(&$1); $$ = $1; }
     | directive '\n' { $$.type = BC_EMPTY; }
     | error '\n' {
-       Error(ERR_INVALID_LINE, (char *)NULL);
+       Error(_("label or instruction expected at start of line"));
        $$.type = BC_EMPTY;
        yyerrok;
     }
@@ -153,7 +155,7 @@ dataval: expr_no_string             { $$ = dataval_new_expr($1); }
     | FLTNUM                   { $$ = dataval_new_float($1); }
     | STRING                   { $$ = dataval_new_string($1); }
     | error                    {
-       Error(ERR_EXPR_SYNTAX, (char *)NULL);
+       Error(_("expression syntax error"));
        $$ = (dataval *)NULL;
     }
 ;
@@ -172,10 +174,10 @@ directive: '[' DIRECTIVE_NAME DIRECTIVE_VAL ']' {
        printf("Directive: Name='%s' Value='%s'\n", $2, $3);
     }
     | '[' DIRECTIVE_NAME DIRECTIVE_VAL error {
-       Error(ERR_MISSING, "%c", ']');
+       Error(_("missing `%c'"), ']');
     }
     | '[' DIRECTIVE_NAME error {
-       Error(ERR_MISSING_ARG, (char *)NULL, $2);
+       Error(_("missing argument to `%s'"), $2);
     }
 ;
 
@@ -415,7 +417,7 @@ ConvertCharConstToInt(char *cc)
     size_t len = strlen(cc);
 
     if(len > 4)
-       Warning(WARN_CHAR_CONST_TOO_BIG, (char *)NULL);
+       Warning(_("character constant too large, ignoring trailing characters"));
 
     switch(len) {
        case 4:
@@ -437,6 +439,6 @@ ConvertCharConstToInt(char *cc)
 void
 nasm_parser_error(char *s)
 {
-    yyerror(s);
+    ParserError(s);
 }
 
index 5cc850a53df28c26f0dd7771ac9502cda092d660..137c596eaebda22a6d63c7dfd586201ab8cca2b5 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: token.l.in,v 1.15 2001/08/19 07:46:52 peter Exp $
+/* $Id: token.l.in,v 1.16 2001/08/30 03:45:26 peter Exp $
  * Main lexer
  *
  *  Copyright (C) 2001  Peter Johnson
@@ -31,6 +31,9 @@
 # include <string.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "errwarn.h"
 #include "expr.h"
 #include "symrec.h"
@@ -39,7 +42,7 @@
 
 #include "bison.h"
 
-RCSID("$Id: token.l.in,v 1.15 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: token.l.in,v 1.16 2001/08/30 03:45:26 peter Exp $");
 
 #define yylval nasm_parser_lval
 
@@ -133,9 +136,9 @@ WS       [ \t\r]
     }
 
     if(inch == '\n')
-       Error(ERR_STRING_UNTERM, (char *)NULL);
+       Error(_("unterminated string"));
     else if(inch == EOF)
-       Error(ERR_STRING_EOF, (char *)NULL);
+       Error(_("unexpected end of file in string"));
 
     strbuf[count] = '\0';
 
@@ -166,10 +169,12 @@ WS       [ \t\r]
     return DIRECTIVE_VAL;
 }
 <DIRECTIVE>. {
-    Warning(WARN_UNREC_CHAR, (char *)NULL, conv_unprint(yytext[0]));
+    Warning(_("ignoring unrecognized character `%s'"),
+           conv_unprint(yytext[0]));
 }
 <DIRECTIVE2>. {
-    Warning(WARN_UNREC_CHAR, (char *)NULL, conv_unprint(yytext[0]));
+    Warning(_("ignoring unrecognized character `%s'"),
+           conv_unprint(yytext[0]));
 }
 
     /* size specifiers */
@@ -293,7 +298,7 @@ $$|$|\.\.[a-z0-9_$#@~.?]+ {
 \.[a-z0-9_$#@~?][a-z0-9_$#@~.?]* {
     if (locallabel_base == NULL) 
     {
-       Warning (WARN_NO_BASE_LABEL, (char *)NULL, yytext);
+       Warning (_("no non-local label before `%s'"), yytext);
        yylval.syminfo.name = strdup (yytext);
        if (yylval.syminfo.name == NULL) Fatal (FATAL_NOMEM);
     }
@@ -329,5 +334,8 @@ $$|$|\.\.[a-z0-9_$#@~.?]+ {
 
 \n     return '\n';
 
-.      { Warning(WARN_UNREC_CHAR, (char *)NULL, conv_unprint(yytext[0])); }
+.      {
+    Warning(_("ignoring unrecognized character `%s'"),
+           conv_unprint(yytext[0]));
+}
 
index 9e956333176750914ffc31e2068d67a0a254c536..5a55488038e01dcc79538c687d129610f1bc810c 100644 (file)
@@ -3,7 +3,9 @@ noinst_LIBRARIES = libpreproc.a
 libpreproc_a_SOURCES = \
        preproc.c
 
-INCLUDES=-I$(top_srcdir)/src
+INCLUDES = \
+       -I$(top_srcdir)/src     \
+       -I$(top_srcdir)/intl
 
 if DEV
 CFLAGS = -ansi -pedantic -Wall -g
index c21980f4db656f579c7dd8734487aeef852e0376..f93d3b3d5149a1802a69d86f908cf0c0ae096dc3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: preproc.c,v 1.5 2001/08/19 07:46:52 peter Exp $
+/* $Id: preproc.c,v 1.6 2001/08/30 03:45:26 peter Exp $
  * Raw preprocessor (preforms NO preprocessing)
  *
  *  Copyright (C) 2001  Peter Johnson
 
 #include <stdio.h>
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "errwarn.h"
 
 #include "outfmt.h"
 #include "preproc.h"
 
-RCSID("$Id: preproc.c,v 1.5 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: preproc.c,v 1.6 2001/08/30 03:45:26 peter Exp $");
 
 static int is_interactive;
 static FILE *in;
@@ -57,9 +60,9 @@ input(char *buf, int max_size)
        if (c == '\n')
            buf[n++] = (char)c;
        if (c == EOF && ferror(in))
-           Error(ERR_FILE_READ, (char *)NULL);
+           Error(_("error when reading from file"));
     } else if (((n = fread(buf, 1, max_size, in)) == 0) && ferror(in))
-       Error(ERR_FILE_READ, (char *)NULL);
+       Error(_("error when reading from file"));
 
     return n;
 }
index 319a4343edcc5420bba0155aaed7228161980a46..1bb5dc4c5ef0900f5d5bf2ef103739de4f8bf396 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: raw-preproc.c,v 1.5 2001/08/19 07:46:52 peter Exp $
+/* $Id: raw-preproc.c,v 1.6 2001/08/30 03:45:26 peter Exp $
  * Raw preprocessor (preforms NO preprocessing)
  *
  *  Copyright (C) 2001  Peter Johnson
 
 #include <stdio.h>
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "errwarn.h"
 
 #include "outfmt.h"
 #include "preproc.h"
 
-RCSID("$Id: raw-preproc.c,v 1.5 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: raw-preproc.c,v 1.6 2001/08/30 03:45:26 peter Exp $");
 
 static int is_interactive;
 static FILE *in;
@@ -57,9 +60,9 @@ input(char *buf, int max_size)
        if (c == '\n')
            buf[n++] = (char)c;
        if (c == EOF && ferror(in))
-           Error(ERR_FILE_READ, (char *)NULL);
+           Error(_("error when reading from file"));
     } else if (((n = fread(buf, 1, max_size, in)) == 0) && ferror(in))
-       Error(ERR_FILE_READ, (char *)NULL);
+       Error(_("error when reading from file"));
 
     return n;
 }
index 153607bda117b9eebba3ae638d3db1fc57dc257e..d1ccf8389a603681c184f725667bebeb98d152e0 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: symrec.c,v 1.8 2001/08/19 07:46:52 peter Exp $
+/* $Id: symrec.c,v 1.9 2001/08/30 03:45:26 peter Exp $
  * Symbol table handling
  *
  *  Copyright (C) 2001  Michael Urman
 # include <string.h>
 #endif
 
+#include <libintl.h>
+#define _(String)      gettext(String)
+
 #include "globals.h"
 #include "errwarn.h"
 #include "symrec.h"
 
-RCSID("$Id: symrec.c,v 1.8 2001/08/19 07:46:52 peter Exp $");
+RCSID("$Id: symrec.c,v 1.9 2001/08/30 03:45:26 peter Exp $");
 
 /* private functions */
 static symtab *symtab_get(char *);
@@ -134,7 +137,8 @@ sym_def_get(char *name, SymType type)
 
     tab = symtab_get_or_new(name, type);
     if (tab->rec.status & SYM_DECLARED)
-       Error(ERR_DUPLICATE_DEF, "%s%d", tab->rec.name, tab->rec.line);
+       Error(_("duplicate definition of `%s'; previously defined on line %d"),
+             tab->rec.name, tab->rec.line);
     tab->rec.status |= SYM_DECLARED;
     return &(tab->rec);
 }