2009-11-29 Chris Allegretta <chrisa@asty.org>

* prompt.c (get_prompt_string) - Universally handle help key when is disabled.  Fixes Savannah
          bug 28117 by David Lawrence Ramsey <pooka109@gmail.com>.
        * chars.c, files.c: Add junk vars to silence the compiler.  Sigh.

2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
        * Change several *chars to const char, additional cleanups and casts to make compilers happier.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4448 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2009-11-29 06:13:22 +00:00
parent 752830573a
commit 5a018f0d3a
9 changed files with 62 additions and 54 deletions

View File

@ -1,3 +1,11 @@
2009-11-29 Chris Allegretta <chrisa@asty.org>
* prompt.c (get_prompt_string) - Universally handle help key when is disabled. Fixes Savannah
bug 28117 by David Lawrence Ramsey <pooka109@gmail.com>.
* chars.c, files.c: Add junk vars to silence the compiler. Sigh.
2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
* Change several *chars to const char, additional cleanups and casts to make compilers happier.
2009-11-27 Chris Allegretta <chrisa@asty.org> 2009-11-27 Chris Allegretta <chrisa@asty.org>
* nano.c (do_suspend): Don't clear the screen but do move the cursor down to the last line * nano.c (do_suspend): Don't clear the screen but do move the cursor down to the last line
first in an effort to not corrupt the screen, which contradicts Pico but is consistent first in an effort to not corrupt the screen, which contradicts Pico but is consistent

View File

@ -89,7 +89,7 @@ bool is_alnum_mbchar(const char *c)
wchar_t wc; wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) { if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar; wc = bad_wchar;
} }
@ -109,7 +109,7 @@ bool is_blank_mbchar(const char *c)
wchar_t wc; wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) { if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar; wc = bad_wchar;
} }
@ -156,7 +156,7 @@ bool is_cntrl_mbchar(const char *c)
wchar_t wc; wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) { if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar; wc = bad_wchar;
} }
@ -177,7 +177,7 @@ bool is_punct_mbchar(const char *c)
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
if (c_mb_len < 0) { if (c_mb_len < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar; wc = bad_wchar;
} }
@ -243,14 +243,14 @@ char *control_mbrep(const char *c, char *crep, int *crep_len)
wchar_t wc; wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) { if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
*crep_len = bad_mbchar_len; *crep_len = bad_mbchar_len;
strncpy(crep, bad_mbchar, *crep_len); strncpy(crep, bad_mbchar, *crep_len);
} else { } else {
*crep_len = wctomb(crep, control_wrep(wc)); *crep_len = wctomb(crep, control_wrep(wc));
if (*crep_len < 0) { if (*crep_len < 0) {
wctomb(NULL, 0); int shutup = wctomb(NULL, 0);
*crep_len = 0; *crep_len = 0;
} }
} }
@ -278,14 +278,14 @@ char *mbrep(const char *c, char *crep, int *crep_len)
/* Reject invalid Unicode characters. */ /* Reject invalid Unicode characters. */
if (mbtowc(&wc, c, MB_CUR_MAX) < 0 || !is_valid_unicode(wc)) { if (mbtowc(&wc, c, MB_CUR_MAX) < 0 || !is_valid_unicode(wc)) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
*crep_len = bad_mbchar_len; *crep_len = bad_mbchar_len;
strncpy(crep, bad_mbchar, *crep_len); strncpy(crep, bad_mbchar, *crep_len);
} else { } else {
*crep_len = wctomb(crep, wc); *crep_len = wctomb(crep, wc);
if (*crep_len < 0) { if (*crep_len < 0) {
wctomb(NULL, 0); int shutup = wctomb(NULL, 0);
*crep_len = 0; *crep_len = 0;
} }
} }
@ -311,7 +311,7 @@ int mbwidth(const char *c)
int width; int width;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) { if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar; wc = bad_wchar;
} }
@ -356,7 +356,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
/* Reject invalid Unicode characters. */ /* Reject invalid Unicode characters. */
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) { if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
wctomb(NULL, 0); int shutup = wctomb(NULL, 0);
*chr_mb_len = 0; *chr_mb_len = 0;
} }
} else { } else {
@ -388,7 +388,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
/* If buf contains an invalid multibyte character, only /* If buf contains an invalid multibyte character, only
* interpret buf's first byte. */ * interpret buf's first byte. */
if (buf_mb_len < 0) { if (buf_mb_len < 0) {
mblen(NULL, 0); int shutup = mblen(NULL, 0);
buf_mb_len = 1; buf_mb_len = 1;
} else if (buf_mb_len == 0) } else if (buf_mb_len == 0)
buf_mb_len++; buf_mb_len++;
@ -545,7 +545,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
s1_mb_len = parse_mbchar(s1, s1_mb, NULL); s1_mb_len = parse_mbchar(s1, s1_mb, NULL);
if (mbtowc(&ws1, s1_mb, s1_mb_len) < 0) { if (mbtowc(&ws1, s1_mb, s1_mb_len) < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
ws1 = (unsigned char)*s1_mb; ws1 = (unsigned char)*s1_mb;
bad_s1_mb = TRUE; bad_s1_mb = TRUE;
} }
@ -553,7 +553,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
s2_mb_len = parse_mbchar(s2, s2_mb, NULL); s2_mb_len = parse_mbchar(s2, s2_mb, NULL);
if (mbtowc(&ws2, s2_mb, s2_mb_len) < 0) { if (mbtowc(&ws2, s2_mb, s2_mb_len) < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
ws2 = (unsigned char)*s2_mb; ws2 = (unsigned char)*s2_mb;
bad_s2_mb = TRUE; bad_s2_mb = TRUE;
} }
@ -781,7 +781,7 @@ char *mbstrchr(const char *s, const char *c)
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX); int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
if (c_mb_len < 0) { if (c_mb_len < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
wc = (unsigned char)*c; wc = (unsigned char)*c;
bad_c_mb = TRUE; bad_c_mb = TRUE;
} }
@ -790,7 +790,7 @@ char *mbstrchr(const char *s, const char *c)
int s_mb_len = parse_mbchar(s, s_mb, NULL); int s_mb_len = parse_mbchar(s, s_mb, NULL);
if (mbtowc(&ws, s_mb, s_mb_len) < 0) { if (mbtowc(&ws, s_mb, s_mb_len) < 0) {
mbtowc(NULL, NULL, 0); int shutup = mbtowc(NULL, NULL, 0);
ws = (unsigned char)*s; ws = (unsigned char)*s;
bad_s_mb = TRUE; bad_s_mb = TRUE;
} }

