[PATCH 12/18] globs: Fix WARNING and ERROR macros to use char * instead of int *
Tim Hentenaar <[email protected]> Sat, 4 Jul 2015 13:43:26 +0200
| Newsgroups | gmane.comp.gnu.indent.bugs |
|---|---|
| Message-ID | <[email protected]> |
Signed-off-by: Tim Hentenaar <[email protected]> --- src/args.c | 4 ++-- src/backup.c | 3 ++- src/globs.c | 13 +++++++------ src/globs.h | 10 +++------- src/handletoken.c | 20 +++++++++++--------- src/indent.c | 10 +++++----- src/lexi.c | 15 +++++++-------- src/parse.c | 4 ++-- 8 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/args.c b/src/args.c index aafd703..77e14dd 100644 --- a/src/args.c +++ b/src/args.c @@ -1019,7 +1019,7 @@ static int skip_c_comment( if (i == EOF) { - WARNING (_("Profile contains an unterminated comment"), 0, 0); + WARNING(_("Profile contains an unterminated comment"), NULL, NULL); break; } /* current char is '*' so skip over it. */ @@ -1057,7 +1057,7 @@ static int skip_comment( i = skip_c_comment(f); break; default: - WARNING (_("Profile contains unpalatable characters"), 0, 0); + WARNING (_("Profile contains unpalatable characters"), NULL, NULL); } return i; diff --git a/src/backup.c b/src/backup.c index 5882dca..ba05138 100644 --- a/src/backup.c +++ b/src/backup.c @@ -520,7 +520,8 @@ void make_backup( if (utime (backup_filename, &buf) != 0) { - WARNING (_("Can't preserve modification time on backup file %s"), backup_filename, 0); + WARNING(_("Can't preserve modification time on backup file %s"), + backup_filename, NULL); } } #endif diff --git a/src/globs.c b/src/globs.c index 941abc6..7699ced 100644 --- a/src/globs.c +++ b/src/globs.c @@ -1,4 +1,5 @@ /** \file + * Copyright (C) 2015 Tim Hentenaar. All rights reserved. * Copyright (c) 1993,1994, Joseph Arceneaux. All rights reserved. * * Copyright (C) 1986, 1989, 1992 Free Software Foundation, Inc. All rights @@ -88,14 +89,14 @@ extern void xfree(void *ptr) } /** + * Write a message to stderr. * + * \param[in] kind "Warning" or "Error" + * \param[in] string Format string + * \param[in] a0 First value to format, or NULL. + * \param[in] a1 Second value to format, or NULL. */ - -extern void message( - char * kind, - char * string, - unsigned * a0, - unsigned * a1) +extern void message(char *kind, char *string, char *a0, char *a1) { if (kind) { diff --git a/src/globs.h b/src/globs.h index 5ecb7da..a2ced48 100644 --- a/src/globs.h +++ b/src/globs.h @@ -23,21 +23,17 @@ RCSTAG_H (globs, "$Id$"); /* *Warning messages: indent continues */ #define WARNING(s, a, b) \ - message (_("Warning"), s, (unsigned int *)(a), (unsigned int *)(b)) + message(_("Warning"), s, (char *)(a), (char *)(b)) /** Error messages: indent stops processing the current file. */ #define ERROR(s, a, b) \ - message (_("Error"), s, (unsigned int *)(a), (unsigned int *)(b)) + message(_("Error"), s, (char *)(a), (char *)(b)) extern void *xmalloc(unsigned int size); extern void *xrealloc(void *ptr, unsigned int size); extern void xfree(void *ptr); extern void do_exit(int code); extern void fatal(const char *string, const char *a0); -extern void message( - char *kind, - char *string, - unsigned int *a0, - unsigned int *a1); +extern void message(char *kind, char *string, char *a0, char *a1); #endif /* INDENT_GLOBS_H */ diff --git a/src/handletoken.c b/src/handletoken.c index 3baf97f..f6ca8a8 100644 --- a/src/handletoken.c +++ b/src/handletoken.c @@ -487,10 +487,10 @@ static void handle_token_rparen( exit_values_ty * file_exit_value, BOOLEAN * pbreak_line) { - + char tmpchar[2]; + parser_state_tos->paren_depth--; -#if 1 /* For declarations, if user wants close of fn decls broken, force that * now. */ @@ -510,7 +510,6 @@ static void handle_token_rparen( parser_state_tos->paren_indents[parser_state_tos->p_l_follow - 1] = paren_target; parser_state_tos->ind_stmt = 0; } -#endif if (parser_state_tos-> cast_mask & (1 << parser_state_tos-> @@ -546,8 +545,8 @@ static void handle_token_rparen( if (--parser_state_tos->p_l_follow < 0) { parser_state_tos->p_l_follow = 0; - WARNING (_("Extra %c"), - (unsigned long) *((unsigned char *) token), 0); + tmpchar[0] = *token; tmpchar[1] = '\0'; + WARNING(_("Extra %s"), tmpchar, NULL); } /* if the paren starts the line, then indent it */ @@ -1260,6 +1259,8 @@ static void handle_token_rbrace( exit_values_ty * file_exit_value, BOOLEAN * pbreak_line) { + char tmpchar[2]; + /* semicolons can be omitted in declarations */ if (((parser_state_tos->p_stack[parser_state_tos->tos] == decl) && !parser_state_tos->block_init) || @@ -1318,8 +1319,9 @@ static void handle_token_rbrace( if (--parser_state_tos->p_l_follow < 0) { parser_state_tos->p_l_follow = 0; - WARNING (_("Extra %c"), - (unsigned long) *((unsigned char *) token), 0); + tmpchar[0] = *token; + tmpchar[1] = '\0'; + WARNING(_("Extra %s"), tmpchar, NULL); } } else if (parser_state_tos->dec_nest > 0) @@ -1440,7 +1442,7 @@ static void handle_token_nparen( { if (settings.verbose) { - WARNING (_("Line broken"), 0, 0); + WARNING(_("Line broken"), NULL, NULL); } dump_line (true, &paren_target, pbreak_line); /* make sure this starts a line */ @@ -1466,7 +1468,7 @@ static void handle_token_nparen( if (settings.verbose) { - WARNING (_("Line broken"), 0, 0); + WARNING(_("Line broken"), NULL, NULL); } dump_line (true, &paren_target, pbreak_line); diff --git a/src/indent.c b/src/indent.c index 091a3ed..98b02a2 100644 --- a/src/indent.c +++ b/src/indent.c @@ -288,8 +288,8 @@ static BOOLEAN search_brace( if (had_eof) { - ERROR (_("EOF encountered in comment"), 0, 0); - return indent_punt; /* RETURN */ + ERROR(_("EOF encountered in comment"), NULL, NULL); + return indent_punt; } } @@ -351,7 +351,7 @@ static BOOLEAN search_brace( save_com.len++; if (settings.verbose && !*flushed_nl) { - WARNING (_("Line broken"), 0, 0); + WARNING(_("Line broken"), NULL, NULL); } *flushed_nl = false; @@ -561,7 +561,7 @@ static exit_values_ty indent_main_loop( if (parser_state_tos->tos > 1) /* check for balanced braces */ { - ERROR (_("Unexpected end of file"), 0, 0); + ERROR(_("Unexpected end of file"), NULL, NULL); file_exit_value = indent_error; } @@ -595,7 +595,7 @@ static exit_values_ty indent_main_loop( { if (settings.verbose && !flushed_nl) { - WARNING (_("Line broken 2"), 0, 0); + WARNING(_("Line broken 2"), NULL, NULL); } flushed_nl = false; diff --git a/src/lexi.c b/src/lexi.c index 99cc431..17330e8 100644 --- a/src/lexi.c +++ b/src/lexi.c @@ -234,9 +234,7 @@ extern codes_ty lexi(void) codes_ty code; /* internal code to be returned */ char qchar; /* the delimiter character for a string */ - static int count = 0; /* debugging counter */ - - count++; + char tmpchar[2]; /* tell world that this token started in column 1 iff the last * thing scanned was nl */ @@ -842,7 +840,7 @@ not_proc: if (*buf_ptr == EOL || *buf_ptr == 0) { WARNING ((qchar == '\'' ? _("Unterminated character constant") : - _("Unterminated string constant")), 0, 0); + _("Unterminated string constant")), NULL, NULL); } else { @@ -861,7 +859,7 @@ not_proc: /* In the gettext situation, the string ends with ") */ if (*buf_ptr != ')') { - WARNING (_("Unterminated string constant"), 0, 0); + WARNING (_("Unterminated string constant"), NULL, NULL); } else { @@ -1118,9 +1116,10 @@ not_proc: * people want to detect and eliminate old style assignments but * they don't want indent to silently change the meaning of their * code). */ - - WARNING (_("old style assignment ambiguity in \"=%c\". Assuming \"= %c\"\n"), - (unsigned long) *((unsigned char *) buf_ptr), (unsigned long) *((unsigned char *) buf_ptr)); + tmpchar[0] = *buf_ptr; + tmpchar[1] = '\0'; + WARNING (_("old style assignment ambiguity in \"=%s\". " + "Assuming \"= %s\"\n"), tmpchar, tmpchar); } else { diff --git a/src/parse.c b/src/parse.c index 143d804..6e41bb5 100644 --- a/src/parse.c +++ b/src/parse.c @@ -470,7 +470,7 @@ extern exit_values_ty parse ( if (parser_state_tos->p_stack[parser_state_tos->tos] != ifhead) { - ERROR (_("Unmatched 'else'"), 0, 0); + ERROR(_("Unmatched 'else'"), NULL, NULL); } else { @@ -496,7 +496,7 @@ extern exit_values_ty parse ( } else { - ERROR (_("Stmt nesting error."), 0, 0); + ERROR(_("Stmt nesting error."), NULL, NULL); } break; -- 2.3.6