Print this page
make: translate using gettext, rather than the unmaintainable catgets
*** 41,57 ****
* Included files
*/
#include <bsd/bsd.h> /* bsd_signal() */
#include <mksh/i18n.h> /* get_char_semantics_value() */
#include <mksh/misc.h>
- #include <mksdmsi18n/mksdmsi18n.h>
#include <stdarg.h> /* va_list, va_start(), va_end() */
#include <stdlib.h> /* mbstowcs() */
#include <sys/signal.h> /* SIG_DFL */
#include <sys/wait.h> /* wait() */
#include <string.h> /* strerror() */
/*
* Defined macros
*/
--- 41,57 ----
* Included files
*/
#include <bsd/bsd.h> /* bsd_signal() */
#include <mksh/i18n.h> /* get_char_semantics_value() */
#include <mksh/misc.h>
#include <stdarg.h> /* va_list, va_start(), va_end() */
#include <stdlib.h> /* mbstowcs() */
#include <sys/signal.h> /* SIG_DFL */
#include <sys/wait.h> /* wait() */
#include <string.h> /* strerror() */
+ #include <libintl.h>
/*
* Defined macros
*/
*** 105,116 ****
getmem(register int size)
{
register char *result = (char *) malloc((unsigned) size);
if (result == NULL) {
char buf[FATAL_ERROR_MSG_SIZE];
! sprintf(buf, NOCATGETS("*** Error: malloc(%d) failed: %s\n"), size, strerror(errno));
! strcat(buf, catgets(libmksdmsi18n_catd, 1, 126, "mksh: Fatal error: Out of memory\n"));
fputs(buf, stderr);
exit_status = 1;
exit(1);
}
return result;
--- 105,116 ----
getmem(register int size)
{
register char *result = (char *) malloc((unsigned) size);
if (result == NULL) {
char buf[FATAL_ERROR_MSG_SIZE];
! sprintf(buf, "*** Error: malloc(%d) failed: %s\n", size, strerror(errno));
! strcat(buf, gettext("mksh: Fatal error: Out of memory\n"));
fputs(buf, stderr);
exit_status = 1;
exit(1);
}
return result;
*** 350,360 ****
extern int sys_nerr;
char *errbuf;
if ((errnum < 0) || (errnum > sys_nerr)) {
errbuf = getmem(6+1+11+1);
! (void) sprintf(errbuf, catgets(libmksdmsi18n_catd, 1, 127, "Error %d"), errnum);
return errbuf;
} else {
return strerror(errnum);
}
--- 350,360 ----
extern int sys_nerr;
char *errbuf;
if ((errnum < 0) || (errnum > sys_nerr)) {
errbuf = getmem(6+1+11+1);
! (void) sprintf(errbuf, gettext("Error %d"), errnum);
return errbuf;
} else {
return strerror(errnum);
}
*** 375,386 ****
void
fatal_mksh(const char *message, ...)
{
va_list args;
char *buf = static_buf;
! char *mksh_fat_err = catgets(libmksdmsi18n_catd, 1, 128, "mksh: Fatal error: ");
! char *cur_wrk_dir = catgets(libmksdmsi18n_catd, 1, 129, "Current working directory: ");
int mksh_fat_err_len = strlen(mksh_fat_err);
va_start(args, message);
(void) fflush(stdout);
(void) strcpy(buf, mksh_fat_err);
--- 375,386 ----
void
fatal_mksh(const char *message, ...)
{
va_list args;
char *buf = static_buf;
! char *mksh_fat_err = gettext("mksh: Fatal error: ");
! char *cur_wrk_dir = gettext("Current working directory: ");
int mksh_fat_err_len = strlen(mksh_fat_err);
va_start(args, message);
(void) fflush(stdout);
(void) strcpy(buf, mksh_fat_err);
*** 435,445 ****
/*
if (file_being_read != NULL) {
WCSTOMBS(mbs_buffer, file_being_read);
if (line_number != 0) {
(void) sprintf(message,
! catgets(libmksdmsi18n_catd, 1, 130, "%s, line %d: %s"),
mbs_buffer,
line_number,
pattern);
} else {
(void) sprintf(message,
--- 435,445 ----
/*
if (file_being_read != NULL) {
WCSTOMBS(mbs_buffer, file_being_read);
if (line_number != 0) {
(void) sprintf(message,
! gettext("%s, line %d: %s"),
mbs_buffer,
line_number,
pattern);
} else {
(void) sprintf(message,
*** 450,479 ****
pattern = message;
}
*/
(void) fflush(stdout);
! (void) fprintf(stderr, catgets(libmksdmsi18n_catd, 1, 131, "mksh: Fatal error in reader: "));
(void) vfprintf(stderr, pattern, args);
(void) fprintf(stderr, "\n");
va_end(args);
/*
if (temp_file_name != NULL) {
(void) fprintf(stderr,
! catgets(libmksdmsi18n_catd, 1, 132, "mksh: Temp-file %s not removed\n"),
temp_file_name->string_mb);
temp_file_name = NULL;
}
*/
/*
if (report_pwd) {
*/
if (1) {
(void) fprintf(stderr,
! catgets(libmksdmsi18n_catd, 1, 133, "Current working directory %s\n"),
get_current_path_mksh());
}
(void) fflush(stderr);
exit_status = 1;
exit(1);
--- 450,479 ----
pattern = message;
}
*/
(void) fflush(stdout);
! (void) fprintf(stderr, gettext("mksh: Fatal error in reader: "));
(void) vfprintf(stderr, pattern, args);
(void) fprintf(stderr, "\n");
va_end(args);
/*
if (temp_file_name != NULL) {
(void) fprintf(stderr,
! gettext("mksh: Temp-file %s not removed\n"),
temp_file_name->string_mb);
temp_file_name = NULL;
}
*/
/*
if (report_pwd) {
*/
if (1) {
(void) fprintf(stderr,
! gettext("Current working directory %s\n"),
get_current_path_mksh());
}
(void) fflush(stderr);
exit_status = 1;
exit(1);
*** 494,513 ****
{
va_list args;
va_start(args, message);
(void) fflush(stdout);
! (void) fprintf(stderr, catgets(libmksdmsi18n_catd, 1, 134, "mksh: Warning: "));
(void) vfprintf(stderr, message, args);
(void) fprintf(stderr, "\n");
va_end(args);
/*
if (report_pwd) {
*/
if (1) {
(void) fprintf(stderr,
! catgets(libmksdmsi18n_catd, 1, 135, "Current working directory %s\n"),
get_current_path_mksh());
}
(void) fflush(stderr);
}
--- 494,513 ----
{
va_list args;
va_start(args, message);
(void) fflush(stdout);
! (void) fprintf(stderr, gettext("mksh: Warning: "));
(void) vfprintf(stderr, message, args);
(void) fprintf(stderr, "\n");
va_end(args);
/*
if (report_pwd) {
*/
if (1) {
(void) fprintf(stderr,
! gettext("Current working directory %s\n"),
get_current_path_mksh());
}
(void) fflush(stderr);
}
*** 600,610 ****
break;
case env_mem_prop:
size = sizeof (struct _Env_mem);
break;
default:
! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 136, "Internal error. Unknown prop type %d"), type);
}
for (; prop != NULL; insert = &prop->next, prop = *insert);
size += PROPERTY_HEAD_SIZE;
*insert = prop = (Property) getmem(size);
memset((char *) prop, 0, size);
--- 600,610 ----
break;
case env_mem_prop:
size = sizeof (struct _Env_mem);
break;
default:
! fatal_mksh(gettext("Internal error. Unknown prop type %d"), type);
}
for (; prop != NULL; insert = &prop->next, prop = *insert);
size += PROPERTY_HEAD_SIZE;
*insert = prop = (Property) getmem(size);
memset((char *) prop, 0, size);
*** 847,857 ****
void
mbstowcs_with_check(wchar_t *pwcs, const char *s, size_t n)
{
if(mbstowcs(pwcs, s, n) == -1) {
! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 143, "The string `%s' is not valid in current locale"), s);
}
}
--- 847,857 ----
void
mbstowcs_with_check(wchar_t *pwcs, const char *s, size_t n)
{
if(mbstowcs(pwcs, s, n) == -1) {
! fatal_mksh(gettext("The string `%s' is not valid in current locale"), s);
}
}