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

@@ -31,24 +31,19 @@
 
 /*
  * Included files
  */
 #include <alloca.h>             /* alloca() */
-
-
 #include <fcntl.h>
 #include <mk/defs.h>
 #include <mksh/i18n.h>          /* get_char_semantics_value() */
 #include <mksh/macro.h>         /* getvar(), expand_value() */
 #include <mksh/misc.h>          /* getmem() */
 #include <poll.h>
-
-
+#include <libintl.h>
 #include <signal.h>
-
-#       include <stropts.h>
-
+#include <stropts.h>
 #include <sys/errno.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/utsname.h>        /* uname() */
 #include <sys/wait.h>

@@ -141,11 +136,11 @@
         case build_running:
                 second_pass = 0;
                 return build_running;
         case build_failed:
                 if (!continue_after_error) {
-                        fatal(catgets(catd, 1, 13, "Target `%s' not remade because of errors"),
+                        fatal(gettext("Target `%s' not remade because of errors"),
                               target->string_mb);
                 }
                 build_failed_seen = true;
                 second_pass = 0;
                 return build_failed;

@@ -167,16 +162,16 @@
                         second_pass = 1;
                         goto try_again;
                 }
                 second_pass = 0;
                 if (continue_after_error && !svr4) {
-                        warning(catgets(catd, 1, 14, "Don't know how to make target `%s'"),
+                        warning(gettext("Don't know how to make target `%s'"),
                                 target->string_mb);
                         build_failed_seen = true;
                         return build_failed;
                 }
-                fatal(catgets(catd, 1, 15, "Don't know how to make target `%s'"), target->string_mb);
+                fatal(gettext("Don't know how to make target `%s'"), target->string_mb);
                 break;
         }
 #ifdef lint
         return build_failed;
 #endif

