Print this page
make: translate using gettext, rather than the unmaintainable catgets

*** 40,55 **** #include <errno.h> /* errno */ #include <fcntl.h> /* open() */ #include <mksh/dosys.h> #include <mksh/macro.h> /* getvar() */ #include <mksh/misc.h> /* getmem(), fatal_mksh(), errmsg() */ - #include <mksdmsi18n/mksdmsi18n.h> /* libmksdmsi18n_init() */ #include <sys/signal.h> /* SIG_DFL */ #include <sys/stat.h> /* open() */ #include <sys/wait.h> /* wait() */ #include <ulimit.h> /* ulimit() */ #include <unistd.h> /* close(), dup2() */ /* * typedefs & structs */ --- 40,55 ---- #include <errno.h> /* errno */ #include <fcntl.h> /* open() */ #include <mksh/dosys.h> #include <mksh/macro.h> /* getvar() */ #include <mksh/misc.h> /* getmem(), fatal_mksh(), errmsg() */ #include <sys/signal.h> /* SIG_DFL */ #include <sys/stat.h> /* open() */ #include <sys/wait.h> /* wait() */ #include <ulimit.h> /* ulimit() */ #include <unistd.h> /* close(), dup2() */ + #include <libintl.h> /* * typedefs & structs */
*** 88,129 **** { long descriptor_limit; int i; if ((descriptor_limit = ulimit(UL_GDESLIM)) < 0) { ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 89, "ulimit() failed: %s"), errmsg(errno)); } for (i = 3; i < descriptor_limit; i++) { (void) close(i); } if ((i = my_open(stdout_file, O_WRONLY | O_CREAT | O_TRUNC | O_DSYNC, S_IREAD | S_IWRITE)) < 0) { ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 90, "Couldn't open standard out temp file `%s': %s"), stdout_file, errmsg(errno)); } else { if (dup2(i, 1) == -1) { ! fatal_mksh(NOCATGETS("*** Error: dup2(3, 1) failed: %s"), errmsg(errno)); } close(i); } if (stderr_file == NULL) { if (dup2(1, 2) == -1) { ! fatal_mksh(NOCATGETS("*** Error: dup2(1, 2) failed: %s"), errmsg(errno)); } } else if ((i = my_open(stderr_file, O_WRONLY | O_CREAT | O_TRUNC | O_DSYNC, S_IREAD | S_IWRITE)) < 0) { ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 91, "Couldn't open standard error temp file `%s': %s"), stderr_file, errmsg(errno)); } else { if (dup2(i, 2) == -1) { ! fatal_mksh(NOCATGETS("*** Error: dup2(3, 2) failed: %s"), errmsg(errno)); } close(i); } } --- 88,129 ---- { long descriptor_limit; int i; if ((descriptor_limit = ulimit(UL_GDESLIM)) < 0) { ! fatal_mksh(gettext("ulimit() failed: %s"), errmsg(errno)); } for (i = 3; i < descriptor_limit; i++) { (void) close(i); } if ((i = my_open(stdout_file, O_WRONLY | O_CREAT | O_TRUNC | O_DSYNC, S_IREAD | S_IWRITE)) < 0) { ! fatal_mksh(gettext("Couldn't open standard out temp file `%s': %s"), stdout_file, errmsg(errno)); } else { if (dup2(i, 1) == -1) { ! fatal_mksh("*** Error: dup2(3, 1) failed: %s", errmsg(errno)); } close(i); } if (stderr_file == NULL) { if (dup2(1, 2) == -1) { ! fatal_mksh("*** Error: dup2(1, 2) failed: %s", errmsg(errno)); } } else if ((i = my_open(stderr_file, O_WRONLY | O_CREAT | O_TRUNC | O_DSYNC, S_IREAD | S_IWRITE)) < 0) { ! fatal_mksh(gettext("Couldn't open standard error temp file `%s': %s"), stderr_file, errmsg(errno)); } else { if (dup2(i, 2) == -1) { ! fatal_mksh("*** Error: dup2(3, 2) failed: %s", errmsg(errno)); } close(i); } }
*** 171,186 **** * Only prepend the /usr/bin/nice command to the original command * if the nice priority, nice_prio, is NOT zero (0). * Nice priorities can be a positive or a negative number. */ if (nice_prio != 0) { ! argv[argv_index++] = (char *)NOCATGETS("nice"); ! (void) sprintf(nice_prio_buf, NOCATGETS("-%d"), nice_prio); argv[argv_index++] = strdup(nice_prio_buf); } argv[argv_index++] = shellname; ! argv[argv_index++] = (char*)(ignore_error ? NOCATGETS("-c") : NOCATGETS("-ce")); if ((length = wslen(command)) >= MAXPATHLEN) { tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1); (void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1); cmd_argv_index = argv_index; argv[argv_index++] = strdup(tmp_mbs_buffer); --- 171,186 ---- * Only prepend the /usr/bin/nice command to the original command * if the nice priority, nice_prio, is NOT zero (0). * Nice priorities can be a positive or a negative number. */ if (nice_prio != 0) { ! argv[argv_index++] = (char *)"nice"; ! (void) sprintf(nice_prio_buf, "-%d", nice_prio); argv[argv_index++] = strdup(nice_prio_buf); } argv[argv_index++] = shellname; ! argv[argv_index++] = (char*)(ignore_error ? "-c" : "-ce"); if ((length = wslen(command)) >= MAXPATHLEN) { tmp_mbs_buffer = getmem((length * MB_LEN_MAX) + 1); (void) wcstombs(tmp_mbs_buffer, command, (length * MB_LEN_MAX) + 1); cmd_argv_index = argv_index; argv[argv_index++] = strdup(tmp_mbs_buffer);
*** 198,219 **** if (filter_stderr) { redirect_stderr(); } #endif if (nice_prio != 0) { ! (void) execve(NOCATGETS("/usr/bin/nice"), argv, environ); ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 92, "Could not load `/usr/bin/nice': %s"), errmsg(errno)); } else { (void) execve(shell->string_mb, argv, environ); ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 93, "Could not load Shell from `%s': %s"), shell->string_mb, errmsg(errno)); } } if (childPid == -1) { ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 94, "fork failed: %s"), errmsg(errno)); } retmem_mb(argv[cmd_argv_index]); return childPid; } --- 198,219 ---- if (filter_stderr) { redirect_stderr(); } #endif if (nice_prio != 0) { ! (void) execve("/usr/bin/nice", argv, environ); ! fatal_mksh(gettext("Could not load `/usr/bin/nice': %s"), errmsg(errno)); } else { (void) execve(shell->string_mb, argv, environ); ! fatal_mksh(gettext("Could not load Shell from `%s': %s"), shell->string_mb, errmsg(errno)); } } if (childPid == -1) { ! fatal_mksh(gettext("fork failed: %s"), errmsg(errno)); } retmem_mb(argv[cmd_argv_index]); return childPid; }
*** 264,274 **** shellname = shell->string_mb; } else { shellname++; } shargv[0] = shellname; ! shargv[1] = (char*)(ignore_error ? NOCATGETS("-c") : NOCATGETS("-ce")); shargv[2] = argv[0]; shargv[3] = NULL; tmp_shell = getvar(shell_name); if (IS_EQUAL(tmp_shell->string_mb, "")) { tmp_shell = shell_name; --- 264,274 ---- shellname = shell->string_mb; } else { shellname++; } shargv[0] = shellname; ! shargv[1] = (char*)(ignore_error ? "-c" : "-ce"); shargv[2] = argv[0]; shargv[3] = NULL; tmp_shell = getvar(shell_name); if (IS_EQUAL(tmp_shell->string_mb, "")) { tmp_shell = shell_name;
*** 351,370 **** WCSTOMBS(mbs_buffer, command); argv[0] = strdup(mbs_buffer); } if (nice_prio != 0) { ! *p++ = strdup(NOCATGETS("/usr/bin/nice")); ! (void) sprintf(nice_prio_buf, NOCATGETS("-%d"), nice_prio); *p++ = strdup(nice_prio_buf); } /* Build list of argument words. */ for (t = command; *t;) { if (p >= &argv[arg_count]) { /* This should never happen, right? */ WCSTOMBS(mbs_buffer, command); ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 95, "Command `%s' has more than %d arguments"), mbs_buffer, arg_count); } q = t; while (!iswspace(*t) && (*t != (int) nul_char)) { --- 351,370 ---- WCSTOMBS(mbs_buffer, command); argv[0] = strdup(mbs_buffer); } if (nice_prio != 0) { ! *p++ = strdup("/usr/bin/nice"); ! (void) sprintf(nice_prio_buf, "-%d", nice_prio); *p++ = strdup(nice_prio_buf); } /* Build list of argument words. */ for (t = command; *t;) { if (p >= &argv[arg_count]) { /* This should never happen, right? */ WCSTOMBS(mbs_buffer, command); ! fatal_mksh(gettext("Command `%s' has more than %d arguments"), mbs_buffer, arg_count); } q = t; while (!iswspace(*t) && (*t != (int) nul_char)) {
*** 393,406 **** if (filter_stderr) { redirect_stderr(); } #endif (void) exec_vp(argv[1], argv, environ, ignore_error, vroot_path); ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 96, "Cannot load command `%s': %s"), argv[1], errmsg(errno)); } if (childPid == -1) { ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 97, "fork failed: %s"), errmsg(errno)); } for (int i = 0; argv[i] != NULL; i++) { retmem_mb(argv[i]); } --- 393,406 ---- if (filter_stderr) { redirect_stderr(); } #endif (void) exec_vp(argv[1], argv, environ, ignore_error, vroot_path); ! fatal_mksh(gettext("Cannot load command `%s': %s"), argv[1], errmsg(errno)); } if (childPid == -1) { ! fatal_mksh(gettext("fork failed: %s"), errmsg(errno)); } for (int i = 0; argv[i] != NULL; i++) { retmem_mb(argv[i]); }
*** 443,476 **** int termination_signal; char tmp_buf[MAXPATHLEN]; while ((pid = wait(&status)) != running_pid) { if (pid == -1) { ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 98, "wait() failed: %s"), errmsg(errno)); } } (void) fflush(stdout); (void) fflush(stderr); if (status == 0) { #ifdef PRINT_EXIT_STATUS ! warning_mksh(NOCATGETS("I'm in await(), and status is 0.")); #endif return succeeded; } #ifdef PRINT_EXIT_STATUS ! warning_mksh(NOCATGETS("I'm in await(), and status is *NOT* 0.")); #endif exit_status = WEXITSTATUS(status); #ifdef PRINT_EXIT_STATUS ! warning_mksh(NOCATGETS("I'm in await(), and exit_status is %d."), exit_status); #endif termination_signal = WTERMSIG(status); core_dumped = WCOREDUMP(status); --- 443,476 ---- int termination_signal; char tmp_buf[MAXPATHLEN]; while ((pid = wait(&status)) != running_pid) { if (pid == -1) { ! fatal_mksh(gettext("wait() failed: %s"), errmsg(errno)); } } (void) fflush(stdout); (void) fflush(stderr); if (status == 0) { #ifdef PRINT_EXIT_STATUS ! warning_mksh("I'm in await(), and status is 0."); #endif return succeeded; } #ifdef PRINT_EXIT_STATUS ! warning_mksh("I'm in await(), and status is *NOT* 0."); #endif exit_status = WEXITSTATUS(status); #ifdef PRINT_EXIT_STATUS ! warning_mksh("I'm in await(), and exit_status is %d.", exit_status); #endif termination_signal = WTERMSIG(status); core_dumped = WCOREDUMP(status);
*** 481,511 **** tmp_buf[0] = (int) nul_char; if (!silent_error) { if (exit_status != 0) { (void) fprintf(stdout, ! catgets(libmksdmsi18n_catd, 1, 103, "*** Error code %d"), exit_status); } else { (void) fprintf(stdout, ! catgets(libmksdmsi18n_catd, 1, 105, "*** Signal %d"), termination_signal); if (core_dumped) { (void) fprintf(stdout, ! catgets(libmksdmsi18n_catd, 1, 107, " - core dumped")); } } if (ignore_error) { (void) fprintf(stdout, ! catgets(libmksdmsi18n_catd, 1, 109, " (ignored)")); } (void) fprintf(stdout, "\n"); (void) fflush(stdout); } #ifdef PRINT_EXIT_STATUS ! warning_mksh(NOCATGETS("I'm in await(), returning failed.")); #endif return failed; } --- 481,511 ---- tmp_buf[0] = (int) nul_char; if (!silent_error) { if (exit_status != 0) { (void) fprintf(stdout, ! gettext("*** Error code %d"), exit_status); } else { (void) fprintf(stdout, ! gettext("*** Signal %d"), termination_signal); if (core_dumped) { (void) fprintf(stdout, ! gettext(" - core dumped")); } } if (ignore_error) { (void) fprintf(stdout, ! gettext(" (ignored)")); } (void) fprintf(stdout, "\n"); (void) fflush(stdout); } #ifdef PRINT_EXIT_STATUS ! warning_mksh("I'm in await(), returning failed."); #endif return failed; }
*** 534,544 **** command->text.p = (int) nul_char; WCSTOMBS(mbs_buffer, command->buffer.start); if ((fd = popen(mbs_buffer, "r")) == NULL) { WCSTOMBS(mbs_buffer, command->buffer.start); ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 111, "Could not run command `%s' for :sh transformation"), mbs_buffer); } while ((chr = getc(fd)) != EOF) { if (chr == (int) newline_char) { chr = (int) space_char; --- 534,544 ---- command->text.p = (int) nul_char; WCSTOMBS(mbs_buffer, command->buffer.start); if ((fd = popen(mbs_buffer, "r")) == NULL) { WCSTOMBS(mbs_buffer, command->buffer.start); ! fatal_mksh(gettext("Could not run command `%s' for :sh transformation"), mbs_buffer); } while ((chr = getc(fd)) != EOF) { if (chr == (int) newline_char) { chr = (int) space_char;
*** 567,577 **** } status = pclose(fd); if (status != 0) { WCSTOMBS(mbs_buffer, command->buffer.start); ! fatal_mksh(catgets(libmksdmsi18n_catd, 1, 112, "The command `%s' returned status `%d'"), mbs_buffer, WEXITSTATUS(status)); } } --- 567,577 ---- } status = pclose(fd); if (status != 0) { WCSTOMBS(mbs_buffer, command->buffer.start); ! fatal_mksh(gettext("The command `%s' returned status `%d'"), mbs_buffer, WEXITSTATUS(status)); } }