buf = charalloc(strlen(name) + num_of_digits(INT_MAX) + 2);
strcpy(buf, name);
- while (1) {
+ while (TRUE) {
if (stat(buf, &fs) == -1)
return buf;
if (operating_dir != NULL && strcmp(operating_dir, "."))
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
- i = statusq(1, insertfile_list, inspath,
+ i = statusq(TRUE, insertfile_list, inspath,
#ifndef NANO_SMALL
- 0,
+ NULL,
#endif
_("File to insert into new buffer [from %s] "),
operating_dir);
else
#endif
- i = statusq(1, insertfile_list, inspath,
+ i = statusq(TRUE, insertfile_list, inspath,
#ifndef NANO_SMALL
- 0,
+ NULL,
#endif
_("File to insert [from %s] "),
operating_dir);
#endif
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
- i = statusq(1, insertfile_list, inspath,
+ i = statusq(TRUE, insertfile_list, inspath,
#ifndef NANO_SMALL
- 0,
+ NULL,
#endif
_("File to insert into new buffer [from ./] "));
else
#endif /* ENABLE_MULTIBUFFER */
- i = statusq(1, insertfile_list, inspath,
+ i = statusq(TRUE, insertfile_list, inspath,
#ifndef NANO_SMALL
- 0,
+ NULL,
#endif
_("File to insert [from ./] "));
#endif /* ENABLE_MULTIBUFFER */
if (i == NANO_EXTCMD_KEY) {
- int ts = statusq(TRUE, extcmd_list, answer, NULL,
+ char *ans = mallocstrcpy(NULL, answer);
+ int ts = statusq(TRUE, extcmd_list, ans, NULL,
_("Command to execute"));
+
+ free(ans);
+
if (ts == -1 || answer == NULL || answer[0] == '\0') {
statusbar(_("Cancelled"));
display_main_list();
}
#endif /* !NANO_SMALL */
-int do_writeout(const char *path, int exiting, int append)
+int do_writeout(int exiting)
{
- int i = 0;
+ int i;
+ int append = 0;
#ifdef NANO_EXTRA
- static int did_cred = 0;
+ static int did_cred = FALSE;
#endif
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_MOUSE)
currshortcut = writefile_list;
#endif
- answer = mallocstrcpy(answer, path);
-
if (exiting && ISSET(TEMP_OPT)) {
+ i = -1;
if (filename[0] != '\0') {
- i = write_file(answer, 0, 0, 0);
- display_main_list();
- return i;
- } else {
+ i = write_file(filename, FALSE, 0, FALSE);
+ if (i == 1) {
+ /* Write succeeded. */
+ display_main_list();
+ return 1;
+ }
+ }
+
+ /* No filename or the write above failed. */
+ if (i == -1) {
UNSET(TEMP_OPT);
do_exit();
- /* They cancelled, abort quit */
+ /* They cancelled; abort quit. */
return -1;
}
}
- while (1) {
#ifndef NANO_SMALL
+ if (ISSET(MARK_ISSET) && !exiting)
+ answer = mallocstrcpy(answer, "");
+ else
+#endif
+ answer = mallocstrcpy(answer, filename);
+
+ while (TRUE) {
+ const char *msg;
+#ifndef NANO_SMALL
+ char *ans = mallocstrcpy(NULL, answer);
const char *formatstr, *backupstr;
if (ISSET(MAC_FILE))
else
backupstr = "";
- /* Be nice to the translation folks */
+ /* Be nice to the translation folks. */
if (ISSET(MARK_ISSET) && !exiting) {
if (append == 2)
- i = statusq(1, writefile_list, "", 0,
- "%s%s%s", _("Prepend Selection to File"), formatstr, backupstr);
+ msg = _("Prepend Selection to File");
else if (append == 1)
- i = statusq(1, writefile_list, "", 0,
- "%s%s%s", _("Append Selection to File"), formatstr, backupstr);
+ msg = _("Append Selection to File");
else
- i = statusq(1, writefile_list, "", 0,
- "%s%s%s", _("Write Selection to File"), formatstr, backupstr);
- } else {
- if (append == 2)
- i = statusq(1, writefile_list, answer, 0,
- "%s%s%s", _("File Name to Prepend to"), formatstr, backupstr);
- else if (append == 1)
- i = statusq(1, writefile_list, answer, 0,
- "%s%s%s", _("File Name to Append to"), formatstr, backupstr);
- else
- i = statusq(1, writefile_list, answer, 0,
- "%s%s%s", _("File Name to Write"), formatstr, backupstr);
- }
-#else
+ msg = _("Write Selection to File");
+ } else
+#endif /* !NANO_SMALL */
if (append == 2)
- i = statusq(1, writefile_list, answer,
- "%s", _("File Name to Prepend to"));
+ msg = _("File Name to Prepend to");
else if (append == 1)
- i = statusq(1, writefile_list, answer,
- "%s", _("File Name to Append to"));
+ msg = _("File Name to Append to");
else
- i = statusq(1, writefile_list, answer,
- "%s", _("File Name to Write"));
-#endif /* !NANO_SMALL */
+ msg = _("File Name to Write");
+
+ i = statusq(TRUE, writefile_list,
+#ifndef NANO_SMALL
+ ans, NULL, "%s%s%s", msg, formatstr, backupstr
+#else
+ filename, "%s", msg
+#endif
+ );
+
+#ifndef NANO_SMALL
+ free(ans);
+#endif
if (i == -1) {
statusbar(_("Cancelled"));
display_main_list();
- return 0;
+ return -1;
}
#ifndef DISABLE_BROWSER
if (exiting && !ISSET(TEMP_OPT) && !strcasecmp(answer, "zzy")
&& !did_cred) {
do_credits();
- did_cred = 1;
+ did_cred = TRUE;
return -1;
}
#endif
struct stat st;
if (!stat(answer, &st)) {
- i = do_yesno(0, _("File exists, OVERWRITE ?"));
+ i = do_yesno(FALSE, _("File exists, OVERWRITE ?"));
if (i == 0 || i == -1)
continue;
} else if (filename[0] != '\0'
&& (!ISSET(MARK_ISSET) || exiting)
#endif
) {
- i = do_yesno(0, _("Save file under DIFFERENT NAME ?"));
+ i = do_yesno(FALSE, _("Save file under DIFFERENT NAME ?"));
if (i == 0 || i == -1)
continue;
}
/* Here's where we allow the selected text to be written to
* a separate file. */
if (ISSET(MARK_ISSET) && !exiting)
- i = write_marked(answer, 0, append, 1);
+ i = write_marked(answer, FALSE, append, FALSE);
else
#endif /* !NANO_SMALL */
- i = write_file(answer, 0, append, 0);
+ i = write_file(answer, FALSE, append, FALSE);
#ifdef ENABLE_MULTIBUFFER
/* If we're not about to exit, update the current entry in
- the open_files structure. */
+ * the open_files structure. */
if (!exiting)
add_open_file(1);
#endif
display_main_list();
return i;
- } /* while (1) */
+ } /* while (TRUE) */
}
int do_writeout_void(void)
{
- return do_writeout(filename, 0, 0);
+ return do_writeout(FALSE);
}
/* Return a malloc()ed string containing the actual directory, used
pos <= strlen(matches[0]); pos++)
tmp++;
- while (1) {
+ while (TRUE) {
match_matches = 0;
for (i = 0; i < num_matches; i++) {
case 'G': /* Pico compatibility */
case 'g':
curs_set(1);
- j = statusq(0, gotodir_list, "",
+ j = statusq(FALSE, gotodir_list, "",
#ifndef NANO_SMALL
- 0,
+ NULL,
#endif
_("Goto Directory"));
bottombars(browser_list);
}
/* This is now one simple call. It just does a lot. */
- i = statusq(0, replacing ? replace_list : whereis_list, backupstring,
+ i = statusq(FALSE, replacing ? replace_list : whereis_list,
+ backupstring,
#ifndef NANO_SMALL
&search_history,
#endif
- "%s%s%s%s%s%s",
- _("Search"),
+ "%s%s%s%s%s%s", _("Search"),
#ifndef NANO_SMALL
/* This string is just a modifier for the search prompt; no
rev_start = fileptr->data + (current_x + 1);
/* Look for needle in searchstr. */
- while (1) {
+ while (TRUE) {
found = strstrwrapper(fileptr->data, needle, rev_start);
if (found != NULL && (!wholeword || is_whole_word(found -
curs_set(0);
do_replace_highlight(TRUE, exp_word);
- i = do_yesno(1, _("Replace this instance?"));
+ i = do_yesno(TRUE, _("Replace this instance?"));
do_replace_highlight(FALSE, exp_word);
free(exp_word);
last_replace = mallocstrcpy(last_replace, "");
#endif
- i = statusq(0, replace_list_2, last_replace,
+ i = statusq(FALSE, replace_list_2, last_replace,
#ifndef NANO_SMALL
- &replace_history,
+ &replace_history,
#endif
- _("Replace with"));
+ _("Replace with"));
#ifndef NANO_SMALL
/* Add this replace string to the replace history list. i == 0
int do_gotoline(int line, int save_pos)
{
if (line <= 0) { /* Ask for it */
- int st = statusq(FALSE, goto_list, line != 0 ? answer : "",
+ char *ans = mallocstrcpy(NULL, answer);
+ int st = statusq(FALSE, goto_list, line != 0 ? ans : "",
#ifndef NANO_SMALL
- NULL,
+ NULL,
#endif
- _("Enter line number"));
+ _("Enter line number"));
+
+ free(ans);
/* Cancel, or Enter with blank string. */
if (st == -1 || st == -2)
assert(ISSET(REGEXP_COMPILED));
search_last_line = 0;
- while (1) {
+ while (TRUE) {
if (findnextstr(FALSE, FALSE, current, current_x, regexp_pat, FALSE) != 0) {
/* Found identical bracket. */
if (current->data[current_x] == ch_under_cursor)