changeset 13331:3e39f9c58fbd

878 regerror() error messages not i18n compliant Reviewed by: Adam Leventhal <ahl@delphix.com> Approved by: Gordon Ross <gwr@nexenta.com>
author Garrett D'Amore <garrett@nexenta.com>
date Sun, 10 Apr 2011 13:16:24 -0700
parents e49c34fd7751
children 7d1bfc4f8455
files usr/src/lib/libc/makelibccatalog.sh usr/src/lib/libc/port/i18n/regerror_msg.h usr/src/lib/libc/port/locale/regerror.c
diffstat 3 files changed, 38 insertions(+), 119 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/libc/makelibccatalog.sh	Sat Apr 09 14:59:27 2011 -0400
+++ b/usr/src/lib/libc/makelibccatalog.sh	Sun Apr 10 13:16:24 2011 -0700
@@ -24,7 +24,10 @@
 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-# ident	"%Z%%M%	%I%	%E% SMI"
+
+#
+# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+#
 
 XGETTEXT=xgettext
 MSGDIR=$1
@@ -88,23 +91,18 @@
 #
 # Change Directory
 #
-	cd ../i18n
-	rm -f messages.po regerror_msg.po
+	cd ../locale
+	rm -f messages.po regerror.po
 
-#
-# regerror_msg.h
-#
-
-sed "s/_MSG/gettext/" regerror_msg.h > regerror_msg.i
-${XGETTEXT} regerror_msg.i
-cat messages.po | sed "/^domain/d" > regerror_msg.po
-rm -f regerror_msg.i messages.po
+	${XGETTEXT} -a regerror.c
+	cat messages.po | sed "/^domain/d" > regerror.po
+	rm -f regerror.i messages.po
 	
 #
 # Copy .po file
 #
-	cp regerror_msg.po ${MSGDIR}
+	cp regerror.po ${MSGDIR}
 
 # And remove it		
 
-	rm -f regerror_msg.po
+	rm -f regerror.po
--- a/usr/src/lib/libc/port/i18n/regerror_msg.h	Sat Apr 09 14:59:27 2011 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * regerror: map error number to text string
- *
- * Copyright 1985, 1992 by Mortice Kern Systems Inc.  All rights reserved.
- *
- */
-/*
- * static char rcsID[] = "$Header: /u/rd/src/libc/regex/rcs/regerror.c "
- * "1.28 1994/11/07 14:40:06 jeffhe Exp $";
- */
-
-#ifndef	_REGERROR_MSG_H
-#define	_REGERROR_MSG_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-/*
- * This string array holds the error message strings for
- * the regerror() function.  The method function implemented in
- * libc_i18n strongly depends on this array.  Do not modify this
- * array without synchronizing with the method function.
- * Also, the _MSG macro is used to extract the message strings
- * for the gettext() messaging by the makelibccatalog.sh script.
- */
-static const char *regerrors[] = {
-	_MSG("success"),			/*  0: REG_OK */
-	_MSG("failed to match"),		/*  1: REG_NOMATCH */
-	_MSG("invalid collation element"),	/*  2: REG_ECOLLATE */
-	_MSG("trailing \\ in pattern"),		/*  3: REG_EESCAPE */
-	_MSG("newline found before end of pattern"),
-						/*  4: REG_ENEWLINE */
-	"",					/*  5: REG_ENSUB (OBS) */
-	_MSG("number in \\[0-9] invalid"),	/*  6: REG_ESUBREG */
-	_MSG("[ ] imbalance or syntax error"),	/*  7: REG_EBRACK */
-	_MSG("( ) or \\( \\) imbalance"),	/*  8: REG_EPAREN */
-	_MSG("{ } or \\{ \\} imbalance"),	/*  9: REG_EBRACE */
-	_MSG("invalid endpoint in range"),	/* 10: REG_ERANGE */
-	_MSG("out of memory"),			/* 11: REG_ESPACE */
-	_MSG("?, *, +, or { } not preceded by valid regular expression"),
-						/* 12: REG_BADRPT */
-	_MSG("invalid character class type"),	/* 13: REG_ECTYPE */
-	_MSG("syntax error"),			/* 14: REG_BADPAT */
-	_MSG("contents of { } or \\{ \\} invalid"),
-						/* 15: REG_BADBR */
-	_MSG("internal error"),			/* 16: REG_EFATAL */
-	_MSG("invalid multibyte character"),	/* 17: REG_ECHAR */
-	_MSG("backtrack stack overflow: expression generates too many "
-	    "alternatives"),			/* 18: REG_STACK */
-	_MSG("function not supported"),		/* 19: REG_ENOSYS */
-	_MSG("unknown regex error"),		/* 20: (reserved) */
-	_MSG("^ anchor not at beginning of pattern"),
-						/* 21: REG_EBOL */
-	_MSG("$ anchor not at end of pattern"),	/* 22: REG_EEOL */
-};
-
-#endif /* _REGERROR_MSG_H */
--- a/usr/src/lib/libc/port/locale/regerror.c	Sat Apr 09 14:59:27 2011 -0400
+++ b/usr/src/lib/libc/port/locale/regerror.c	Sun Apr 10 13:16:24 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 1992, 1993, 1994 Henry Spencer.
  * Copyright (c) 1992, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -42,38 +42,41 @@
 #include <regex.h>
 
 #include "utils.h"