View File

@ -1092,6 +1092,7 @@ char *get_full_path(const char *origpath)
char *d_here, *d_there, *d_there_file = NULL; char *d_here, *d_there, *d_there_file = NULL;
const char *last_slash; const char *last_slash;
bool path_only; bool path_only;
int shutup;
if (origpath == NULL) if (origpath == NULL)
return NULL; return NULL;
@ -1190,7 +1191,7 @@ char *get_full_path(const char *origpath)
/* Finally, go back to the path specified in d_here, /* Finally, go back to the path specified in d_here,
* where we were before. We don't check for a chdir() * where we were before. We don't check for a chdir()
* error, since we can do nothing if we get one. */ * error, since we can do nothing if we get one. */
chdir(d_here); shutup = chdir(d_here);
/* Free d_here, since we're done using it. */ /* Free d_here, since we're done using it. */
free(d_here); free(d_here);

View File

@ -214,7 +214,7 @@ size_t length_of_list(int menu)
} }
/* Set type of function based on the string */ /* Set type of function based on the string */
function_type strtokeytype(char *str) function_type strtokeytype(const char *str)
{ {
if (str[0] == 'M' || str[0] == 'm') if (str[0] == 'M' || str[0] == 'm')
return META; return META;
@ -289,7 +289,7 @@ const sc *first_sc_for(int menu, short func) {
/* Add a string to the new shortcut list implementation /* Add a string to the new shortcut list implementation
Allows updates to existing entries in the list */ Allows updates to existing entries in the list */
void add_to_sclist(int menu, char *scstring, short func, int toggle, int execute) void add_to_sclist(int menu, const char *scstring, short func, int toggle, int execute)
{ {
sc *s; sc *s;
@ -315,7 +315,7 @@ void add_to_sclist(int menu, char *scstring, short func, int toggle, int execute
s->type = strtokeytype(scstring); s->type = strtokeytype(scstring);
s->menu = menu; s->menu = menu;
s->toggle = toggle; s->toggle = toggle;
s->keystr = scstring; s->keystr = (char *) scstring;
s->scfunc = func; s->scfunc = func;
s->execute = execute; s->execute = execute;
assign_keyinfo(s); assign_keyinfo(s);
@ -1344,7 +1344,7 @@ const subnfunc *sctofunc(sc *s)
#ifndef NANO_TINY #ifndef NANO_TINY
/* Now lets come up with a single (hopefully) /* Now lets come up with a single (hopefully)
function to get a string for each flag */ function to get a string for each flag */
char *flagtostr(int flag) const char *flagtostr(int flag)
{ {
switch (flag) { switch (flag) {
case NO_HELP: case NO_HELP:

View File

@ -1752,7 +1752,7 @@ int do_mouse(void)
void alloc_multidata_if_needed(filestruct *fileptr) void alloc_multidata_if_needed(filestruct *fileptr)
{ {
if (!fileptr->multidata) if (!fileptr->multidata)
fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short)); fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
} }
/* Precalculate the multi-line start and end regex info so we can speed up /* Precalculate the multi-line start and end regex info so we can speed up

View File

@ -1070,7 +1070,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
} }
} else } else
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
#ifndef DISABLE_HELP
if (s && s->scfunc == DO_HELP_VOID) { if (s && s->scfunc == DO_HELP_VOID) {
update_statusbar_line(answer, statusbar_x); update_statusbar_line(answer, statusbar_x);
@ -1082,7 +1081,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
* prompt. */ * prompt. */
finished = FALSE; finished = FALSE;
} }
#endif
/* If we have a shortcut with an associated function, break out /* If we have a shortcut with an associated function, break out
* if we're finished after running or trying to run the * if we're finished after running or trying to run the

View File

@ -783,12 +783,12 @@ void display_main_list(void);
void do_cursorpos(bool constant); void do_cursorpos(bool constant);
void do_cursorpos_void(void); void do_cursorpos_void(void);
void do_replace_highlight(bool highlight, const char *word); void do_replace_highlight(bool highlight, const char *word);
char *flagtostr(int flag); const char *flagtostr(int flag);
const subnfunc *sctofunc(sc *s); const subnfunc *sctofunc(sc *s);
const subnfunc *getfuncfromkey(WINDOW *win); const subnfunc *getfuncfromkey(WINDOW *win);
void print_sclist(void); void print_sclist(void);
sc *strtosc(int menu, char *input); sc *strtosc(int menu, char *input);
function_type strtokeytype(char *str); function_type strtokeytype(const char *str);
int strtomenu(char *input); int strtomenu(char *input);
void assign_keyinfo(sc *s); void assign_keyinfo(sc *s);
void xon_complaint(void); void xon_complaint(void);
@ -796,35 +796,36 @@ void xoff_complaint(void);
int sc_seq_or (short func, int defaultval); int sc_seq_or (short func, int defaultval);
void do_suspend_void(void); void do_suspend_void(void);
const char *cancel_msg; extern const char *cancel_msg;
#ifndef NANO_TINY #ifndef NANO_TINY
const char *case_sens_msg; extern const char *case_sens_msg;
const char *backwards_msg; extern const char *backwards_msg;
const char *prev_history_msg; extern const char *prev_history_msg;
const char *next_history_msg; extern const char *next_history_msg;
#endif #endif
const char *replace_msg; extern const char *replace_msg;
const char *no_replace_msg; extern const char *no_replace_msg;
const char *go_to_line_msg; extern const char *go_to_line_msg;
const char *whereis_next_msg; extern const char *whereis_next_msg;
const char *first_file_msg; extern const char *first_file_msg;
const char *last_file_msg; extern const char *last_file_msg;
const char *goto_dir_msg; extern const char *goto_dir_msg;
const char *ext_cmd_msg; extern const char *ext_cmd_msg;
const char *to_files_msg; extern const char *to_files_msg;
const char *dos_format_msg; extern const char *dos_format_msg;
const char *mac_format_msg; extern const char *mac_format_msg;
const char *append_msg; extern const char *append_msg;
const char *prepend_msg; extern const char *prepend_msg;
const char *backup_file_msg; extern const char *backup_file_msg;
const char *gototext_msg; extern const char *gototext_msg;
const char *new_buffer_msg; extern const char *new_buffer_msg;
void iso_me_harder_funcmap(short func); void iso_me_harder_funcmap(short func);
void enable_nodelay(void); void enable_nodelay(void);
void disable_nodelay(void); void disable_nodelay(void);
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
const char *regexp_msg; extern const char *regexp_msg;
#endif #endif
#ifdef NANO_EXTRA #ifdef NANO_EXTRA

View File

@ -181,7 +181,7 @@ void do_tab(void)
free(output); free(output);
} else { } else {
#endif #endif
do_output("\t", 1, TRUE); do_output((char *) "\t", 1, TRUE);
#ifndef NANO_TINY #ifndef NANO_TINY
} }
#endif #endif
@ -483,7 +483,7 @@ void do_undo(void)
break; break;
case SPLIT: case SPLIT:
undidmsg = _("line wrap"); undidmsg = _("line wrap");
f->data = nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1); f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
strcpy(&f->data[strlen(f->data) - 1], u->strdata); strcpy(&f->data[strlen(f->data) - 1], u->strdata);
if (u->strdata2 != NULL) if (u->strdata2 != NULL)
f->next->data = mallocstrcpy(f->next->data, u->strdata2); f->next->data = mallocstrcpy(f->next->data, u->strdata2);
@ -517,7 +517,7 @@ void do_undo(void)
undidmsg = _("line break"); undidmsg = _("line break");
if (f->next) { if (f->next) {
filestruct *foo = f->next; filestruct *foo = f->next;
f->data = nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1); f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1);
strcat(f->data, f->next->data); strcat(f->data, f->next->data);
unlink_node(foo); unlink_node(foo);
delete_node(foo); delete_node(foo);
@ -765,7 +765,7 @@ bool execute_command(const char *command)
* arguments. */ * arguments. */
shellenv = getenv("SHELL"); shellenv = getenv("SHELL");
if (shellenv == NULL) if (shellenv == NULL)
shellenv = "/bin/sh"; shellenv = (char *) "/bin/sh";
/* Fork a child. */ /* Fork a child. */
if ((pid = fork()) == 0) { if ((pid = fork()) == 0) {
@ -859,7 +859,7 @@ void add_undo(undo_type current_action)
} }
/* Allocate and initialize a new undo type */ /* Allocate and initialize a new undo type */
u = nmalloc(sizeof(undo)); u = (undo *) nmalloc(sizeof(undo));
u->type = current_action; u->type = current_action;
u->lineno = fs->current->lineno; u->lineno = fs->current->lineno;
u->begin = fs->current_x; u->begin = fs->current_x;
@ -993,7 +993,7 @@ void update_undo(undo_type action)
fs->current->data, (unsigned long) fs->current_x, u->begin); fs->current->data, (unsigned long) fs->current_x, u->begin);
#endif #endif
len = strlen(u->strdata) + 2; len = strlen(u->strdata) + 2;
data = nrealloc((void *) u->strdata, len * sizeof(char *)); data = (char *) nrealloc((void *) u->strdata, len * sizeof(char *));
data[len-2] = fs->current->data[fs->current_x]; data[len-2] = fs->current->data[fs->current_x];
data[len-1] = '\0'; data[len-1] = '\0';
u->strdata = (char *) data; u->strdata = (char *) data;

View File

@ -2495,7 +2495,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if (fileptr->multidata == NULL && openfile->syntax if (fileptr->multidata == NULL && openfile->syntax
&& openfile->syntax->nmultis > 0) { && openfile->syntax->nmultis > 0) {
int i; int i;
fileptr->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short)); fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
for (i = 0; i < openfile->syntax->nmultis; i++) for (i = 0; i < openfile->syntax->nmultis; i++)
fileptr->multidata[i] = -1; /* Assue this applies until we know otherwise */ fileptr->multidata[i] = -1; /* Assue this applies until we know otherwise */
} }