Print this page
make: translate using gettext, rather than the unmaintainable catgets
*** 39,48 ****
--- 39,49 ----
#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,125 ****
wchar_t * wcb = get_wstring(makefile_name->string_mb);
if (max_include_depth++ >= 40) {
! fatal(catgets(catd, 1, 66, "Too many nested include statements"));
}
if (makefile->body.makefile.contents != NULL) {
retmem(makefile->body.makefile.contents);
}
source->inp_buf =
--- 116,126 ----
wchar_t * wcb = get_wstring(makefile_name->string_mb);
if (max_include_depth++ >= 40) {
! fatal(gettext("Too many nested include statements"));
}
if (makefile->body.makefile.contents != NULL) {
retmem(makefile->body.makefile.contents);
}
source->inp_buf =
*** 148,161 ****
// 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"),
&makefile_path,
-1);
! add_dir_to_path(NOCATGETS("/etc/default"),
&makefile_path,
-1);
free(pfx);
}
--- 149,162 ----
// Tools build
asprintf(&path, "%s/../../share/", pfx);
add_dir_to_path(path, &makefile_path, -1);
free(path);
! add_dir_to_path("/usr/share/lib/make",
&makefile_path,
-1);
! add_dir_to_path("/etc/default",
&makefile_path,
-1);
free(pfx);
}
*** 202,221 ****
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);
(void) sprintf(make_state_lockfile,
! NOCATGETS("%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"));
retmem_mb(make_state_lockfile);
make_state_lockfile = 0;
return failed;
}
}
--- 203,222 ----
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(".lock") + 1);
(void) sprintf(make_state_lockfile,
! "%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("-- NO LOCKING for read\n");
retmem_mb(make_state_lockfile);
make_state_lockfile = 0;
return failed;
}
}
*** 224,234 ****
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"),
makefile_name->string_mb);
}
max_include_depth--;
makefile_type = save_makefile_type;
return failed;
--- 225,235 ----
makefile_type = reading_nothing;
if ((doname_it) &&
(doname(makefile_name, true, false) == build_failed)) {
if (complain) {
(void) fprintf(stderr,
! gettext("make: Couldn't make `%s'\n"),
makefile_name->string_mb);
}
max_include_depth--;
makefile_type = save_makefile_type;
return failed;
*** 241,256 ****
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"),
makefile_name->string_mb,
errmsg(makefile_name->
stat.stat_errno));
} else {
! warning(catgets(catd, 1, 69, "Can't find `%s': %s"),
makefile_name->string_mb,
errmsg(makefile_name->
stat.stat_errno));
}
}
--- 242,257 ----
if (exists(makefile_name) == file_doesnt_exist) {
if (complain ||
(makefile_name->stat.stat_errno != ENOENT)) {
if (must_exist) {
! fatal(gettext("Can't find `%s': %s"),
makefile_name->string_mb,
errmsg(makefile_name->
stat.stat_errno));
} else {
! warning(gettext("Can't find `%s': %s"),
makefile_name->string_mb,
errmsg(makefile_name->
stat.stat_errno));
}
}
*** 291,305 ****
NULL,
VROOT_DEFAULT);
if (source->fd < 0) {
if (complain || (errno != ENOENT)) {
if (must_exist) {
! fatal(catgets(catd, 1, 70, "Can't open `%s': %s"),
makefile_name->string_mb,
errmsg(errno));
} else {
! warning(catgets(catd, 1, 71, "Can't open `%s': %s"),
makefile_name->string_mb,
errmsg(errno));
}
}
max_include_depth--;
--- 292,306 ----
NULL,
VROOT_DEFAULT);
if (source->fd < 0) {
if (complain || (errno != ENOENT)) {
if (must_exist) {
! fatal(gettext("Can't open `%s': %s"),
makefile_name->string_mb,
errmsg(errno));
} else {
! warning(gettext("Can't open `%s': %s"),
makefile_name->string_mb,
errmsg(errno));
}
}
max_include_depth--;
*** 337,356 ****
char *stdin_buffer_end;
char *p_mb;
int num_mb_chars;
size_t num_wc_chars;
! MBSTOWCS(wcs_buffer, NOCATGETS("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"));
file_being_read = (wchar_t *) wsdup(wcs_buffer);
line_number = 0;
while ((n = read(fileno(stdin),
stdin_text_p,
length)) > 0) {
--- 338,357 ----
char *stdin_buffer_end;
char *p_mb;
int num_mb_chars;
size_t num_wc_chars;
! 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, "standard input");
file_being_read = (wchar_t *) wsdup(wcs_buffer);
line_number = 0;
while ((n = read(fileno(stdin),
stdin_text_p,
length)) > 0) {
*** 372,382 ****
stdin_buffer_start + length;
length = 1024;
}
}
if (n < 0) {
! fatal(catgets(catd, 1, 72, "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;
--- 373,383 ----
stdin_buffer_start + length;
length = 1024;
}
}
if (n < 0) {
! 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,418 ****
}
(void) retmem_mb(stdin_text_p);
}
line_number = 1;
if (trace_reader) {
! (void) printf(catgets(catd, 1, 73, ">>>>>>>>>>>>>>>> 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"),
makefile_name->string_mb);
}
if(file_being_read) {
retmem(file_being_read);
}
--- 404,419 ----
}
(void) retmem_mb(stdin_text_p);
}
line_number = 1;
if (trace_reader) {
! (void) printf(gettext(">>>>>>>>>>>>>>>> Reading makefile %s\n"),
makefile_name->string_mb);
}
parse_makefile(makefile_name, source);
if (trace_reader) {
! (void) printf(gettext(">>>>>>>>>>>>>>>> End of makefile %s\n"),
makefile_name->string_mb);
}
if(file_being_read) {
retmem(file_being_read);
}
*** 727,738 ****
}
/* 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"));
}
if ((IS_WEQUALN(source_p, include_space, 8)) ||
(IS_WEQUALN(source_p, include_tab, 8))) {
source_p += 7;
if (iswspace(*source_p)) {
--- 728,739 ----
}
/* 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, "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,881 ****
true,
true,
false,
true,
false) == failed) {
! fatal_reader(catgets(catd, 1, 75, "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);
--- 872,882 ----
true,
true,
false,
true,
false) == 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,1070 ****
GOTO_STATE(on_eoln_state);
}
break;
case newline_char:
if (paren_count > 0) {
! fatal_reader(catgets(catd, 1, 76, "Unmatched `(' on line"));
}
if (brace_count > 0) {
! fatal_reader(catgets(catd, 1, 77, "Unmatched `{' on line"));
}
source_p++;
/* Enter name */
current_names = enter_name(&name_string,
macro_seen_in_string,
--- 1058,1071 ----
GOTO_STATE(on_eoln_state);
}
break;
case newline_char:
if (paren_count > 0) {
! fatal_reader(gettext("Unmatched `(' on line"));
}
if (brace_count > 0) {
! fatal_reader(gettext("Unmatched `{' on line"));
}
source_p++;
/* Enter name */
current_names = enter_name(&name_string,
macro_seen_in_string,
*** 1113,1123 ****
break;
case numbersign_char:
if (paren_count + brace_count > 0) {
break;
}
! fatal_reader(catgets(catd, 1, 78, "Unexpected comment seen"));
case dollar_char:
if (source->already_expanded) {
break;
}
/* Save the identifier so far */
--- 1114,1124 ----
break;
case numbersign_char:
if (paren_count + brace_count > 0) {
break;
}
! fatal_reader(gettext("Unexpected comment seen"));
case dollar_char:
if (source->already_expanded) {
break;
}
/* Save the identifier so far */
*** 1148,1166 ****
case parenleft_char:
paren_count++;
break;
case parenright_char:
if (--paren_count < 0) {
! fatal_reader(catgets(catd, 1, 79, "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"));
}
break;
case ampersand_char:
case greater_char:
case bar_char:
--- 1149,1167 ----
case parenleft_char:
paren_count++;
break;
case parenright_char:
if (--paren_count < 0) {
! fatal_reader(gettext("Unmatched `)' on line"));
}
break;
case braceleft_char:
brace_count++;
break;
case braceright_char:
if (--brace_count < 0) {
! fatal_reader(gettext("Unmatched `}' on line"));
}
break;
case ampersand_char:
case greater_char:
case bar_char:
*** 1201,1211 ****
#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"));
}
/* Enter the last target */
if ((string_start != source_p) ||
macro_seen_in_string) {
current_names =
--- 1202,1212 ----
#endif
/** END POSIX **/
/* End of the target list. We now start reading */
/* dependencies or a conditional assignment */
if (separator != none_seen) {
! fatal_reader(gettext("Extra `:', `::', or `:=' on dependency line"));
}
/* Enter the last target */
if ((string_start != source_p) ||
macro_seen_in_string) {
current_names =
*** 1233,1243 ****
GOTO_STATE(enter_dependencies_state);
}
goto scan_colon_label;
case equal_char:
if(svr4) {
! fatal_reader(catgets(catd, 1, 82, "syntax error"));
}
separator = conditional_seen;
source_p++;
current_names = &depes;
GOTO_STATE(scan_name_state);
--- 1234,1244 ----
GOTO_STATE(enter_dependencies_state);
}
goto scan_colon_label;
case equal_char:
if(svr4) {
! fatal_reader(gettext("syntax error"));
}
separator = conditional_seen;
source_p++;
current_names = &depes;
GOTO_STATE(scan_name_state);
*** 1256,1266 ****
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"));
}
/* Enter the last dependency */
if ((string_start != source_p) ||
macro_seen_in_string) {
current_names =
--- 1257,1267 ----
break;
}
/* End of reading names. Start reading the rule */
if ((separator != one_colon) &&
(separator != two_colon)) {
! fatal_reader(gettext("Unexpected command seen"));
}
/* Enter the last dependency */
if ((string_start != source_p) ||
macro_seen_in_string) {
current_names =
*** 1383,1393 ****
goto scan_append;
case equal_char:
if(!svr4) {
append = true;
} else {
! fatal_reader(catgets(catd, 1, 84, "Must be a separator on rules"));
}
break;
default:
/* The "+" just starts a regular name. */
/* Start reading that name */
--- 1384,1394 ----
goto scan_append;
case equal_char:
if(!svr4) {
append = true;
} else {
! fatal_reader(gettext("Must be a separator on rules"));
}
break;
default:
/* The "+" just starts a regular name. */
/* Start reading that name */
*** 1410,1422 ****
break;
default:
/* Reader must special check for "MACRO:sh=" */
/* notation */
if (sh_name == NULL) {
! MBSTOWCS(wcs_buffer, NOCATGETS("sh"));
sh_name = GETNAME(wcs_buffer, FIND_LENGTH);
! MBSTOWCS(wcs_buffer, NOCATGETS("shell"));
shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
}
if (!macro_seen_in_string) {
INIT_STRING_FROM_STACK(name_string,
--- 1411,1423 ----
break;
default:
/* Reader must special check for "MACRO:sh=" */
/* notation */
if (sh_name == NULL) {
! MBSTOWCS(wcs_buffer, "sh");
sh_name = GETNAME(wcs_buffer, FIND_LENGTH);
! MBSTOWCS(wcs_buffer, "shell");
shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
}
if (!macro_seen_in_string) {
INIT_STRING_FROM_STACK(name_string,
*** 1481,1494 ****
separator = equal_seen;
on_eoln_state = enter_equal_state;
break;
}
if(svr4) {
! fatal_reader(catgets(catd, 1, 85, "syntax error"));
}
else {
! fatal_reader(catgets(catd, 1, 86, "Macro assignment on dependency line"));
}
}
if (append) {
source_p--;
}
--- 1482,1495 ----
separator = equal_seen;
on_eoln_state = enter_equal_state;
break;
}
if(svr4) {
! fatal_reader(gettext("syntax error"));
}
else {
! fatal_reader(gettext("Macro assignment on dependency line"));
}
}
if (append) {
source_p--;
}
*** 1983,2007 ****
/****************************************************************
* Error states
*/
case illegal_bytes_state:
! fatal_reader(catgets(catd, 1, 340, "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(catgets(catd, 1, 87, "Unexpected end of line seen"));
case poorly_formed_macro_state:
! fatal_reader(catgets(catd, 1, 88, "Badly formed macro assignment"));
case exit_state:
return;
default:
! fatal_reader(catgets(catd, 1, 89, "Internal error. Unknown reader state"));
}
}
/*
* push_macro_value(bp, buffer, size, source)
--- 1984,2008 ----
/****************************************************************
* Error states
*/
case illegal_bytes_state:
! 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(gettext("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"));
case poorly_formed_macro_state:
! fatal_reader(gettext("Badly formed macro assignment"));
case exit_state:
return;
default:
! fatal_reader(gettext("Internal error. Unknown reader state"));
}
}
/*
* push_macro_value(bp, buffer, size, source)
*** 2085,2095 ****
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"));
}
}
reset = false;
/* If we saw it in the makefile it must be
--- 2086,2096 ----
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(gettext("Unexpected '+' on dependency line"));
}
}
reset = false;
/* If we saw it in the makefile it must be