diff --git a/ChangeLog b/ChangeLog index 5498ce72..5bbb3146 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-11-03 Chris Allegretta + * nano.h - Fix comma at end of enumerator list which angers -pedantic. + +2009-11-03 Mike Frysinger + * files.c - Move up is_file_writable() to stop implicit definition complaints. + 2009-10-27 Chris Allegretta * browser.c (browser_init): Set column width to something sane when initializing in a directory with no file entries. Fixes Savannah diff --git a/src/files.c b/src/files.c index bf96960d..de69181a 100644 --- a/src/files.c +++ b/src/files.c @@ -291,6 +291,47 @@ bool close_buffer(void) } #endif /* ENABLE_MULTIBUFFER */ +/* A bit of a copy and paste from open_file(), is_file_writable() + * just checks whether the file is appendable as a quick + * permissions check, and we tend to err on the side of permissiveness + * (reporting TRUE when it might be wrong) to not fluster users + * editing on odd filesystems by printing incorrect warnings. + */ +int is_file_writable(const char *filename) +{ + struct stat fileinfo, fileinfo2; + int fd; + FILE *f; + char *full_filename; + bool ans = TRUE; + + + if (ISSET(VIEW_MODE)) + return TRUE; + + assert(filename != NULL && f != NULL); + + /* Get the specified file's full path. */ + full_filename = get_full_path(filename); + + /* Okay, if we can't stat the path due to a component's + permissions, just try the relative one */ + if (full_filename == NULL + || (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1)) + full_filename = mallocstrcpy(NULL, filename); + + if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | + S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1 + || (f = fdopen(fd, "a")) == NULL) + ans = FALSE; + else + fclose(f); + close(fd); + + free(full_filename); + return ans; +} + /* We make a new line of text from buf. buf is length buf_len. If * first_line_ins is TRUE, then we put the new line at the top of the * file. Otherwise, we assume prevnode is the last line of the file, @@ -701,48 +742,6 @@ int open_file(const char *filename, bool newfie, FILE **f) return fd; } -/* A bit of a copy and paste from open_file(), is_file_writable() - * just checks whether the file is appendable as a quick - * permissions check, and we tend to err on the side of permissiveness - * (reporting TRUE when it might be wrong) to not fluster users - * editing on odd filesystems by printing incorrect warnings. - */ -int is_file_writable(const char *filename) -{ - struct stat fileinfo, fileinfo2; - int fd; - FILE *f; - char *full_filename; - bool ans = TRUE; - - - if (ISSET(VIEW_MODE)) - return TRUE; - - assert(filename != NULL && f != NULL); - - /* Get the specified file's full path. */ - full_filename = get_full_path(filename); - - /* Okay, if we can't stat the path due to a component's - permissions, just try the relative one */ - if (full_filename == NULL - || (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1)) - full_filename = mallocstrcpy(NULL, filename); - - if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | - S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1 - || (f = fdopen(fd, "a")) == NULL) - ans = FALSE; - else - fclose(f); - close(fd); - - free(full_filename); - return ans; -} - - /* This function will return the name of the first available extension * of a filename (starting with [name][suffix], then [name][suffix].1, * etc.). Memory is allocated for the return value. If no writable diff --git a/src/nano.h b/src/nano.h index e9996a4d..63b6a7c8 100644 --- a/src/nano.h +++ b/src/nano.h @@ -490,7 +490,7 @@ enum BOLD_TEXT, QUIET, UNDOABLE, - SOFTWRAP, + SOFTWRAP }; /* Flags for which menus in which a given function should be present */