aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/c.l10
-rw-r--r--src/cflow.h11
-rw-r--r--src/main.c100
-rw-r--r--src/output.c2
-rw-r--r--src/parser.c36
-rw-r--r--src/rc.c4
-rw-r--r--src/symbol.c2
7 files changed, 90 insertions, 75 deletions
diff --git a/src/c.l b/src/c.l
index 5c4de7c..b897c1c 100644
--- a/src/c.l
+++ b/src/c.l
@@ -131,7 +131,7 @@ enum {yylval.str = "enum"; return STRUCT;}
*/
\" BEGIN(string);
<string>[^\\"\n]* ;
-<string>\n { ++line_num; lex_error("unterminated string?"); }
+<string>\n { ++line_num; lex_error(_("unterminated string?")); }
<string>\\. ;
<string>\\\n ++line_num;
<string>\" BEGIN(stringwait);
@@ -289,10 +289,10 @@ pp_open(const char *name)
strcat(s, " ");
strcat(s, name);
if (debug)
- printf("Command line: %s\n", s);
+ printf(_("Command line: %s\n"), s);
fp = popen(s, "r");
if (!fp)
- error(0, errno, "cannot execute `%s'", s);
+ error(0, errno, _("cannot execute `%s'"), s);
free(s);
return fp;
}
@@ -321,7 +321,7 @@ source(char *name)
fp = fopen(name, "r");
if (!fp) {
- error(0, errno, "cannot open `%s'", name);
+ error(0, errno, _("cannot open `%s'"), name);
return 1;
}
if (pp_bin) {
@@ -400,6 +400,6 @@ update_loc()
filename = obstack_finish(&string_stk);
}
if (debug > 1)
- printf("New location: %s:%d\n", filename, line_num);
+ printf(_("New location: %s:%d\n"), filename, line_num);
}
diff --git a/src/cflow.h b/src/cflow.h
index 2752dc0..1e05849 100644
--- a/src/cflow.h
+++ b/src/cflow.h
@@ -30,6 +30,17 @@
#include <obstack.h>
#include <error.h>
#include <xalloc.h>
+#include <gettext.h>
+
+#define _(c) gettext(c)
+#define N_(c) c
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif
+#if !HAVE_SETLOCALE
+# define setlocale(category, locale) /* empty */
+#endif
#define NUMITEMS(a) sizeof(a)/sizeof((a)[0])
diff --git a/src/main.c b/src/main.c
index f6a9d8d..be34831 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,79 +33,79 @@ static char doc[] = "";
static struct argp_option options[] = {
#define GROUP_ID 0
{ NULL, 0, NULL, 0,
- "General options:", GROUP_ID },
- { "depth", 'd', "NUMBER", 0,
- "set the depth at which the flowgraph is cut off.", GROUP_ID+1 },
- { "include", 'i', "SPEC", 0,
- "Increase the number of included symbols. SPEC is a string consisting of the following characters: x (include external and static data symbols), and _ (include names that begin with an underscore). If SPEC starts with ^, its meaning is reversed", GROUP_ID+1 },
- { "format", 'f', "NAME", 0,
- "use given output format NAME. Valid names are gnu (default) and posix",
+ N_("General options:"), GROUP_ID },
+ { "depth", 'd', N_("NUMBER"), 0,
+ N_("Set the depth at which the flowgraph is cut off."), GROUP_ID+1 },
+ { "include", 'i', N_("SPEC"), 0,
+ N_("Increase the number of included symbols. SPEC is a string consisting of the following characters: x (include external and static data symbols), and _ (include names that begin with an underscore). If SPEC starts with ^, its meaning is reversed"), GROUP_ID+1 },
+ { "format", 'f', N_("NAME"), 0,
+ N_("Use given output format NAME. Valid names are gnu (default) and posix"),
GROUP_ID+1 },
{ "reverse", 'r', NULL, 0,
- "Print reverse call tree", GROUP_ID+1 },
+ N_("Print reverse call tree"), GROUP_ID+1 },
{ "xref", 'x', NULL, 0,
- "produce cross-reference listing only", GROUP_ID+1 },
+ N_("Produce cross-reference listing only"), GROUP_ID+1 },
{ "print", 'P', "OPT", 0,
- "Set printing option to OPT. Valid OPT values are: xref (or cross-ref), tree. Any unambiguous abbreviation of the above is also accepted",
+ N_("Set printing option to OPT. Valid OPT values are: xref (or cross-ref), tree. Any unambiguous abbreviation of the above is also accepted"),
GROUP_ID+1 },
{ "output", 'o', "FILE", 0,
- "set output file name (default -, meaning stdout)",
+ N_("Set output file name (default -, meaning stdout)"),
GROUP_ID+1 },
#undef GROUP_ID
#define GROUP_ID 10
{ NULL, 0, NULL, 0,
- "Parser control:", GROUP_ID },
- { "use-indentation", 'S', "BOOL", OPTION_ARG_OPTIONAL,
- "rely on indentation", GROUP_ID+1 },
+ N_("Parser control:"), GROUP_ID },
+ { "use-indentation", 'S', N_("BOOL"), OPTION_ARG_OPTIONAL,
+ N_("Rely on indentation"), GROUP_ID+1 },
{ "ansi", 'a', NULL, 0,
- "Assume input to be written in ANSI C", GROUP_ID+1 },
+ N_("Assume input to be written in ANSI C"), GROUP_ID+1 },
{ "pushdown", 'p', "NUMBER", 0,
- "set initial token stack size to NUMBER", GROUP_ID+1 },
+ N_("Set initial token stack size to NUMBER"), GROUP_ID+1 },
{ "symbol", 's', "SYM:TYPE", 0,
- "make cflow believe the symbol SYM is of type TYPE. Valid types are: keyword (or kw), modifier, identifier, type, wrapper. Any unambiguous abbreviation of the above is also accepted", GROUP_ID+1 },
- { "main", 'm', "NAME", 0,
- "Assume main function to be called NAME", GROUP_ID+1 },
+ N_("Make cflow believe the symbol SYM is of type TYPE. Valid types are: keyword (or kw), modifier, identifier, type, wrapper. Any unambiguous abbreviation of the above is also accepted"), GROUP_ID+1 },
+ { "main", 'm', N_("NAME"), 0,
+ N_("Assume main function to be called NAME"), GROUP_ID+1 },
{ "define", 'D', "NAME[=DEFN]", 0,
- "Predefine NAME as a macro.", GROUP_ID+1 },
+ N_("Predefine NAME as a macro"), GROUP_ID+1 },
{ "undefine", 'U', "NAME", 0,
- "Cancel any previous definition of NAME", GROUP_ID+1 },
+ N_("Cancel any previous definition of NAME"), GROUP_ID+1 },
{ "include-dir", 'I', "DIR", 0,
- "Add the directory dir to the list of directories to be searched for header files.", GROUP_ID+1 },
+ N_("Add the directory dir to the list of directories to be searched for header files."), GROUP_ID+1 },
{ "preprocess", OPT_PREPROCESS, "COMMAND", OPTION_ARG_OPTIONAL,
- "Run the specified preprocessor command", GROUP_ID+1 },
+ N_("Run the specified preprocessor command"), GROUP_ID+1 },
{ "cpp", 0, NULL, OPTION_ALIAS, NULL, GROUP_ID+1 },
{ "no-preprocess", OPT_NO_PREPROCESS, NULL, 0,
- "Do not preprocess the sources", GROUP_ID+1 },
+ N_("Do not preprocess the sources"), GROUP_ID+1 },
{ "no-cpp", 0, NULL, OPTION_ALIAS, NULL, GROUP_ID+1 },
#undef GROUP_ID
#define GROUP_ID 20
{ NULL, 0, NULL, 0,
- "Output control:", GROUP_ID },
- { "number", 'n', "BOOL", OPTION_ARG_OPTIONAL,
- "Print line numbers", GROUP_ID+1 },
+ N_("Output control:"), GROUP_ID },
+ { "number", 'n', N_("BOOL"), OPTION_ARG_OPTIONAL,
+ N_("Print line numbers"), GROUP_ID+1 },
{ "print-level", 'l', NULL, 0,
- "Print nesting level along with the call tree", GROUP_ID+1 },
+ N_("Print nesting level along with the call tree"), GROUP_ID+1 },
{ "level-indent", OPT_LEVEL_INDENT, "STRING", 0,
- "Use STRING when indenting to each new level", GROUP_ID+1 },
+ N_("Use STRING when indenting to each new level"), GROUP_ID+1 },
{ "tree", 'T', NULL, 0,
- "Draw tree", GROUP_ID+1 },
+ N_("Draw tree"), GROUP_ID+1 },
{ "brief", 'b', "BOOL", OPTION_ARG_OPTIONAL,
- "brief output", GROUP_ID+1 },
+ N_("Brief output"), GROUP_ID+1 },
#undef GROUP_ID
#define GROUP_ID 30
{ NULL, 0, NULL, 0,
- "Informational options:", GROUP_ID },
+ N_("Informational options:"), GROUP_ID },
{ "verbose", 'v', NULL, 0,
- "be verbose on output", GROUP_ID+1 },
+ N_("Be verbose on output"), GROUP_ID+1 },
{ "license", 'L', 0, 0,
- "Print license and exit", GROUP_ID+1 },
+ N_("Print license and exit"), GROUP_ID+1 },
{ "debug", OPT_DEBUG, "NUMBER", OPTION_ARG_OPTIONAL,
- "set debugging level", GROUP_ID+1 },
+ N_("Set debugging level"), GROUP_ID+1 },
#undef GROUP_ID
{ 0, }
};
-char *cflow_license_text =
+char *cflow_license_text = N_(
" GNU cflow is free software; you can redistribute it and/or modify\n"
" it under the terms of the GNU General Public License as published by\n"
" the Free Software Foundation; either version 2 of the License, or\n"
@@ -118,7 +118,7 @@ char *cflow_license_text =
"\n"
" You should have received a copy of the GNU General Public License\n"
" along with GNU cflow; if not, write to the Free Software\n"
-" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n";
+" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n\n");
/* Structure representing various arguments of command line options */
struct option_type {
@@ -211,7 +211,7 @@ symbol_override(const char *str)
if (*ptr == ':') {
type = find_option_type(symbol_optype, ptr+1, 0);
if (type == 0) {
- error(0, 0, "unknown symbol type: %s", ptr+1);
+ error(0, 0, _("unknown symbol type: %s"), ptr+1);
return;
}
} else
@@ -240,7 +240,7 @@ set_print_option(char *str)
opt = find_option_type(print_optype, str, 0);
if (opt == 0) {
- error(0, 0, "unknown print option: %s", str);
+ error(0, 0, _("unknown print option: %s"), str);
return;
}
print_option |= opt;
@@ -362,7 +362,7 @@ parse_level_string(const char *str, char **return_ptr)
for (i = 1; i < num; i++) {
*p++ = c;
if (*p == 0) {
- error(1, 0, "level indent string too long");
+ error(1, 0, _("level indent string too long"));
return;
}
}
@@ -371,7 +371,7 @@ parse_level_string(const char *str, char **return_ptr)
copy:
*p++ = *str++;
if (*p == 0) {
- error(1, 0, "level indent string is too long");
+ error(1, 0, _("level indent string is too long"));
return;
}
}
@@ -399,7 +399,7 @@ set_level_indent(const char *str)
p = str;
while (*p != '=') {
if (*p == 0) {
- error(1, 0, "level-indent syntax");
+ error(1, 0, _("level-indent syntax"));
return;
}
p++;
@@ -423,7 +423,7 @@ set_level_indent(const char *str)
parse_level_string(p, &level_end[1]);
break;
default:
- error(1, 0, "unknown level indent option: %s", str);
+ error(1, 0, _("unknown level indent option: %s"), str);
}
}
@@ -454,7 +454,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
debug = arg ? atoi(arg) : 1;
break;
case 'L':
- printf("License for %s:\n\n", argp_program_version);
+ printf(_("License for %s:\n\n"), argp_program_version);
printf("%s", cflow_license_text);
exit(0);
case 'P':
@@ -483,7 +483,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
break;
case 'f':
if (select_output_driver(arg))
- argp_error(state, "%s: No such output driver", optarg);
+ argp_error(state, _("%s: No such output driver"), optarg);
else if (strcmp(arg, "posix") == 0)
brief_listing = print_line_numbers = 1;
break;
@@ -555,7 +555,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
static struct argp argp = {
options,
parse_opt,
- "[FILE]...",
+ N_("[FILE]..."),
doc,
NULL,
NULL,
@@ -604,7 +604,7 @@ include_symbol(Symbol *sym)
void
xalloc_die(void)
{
- error(1, ENOMEM, "Exiting");
+ error(1, ENOMEM, _("Exiting"));
}
void
@@ -628,6 +628,10 @@ main(int argc, char **argv)
{
int index;
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
register_output("gnu", gnu_output_handler, NULL);
register_output("posix", posix_output_handler, NULL);
@@ -639,7 +643,7 @@ main(int argc, char **argv)
exit (1);
if (!arglist)
- error(1, 0, "no input files");
+ error(1, 0, _("no input files"));
if (print_option == 0)
print_option = PRINT_TREE;
diff --git a/src/output.c b/src/output.c
index 2253ed5..d7dea98 100644
--- a/src/output.c
+++ b/src/output.c
@@ -397,7 +397,7 @@ output()
} else {
outfile = fopen(outname, "w");
if (!outfile)
- error(2, errno, "cannot open file `%s'", outname);
+ error(2, errno, _("cannot open file `%s'"), outname);
}
level_mark = xmalloc(level_mark_size);
diff --git a/src/parser.c b/src/parser.c
index 6df2d22..168d7ba 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -118,7 +118,7 @@ file_error(char *msg, int near)
{
fprintf(stderr, "%s:%d: %s", filename, tok.line, msg);
if (near) {
- fprintf(stderr, " near ");
+ fprintf(stderr, _(" near "));
print_token(&tok);
}
fprintf(stderr, "\n");
@@ -198,7 +198,7 @@ int
putback()
{
if (curs == 0)
- error(10, 0, "can't putback");
+ error(10, 0, _("INTERNAL ERROR: cannot return token to stream"));
curs--;
if (curs > 0) {
tok.type = token_stack[curs-1].type;
@@ -371,7 +371,7 @@ expression()
break;
case 0:
if (verbose)
- file_error("unexpected eof in expression", 0);
+ file_error(_("unexpected eof in expression"), 0);
return;
case IDENTIFIER:
@@ -417,7 +417,7 @@ parse_function_declaration(Ident *ident)
switch (tok.type) {
default:
if (verbose)
- file_error("expected ';'", 1);
+ file_error(_("expected `;'"), 1);
/* should putback() here */
/* FALLTHRU */
case ';':
@@ -429,7 +429,7 @@ parse_function_declaration(Ident *ident)
break;
case 0:
if (verbose)
- file_error("unexpected eof in declaration", 0);
+ file_error(_("unexpected eof in declaration"), 0);
}
}
@@ -461,7 +461,7 @@ fake_struct(Ident *ident)
tokpush(hold.type, hold.line, hold.token);
} else {
if (tok.type != ';')
- file_error("missing ; after struct declaration", 0);
+ file_error(_("missing `;' after struct declaration"), 0);
}
return 1;
}
@@ -507,7 +507,7 @@ parse_variable_declaration(Ident *ident)
switch (tok.type) {
default:
if (verbose)
- file_error("expected ';'", 1);
+ file_error(_("expected ';'"), 1);
/* should putback() here */
/* FALLTHRU */
case ';':
@@ -530,7 +530,7 @@ parse_variable_declaration(Ident *ident)
break;
case 0:
if (verbose)
- file_error("unexpected eof in declaration", 0);
+ file_error(_("unexpected eof in declaration"), 0);
}
}
@@ -552,7 +552,7 @@ initializer_list()
}
break;
case 0:
- file_error("unexpected eof in initializer list", 0);
+ file_error(_("unexpected eof in initializer list"), 0);
return;
case ',':
break;
@@ -635,7 +635,7 @@ skip_struct()
do {
switch (tok.type) {
case 0:
- file_error("unexpected eof in struct", 0);
+ file_error(_("unexpected eof in struct"), 0);
return;
case LBRACE:
case LBRACE0:
@@ -725,7 +725,7 @@ dirdcl(Ident *idptr)
if (tok.type == '(') {
dcl(idptr);
if (tok.type != ')' && verbose) {
- file_error("expected ')'", 1);
+ file_error(_("expected `)'"), 1);
return 1;
}
} else if (tok.type == IDENTIFIER) {
@@ -747,7 +747,7 @@ dirdcl(Ident *idptr)
else {
maybe_parm_list(parm_ptr);
if (tok.type != ')' && verbose) {
- file_error("expected ')'", 1);
+ file_error(_("expected ')'"), 1);
return 1;
}
}
@@ -833,7 +833,7 @@ func_body()
case RBRACE0:
if (use_indentation) {
if (verbose && level != 1)
- file_error("forced function body close", 0);
+ file_error(_("forced function body close"), 0);
for ( ; level; level--) {
delete_autos(level);
}
@@ -847,7 +847,7 @@ func_body()
break;
case 0:
if (verbose)
- file_error("unexpected eof in function body", 0);
+ file_error(_("unexpected eof in function body"), 0);
return;
}
}
@@ -879,10 +879,10 @@ declare(Ident *ident)
sp = get_symbol(ident->name);
if (sp->source) {
error_at_line(0, 0, filename, ident->line,
- "%s/%d redefined",
+ _("%s/%d redefined"),
ident->name, sp->arity);
error_at_line(0, 0, sp->source, sp->def_line,
- "this is the place of previous definition");
+ _("this is the place of previous definition"));
}
sp->type = SymIdentifier;
@@ -894,7 +894,7 @@ declare(Ident *ident)
sp->def_line = ident->line;
sp->level = level;
if (debug)
- printf("%s:%d: %s/%d defined to %s\n",
+ printf(_("%s:%d: %s/%d defined to %s\n"),
filename,
line_num,
ident->name, ident->parmcnt,
@@ -919,7 +919,7 @@ declare_type(Ident *ident)
sp->def_line = ident->line;
sp->ref_line = NULL;
if (debug)
- printf("%s:%d: type %s\n",
+ printf(_("%s:%d: type %s\n"),
filename,
line_num,
ident->name);
diff --git a/src/rc.c b/src/rc.c
index b5ebd2d..8241920 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -51,12 +51,12 @@ parse_rc(int *argc_ptr, char ***argv_ptr, char *name)
return;
buf = malloc(st.st_size+1);
if (!buf) {
- error(0, 0, "not enough memory to process rc file");
+ error(0, 0, _("not enough memory to process rc file"));
return;
}
rcfile = fopen(name, "r");
if (!rcfile) {
- error(0, errno, "cannot open %s", name);
+ error(0, errno, _("cannot open `%s'"), name);
return;
}
size = fread(buf, 1, st.st_size, rcfile);
diff --git a/src/symbol.c b/src/symbol.c
index ddc5817..dd46477 100644
--- a/src/symbol.c
+++ b/src/symbol.c
@@ -265,7 +265,7 @@ alloc_cons()
if (!cp) {
alloc_new_bucket();
if ((cp = alloc_cons_from_bucket()) == NULL) {
- error(2, 0, "not enough core");
+ error(2, 0, _("not enough core"));
}
}
CAR(cp) = CDR(cp) = NULL;

Return to:

Send suggestions and report system problems to the System administrator.