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

@@ -39,10 +39,11 @@
 #include <mksh/macro.h>         /* expand_value(), expand_macro() */
 #include <mksh/misc.h>          /* getmem() */
 #include <mksh/read.h>          /* get_next_block_fn() */
 #include <sys/uio.h>            /* read() */
 #include <unistd.h>             /* read(), unlink() */
+#include <libintl.h>
 
 
 /*
  * typedefs & structs
  */

@@ -115,11 +116,11 @@
 
 
         wchar_t * wcb = get_wstring(makefile_name->string_mb);
 
         if (max_include_depth++ >= 40) {
-                fatal(catgets(catd, 1, 66, "Too many nested include statements"));
+                fatal(gettext("Too many nested include statements"));
         }
         if (makefile->body.makefile.contents != NULL) {
                 retmem(makefile->body.makefile.contents);
         }
         source->inp_buf =

@@ -148,14 +149,14 @@
                                 // Tools build
                                 asprintf(&path, "%s/../../share/", pfx);
                                 add_dir_to_path(path, &makefile_path, -1);
                                 free(path);
                                     
-                                add_dir_to_path(NOCATGETS("/usr/share/lib/make"),
+                                add_dir_to_path("/usr/share/lib/make",
                                                 &makefile_path,
                                                 -1);
-                                add_dir_to_path(NOCATGETS("/etc/default"),
+                                add_dir_to_path("/etc/default",
                                                 &makefile_path,
                                                 -1);
 
                                 free(pfx);
                         }

@@ -202,20 +203,20 @@
                 source->already_expanded = false;
                 /* Lock the file for read, but not when -n. */
                 if (lock_makefile && 
                     !do_not_exec_rule) {
 
-                         make_state_lockfile = getmem(strlen(make_state->string_mb) + strlen(NOCATGETS(".lock")) + 1);
+                         make_state_lockfile = getmem(strlen(make_state->string_mb) + strlen(".lock") + 1);
                          (void) sprintf(make_state_lockfile,
-                                                NOCATGETS("%s.lock"),
+                                                "%s.lock",
                                                 make_state->string_mb);
                         (void) file_lock(make_state->string_mb,
                                          make_state_lockfile,
                                          (int *) &make_state_locked,
                                          0);
                         if(!make_state_locked) {
-                                printf(NOCATGETS("-- NO LOCKING for read\n"));
+                                printf("-- NO LOCKING for read\n");
                                 retmem_mb(make_state_lockfile);
                                 make_state_lockfile = 0;
                                 return failed;
                         }
                 }

@@ -224,11 +225,11 @@
                         makefile_type = reading_nothing;
                         if ((doname_it) &&
                             (doname(makefile_name, true, false) == build_failed)) {
                                 if (complain) {
                                         (void) fprintf(stderr,
-                                                       catgets(catd, 1, 237, "make: Couldn't make `%s'\n"),
+                                                       gettext("make: Couldn't make `%s'\n"),
                                                        makefile_name->string_mb);
                                 }
                                 max_include_depth--;
                                 makefile_type = save_makefile_type;
                                 return failed;

@@ -241,16 +242,16 @@
 
                         if (exists(makefile_name) == file_doesnt_exist) {
                                 if (complain ||
                                     (makefile_name->stat.stat_errno != ENOENT)) {
                                         if (must_exist) {
-                                                fatal(catgets(catd, 1, 68, "Can't find `%s': %s"),
+                                                fatal(gettext("Can't find `%s': %s"),
                                                       makefile_name->string_mb,
                                                       errmsg(makefile_name->
                                                              stat.stat_errno));
                                         } else {
-                                                warning(catgets(catd, 1, 69, "Can't find `%s': %s"),
+                                                warning(gettext("Can't find `%s': %s"),
                                                         makefile_name->string_mb,
                                                         errmsg(makefile_name->
                                                                stat.stat_errno));
                                         }
                                 }

@@ -291,15 +292,15 @@
                                                 NULL,
                                                 VROOT_DEFAULT);
                         if (source->fd < 0) {
                                 if (complain || (errno != ENOENT)) {
                                         if (must_exist) {
-                                                fatal(catgets(catd, 1, 70, "Can't open `%s': %s"),
+                                                fatal(gettext("Can't open `%s': %s"),
                                                       makefile_name->string_mb,
                                                       errmsg(errno));
                                         } else {
-                                                warning(catgets(catd, 1, 71, "Can't open `%s': %s"),
+                                                warning(gettext("Can't open `%s': %s"),
                                                         makefile_name->string_mb,
                                                         errmsg(errno));
                                         }
                                 }
                                 max_include_depth--;

@@ -337,20 +338,20 @@
                 char            *stdin_buffer_end;
                 char            *p_mb;
                 int             num_mb_chars;
                 size_t          num_wc_chars;
 
-                MBSTOWCS(wcs_buffer, NOCATGETS("Standard in"));
+                MBSTOWCS(wcs_buffer, "Standard in");
                 makefile_name = GETNAME(wcs_buffer, FIND_LENGTH);
                 /*
                  * Memory to read standard in, then convert it
                  * to wide char strings.
                  */
                 stdin_buffer_start =
                   stdin_text_p = getmem(length = 1024);
                 stdin_buffer_end = stdin_text_p + length;
-                MBSTOWCS(wcs_buffer, NOCATGETS("standard input"));
+                MBSTOWCS(wcs_buffer, "standard input");
                 file_being_read = (wchar_t *) wsdup(wcs_buffer);
                 line_number = 0;
                 while ((n = read(fileno(stdin),
                                  stdin_text_p,
                                  length)) > 0) {

@@ -372,11 +373,11 @@
                                   stdin_buffer_start + length;
                                 length = 1024;
                         }
                 }
                 if (n < 0) {
-                        fatal(catgets(catd, 1, 72, "Error reading standard input: %s"),
+                        fatal(gettext("Error reading standard input: %s"),
                               errmsg(errno));
                 }
                 stdin_text_p = stdin_buffer_start;
                 stdin_text_end = stdin_buffer_end - length;
                 num_mb_chars = stdin_text_end - stdin_text_p;

@@ -403,16 +404,16 @@
                 }
                 (void) retmem_mb(stdin_text_p);
         }
         line_number = 1;
         if (trace_reader) {
-                (void) printf(catgets(catd, 1, 73, ">>>>>>>>>>>>>>>> Reading makefile %s\n"),
+                (void) printf(gettext(">>>>>>>>>>>>>>>> Reading makefile %s\n"),
                               makefile_name->string_mb);
         }
         parse_makefile(makefile_name, source);
         if (trace_reader) {
-                (void) printf(catgets(catd, 1, 74, ">>>>>>>>>>>>>>>> End of makefile %s\n"),
+                (void) printf(gettext(">>>>>>>>>>>>>>>> End of makefile %s\n"),
                               makefile_name->string_mb);
         }
         if(file_being_read) {
                 retmem(file_being_read);
         }

@@ -727,12 +728,12 @@
         }
         /* Check if this is an include command */
         if ((makefile_type == reading_makefile) &&
             !source->already_expanded) {
             if (include_space[0] == (int) nul_char) {
-                MBSTOWCS(include_space, NOCATGETS("include "));
-                MBSTOWCS(include_tab, NOCATGETS("include\t"));
+                MBSTOWCS(include_space, "include ");
+                MBSTOWCS(include_tab, "include\t");
             }
             if ((IS_WEQUALN(source_p, include_space, 8)) ||
                 (IS_WEQUALN(source_p, include_tab, 8))) {
                 source_p += 7;
                 if (iswspace(*source_p)) {

@@ -871,11 +872,11 @@
                                              true,
                                              true,
                                              false,
                                              true,
                                              false) == failed) {
-                                fatal_reader(catgets(catd, 1, 75, "Read of include file `%s' failed"),
+                                fatal_reader(gettext("Read of include file `%s' failed"),
                                              makefile_name->string_mb);
                         }
                         makefile_type = save_makefile_type;
                         do_not_exec_rule = save_do_not_exec_rule;
                         CACHE_SOURCE(0);

@@ -1057,14 +1058,14 @@
                                 GOTO_STATE(on_eoln_state);
                         }
                         break;
                 case newline_char:
                         if (paren_count > 0) {
-                                fatal_reader(catgets(catd, 1, 76, "Unmatched `(' on line"));
+                                fatal_reader(gettext("Unmatched `(' on line"));
                         }
                         if (brace_count > 0) {
-                                fatal_reader(catgets(catd, 1, 77, "Unmatched `{' on line"));
+                                fatal_reader(gettext("Unmatched `{' on line"));
                         }
                         source_p++;
                         /* Enter name */
                         current_names = enter_name(&name_string,
                                                    macro_seen_in_string,

@@ -1113,11 +1114,11 @@
                         break;
                 case numbersign_char:
                         if (paren_count + brace_count > 0) {
                                 break;
                         }
-                        fatal_reader(catgets(catd, 1, 78, "Unexpected comment seen"));
+                        fatal_reader(gettext("Unexpected comment seen"));
                 case dollar_char:
                         if (source->already_expanded) {
                                 break;
                         }
                         /* Save the identifier so far */

@@ -1148,19 +1149,19 @@
                 case parenleft_char:
                         paren_count++;
                         break;
                 case parenright_char:
                         if (--paren_count < 0) {
-                                fatal_reader(catgets(catd, 1, 79, "Unmatched `)' on line"));
+                                fatal_reader(gettext("Unmatched `)' on line"));
                         }
                         break;
                 case braceleft_char:
                         brace_count++;
                         break;
                 case braceright_char:
                         if (--brace_count < 0) {
-                                fatal_reader(catgets(catd, 1, 80, "Unmatched `}' on line"));
+                                fatal_reader(gettext("Unmatched `}' on line"));
                         }
                         break;
                 case ampersand_char:
                 case greater_char:
                 case bar_char:

@@ -1201,11 +1202,11 @@
 #endif
 /** END POSIX **/
                         /* End of the target list. We now start reading */
                         /* dependencies or a conditional assignment */
                         if (separator != none_seen) {
-                                fatal_reader(catgets(catd, 1, 81, "Extra `:', `::', or `:=' on dependency line"));
+                                fatal_reader(gettext("Extra `:', `::', or `:=' on dependency line"));
                         }
                         /* Enter the last target */
                         if ((string_start != source_p) ||
                             macro_seen_in_string) {
                                 current_names =

@@ -1233,11 +1234,11 @@
                                         GOTO_STATE(enter_dependencies_state);
                                 }
                                 goto scan_colon_label;
                         case equal_char:
                                 if(svr4) {
-                                  fatal_reader(catgets(catd, 1, 82, "syntax error"));
+                                  fatal_reader(gettext("syntax error"));
                                 }
                                 separator = conditional_seen;
                                 source_p++;
                                 current_names = &depes;
                                 GOTO_STATE(scan_name_state);

@@ -1256,11 +1257,11 @@
                                 break;
                         }
                         /* End of reading names. Start reading the rule */
                         if ((separator != one_colon) &&
                             (separator != two_colon)) {
-                                fatal_reader(catgets(catd, 1, 83, "Unexpected command seen"));
+                                fatal_reader(gettext("Unexpected command seen"));
                         }
                         /* Enter the last dependency */
                         if ((string_start != source_p) ||
                             macro_seen_in_string) {
                                 current_names =

@@ -1383,11 +1384,11 @@
                                 goto scan_append;
                         case equal_char:
                                 if(!svr4) {
                                   append = true;
                                 } else {
-                                  fatal_reader(catgets(catd, 1, 84, "Must be a separator on rules"));
+                                  fatal_reader(gettext("Must be a separator on rules"));
                                 }
                                 break;
                         default:
                                 /* The "+" just starts a regular name. */
                                 /* Start reading that name */

@@ -1410,13 +1411,13 @@
                                 break;
                         default:
                                 /* Reader must special check for "MACRO:sh=" */
                                 /* notation */
                                 if (sh_name == NULL) {
-                                        MBSTOWCS(wcs_buffer, NOCATGETS("sh"));
+                                        MBSTOWCS(wcs_buffer, "sh");
                                         sh_name = GETNAME(wcs_buffer, FIND_LENGTH);
-                                        MBSTOWCS(wcs_buffer, NOCATGETS("shell"));
+                                        MBSTOWCS(wcs_buffer, "shell");
                                         shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
                                 }
 
                                 if (!macro_seen_in_string) {
                                         INIT_STRING_FROM_STACK(name_string,

@@ -1481,14 +1482,14 @@
                                         separator = equal_seen;
                                         on_eoln_state = enter_equal_state;
                                         break;
                                 } 
                                 if(svr4) {
-                                  fatal_reader(catgets(catd, 1, 85, "syntax error"));
+                                  fatal_reader(gettext("syntax error"));
                                 }
                                 else {
-                                  fatal_reader(catgets(catd, 1, 86, "Macro assignment on dependency line"));
+                                  fatal_reader(gettext("Macro assignment on dependency line"));
                                 }
                         }
                         if (append) {
                                 source_p--;
                         }

@@ -1983,25 +1984,25 @@
 
 /****************************************************************
  *      Error states
  */
 case illegal_bytes_state:
-        fatal_reader(catgets(catd, 1, 340, "Invalid byte sequence"));
+        fatal_reader(gettext("Invalid byte sequence"));
 case illegal_eoln_state:
         if (line_number > 1) {
                 if (line_started_with_space == (line_number - 1)) {
                         line_number--;
-                        fatal_reader(catgets(catd, 1, 90, "Unexpected end of line seen\n\t*** missing separator (did you mean TAB instead of 8 spaces?)"));
+                        fatal_reader(gettext("Unexpected end of line seen\n\t*** missing separator (did you mean TAB instead of 8 spaces?)"));
                 }
         }
-        fatal_reader(catgets(catd, 1, 87, "Unexpected end of line seen"));
+        fatal_reader(gettext("Unexpected end of line seen"));
 case poorly_formed_macro_state:
-        fatal_reader(catgets(catd, 1, 88, "Badly formed macro assignment"));
+        fatal_reader(gettext("Badly formed macro assignment"));
 case exit_state:
         return;
 default:
-        fatal_reader(catgets(catd, 1, 89, "Internal error. Unknown reader state"));
+        fatal_reader(gettext("Internal error. Unknown reader state"));
 }
 }
 
 /*
  *      push_macro_value(bp, buffer, size, source)

@@ -2085,11 +2086,11 @@
                         if (target->names[i] != NULL) {
                                 if (target_group_seen) {
                                         target_group_member =
                                           find_target_groups(target, i, reset);
                                         if(target_group_member == NULL) {
-                                                fatal_reader(catgets(catd, 1, 328, "Unexpected '+' on dependency line"));
+                                                fatal_reader(gettext("Unexpected '+' on dependency line"));
                                         }
                                 }
                                 reset = false;
 
                                 /* If we saw it in the makefile it must be