1
1
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4028 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
David Lawrence Ramsey 2007-01-11 21:36:29 +00:00
родитель 8310cd3de6
Коммит 4154d08362
4 изменённых файлов: 36 добавлений и 22 удалений

Просмотреть файл

@ -10,6 +10,13 @@ CVS code -
order to remove unnecessary usage of cat. Changes to order to remove unnecessary usage of cat. Changes to
doc/man/Makefile.am, doc/man/fr/Makefile.am, and doc/man/Makefile.am, doc/man/fr/Makefile.am, and
doc/texinfo/Makefile.am. (DLR) doc/texinfo/Makefile.am. (DLR)
- files.c:
is_dir()
- Don't assign dirptr's value using buf until we've asserted
that buf isn't NULL. (DLR)
- Remove unneeded assert. (DLR)
- proto.h:
- Add missing is_dir() prototype. (DLR)
- search.c: - search.c:
regexp_init() regexp_init()
- Don't assign rc's value via regcomp() until we've asserted - Don't assign rc's value via regcomp() until we've asserted

Просмотреть файл

@ -1265,11 +1265,11 @@ int copy_file(FILE *inn, FILE *out)
* nonamechange means don't change the current filename. It is ignored * nonamechange means don't change the current filename. It is ignored
* if tmp is FALSE or if we're appending/prepending. * if tmp is FALSE or if we're appending/prepending.
* *
* Return 0 on success or -1 on error. */ * Return TRUE on success or FALSE on error. */
int write_file(const char *name, FILE *f_open, bool tmp, append_type bool write_file(const char *name, FILE *f_open, bool tmp, append_type
append, bool nonamechange) append, bool nonamechange)
{ {
int retval = -1; bool retval = FALSE;
/* Instead of returning in this function, you should always /* Instead of returning in this function, you should always
* merely set retval and then goto cleanup_and_exit. */ * merely set retval and then goto cleanup_and_exit. */
size_t lineswritten = 0; size_t lineswritten = 0;
@ -1686,7 +1686,7 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type
titlebar(NULL); titlebar(NULL);
} }
retval = 0; retval = TRUE;
cleanup_and_exit: cleanup_and_exit:
free(realname); free(realname);
@ -1697,11 +1697,12 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type
} }
#ifndef NANO_TINY #ifndef NANO_TINY
/* Write a marked selection from a file out. */ /* Write a marked selection from a file out. Return TRUE on success or
int write_marked_file(const char *name, FILE *f_open, bool tmp, * FALSE on error. */
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
append_type append) append_type append)
{ {
int retval = -1; bool retval = FALSE;
bool old_modified = openfile->modified; bool old_modified = openfile->modified;
/* write_file() unsets the modified flag. */ /* write_file() unsets the modified flag. */
bool added_magicline = FALSE; bool added_magicline = FALSE;
@ -1746,16 +1747,17 @@ int write_marked_file(const char *name, FILE *f_open, bool tmp,
/* Write the current file to disk. If the mark is on, write the current /* Write the current file to disk. If the mark is on, write the current
* marked selection to disk. If exiting is TRUE, write the file to disk * marked selection to disk. If exiting is TRUE, write the file to disk
* regardless of whether the mark is on, and without prompting if the * regardless of whether the mark is on, and without prompting if the
* TEMP_FILE flag is set. */ * TEMP_FILE flag is set. Return TRUE on success or FALSE on error. */
int do_writeout(bool exiting) bool do_writeout(bool exiting)
{ {
int i, retval = 0; int i;
append_type append = OVERWRITE; append_type append = OVERWRITE;
char *ans; char *ans;
/* The last answer the user typed at the statusbar prompt. */ /* The last answer the user typed at the statusbar prompt. */
#ifdef NANO_EXTRA #ifdef NANO_EXTRA
static bool did_credits = FALSE; static bool did_credits = FALSE;
#endif #endif
bool retval = FALSE;
currshortcut = writefile_list; currshortcut = writefile_list;
@ -1764,7 +1766,7 @@ int do_writeout(bool exiting)
FALSE); FALSE);
/* Write succeeded. */ /* Write succeeded. */
if (retval == 0) if (retval)
return retval; return retval;
} }
@ -1820,7 +1822,7 @@ int do_writeout(bool exiting)
* encoded null), treat it as though it's blank. */ * encoded null), treat it as though it's blank. */
if (i < 0 || answer[0] == '\n') { if (i < 0 || answer[0] == '\n') {
statusbar(_("Cancelled")); statusbar(_("Cancelled"));
retval = -1; retval = FALSE;
break; break;
} else { } else {
ans = mallocstrcpy(ans, answer); ans = mallocstrcpy(ans, answer);
@ -1874,7 +1876,7 @@ int do_writeout(bool exiting)
strcasecmp(answer, "zzy") == 0) { strcasecmp(answer, "zzy") == 0) {
do_credits(); do_credits();
did_credits = TRUE; did_credits = TRUE;
retval = -1; retval = FALSE;
break; break;
} }
#endif #endif
@ -2050,14 +2052,18 @@ void free_chararray(char **array, size_t len)
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
/* Is the given file a directory? */ /* Is the given file a directory? */
int is_dir(const char *buf) bool is_dir(const char *buf)
{ {
char *dirptr = real_dir_from_tilde(buf); char *dirptr;
struct stat fileinfo; struct stat fileinfo;
int retval = (stat(dirptr, &fileinfo) != -1 && bool retval;
S_ISDIR(fileinfo.st_mode));
assert(buf != NULL && dirptr != buf); assert(buf != NULL);
dirptr = real_dir_from_tilde(buf);
retval = (stat(dirptr, &fileinfo) != -1 &&
S_ISDIR(fileinfo.st_mode));
free(dirptr); free(dirptr);

Просмотреть файл

@ -952,7 +952,7 @@ void do_exit(void)
/* If the user chose not to save, or if the user chose to save and /* If the user chose not to save, or if the user chose to save and
* the save succeeded, we're ready to exit. */ * the save succeeded, we're ready to exit. */
if (i == 0 || (i == 1 && do_writeout(TRUE) == 0)) { if (i == 0 || (i == 1 && do_writeout(TRUE))) {
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
/* Exit only if there are no more open file buffers. */ /* Exit only if there are no more open file buffers. */
if (!close_buffer()) if (!close_buffer())

Просмотреть файл

@ -310,13 +310,13 @@ bool check_operating_dir(const char *currpath, bool allow_tabcomp);
void init_backup_dir(void); void init_backup_dir(void);
#endif #endif
int copy_file(FILE *inn, FILE *out); int copy_file(FILE *inn, FILE *out);
int write_file(const char *name, FILE *f_open, bool tmp, append_type bool write_file(const char *name, FILE *f_open, bool tmp, append_type
append, bool nonamechange); append, bool nonamechange);
#ifndef NANO_TINY #ifndef NANO_TINY
int write_marked_file(const char *name, FILE *f_open, bool tmp, bool write_marked_file(const char *name, FILE *f_open, bool tmp,
append_type append); append_type append);
#endif #endif
int do_writeout(bool exiting); bool do_writeout(bool exiting);
void do_writeout_void(void); void do_writeout_void(void);
char *real_dir_from_tilde(const char *buf); char *real_dir_from_tilde(const char *buf);
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER) #if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
@ -324,6 +324,7 @@ int diralphasort(const void *va, const void *vb);
void free_chararray(char **array, size_t len); void free_chararray(char **array, size_t len);
#endif #endif
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
bool is_dir(const char *buf);
char **username_tab_completion(const char *buf, size_t *num_matches, char **username_tab_completion(const char *buf, size_t *num_matches,
size_t buflen); size_t buflen);
char **cwd_tab_completion(const char *buf, bool allow_files, size_t char **cwd_tab_completion(const char *buf, bool allow_files, size_t