@@ -437,19 +432,19 @@
                                 *p++ = dependency->name;
                         }
                 }
         }
         if (debug_level > 1) {
-                (void) printf(NOCATGETS("%*sdoname(%s)\n"),
+                (void) printf("%*sdoname(%s)\n",
                               recursion_level,
                               "",
                               target->string_mb);
         }
         recursion_level++;
         /* Avoid infinite loops */
         if (target->state == build_in_progress) {
-                warning(catgets(catd, 1, 16, "Infinite loop: Target `%s' depends on itself"),
+                warning(gettext("Infinite loop: Target `%s' depends on itself"),
                         target->string_mb);
                 return build_ok;
         }
         target->state = build_in_progress;
 

@@ -683,11 +678,11 @@
                                                                     line->body.line.dependency_time);
                         }
                         if (build_unconditional || out_of_date) {
                                 line->body.line.is_out_of_date = true;
                                 if (debug_level > 0) {
-                                        (void) printf(catgets(catd, 1, 17, "%*sBuilding %s using .DEFAULT because it is out of date\n"),
+                                        (void) printf(gettext("%*sBuilding %s using .DEFAULT because it is out of date\n"),
                                                       recursion_level,
                                                       "",
                                                       true_target->string_mb);
                                 }
                         }

@@ -877,11 +872,11 @@
          */
         if ((result == build_ok) && check_auto_dependencies(target,
                                                             auto_count,
                                                             automatics)) {
                 if (debug_level > 0) {
-                        (void) printf(catgets(catd, 1, 18, "%*sTarget `%s' acquired new dependencies from build, rechecking all dependencies\n"),
+                        (void) printf(gettext("%*sTarget `%s' acquired new dependencies from build, rechecking all dependencies\n"),
                                       recursion_level,
                                       "",
                                       true_target->string_mb);
                 }
                 rechecking_target = true;

@@ -1030,11 +1025,11 @@
                                 dependency->stale = true;
                                 rewrite_statefile =
                                   command_changed =
                                     true;
                                 if (debug_level > 0) {
-                                        (void) printf(catgets(catd, 1, 19, "Target %s rebuilt because dependency %s does not exist\n"),
+                                        (void) printf(gettext("Target %s rebuilt because dependency %s does not exist\n"),
                                                      true_target->string_mb,
                                                      dependency->name->string_mb);
                                 }
                                 break;
                         }

@@ -1060,18 +1055,18 @@
                         if(true_target->is_member || dependency->name->is_member) {
                                 line->body.line.dependency_time.tv_nsec = 0;
                         }
 
                         if (debug_level > 1) {
-                                (void) printf(catgets(catd, 1, 20, "%*sDate(%s)=%s \n"),
+                                (void) printf(gettext("%*sDate(%s)=%s \n"),
                                               recursion_level,
                                               "",
                                               dependency->name->string_mb,
                                               time_to_string(dependency->name->
                                                              stat.time));
                                 if (dependency->name->stat.time > line->body.line.dependency_time) {
-                                        (void) printf(catgets(catd, 1, 21, "%*sDate-dependencies(%s) set to %s\n"),
+                                        (void) printf(gettext("%*sDate-dependencies(%s) set to %s\n"),
                                                       recursion_level,
                                                       "",
                                                       true_target->string_mb,
                                                       time_to_string(line->body.line.
                                                                      dependency_time));

@@ -1126,17 +1121,17 @@
                                 }
                                 (*out_of_date_tail)->next = NULL;
                                 out_of_date_tail = &(*out_of_date_tail)->next;
                                 if (debug_level > 0) {
                                         if (dependency->name->stat.time == file_max_time) {
-                                                (void) printf(catgets(catd, 1, 22, "%*sBuilding %s because %s does not exist\n"),
+                                                (void) printf(gettext("%*sBuilding %s because %s does not exist\n"),
                                                               recursion_level,
                                                               "",
                                                               true_target->string_mb,
                                                               dependency->name->string_mb);
                                         } else {
-                                                (void) printf(catgets(catd, 1, 23, "%*sBuilding %s because it is out of date relative to %s\n"),
+                                                (void) printf(gettext("%*sBuilding %s because it is out of date relative to %s\n"),
                                                               recursion_level,
                                                               "",
                                                               true_target->string_mb,
                                                               dependency->name->string_mb);
                                         }

@@ -1202,11 +1197,11 @@
          * After scanning all the dependencies, we check the rule
          * if we found one.
          */
         if (line->body.line.command_template != NULL) {
                 if (line->body.line.command_template_redefined) {
-                        warning(catgets(catd, 1, 24, "Too many rules defined for target %s"),
+                        warning(gettext("Too many rules defined for target %s"),
                                 target->string_mb);
                 }
                 *command = line;
                 /* Check if the target is out of date */
                 Boolean out_of_date;

@@ -1422,11 +1417,11 @@
                                 // include "//" and "/./"
                                 //dependency->name = GETNAME(start, p - start);
                                 dependency->name = normalize_name(start, p - start);
                                 if ((debug_level > 0) &&
                                     (first_member == NULL)) {
-                                        (void) printf(catgets(catd, 1, 25, "%*sDynamic dependency `%s' for target `%s'\n"),
+                                        (void) printf(gettext("%*sDynamic dependency `%s' for target `%s'\n"),
                                                       recursion_level,
                                                       "",
                                                       dependency->name->string_mb,
                                                       true_target->string_mb);
                                 }

@@ -1457,11 +1452,11 @@
                                   GETNAME(string.buffer.start, FIND_LENGTH);
                                 if (string.free_after_use) {
                                         retmem(string.buffer.start);
                                 }
                                 if (debug_level > 0) {
-                                        (void) printf(catgets(catd, 1, 26, "%*sDynamic dependency `%s' for target `%s'\n"),
+                                        (void) printf(gettext("%*sDynamic dependency `%s' for target `%s'\n"),
                                                       recursion_level,
                                                       "",
                                                       first_member->name->
                                                       string_mb,
                                                       true_target->string_mb);

@@ -1614,11 +1609,11 @@
          */
         if (!touch &&
             line->body.line.sccs_command &&
             (target->stat.time != file_doesnt_exist) &&
             ((target->stat.mode & 0222) != 0)) {
-                fatal(catgets(catd, 1, 27, "%s is writable so it cannot be sccs gotten"),
+                fatal(gettext("%s is writable so it cannot be sccs gotten"),
                       target->string_mb);
                 target->has_complained = remember_only = true;
         }
         /*
          * If KEEP_STATE is on, we make sure we have the timestamp for

@@ -1635,11 +1630,11 @@
                    tmp_file_path[0] = '\0';
                 } else {
                    strcpy(tmp_file_path, temp_file_directory);
                 }
                 sprintf(mbs_buffer,
-                                NOCATGETS("%s/.make.dependency.%08x.%d.%d"),
+                                "%s/.make.dependency.%08x.%d.%d",
                                 tmp_file_path,
                                 hostid,
                                 getpid(),
                                 file_number++);
                 MBSTOWCS(wcs_buffer, mbs_buffer);

@@ -1825,16 +1820,16 @@
                 } else {
                         result = build_ok;
                 }
                 if (result == build_failed) {
                         if (silent || rule->silent) {
-                                (void) printf(catgets(catd, 1, 242, "The following command caused the error:\n%s\n"),
+                                (void) printf(gettext("The following command caused the error:\n%s\n"),
                                               rule->command_line->string_mb);
                         }
                         if (!rule->ignore_error && !ignore_errors) {
                                 if (!continue_after_error) {
-                                        fatal(catgets(catd, 1, 244, "Command failed for target `%s'"),
+                                        fatal(gettext("Command failed for target `%s'"),
                                               target->string_mb);
                                 }
                                 /*
                                  * Make sure a failing command is not
                                  * saved in .make.state.

@@ -2108,11 +2103,11 @@
                  (*equal == (int) plus_char))) {
                 equal++;
         }
         switch (*equal) {
         case nul_char:
-                fatal(catgets(catd, 1, 31, "= expected in rule `%s' for target `%s'"),
+                fatal(gettext("= expected in rule `%s' for target `%s'"),
                       line->string_mb,
                       target->string_mb);
         case plus_char:
                 append = true;
                 equal++;

@@ -2402,22 +2397,22 @@
                             !used->ignore_command_dependency && (vpath_translated != used->command_line)) {
                                 if (debug_level > 0) {
                                         if (used->command_line != NULL
                                             && *used->command_line->string_mb !=
                                             '\0') {
-                                                (void) printf(catgets(catd, 1, 32, "%*sBuilding %s because new command \n\t%s\n%*sdifferent from old\n\t%s\n"),
+                                                (void) printf(gettext("%*sBuilding %s because new command \n\t%s\n%*sdifferent from old\n\t%s\n"),
                                                               recursion_level,
                                                               "",
                                                               target->string_mb,
                                                               vpath_translated->string_mb,
                                                               recursion_level,
                                                               "",
                                                               used->
                                                               command_line->
                                                               string_mb);
                                         } else {
-                                                (void) printf(catgets(catd, 1, 33, "%*sBuilding %s because new command \n\t%s\n%*sdifferent from empty old command\n"),
+                                                (void) printf(gettext("%*sBuilding %s because new command \n\t%s\n%*sdifferent from empty old command\n"),
                                                               recursion_level,
                                                               "",
                                                               target->string_mb,
                                                               vpath_translated->string_mb,
                                                               recursion_level,

@@ -2438,11 +2433,11 @@
         if (used != NULL) {
                 *insert = NULL;
                 if (keep_state &&
                     !ignore_all_command_dependency) {
                         if (debug_level > 0) {
-                                (void) printf(catgets(catd, 1, 34, "%*sBuilding %s because new command shorter than old\n"),
+                                (void) printf(gettext("%*sBuilding %s because new command shorter than old\n"),
                                               recursion_level,
                                               "",
                                               target->string_mb);
                         }
                         command_changed = true;

@@ -2453,11 +2448,11 @@
         /* command consistency */
         if (new_command_longer &&
             !ignore_all_command_dependency &&
             keep_state) {
                 if (debug_level > 0) {
-                        (void) printf(catgets(catd, 1, 35, "%*sBuilding %s because new command longer than old\n"),
+                        (void) printf(gettext("%*sBuilding %s because new command longer than old\n"),
                                       recursion_level,
                                       "",
                                       target->string_mb);
                 }
                 command_changed = true;

@@ -2519,11 +2514,11 @@
                          * to dosys(). If KEEP_STATE is on, "make -t"
                          * will save the proper command, not the
                          * "touch" in .make.state.
                          */
                         INIT_STRING_FROM_STACK(touch_string, buffer);
-                        MBSTOWCS(wcs_buffer, NOCATGETS("touch "));
+                        MBSTOWCS(wcs_buffer, "touch ");
                         append_string(wcs_buffer, &touch_string, FIND_LENGTH);
                         touch_cmd = name;
                         if (name->has_vpath_alias_prop) {
                                 touch_cmd = get_prop(name->prop,
                                                  vpath_alias_prop)->

@@ -2684,21 +2679,21 @@
         int                     sym_link_depth = 0;
 
         /* For sccs, we need to chase symlinks. */
         while (target->stat.is_sym_link) {
                 if (sym_link_depth++ > 90) {
-                        fatal(catgets(catd, 1, 95, "Can't read symbolic link `%s': Number of symbolic links encountered during path name traversal exceeds 90."),
+                        fatal(gettext("Can't read symbolic link `%s': Number of symbolic links encountered during path name traversal exceeds 90."),
                               target->string_mb);
                 }
                 /* Read the value of the link. */
                 result = readlink_vroot(target->string_mb,
                                         link,
                                         sizeof(link),
                                         NULL,
                                         VROOT_DEFAULT);
                 if (result == -1) {
-                        fatal(catgets(catd, 1, 36, "Can't read symbolic link `%s': %s"),
+                        fatal(gettext("Can't read symbolic link `%s': %s"),
                               target->string_mb, errmsg(errno));
                 }
                 link[result] = 0;
                 /* Use the value to build the proper filename. */
                 INIT_STRING_FROM_STACK(string, name);

@@ -2766,11 +2761,11 @@
                          * And only if the plain file is out of date do we
                          * request execution of the command.
                          */
                         line->body.line.is_out_of_date = true;
                         if (debug_level > 0) {
-                                (void) printf(catgets(catd, 1, 37, "%*sSccs getting %s because s. file is younger than source file\n"),
+                                (void) printf(gettext("%*sSccs getting %s because s. file is younger than source file\n"),
                                               recursion_level,
                                               "",
                                               target->string_mb);
                         }
                 }

@@ -2828,13 +2823,13 @@
         register int            length = p - wcb;
         static Name             usr_include;
         static Name             usr_include_sys;
 
         if (usr_include == NULL) {
-                MBSTOWCS(usr_include_buf, NOCATGETS("/usr/include"));
+                MBSTOWCS(usr_include_buf, "/usr/include");
                 usr_include = GETNAME(usr_include_buf, FIND_LENGTH);
-                MBSTOWCS(usr_include_sys_buf, NOCATGETS("/usr/include/sys"));
+                MBSTOWCS(usr_include_sys_buf, "/usr/include/sys");
                 usr_include_sys = GETNAME(usr_include_sys_buf, FIND_LENGTH);
         }
 
         /*
          * If the filename contains a "/" we have to extract the path

@@ -2963,11 +2958,11 @@
                 /* Save the old value */
                 old_locals[i].body.macro =
                   maybe_append_prop(conditional->body.conditional.name,
                                     macro_prop)->body.macro;
                 if (debug_level > 1) {
-                        (void) printf(catgets(catd, 1, 38, "%*sActivating conditional value: "),
+                        (void) printf(gettext("%*sActivating conditional value: "),
                                       recursion_level,
                                       "");
                 }
                 /* Set the conditional value. Macros are expanded when the */
                 /* macro is refd as usual */

@@ -3019,11 +3014,11 @@
                 reset_locals(target, old_locals, this_conditional, index+1);
         } else {
                 /* Remove conditional target from chain */
                 if (conditional_targets == NULL ||
                     conditional_targets->name != target) {
-                        warning(catgets(catd, 1, 39, "Internal error: reset target not at head of condtional_targets chain"));
+                        warning(gettext("Internal error: reset target not at head of condtional_targets chain"));
                 } else {
                         cond_chain = conditional_targets->next;
                         retmem_mb((caddr_t) conditional_targets);
                         conditional_targets = cond_chain;
                 }

@@ -3033,19 +3028,19 @@
         if (conditional->body.conditional.name == virtual_root) {
                 (void) SETVAR(virtual_root, getvar(virtual_root), false);
         }
         if (debug_level > 1) {
                 if (old_locals[index].body.macro.value != NULL) {
-                        (void) printf(catgets(catd, 1, 40, "%*sdeactivating conditional value: %s= %s\n"),
+                        (void) printf(gettext("%*sdeactivating conditional value: %s= %s\n"),
                                       recursion_level,
                                       "",
                                       conditional->body.conditional.name->
                                       string_mb,
                                       old_locals[index].body.macro.value->
                                       string_mb);
                 } else {
-                        (void) printf(catgets(catd, 1, 41, "%*sdeactivating conditional value: %s =\n"),
+                        (void) printf(gettext("%*sdeactivating conditional value: %s =\n"),
                                       recursion_level,
                                       "",
                                       conditional->body.conditional.name->
                                       string_mb);
                 }