commit 5a018f0d3a6fdc41c0f7026e7be1733f2b8447b2
parent 752830573aeea5daeafe4214c4fd23b3c01534bc
Author: Chris Allegretta <chrisa@asty.org>
Date: Sun, 29 Nov 2009 06:13:22 +0000
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
Diffstat:
9 files changed, 64 insertions(+), 56 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -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>
* 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
diff --git a/src/chars.c b/src/chars.c
@@ -89,7 +89,7 @@ bool is_alnum_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar;
}
@@ -109,7 +109,7 @@ bool is_blank_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar;
}
@@ -156,7 +156,7 @@ bool is_cntrl_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar;
}
@@ -177,7 +177,7 @@ bool is_punct_mbchar(const char *c)
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
if (c_mb_len < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar;
}
@@ -243,14 +243,14 @@ char *control_mbrep(const char *c, char *crep, int *crep_len)
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
*crep_len = bad_mbchar_len;
strncpy(crep, bad_mbchar, *crep_len);
} else {
*crep_len = wctomb(crep, control_wrep(wc));
if (*crep_len < 0) {
- wctomb(NULL, 0);
+ int shutup = wctomb(NULL, 0);
*crep_len = 0;
}
}
@@ -278,14 +278,14 @@ char *mbrep(const char *c, char *crep, int *crep_len)
/* Reject invalid Unicode characters. */
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;
strncpy(crep, bad_mbchar, *crep_len);
} else {
*crep_len = wctomb(crep, wc);
if (*crep_len < 0) {
- wctomb(NULL, 0);
+ int shutup = wctomb(NULL, 0);
*crep_len = 0;
}
}
@@ -311,7 +311,7 @@ int mbwidth(const char *c)
int width;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
wc = bad_wchar;
}
@@ -356,7 +356,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
/* Reject invalid Unicode characters. */
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
- wctomb(NULL, 0);
+ int shutup = wctomb(NULL, 0);
*chr_mb_len = 0;
}
} else {
@@ -388,7 +388,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
/* If buf contains an invalid multibyte character, only
* interpret buf's first byte. */
if (buf_mb_len < 0) {
- mblen(NULL, 0);
+ int shutup = mblen(NULL, 0);
buf_mb_len = 1;
} else if (buf_mb_len == 0)
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);
if (mbtowc(&ws1, s1_mb, s1_mb_len) < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
ws1 = (unsigned char)*s1_mb;
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);
if (mbtowc(&ws2, s2_mb, s2_mb_len) < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
ws2 = (unsigned char)*s2_mb;
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);
if (c_mb_len < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
wc = (unsigned char)*c;
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);
if (mbtowc(&ws, s_mb, s_mb_len) < 0) {
- mbtowc(NULL, NULL, 0);
+ int shutup = mbtowc(NULL, NULL, 0);
ws = (unsigned char)*s;
bad_s_mb = TRUE;
}
diff --git a/src/files.c b/src/files.c
@@ -1092,6 +1092,7 @@ char *get_full_path(const char *origpath)
char *d_here, *d_there, *d_there_file = NULL;
const char *last_slash;
bool path_only;
+ int shutup;
if (origpath == NULL)
return NULL;
@@ -1190,7 +1191,7 @@ char *get_full_path(const char *origpath)
/* Finally, go back to the path specified in d_here,
* where we were before. We don't check for a chdir()
* 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);
diff --git a/src/global.c b/src/global.c
@@ -214,7 +214,7 @@ size_t length_of_list(int menu)
}
/* 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')
return META;
@@ -289,7 +289,7 @@ const sc *first_sc_for(int menu, short func) {
/* Add a string to the new shortcut list implementation
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;
@@ -315,7 +315,7 @@ void add_to_sclist(int menu, char *scstring, short func, int toggle, int execute
s->type = strtokeytype(scstring);
s->menu = menu;
s->toggle = toggle;
- s->keystr = scstring;
+ s->keystr = (char *) scstring;
s->scfunc = func;
s->execute = execute;
assign_keyinfo(s);
@@ -1344,7 +1344,7 @@ const subnfunc *sctofunc(sc *s)
#ifndef NANO_TINY
/* Now lets come up with a single (hopefully)
function to get a string for each flag */
-char *flagtostr(int flag)
+const char *flagtostr(int flag)
{
switch (flag) {
case NO_HELP:
diff --git a/src/nano.c b/src/nano.c
@@ -1752,7 +1752,7 @@ int do_mouse(void)
void alloc_multidata_if_needed(filestruct *fileptr)
{
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
diff --git a/src/prompt.c b/src/prompt.c
@@ -1070,7 +1070,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
}
} else
#endif /* !NANO_TINY */
-#ifndef DISABLE_HELP
if (s && s->scfunc == DO_HELP_VOID) {
update_statusbar_line(answer, statusbar_x);
@@ -1082,7 +1081,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
* prompt. */
finished = FALSE;
}
-#endif
/* If we have a shortcut with an associated function, break out
* if we're finished after running or trying to run the
diff --git a/src/proto.h b/src/proto.h
@@ -783,12 +783,12 @@ void display_main_list(void);
void do_cursorpos(bool constant);
void do_cursorpos_void(void);
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 *getfuncfromkey(WINDOW *win);
void print_sclist(void);
sc *strtosc(int menu, char *input);
-function_type strtokeytype(char *str);
+function_type strtokeytype(const char *str);
int strtomenu(char *input);
void assign_keyinfo(sc *s);
void xon_complaint(void);
@@ -796,35 +796,36 @@ void xoff_complaint(void);
int sc_seq_or (short func, int defaultval);
void do_suspend_void(void);
-const char *cancel_msg;
-#ifndef NANO_TINY
-const char *case_sens_msg;
-const char *backwards_msg;
-const char *prev_history_msg;
-const char *next_history_msg;
-#endif
-const char *replace_msg;
-const char *no_replace_msg;
-const char *go_to_line_msg;
-const char *whereis_next_msg;
-const char *first_file_msg;
-const char *last_file_msg;
-const char *goto_dir_msg;
-const char *ext_cmd_msg;
-const char *to_files_msg;
-const char *dos_format_msg;
-const char *mac_format_msg;
-const char *append_msg;
-const char *prepend_msg;
-const char *backup_file_msg;
-const char *gototext_msg;
-const char *new_buffer_msg;
+extern const char *cancel_msg;
+#ifndef NANO_TINY
+extern const char *case_sens_msg;
+extern const char *backwards_msg;
+extern const char *prev_history_msg;
+extern const char *next_history_msg;
+#endif
+extern const char *replace_msg;
+extern const char *no_replace_msg;
+extern const char *go_to_line_msg;
+extern const char *whereis_next_msg;
+extern const char *first_file_msg;
+extern const char *last_file_msg;
+extern const char *goto_dir_msg;
+extern const char *ext_cmd_msg;
+extern const char *to_files_msg;
+extern const char *dos_format_msg;
+extern const char *mac_format_msg;
+extern const char *append_msg;
+extern const char *prepend_msg;
+extern const char *backup_file_msg;
+extern const char *gototext_msg;
+extern const char *new_buffer_msg;
+
void iso_me_harder_funcmap(short func);
void enable_nodelay(void);
void disable_nodelay(void);
#ifdef HAVE_REGEX_H
-const char *regexp_msg;
+extern const char *regexp_msg;
#endif
#ifdef NANO_EXTRA
diff --git a/src/text.c b/src/text.c
@@ -181,7 +181,7 @@ void do_tab(void)
free(output);
} else {
#endif
- do_output("\t", 1, TRUE);
+ do_output((char *) "\t", 1, TRUE);
#ifndef NANO_TINY
}
#endif
@@ -483,7 +483,7 @@ void do_undo(void)
break;
case SPLIT:
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);
if (u->strdata2 != NULL)
f->next->data = mallocstrcpy(f->next->data, u->strdata2);
@@ -517,7 +517,7 @@ void do_undo(void)
undidmsg = _("line break");
if (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);
unlink_node(foo);
delete_node(foo);
@@ -765,7 +765,7 @@ bool execute_command(const char *command)
* arguments. */
shellenv = getenv("SHELL");
if (shellenv == NULL)
- shellenv = "/bin/sh";
+ shellenv = (char *) "/bin/sh";
/* Fork a child. */
if ((pid = fork()) == 0) {
@@ -859,7 +859,7 @@ void add_undo(undo_type current_action)
}
/* Allocate and initialize a new undo type */
- u = nmalloc(sizeof(undo));
+ u = (undo *) nmalloc(sizeof(undo));
u->type = current_action;
u->lineno = fs->current->lineno;
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);
#endif
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-1] = '\0';
u->strdata = (char *) data;
diff --git a/src/winio.c b/src/winio.c
@@ -2495,7 +2495,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
if (fileptr->multidata == NULL && openfile->syntax
&& openfile->syntax->nmultis > 0) {
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++)
fileptr->multidata[i] = -1; /* Assue this applies until we know otherwise */
}