Commit 92d2bab3 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

nanoget_repaint changes, do_writeout fix with var length strings

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@259 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 30 additions and 26 deletions
+30 -26
...@@ -14,7 +14,9 @@ CVS Code - ...@@ -14,7 +14,9 @@ CVS Code -
*** Note that backspace key makes input be off by one when entring *** Note that backspace key makes input be off by one when entring
*** a string > COLS in length. This must be fixed before a new release *** a string > COLS in length. This must be fixed before a new release
- files.c:
do_writeout()
- Change strcpy to answer to mallocstrcpy.
- global.c - global.c
- New global replace_list_2, for 2nd half of the replace dialog - New global replace_list_2, for 2nd half of the replace dialog
("Replace with:"), has fewer options than first half because ("Replace with:"), has fewer options than first half because
......
...@@ -444,7 +444,7 @@ int do_writeout(int exiting) ...@@ -444,7 +444,7 @@ int do_writeout(int exiting)
{ {
int i = 0; int i = 0;
strncpy(answer, filename, 132); answer = mallocstrcpy(answer, filename);
if ((exiting) && (ISSET(TEMP_OPT))) { if ((exiting) && (ISSET(TEMP_OPT))) {
if (filename[0]) { if (filename[0]) {
...@@ -469,7 +469,7 @@ int do_writeout(int exiting) ...@@ -469,7 +469,7 @@ int do_writeout(int exiting)
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, _("filename is %s"), answer); fprintf(stderr, _("filename is %s"), answer);
#endif #endif
if (strncmp(answer, filename, 132)) { if (strcmp(answer, filename)) {
struct stat st; struct stat st;
if (!stat(answer, &st)) { if (!stat(answer, &st)) {
i = do_yesno(0, 0, _("File exists, OVERWRITE ?")); i = do_yesno(0, 0, _("File exists, OVERWRITE ?"));
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-11-02 00:10-0500\n" "POT-Creation-Date: 2000-11-02 09:51-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
...@@ -380,7 +380,7 @@ msgid "Case Sens" ...@@ -380,7 +380,7 @@ msgid "Case Sens"
msgstr "" msgstr ""
#: global.c:344 global.c:364 global.c:375 global.c:385 global.c:401 #: global.c:344 global.c:364 global.c:375 global.c:385 global.c:401
#: global.c:405 global.c:411 winio.c:981 #: global.c:405 global.c:411 winio.c:983
msgid "Cancel" msgid "Cancel"
msgstr "" msgstr ""
...@@ -814,67 +814,67 @@ msgstr "" ...@@ -814,67 +814,67 @@ msgstr ""
msgid "actual_x_from_start for xplus=%d returned %d\n" msgid "actual_x_from_start for xplus=%d returned %d\n"
msgstr "" msgstr ""
#: winio.c:398 #: winio.c:399
#, c-format #, c-format
msgid "input '%c' (%d)\n" msgid "input '%c' (%d)\n"
msgstr "" msgstr ""
#: winio.c:434 #: winio.c:436
msgid "New Buffer" msgid "New Buffer"
msgstr "" msgstr ""
#: winio.c:437 #: winio.c:439
msgid " File: ..." msgid " File: ..."
msgstr "" msgstr ""
#: winio.c:445 #: winio.c:447
msgid "Modified" msgid "Modified"
msgstr "" msgstr ""
#: winio.c:897 #: winio.c:899
#, c-format #, c-format
msgid "Moved to (%d, %d) in edit buffer\n" msgid "Moved to (%d, %d) in edit buffer\n"
msgstr "" msgstr ""
#: winio.c:908 #: winio.c:910
#, c-format #, c-format
msgid "current->data = \"%s\"\n" msgid "current->data = \"%s\"\n"
msgstr "" msgstr ""
#: winio.c:951 #: winio.c:953
#, c-format #, c-format
msgid "I got \"%s\"\n" msgid "I got \"%s\"\n"
msgstr "" msgstr ""
#: winio.c:976 #: winio.c:978
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
#: winio.c:978 #: winio.c:980
msgid "All" msgid "All"
msgstr "" msgstr ""
#: winio.c:980 #: winio.c:982
msgid "No" msgid "No"
msgstr "" msgstr ""
#: winio.c:1117 #: winio.c:1119
#, c-format #, c-format
msgid "do_cursorpos: linepct = %f, bytepct = %f\n" msgid "do_cursorpos: linepct = %f, bytepct = %f\n"
msgstr "" msgstr ""
#: winio.c:1121 #: winio.c:1123
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)" msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr "" msgstr ""
#: winio.c:1249 #: winio.c:1251
msgid "Dumping file buffer to stderr...\n" msgid "Dumping file buffer to stderr...\n"
msgstr "" msgstr ""
#: winio.c:1251 #: winio.c:1253
msgid "Dumping cutbuffer to stderr...\n" msgid "Dumping cutbuffer to stderr...\n"
msgstr "" msgstr ""
#: winio.c:1253 #: winio.c:1255
msgid "Dumping a buffer to stderr...\n" msgid "Dumping a buffer to stderr...\n"
msgstr "" msgstr ""
...@@ -222,17 +222,17 @@ void check_statblank(void) ...@@ -222,17 +222,17 @@ void check_statblank(void)
void nanoget_repaint(char *buf, char *inputbuf, int x) void nanoget_repaint(char *buf, char *inputbuf, int x)
{ {
blank_statusbar(); blank_statusbar();
if (x <= COLS) { if (x <= COLS - 1) {
mvwaddstr(bottomwin, 0, 0, buf); mvwaddstr(bottomwin, 0, 0, buf);
waddnstr(bottomwin, inputbuf, COLS - strlen(buf)); waddnstr(bottomwin, inputbuf, (COLS - 1) - strlen(buf));
} else if (x > COLS && x <= COLS * 2) } else if (x > COLS - 1 && x <= (COLS - 1) * 2)
mvwaddnstr(bottomwin, 0, 0, &inputbuf[COLS - strlen(buf)], COLS); mvwaddnstr(bottomwin, 0, 0, &inputbuf[(COLS - 1) - strlen(buf)], COLS);
else else
mvwaddnstr(bottomwin, 0, 0, &inputbuf[COLS * (x / COLS) - mvwaddnstr(bottomwin, 0, 0, &inputbuf[COLS * (x / (COLS - 1)) -
strlen(buf)], COLS); strlen(buf)], COLS);
wmove(bottomwin, 0, (x % COLS)); wmove(bottomwin, 0, (x % (COLS - 1)));
} }
...@@ -259,6 +259,7 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x) ...@@ -259,6 +259,7 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
for (j = 0; j <= slen - 1; j++) { for (j = 0; j <= slen - 1; j++) {
if (kbinput == s[j].val) { if (kbinput == s[j].val) {
answer = mallocstrcpy(answer, ""); answer = mallocstrcpy(answer, "");
free(inputbuf);
return s[j].val; return s[j].val;
} }
} }
...@@ -402,6 +403,7 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x) ...@@ -402,6 +403,7 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
} }
answer = mallocstrcpy(answer, inputbuf); answer = mallocstrcpy(answer, inputbuf);
free(inputbuf);
/* Now that the text is editable instead of bracketed, we have to /* Now that the text is editable instead of bracketed, we have to
check for answer == def, instead of answer == "" */ check for answer == def, instead of answer == "" */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment