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

*** 44,53 **** --- 44,54 ---- #include <sys/types.h> #include <sys/utsname.h> #include <sys/wait.h> #include <unistd.h> #include <netdb.h> + #include <libintl.h> /* * Defined macros
*** 129,156 **** if ((pmake_max_jobs == 0) && (dmake_mode_type == parallel_mode)) { if (local_host[0] == '\0') { (void) gethostname(local_host, MAXNAMELEN); } ! MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MAX_JOBS")); dmake_name = GETNAME(wcs_buffer, FIND_LENGTH); if (((prop = get_prop(dmake_name->prop, macro_prop)) != NULL) && ((dmake_value = prop->body.macro.value) != NULL)) { pmake_max_jobs = atoi(dmake_value->string_mb); if (pmake_max_jobs <= 0) { ! warning(catgets(catd, 1, 308, "DMAKE_MAX_JOBS cannot be less than or equal to zero.")); ! warning(catgets(catd, 1, 309, "setting DMAKE_MAX_JOBS to %d."), PMAKE_DEF_MAX_JOBS); pmake_max_jobs = PMAKE_DEF_MAX_JOBS; } } else { /* * For backwards compatibility w/ PMake 1.x, when * DMake 2.x is being run in parallel mode, DMake * should parse the PMake startup file * $(HOME)/.make.machines to get the pmake_max_jobs. */ ! MBSTOWCS(wcs_buffer, NOCATGETS("PMAKE_MACHINESFILE")); dmake_name = GETNAME(wcs_buffer, FIND_LENGTH); if (((prop = get_prop(dmake_name->prop, macro_prop)) != NULL) && ((dmake_value = prop->body.macro.value) != NULL)) { make_machines_name = dmake_value; } else { --- 130,157 ---- if ((pmake_max_jobs == 0) && (dmake_mode_type == parallel_mode)) { if (local_host[0] == '\0') { (void) gethostname(local_host, MAXNAMELEN); } ! MBSTOWCS(wcs_buffer, "DMAKE_MAX_JOBS"); dmake_name = GETNAME(wcs_buffer, FIND_LENGTH); if (((prop = get_prop(dmake_name->prop, macro_prop)) != NULL) && ((dmake_value = prop->body.macro.value) != NULL)) { pmake_max_jobs = atoi(dmake_value->string_mb); if (pmake_max_jobs <= 0) { ! warning(gettext("DMAKE_MAX_JOBS cannot be less than or equal to zero.")); ! warning(gettext("setting DMAKE_MAX_JOBS to %d."), PMAKE_DEF_MAX_JOBS); pmake_max_jobs = PMAKE_DEF_MAX_JOBS; } } else { /* * For backwards compatibility w/ PMake 1.x, when * DMake 2.x is being run in parallel mode, DMake * should parse the PMake startup file * $(HOME)/.make.machines to get the pmake_max_jobs. */ ! MBSTOWCS(wcs_buffer, "PMAKE_MACHINESFILE"); dmake_name = GETNAME(wcs_buffer, FIND_LENGTH); if (((prop = get_prop(dmake_name->prop, macro_prop)) != NULL) && ((dmake_value = prop->body.macro.value) != NULL)) { make_machines_name = dmake_value; } else {
*** 320,332 **** static int m2_init() { char *var; key_t key; ! if ((var = getenv(NOCATGETS("__DMAKE_M2_FILE__"))) == 0) { /* compose tmp file name */ ! sprintf(m2_file, NOCATGETS("%s/dmake.m2.%d.XXXXXX"), tmpdir, getpid()); /* create tmp file */ int fd = mkstemp(m2_file); if (fd < 0) { return -1; --- 321,333 ---- static int m2_init() { char *var; key_t key; ! if ((var = getenv("__DMAKE_M2_FILE__")) == 0) { /* compose tmp file name */ ! sprintf(m2_file, "%s/dmake.m2.%d.XXXXXX", tmpdir, getpid()); /* create tmp file */ int fd = mkstemp(m2_file); if (fd < 0) { return -1;
*** 364,374 **** if ((var = (char*) malloc(MAXPATHLEN)) == 0) { return -1; } /* put key to env */ ! sprintf(var, NOCATGETS("__DMAKE_M2_FILE__=%s"), m2_file); if (putenv(var)) { return -1; } } return 0; --- 365,375 ---- if ((var = (char*) malloc(MAXPATHLEN)) == 0) { return -1; } /* put key to env */ ! sprintf(var, "__DMAKE_M2_FILE__=%s", m2_file); if (putenv(var)) { return -1; } } return 0;
*** 479,492 **** if (job_adjust_mode != ADJUST_NONE) { /* cleanup internals */ job_adjust_fini(); /* warning message for the user */ ! warning(catgets(catd, 1, 339, "Encountered max jobs auto adjustment error - disabling auto adjustment.")); /* switch off job adjustment for the children */ ! putenv(strdup(NOCATGETS("DMAKE_ADJUST_MAX_JOBS=NO"))); /* and for this dmake */ job_adjust_mode = ADJUST_NONE; } } --- 480,493 ---- if (job_adjust_mode != ADJUST_NONE) { /* cleanup internals */ job_adjust_fini(); /* warning message for the user */ ! warning(gettext("Encountered max jobs auto adjustment error - disabling auto adjustment.")); /* switch off job adjustment for the children */ ! putenv(strdup("DMAKE_ADJUST_MAX_JOBS=NO")); /* and for this dmake */ job_adjust_mode = ADJUST_NONE; } }
*** 515,528 **** if (job_adjust_mode == ADJUST_UNKNOWN) { /* default mode */ job_adjust_mode = ADJUST_M1; /* determine adjust mode */ ! if (char *var = getenv(NOCATGETS("DMAKE_ADJUST_MAX_JOBS"))) { ! if (strcasecmp(var, NOCATGETS("NO")) == 0) { job_adjust_mode = ADJUST_NONE; ! } else if (strcasecmp(var, NOCATGETS("M2")) == 0) { job_adjust_mode = ADJUST_M2; } } /* M2 specific initialization */ --- 516,529 ---- if (job_adjust_mode == ADJUST_UNKNOWN) { /* default mode */ job_adjust_mode = ADJUST_M1; /* determine adjust mode */ ! if (char *var = getenv("DMAKE_ADJUST_MAX_JOBS")) { ! if (strcasecmp(var, "NO") == 0) { job_adjust_mode = ADJUST_NONE; ! } else if (strcasecmp(var, "M2") == 0) { job_adjust_mode = ADJUST_M2; } } /* M2 specific initialization */
*** 619,632 **** if (!silent && output_mode != txt2_mode) { /* * Print local_host --> x job(s). */ (void) fprintf(stdout, ! catgets(catd, 1, 325, "%s --> %d %s\n"), local_host, parallel_process_cnt + 1, ! (parallel_process_cnt == 0) ? catgets(catd, 1, 124, "job") : catgets(catd, 1, 125, "jobs")); /* Print command line(s). */ tmp_index = 0; while (commands[tmp_index] != NULL) { /* No @ char. */ --- 620,633 ---- if (!silent && output_mode != txt2_mode) { /* * Print local_host --> x job(s). */ (void) fprintf(stdout, ! gettext("%s --> %d %s\n"), local_host, parallel_process_cnt + 1, ! (parallel_process_cnt == 0) ? gettext("job") : gettext("jobs")); /* Print command line(s). */ tmp_index = 0; while (commands[tmp_index] != NULL) { /* No @ char. */
*** 643,653 **** } (void) fflush(stdout); } (void) sprintf(mbstring, ! NOCATGETS("%s/dmake.stdout.%d.%d.XXXXXX"), tmpdir, getpid(), file_number++); mktemp(mbstring); --- 644,654 ---- } (void) fflush(stdout); } (void) sprintf(mbstring, ! "%s/dmake.stdout.%d.%d.XXXXXX", tmpdir, getpid(), file_number++); mktemp(mbstring);
*** 655,665 **** stdout_file = strdup(mbstring); stderr_file = NULL; if (!out_err_same) { (void) sprintf(mbstring, ! NOCATGETS("%s/dmake.stderr.%d.%d.XXXXXX"), tmpdir, getpid(), file_number++); mktemp(mbstring); --- 656,666 ---- stdout_file = strdup(mbstring); stderr_file = NULL; if (!out_err_same) { (void) sprintf(mbstring, ! "%s/dmake.stderr.%d.%d.XXXXXX", tmpdir, getpid(), file_number++); mktemp(mbstring);
*** 932,946 **** * or a subtree with a dependency conflict with something waiting * to build. */ if (quiescent) { if (subtree_target == NULL) { ! fatal(catgets(catd, 1, 126, "Internal error: deadlock detected in process_next")); } else { rp = *subtree_target; if (debug_level > 0) { ! warning(catgets(catd, 1, 127, "Conditional macro conflict encountered for %s between %s and %s"), subtree_conflict2->string_mb, rp->target->string_mb, subtree_conflict->string_mb); } *subtree_target = (*subtree_target)->next; --- 933,947 ---- * or a subtree with a dependency conflict with something waiting * to build. */ if (quiescent) { if (subtree_target == NULL) { ! fatal(gettext("Internal error: deadlock detected in process_next")); } else { rp = *subtree_target; if (debug_level > 0) { ! warning(gettext("Conditional macro conflict encountered for %s between %s and %s"), subtree_conflict2->string_mb, rp->target->string_mb, subtree_conflict->string_mb); } *subtree_target = (*subtree_target)->next;
*** 1142,1152 **** (rp != NULL) && (rp->pid != pid); rp = rp->next) { ; } if (rp == NULL) { ! fatal(catgets(catd, 1, 128, "Internal error: returned child pid not in running_list")); } else { rp->state = (WIFEXITED(status) && WEXITSTATUS(status) == 0) ? build_ok : build_failed; } nohang = true; parallel_process_cnt--; --- 1143,1153 ---- (rp != NULL) && (rp->pid != pid); rp = rp->next) { ; } if (rp == NULL) { ! fatal(gettext("Internal error: returned child pid not in running_list")); } else { rp->state = (WIFEXITED(status) && WEXITSTATUS(status) == 0) ? build_ok : build_failed; } nohang = true; parallel_process_cnt--;
*** 1216,1226 **** * Check if there were any job output * from the parallel build. */ if (rp->stdout_file != NULL) { if (stat(rp->stdout_file, &out_buf) < 0) { ! fatal(catgets(catd, 1, 130, "stat of %s failed: %s"), rp->stdout_file, errmsg(errno)); } if ((line2 != NULL) && --- 1217,1227 ---- * Check if there were any job output * from the parallel build. */ if (rp->stdout_file != NULL) { if (stat(rp->stdout_file, &out_buf) < 0) { ! fatal(gettext("stat of %s failed: %s"), rp->stdout_file, errmsg(errno)); } if ((line2 != NULL) &&
*** 1243,1253 **** rp->stdout_file = NULL; } if (!out_err_same && (rp->stderr_file != NULL)) { if (stat(rp->stderr_file, &out_buf) < 0) { ! fatal(catgets(catd, 1, 130, "stat of %s failed: %s"), rp->stderr_file, errmsg(errno)); } if ((line2 != NULL) && (out_buf.st_size > 0)) { --- 1244,1254 ---- rp->stdout_file = NULL; } if (!out_err_same && (rp->stderr_file != NULL)) { if (stat(rp->stderr_file, &out_buf) < 0) { ! fatal(gettext("stat of %s failed: %s"), rp->stderr_file, errmsg(errno)); } if ((line2 != NULL) && (out_buf.st_size > 0)) {
*** 1269,1291 **** line->body.line.command_used = NULL; } if (continue_after_error || fatal_in_progress || !docheck) { ! warning(catgets(catd, 1, 256, "Command failed for target `%s'"), rp->command ? line2->body.line.target->string_mb : rp->target->string_mb); build_failed_seen = true; } else { /* * XXX??? - DMake needs to exit(), * but shouldn't call fatal(). */ #ifdef PRINT_EXIT_STATUS ! warning(NOCATGETS("I'm in finish_children. rp->state == build_failed.")); #endif ! fatal(catgets(catd, 1, 258, "Command failed for target `%s'"), rp->command ? line2->body.line.target->string_mb : rp->target->string_mb); } } if (!docheck) { delete_running_struct(rp); --- 1270,1292 ---- line->body.line.command_used = NULL; } if (continue_after_error || fatal_in_progress || !docheck) { ! warning(gettext("Command failed for target `%s'"), rp->command ? line2->body.line.target->string_mb : rp->target->string_mb); build_failed_seen = true; } else { /* * XXX??? - DMake needs to exit(), * but shouldn't call fatal(). */ #ifdef PRINT_EXIT_STATUS ! warning("I'm in finish_children. rp->state == build_failed."); #endif ! fatal(gettext("Command failed for target `%s'"), rp->command ? line2->body.line.target->string_mb : rp->target->string_mb); } } if (!docheck) { delete_running_struct(rp);
*** 1329,1358 **** char copybuf[BUFSIZ]; int fd; int out_fd = (err ? 2 : 1); if ((fd = open(filename, O_RDONLY)) < 0) { ! fatal(catgets(catd, 1, 141, "open failed for output file %s: %s"), filename, errmsg(errno)); } if (!silent && output_mode != txt2_mode) { (void) fprintf(err ? stderr : stdout, err ? ! catgets(catd, 1, 338, "%s --> Job errors\n") : ! catgets(catd, 1, 259, "%s --> Job output\n"), local_host); (void) fflush(err ? stderr : stdout); } for (chars_read = read(fd, copybuf, BUFSIZ); chars_read > 0; chars_read = read(fd, copybuf, BUFSIZ)) { /* * Read buffers from the source file until end or error. */ if (write(out_fd, copybuf, chars_read) < 0) { ! fatal(catgets(catd, 1, 260, "write failed for output file %s: %s"), filename, errmsg(errno)); } } (void) close(fd); --- 1330,1359 ---- char copybuf[BUFSIZ]; int fd; int out_fd = (err ? 2 : 1); if ((fd = open(filename, O_RDONLY)) < 0) { ! fatal(gettext("open failed for output file %s: %s"), filename, errmsg(errno)); } if (!silent && output_mode != txt2_mode) { (void) fprintf(err ? stderr : stdout, err ? ! gettext("%s --> Job errors\n") : ! gettext("%s --> Job output\n"), local_host); (void) fflush(err ? stderr : stdout); } for (chars_read = read(fd, copybuf, BUFSIZ); chars_read > 0; chars_read = read(fd, copybuf, BUFSIZ)) { /* * Read buffers from the source file until end or error. */ if (write(out_fd, copybuf, chars_read) < 0) { ! fatal(gettext("write failed for output file %s: %s"), filename, errmsg(errno)); } } (void) close(fd);
*** 1382,1394 **** Property *conditionals; recursion_level = rp->recursion_level; if (result == build_ok) { if (true_target == NULL) { ! (void) printf(NOCATGETS("Target = %s\n"), target->string_mb); ! (void) printf(NOCATGETS(" State = %d\n"), result); ! fatal(NOCATGETS("Internal error: NULL true_target in finish_doname")); } /* If all went OK, set a nice timestamp */ if (true_target->stat.time == file_doesnt_exist) { true_target->stat.time = file_max_time; } --- 1383,1395 ---- Property *conditionals; recursion_level = rp->recursion_level; if (result == build_ok) { if (true_target == NULL) { ! (void) printf("Target = %s\n", target->string_mb); ! (void) printf(" State = %d\n", result); ! fatal("Internal error: NULL true_target in finish_doname"); } /* If all went OK, set a nice timestamp */ if (true_target->stat.time == file_doesnt_exist) { true_target->stat.time = file_max_time; }
*** 1414,1424 **** */ if ((result == build_ok) && check_auto_dependencies(target, auto_count, automatics)) { if (debug_level > 0) { ! (void) printf(catgets(catd, 1, 261, "%*sTarget `%s' acquired new dependencies from build, checking all dependencies\n"), recursion_level, "", true_target->string_mb); } target->rechecking_target = true; --- 1415,1425 ---- */ if ((result == build_ok) && check_auto_dependencies(target, auto_count, automatics)) { if (debug_level > 0) { ! (void) printf(gettext("%*sTarget `%s' acquired new dependencies from build, checking all dependencies\n"), recursion_level, "", true_target->string_mb); } target->rechecking_target = true;
*** 1782,1792 **** wchar_t *tmp_wcs_buffer; childPid = fork(); switch (childPid) { case -1: /* Error */ ! fatal(catgets(catd, 1, 337, "Could not fork child process for dmake job: %s"), errmsg(errno)); break; case 0: /* Child */ /* To control the processed targets list is not the child's business */ running_list = NULL; --- 1783,1793 ---- wchar_t *tmp_wcs_buffer; childPid = fork(); switch (childPid) { case -1: /* Error */ ! fatal(gettext("Could not fork child process for dmake job: %s"), errmsg(errno)); break; case 0: /* Child */ /* To control the processed targets list is not the child's business */ running_list = NULL;
*** 1835,1845 **** /* BOOLEAN(silent_flag && ignore), */ always_exec, (Name) NULL); if (result == build_failed) { if (silent_flag) { ! (void) printf(catgets(catd, 1, 152, "The following command caused the error:\n%s\n"), command->string_mb); } if (!ignore) { _exit(1); } } --- 1836,1846 ---- /* BOOLEAN(silent_flag && ignore), */ always_exec, (Name) NULL); if (result == build_failed) { if (silent_flag) { ! (void) printf(gettext("The following command caused the error:\n%s\n"), command->string_mb); } if (!ignore) { _exit(1); } }