+#include "../gen/_libc_gettext.h"
+
+#define	RERR(x, msg)	{ x, #x, msg }
 
 static struct rerr {
 	int code;
 	char *name;
 	char *explain;
 } rerrs[] = {
-	{REG_NOMATCH,	"REG_NOMATCH",	"regexec() failed to match"},
-	{REG_BADPAT,	"REG_BADPAT",	"invalid regular expression"},
-	{REG_ECOLLATE,	"REG_ECOLLATE",	"invalid collating element"},
-	{REG_ECTYPE,	"REG_ECTYPE",	"invalid character class"},
-	{REG_EESCAPE,	"REG_EESCAPE",	"trailing backslash (\\)"},
-	{REG_ESUBREG,	"REG_ESUBREG",	"invalid backreference number"},
-	{REG_EBRACK,	"REG_EBRACK",	"brackets ([ ]) not balanced"},
-	{REG_EPAREN,	"REG_EPAREN",	"parentheses not balanced"},
-	{REG_EBRACE,	"REG_EBRACE",	"braces not balanced"},
-	{REG_BADBR,	"REG_BADBR",	"invalid repetition count(s)"},
-	{REG_ERANGE,	"REG_ERANGE",	"invalid character range"},
-	{REG_ESPACE,	"REG_ESPACE",	"out of memory"},
-	{REG_BADRPT,	"REG_BADRPT",	"repetition-operator operand invalid"},
+	RERR(REG_NOMATCH,	"regexec() failed to match"),
+	RERR(REG_BADPAT,	"invalid regular expression"),
+	RERR(REG_ECOLLATE,	"invalid collating element"),
+	RERR(REG_ECTYPE,	"invalid character class"),
+	RERR(REG_EESCAPE,	"trailing backslash (\\)"),
+	RERR(REG_ESUBREG,	"invalid backreference number"),
+	RERR(REG_EBRACK,	"brackets ([ ]) not balanced"),
+	RERR(REG_EPAREN,	"parentheses not balanced"),
+	RERR(REG_EBRACE,	"braces not balanced"),
+	RERR(REG_BADBR,		"invalid repetition count(s)"),
+	RERR(REG_ERANGE,	"invalid character range"),
+	RERR(REG_ESPACE,	"out of memory"),
+	RERR(REG_BADRPT,	"repetition-operator operand invalid"),
 #ifdef	REG_EMPTY
-	{REG_EMPTY,	"REG_EMPTY",	"empty (sub)expression"},
+	RERR(REG_EMPTY,		"empty (sub)expression"),
 #endif
-	{REG_EFATAL,	"REG_EFATAL",	"\"can't happen\" -- you found a bug"},
+	RERR(REG_EFATAL,	"fatal internal error"),
 #ifdef	REG_INVARG
-	{REG_INVARG,	"REG_INVARG",	"invalid argument to regex routine"},
+	RERR(REG_INVARG,	"invalid argument to regex routine"),
 #endif
-	{REG_ECHAR,	"REG_ECHAR",	"illegal byte sequence"},
-	{REG_ENOSYS,	"REG_ENOSYS",	"function not supported"},
-	{REG_STACK,	"REG_STACK",	"backtrack stack overflow"},
-	{REG_ENSUB,	"REG_ENSUB",	"more than 9 \\( \\) pairs"},
-	{REG_ENEWLINE,	"REG_ENEWLINE",	"\n found before end of pattern"},
-	{0,		"",		"*** unknown regexp error code ***"}
+	RERR(REG_ECHAR,		"illegal byte sequence"),
+	RERR(REG_ENOSYS,	"function not supported"),
+	RERR(REG_STACK,		"backtrack stack overflow"),
+	RERR(REG_ENSUB,		"more than 9 \\( \\) pairs"),
+	RERR(REG_ENEWLINE,	"\n found before end of pattern"),
+	{0,	"",		"*** unknown regexp error code ***"}
 };
 
 
@@ -93,7 +96,7 @@
 		if (r->code == errcode)
 			break;
 
-	s = r->explain;
+	s = _libc_gettext(r->explain);
 
 	len = strlen(s) + 1;
 	if (errbuf_size > 0) {