[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH 3/9] Indicate predicates and debug strings do
From: |
James Youngman |
Subject: |
[Findutils-patches] [PATCH 3/9] Indicate predicates and debug strings don't need translation. |
Date: |
Sat, 9 Jul 2011 23:15:45 +0100 |
* find/tree.c (matches_start_point): Don't translate the name of
the current directory.
(opt_expr): Translate an error message which had been left unmarked.
(print_predicate): Annotate debug strings as not needing translation.
(predlist_merge_sort): Likewise.
(consider_arm_swap): Likewise.
(opt_expr): Likewise.
(get_new_pred): Likewise.
(print_tree): Likewise.
(set_new_parent): Annotate predicate names as not needing
translation.
(get_new_pred_chk_op): Likewise.
(get_pred_cost): Translate an error message.
(prec_table): Annotate precedence names as not needing translation.
(type_table): Annotate operator type names as not needing
translation.
(cost_table): Likewise for cost names.
(cost_name): Here also for cost names.
(build_expression_tree): Annotate predicates and debug strings as
not needing translation.
* find/exec.c (prep_child_for_exec): Annotate "/dev/null" as not
needing translation.
(prep_child_for_exec): Likewise "%s".
(launch): Likewise for "%s" here.
---
ChangeLog | 26 +++++++++
find/exec.c | 6 +-
find/tree.c | 169 ++++++++++++++++++++++++++++++-----------------------------
3 files changed, 114 insertions(+), 87 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 649289a..1c474aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
2011-07-09 James Youngman <address@hidden>
+ Indicate predicates and debug strings don't need translation.
+ * find/tree.c (matches_start_point): Don't translate the name of
+ the current directory.
+ (opt_expr): Translate an error message which had been left unmarked.
+ (print_predicate): Annotate debug strings as not needing translation.
+ (predlist_merge_sort): Likewise.
+ (consider_arm_swap): Likewise.
+ (opt_expr): Likewise.
+ (get_new_pred): Likewise.
+ (print_tree): Likewise.
+ (set_new_parent): Annotate predicate names as not needing
+ translation.
+ (get_new_pred_chk_op): Likewise.
+ (get_pred_cost): Translate an error message.
+ (prec_table): Annotate precedence names as not needing translation.
+ (type_table): Annotate operator type names as not needing
+ translation.
+ (cost_table): Likewise for cost names.
+ (cost_name): Here also for cost names.
+ (build_expression_tree): Annotate predicates and debug strings as
+ not needing translation.
+ * find/exec.c (prep_child_for_exec): Annotate "/dev/null" as not
+ needing translation.
+ (prep_child_for_exec): Likewise "%s".
+ (launch): Likewise for "%s" here.
+
Predicate names and trivial formats don't need translation.
* find/parser.c (parse_table): Annotate predicate names as not
being translated.
diff --git a/find/exec.c b/find/exec.c
index b83131d..b4039a5 100644
--- a/find/exec.c
+++ b/find/exec.c
@@ -246,7 +246,7 @@ prep_child_for_exec (bool close_stdin, const struct
saved_cwd *wd)
bool ok = true;
if (close_stdin)
{
- const char inputfile[] = "/dev/null";
+ const char inputfile[] = N_("/dev/null");
if (close (0) < 0)
{
@@ -266,7 +266,7 @@ prep_child_for_exec (bool close_stdin, const struct
saved_cwd *wd)
* stdin is almost as good as executing it
* with its stdin attached to /dev/null.
*/
- error (0, errno, "%s", safely_quote_err_filename (0, inputfile));
+ error (0, errno, N_("%s"), safely_quote_err_filename (0,
inputfile));
/* do not set ok=false, it is OK to continue anyway. */
}
}
@@ -328,7 +328,7 @@ launch (struct buildcmd_control *ctl, void *usercontext,
int argc, char **argv)
else
execvp (argv[0], argv);
/* TODO: use a pipe to pass back the errno value, like xargs does */
- error (0, errno, "%s",
+ error (0, errno, N_("%s"),
safely_quote_err_filename (0, argv[0]));
_exit (1);
}
diff --git a/find/tree.c b/find/tree.c
index 7502fd5..28e416a 100644
--- a/find/tree.c
+++ b/find/tree.c
@@ -93,7 +93,7 @@ matches_start_point (const char *glob, bool foldcase)
}
else
{
- return fnmatch (glob, ".", fnmatch_flags) == 0;
+ return fnmatch (glob, N_("."), fnmatch_flags) == 0;
}
}
@@ -321,11 +321,11 @@ void print_predicate (FILE *fp, const struct predicate *p)
{
if (p->arg_text)
{
- fprintf (fp, "%s %s", p->p_name, p->arg_text);
+ fprintf (fp, N_("%s %s"), p->p_name, p->arg_text);
}
else
{
- fprintf (fp, "%s", p->p_name);
+ fprintf (fp, N_("%s"), p->p_name);
}
}
@@ -387,7 +387,7 @@ predlist_merge_sort (struct predlist *list,
if (options.debug_options & DebugTreeOpt)
{
- fprintf (stderr, "%s:\n", "predlist before merge sort");
+ fprintf (stderr, N_("%s:\n"), N_("predlist before merge sort"));
print_tree (stderr, list->head, 2);
}
@@ -434,7 +434,7 @@ predlist_merge_sort (struct predlist *list,
}
if (options.debug_options & DebugTreeOpt)
{
- fprintf (stderr, "%s:\n", "predlist after merge sort");
+ fprintf (stderr, N_("%s:\n"), N_("predlist after merge sort"));
print_tree (stderr, new_list.head, 2);
}
@@ -532,19 +532,19 @@ consider_arm_swap (struct predicate *p)
struct predicate **pl, **pr;
if (BI_OP != p->p_type)
- reason = "Not a binary operation";
+ reason = N_("Not a binary operation");
if (!reason)
{
if (NULL == p->pred_left || NULL == p->pred_right)
- reason = "Doesn't have two arms";
+ reason = N_("Doesn't have two arms");
}
if (!reason)
{
if (NULL == p->pred_left->pred_right)
- reason = "Left arm has no child on RHS";
+ reason = N_("Left arm has no child on RHS");
}
pr = &p->pred_right;
pl = &p->pred_left->pred_right;
@@ -552,12 +552,12 @@ consider_arm_swap (struct predicate *p)
if (!reason)
{
if (subtree_has_side_effects (*pl))
- reason = "Left subtree has side-effects";
+ reason = N_("Left subtree has side-effects");
}
if (!reason)
{
if (subtree_has_side_effects (*pr))
- reason = "Right subtree has side-effects";
+ reason = N_("Right subtree has side-effects");
}
if (!reason)
@@ -567,7 +567,7 @@ consider_arm_swap (struct predicate *p)
if (left_cost < right_cost)
{
- reason = "efficient as-is";
+ reason = N_("efficient as-is");
}
}
if (!reason)
@@ -582,25 +582,26 @@ consider_arm_swap (struct predicate *p)
if (options.debug_options & DebugTreeOpt)
{
- fprintf (stderr, "Success rates: l=%f, r=%f\n", succ_rate_l,
succ_rate_r);
+ fprintf (stderr, N_("Success rates: l=%f, r=%f\n"),
+ succ_rate_l, succ_rate_r);
}
if (pred_is (p, pred_or))
{
want_swap = succ_rate_r < succ_rate_l;
if (!want_swap)
- reason = "Operation is OR; right success rate >= left";
+ reason = N_("Operation is OR; right success rate >= left");
}
else if (pred_is (p, pred_and))
{
want_swap = succ_rate_r > succ_rate_l;
if (!want_swap)
- reason = "Operation is AND; right success rate <= left";
+ reason = N_("Operation is AND; right success rate <= left");
}
else
{
want_swap = false;
- reason = "Not 'AND' or 'OR'";
+ reason = N_("Not 'AND' or 'OR'");
}
}
else
@@ -612,7 +613,7 @@ consider_arm_swap (struct predicate *p)
{
if (options.debug_options & DebugTreeOpt)
{
- fprintf (stderr, "Performing arm swap on:\n");
+ fprintf (stderr, N_("Performing arm swap on:\n"));
print_tree (stderr, p, 0);
}
perform_arm_swap (p);
@@ -623,7 +624,7 @@ consider_arm_swap (struct predicate *p)
if (options.debug_options & DebugTreeOpt)
{
- fprintf (stderr, "Not an arm swap candidate (%s):\n", reason);
+ fprintf (stderr, N_("Not an arm swap candidate (%s):\n"), reason);
print_tree (stderr, p, 0);
}
return false;
@@ -727,7 +728,7 @@ opt_expr (struct predicate **eval_treep)
if (options.debug_options & (DebugExpressionTree|DebugTreeOpt))
{
/* Normalized tree. */
- fprintf (stderr, "Normalized Eval Tree:\n");
+ fprintf (stderr, N_("Normalized Eval Tree:\n"));
print_tree (stderr, *eval_treep, 0);
}
@@ -775,10 +776,10 @@ opt_expr (struct predicate **eval_treep)
{
if (options.debug_options & DebugTreeOpt)
{
- fprintf (stderr, "-O%d: promoting cheap predicate ",
+ fprintf (stderr, N_("-O%d: promoting cheap predicate "),
(int)options.optimisation_level);
print_predicate (stderr, curr->pred_right);
- fprintf (stderr, " into name_list\n");
+ fprintf (stderr, N_(" into name_list\n"));
}
predlist_insert (&name_list, curr, prevp);
continue;
@@ -800,10 +801,10 @@ opt_expr (struct predicate **eval_treep)
{
if (options.debug_options & DebugTreeOpt)
{
- fprintf (stderr, "-O%d: categorising predicate ",
+ fprintf (stderr, N_("-O%d: categorising predicate "),
(int)options.optimisation_level);
print_predicate (stderr, curr->pred_right);
- fprintf (stderr, " by cost (%s)\n",
+ fprintf (stderr, N_(" by cost (%s)\n"),
cost_name(curr->pred_right->p_cost));
}
predlist_insert (&cbo_list[curr->pred_right->p_cost], curr,
prevp);
@@ -884,17 +885,17 @@ set_new_parent (struct predicate *curr, enum
predicate_precedence high_prec, str
{
case COMMA_PREC:
new_parent->pred_func = pred_comma;
- new_parent->p_name = ",";
+ new_parent->p_name = N_(",");
new_parent->est_success_rate = 1.0;
break;
case OR_PREC:
new_parent->pred_func = pred_or;
- new_parent->p_name = "-o";
+ new_parent->p_name = N_("-o");
new_parent->est_success_rate = constrain_rate (curr->est_success_rate);
break;
case AND_PREC:
new_parent->pred_func = pred_and;
- new_parent->p_name = "-a";
+ new_parent->p_name = N_("-a");
new_parent->est_success_rate = constrain_rate (curr->est_success_rate);
break;
default:
@@ -1095,7 +1096,7 @@ get_pred_cost (const struct predicate *p)
cost_table_comparison))
{
error (EXIT_FAILURE, 0,
- "failed to sort the costlookup array");
+ _("failed to sort the costlookup array"));
}
pred_table_sorted = 1;
}
@@ -1272,15 +1273,15 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
/* Enclose the expression in `( ... )' so a default -print will
apply to the whole expression. */
- entry_open = find_parser ("(");
- entry_close = find_parser (")");
- entry_print = find_parser ("print");
+ entry_open = find_parser (N_("("));
+ entry_close = find_parser (N_(")"));
+ entry_print = find_parser (N_("print"));
assert (entry_open != NULL);
assert (entry_close != NULL);
assert (entry_print != NULL);
parse_openparen (entry_open, argv, &argc);
- last_pred->p_name = "(";
+ last_pred->p_name = N_("(");
predicates->artificial = true;
parse_begin_user_args (argv, argc, last_pred, predicates);
pred_sanity_check (last_pred);
@@ -1358,7 +1359,7 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
predicates = last_pred = predicates->pred_next;
free (cur_pred);
parse_print (entry_print, argv, &argc);
- last_pred->p_name = "-print";
+ last_pred->p_name = N_("-print");
pred_sanity_check(last_pred);
pred_sanity_check(predicates); /* XXX: expensive */
}
@@ -1375,11 +1376,11 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
{
/* `( user-supplied-expression ) -print'. */
parse_closeparen (entry_close, argv, &argc);
- last_pred->p_name = ")";
+ last_pred->p_name = N_(")");
last_pred->artificial = true;
pred_sanity_check (last_pred);
parse_print (entry_print, argv, &argc);
- last_pred->p_name = "-print";
+ last_pred->p_name = N_("-print");
last_pred->artificial = true;
pred_sanity_check (last_pred);
pred_sanity_check (predicates); /* XXX: expensive */
@@ -1387,7 +1388,7 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
if (options.debug_options & (DebugExpressionTree|DebugTreeOpt))
{
- fprintf (stderr, "Predicate List:\n");
+ fprintf (stderr, N_("Predicate List:\n"));
print_list (stderr, predicates);
}
@@ -1423,7 +1424,7 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
if (options.debug_options & (DebugExpressionTree|DebugTreeOpt))
{
- fprintf (stderr, "Eval Tree:\n");
+ fprintf (stderr, N_("Eval Tree:\n"));
print_tree (stderr, eval_tree, 0);
}
@@ -1442,11 +1443,11 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
if (options.debug_options & (DebugExpressionTree|DebugTreeOpt))
{
- fprintf (stderr, "Optimized Eval Tree:\n");
+ fprintf (stderr, N_("Optimized Eval Tree:\n"));
print_tree (stderr, eval_tree, 0);
- fprintf (stderr, "Optimized command line:\n");
+ fprintf (stderr, N_("Optimized command line:\n"));
print_optlist (stderr, eval_tree);
- fprintf (stderr, "\n");
+ fprintf (stderr, N_("\n"));
}
return eval_tree;
@@ -1515,7 +1516,7 @@ get_new_pred (const struct parser_table *entry)
last_pred->need_type = true;
last_pred->need_inum = false;
last_pred->p_cost = NeedsUnknown;
- last_pred->arg_text = "ThisShouldBeSetToSomethingElse";
+ last_pred->arg_text = N_("ThisShouldBeSetToSomethingElse");
last_pred->args.str = NULL;
last_pred->args.scontext = NULL;
last_pred->pred_next = NULL;
@@ -1541,7 +1542,7 @@ get_new_pred_chk_op (const struct parser_table *entry,
/* Locate the entry in the parser table for the "and" operator */
if (NULL == entry_and)
- entry_and = find_parser ("and");
+ entry_and = find_parser (N_("and"));
/* Check that it's actually there. If not, that is a bug.*/
assert (entry_and != NULL);
@@ -1558,7 +1559,7 @@ get_new_pred_chk_op (const struct parser_table *entry,
/* We need to interpose the and operator. */
new_pred = get_new_pred_noarg (entry_and);
new_pred->pred_func = pred_and;
- new_pred->p_name = "-a";
+ new_pred->p_name = N_("-a");
new_pred->p_type = BI_OP;
new_pred->p_prec = AND_PREC;
new_pred->need_stat = false;
@@ -1587,17 +1588,17 @@ struct cost_assoc
};
struct cost_assoc cost_table[] =
{
- { NeedsNothing, "Nothing" },
- { NeedsInodeNumber, "InodeNumber" },
- { NeedsType, "Type" },
- { NeedsStatInfo, "StatInfo" },
- { NeedsLinkName, "LinkName" },
- { NeedsAccessInfo, "AccessInfo" },
- { NeedsSyncDiskHit, "SyncDiskHit" },
- { NeedsEventualExec, "EventualExec" },
- { NeedsImmediateExec, "ImmediateExec" },
- { NeedsUserInteraction, "UserInteraction" },
- { NeedsUnknown, "Unknown" }
+ { NeedsNothing, N_("Nothing")},
+ { NeedsInodeNumber, N_("InodeNumber")},
+ { NeedsType, N_("Type")},
+ { NeedsStatInfo, N_("StatInfo")},
+ { NeedsLinkName, N_("LinkName")},
+ { NeedsAccessInfo, N_("AccessInfo")},
+ { NeedsSyncDiskHit, N_("SyncDiskHit")},
+ { NeedsEventualExec, N_("EventualExec")},
+ { NeedsImmediateExec, N_("ImmediateExec")},
+ { NeedsUserInteraction, N_("UserInteraction")},
+ { NeedsUnknown, N_("Unknown")}
};
struct prec_assoc
@@ -1608,13 +1609,13 @@ struct prec_assoc
static struct prec_assoc prec_table[] =
{
- {NO_PREC, "no"},
- {COMMA_PREC, "comma"},
- {OR_PREC, "or"},
- {AND_PREC, "and"},
- {NEGATE_PREC, "negate"},
- {MAX_PREC, "max"},
- {-1, "unknown "}
+ {NO_PREC, N_("no")},
+ {COMMA_PREC, N_("comma")},
+ {OR_PREC, N_("or")},
+ {AND_PREC, N_("and")},
+ {NEGATE_PREC, N_("negate")},
+ {MAX_PREC, N_("max")},
+ {-1, N_("unknown ")}
};
struct op_assoc
@@ -1625,13 +1626,13 @@ struct op_assoc
static struct op_assoc type_table[] =
{
- {NO_TYPE, "no"},
- {PRIMARY_TYPE, "primary"},
- {UNI_OP, "uni_op"},
- {BI_OP, "bi_op"},
- {OPEN_PAREN, "open_paren "},
- {CLOSE_PAREN, "close_paren "},
- {-1, "unknown"}
+ {NO_TYPE, N_("no")},
+ {PRIMARY_TYPE, N_("primary")},
+ {UNI_OP, N_("uni_op")},
+ {BI_OP, N_("bi_op")},
+ {OPEN_PAREN, N_("open_paren ")},
+ {CLOSE_PAREN, N_("close_paren ")},
+ {-1, N_("unknown")}
};
static const char *
@@ -1643,7 +1644,7 @@ cost_name (enum EvaluationCost cost)
for (i = 0; i<n; ++i)
if (cost_table[i].cost == cost)
return cost_table[i].name;
- return "unknown";
+ return N_("unknown");
}
@@ -1681,67 +1682,67 @@ print_tree (FILE *fp, struct predicate *node, int
indent)
if (node == NULL)
return;
for (i = 0; i < indent; i++)
- fprintf (fp, " ");
- fprintf (fp, "pred=[");
+ fprintf (fp, N_(" "));
+ fprintf (fp, N_("pred=["));
print_predicate (fp, node);
- fprintf (fp, "] type=%s prec=%s",
+ fprintf (fp, N_("] type=%s prec=%s"),
type_name (node->p_type), prec_name (node->p_prec));
- fprintf (fp, " cost=%s rate=%#03.2g %sside effects ",
+ fprintf (fp, N_(" cost=%s rate=%#03.2g %sside effects "),
cost_name (node->p_cost),
node->est_success_rate,
- (node->side_effects ? "" : "no "));
+ (node->side_effects ? N_("") : N_("no ")));
if (node->need_stat || node->need_type || node->need_inum)
{
int comma = 0;
- fprintf (fp, "Needs ");
+ fprintf (fp, N_("Needs "));
if (node->need_stat)
{
- fprintf (fp, "stat");
+ fprintf (fp, N_("stat"));
comma = 1;
}
if (node->need_inum)
{
- fprintf (fp, "%sinode", comma ? "," : "");
+ fprintf (fp, N_("%sinode"), comma ? N_(",") : N_(""));
comma = 1;
}
if (node->need_type)
{
- fprintf (fp, "%stype", comma ? "," : "");
+ fprintf (fp, N_("%stype"), comma ? N_(",") : N_(""));
}
}
- fprintf (fp, "\n");
+ fprintf (fp, N_("\n"));
for (i = 0; i < indent; i++)
- fprintf (fp, " ");
+ fprintf (fp, N_(" "));
if (NULL == node->pred_left && NULL == node->pred_right)
{
- fprintf (fp, "no children.\n");
+ fprintf (fp, N_("no children.\n"));
}
else
{
if (node->pred_left)
{
- fprintf (fp, "left:\n");
+ fprintf (fp, N_("left:\n"));
print_tree (fp, node->pred_left, indent + 1);
}
else
{
- fprintf (fp, "no left.\n");
+ fprintf (fp, N_("no left.\n"));
}
for (i = 0; i < indent; i++)
- fprintf (fp, " ");
+ fprintf (fp, N_(" "));
if (node->pred_right)
{
- fprintf (fp, "right:\n");
+ fprintf (fp, N_("right:\n"));
print_tree (fp, node->pred_right, indent + 1);
}
else
{
- fprintf (fp, "no right.\n");
+ fprintf (fp, N_("no right.\n"));
}
}
}
--
1.7.2.5
- [Findutils-patches] [PATCH 1/9] File system type names should be untranslated strings., James Youngman, 2011/07/09
- [Findutils-patches] [PATCH 9/9] Disable the noisy but not useful -Wswitch-default warning., James Youngman, 2011/07/09
- [Findutils-patches] [PATCH 4/9] Annotate strings as needing translation or not as appropriate., James Youngman, 2011/07/09
- [Findutils-patches] [PATCH 3/9] Indicate predicates and debug strings don't need translation.,
James Youngman <=
- [Findutils-patches] [PATCH 5/9] Translate error messages, mark other strings as not needing it., James Youngman, 2011/07/09
- [Findutils-patches] [PATCH 6/9] Mark strings in ftsfind.c as not needing translation., James Youngman, 2011/07/09
- [Findutils-patches] [PATCH 2/9] Predicate names and trivial formats don't need translation., James Youngman, 2011/07/09
- [Findutils-patches] [PATCH 7/9] Mark strings in find.c as not needing translation., James Youngman, 2011/07/09
- [Findutils-patches] [PATCH 8/9] Fix a number of compiler warnings (mostly const-correctness)., James Youngman, 2011/07/09