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

@@ -44,10 +44,11 @@
 #include <sys/types.h>
 #include <sys/utsname.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #include <netdb.h>
+#include <libintl.h>
 
 
 
 /*
  * Defined macros

@@ -129,28 +130,28 @@
         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"));
+                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(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);
+                                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, NOCATGETS("PMAKE_MACHINESFILE"));
+                        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,13 +321,13 @@
 static int
 m2_init() {
         char    *var;
         key_t   key;
 
-        if ((var = getenv(NOCATGETS("__DMAKE_M2_FILE__"))) == 0) {
+        if ((var = getenv("__DMAKE_M2_FILE__")) == 0) {
                 /* compose tmp file name */
-                sprintf(m2_file, NOCATGETS("%s/dmake.m2.%d.XXXXXX"), tmpdir, getpid());
+                sprintf(m2_file, "%s/dmake.m2.%d.XXXXXX", tmpdir, getpid());
 
                 /* create tmp file */
                 int fd = mkstemp(m2_file);
                 if (fd < 0) {
                         return -1;

@@ -364,11 +365,11 @@
                 if ((var = (char*) malloc(MAXPATHLEN)) == 0) {
                         return -1;
                 }
 
                 /* put key to env */
-                sprintf(var, NOCATGETS("__DMAKE_M2_FILE__=%s"), m2_file);
+                sprintf(var, "__DMAKE_M2_FILE__=%s", m2_file);
                 if (putenv(var)) {
                         return -1;
                 }
         }
         return 0;

@@ -479,14 +480,14 @@
         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."));
+                warning(gettext("Encountered max jobs auto adjustment error - disabling auto adjustment."));
 
                 /* switch off job adjustment for the children */
-                putenv(strdup(NOCATGETS("DMAKE_ADJUST_MAX_JOBS=NO")));
+                putenv(strdup("DMAKE_ADJUST_MAX_JOBS=NO"));
 
                 /* and for this dmake */
                 job_adjust_mode = ADJUST_NONE;
         }
 }

@@ -515,14 +516,14 @@
         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) {
+                if (char *var = getenv("DMAKE_ADJUST_MAX_JOBS")) {
+                        if (strcasecmp(var, "NO") == 0) {
                                 job_adjust_mode = ADJUST_NONE;
-                        } else if (strcasecmp(var, NOCATGETS("M2")) == 0) {
+                        } else if (strcasecmp(var, "M2") == 0) {
                                 job_adjust_mode = ADJUST_M2;
                         }
                 }
 
                 /* M2 specific initialization */

@@ -619,14 +620,14 @@
         if (!silent && output_mode != txt2_mode) {
                 /*
                  * Print local_host --> x job(s).
                  */
                 (void) fprintf(stdout,
-                               catgets(catd, 1, 325, "%s --> %d %s\n"),
+                               gettext("%s --> %d %s\n"),
                                local_host,
                                parallel_process_cnt + 1,
-                               (parallel_process_cnt == 0) ? catgets(catd, 1, 124, "job") : catgets(catd, 1, 125, "jobs"));
+                               (parallel_process_cnt == 0) ? gettext("job") : gettext("jobs"));
 
                 /* Print command line(s). */
                 tmp_index = 0;
                 while (commands[tmp_index] != NULL) {
                     /* No @ char. */

@@ -643,11 +644,11 @@
                 }
                 (void) fflush(stdout);
         }
 
         (void) sprintf(mbstring,
-                        NOCATGETS("%s/dmake.stdout.%d.%d.XXXXXX"),
+                        "%s/dmake.stdout.%d.%d.XXXXXX",
                         tmpdir,
                         getpid(),
                         file_number++);
 
         mktemp(mbstring);

@@ -655,11 +656,11 @@
         stdout_file = strdup(mbstring);
         stderr_file = NULL;
 
         if (!out_err_same) {
                 (void) sprintf(mbstring,
-                                NOCATGETS("%s/dmake.stderr.%d.%d.XXXXXX"),
+                                "%s/dmake.stderr.%d.%d.XXXXXX",
                                 tmpdir,
                                 getpid(),
                                 file_number++);
 
                 mktemp(mbstring);

@@ -932,15 +933,15 @@
          * 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"));
+                        fatal(gettext("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"),
+                                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,11 +1143,11 @@
                      (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"));
+                        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,11 +1217,11 @@
                          * 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"),
+                                        fatal(gettext("stat of %s failed: %s"),
                                             rp->stdout_file,
                                             errmsg(errno));
                                 }
 
                                 if ((line2 != NULL) &&

@@ -1243,11 +1244,11 @@
                                 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"),
+                                        fatal(gettext("stat of %s failed: %s"),
                                             rp->stderr_file,
                                             errmsg(errno));
                                 }
                                 if ((line2 != NULL) &&
                                     (out_buf.st_size > 0)) {

@@ -1269,23 +1270,23 @@
                                         line->body.line.command_used = NULL;
                                 }
                                 if (continue_after_error ||
                                     fatal_in_progress ||
                                     !docheck) {
-                                        warning(catgets(catd, 1, 256, "Command failed for target `%s'"),
+                                        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(NOCATGETS("I'm in finish_children. rp->state == build_failed."));
+                                        warning("I'm in finish_children. rp->state == build_failed.");
 #endif
 
-                                        fatal(catgets(catd, 1, 258, "Command failed for target `%s'"),
+                                        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,30 +1330,30 @@
         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"),
+                fatal(gettext("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"),
+                                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(catgets(catd, 1, 260, "write failed for output file %s: %s"),
+                        fatal(gettext("write failed for output file %s: %s"),
                               filename,
                               errmsg(errno));
                 }
         }
         (void) close(fd);

@@ -1382,13 +1383,13 @@
         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"));
+                        (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,11 +1415,11 @@
          */
         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"),
+                        (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,11 +1783,11 @@
         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"),
+                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,11 +1836,11 @@
                                        /* 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);
+                                        (void) printf(gettext("The following command caused the error:\n%s\n"), command->string_mb);
                                 }
                                 if (!ignore) {
                                         _exit(1);
                                 }
                         }