From 9092dccab89901b7074f9340bc7984910a80128f Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 19 Dec 2010 21:20:10 +0000 Subject: Changed all fixed filename buffers (that I could find) to use FL_PATH_MX instead. Raised FL_PATH_MX from skipy 256 characters to 2048, which corresponds with modern file systems. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8063 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_File_Browser.cxx | 2 +- src/Fl_File_Chooser2.cxx | 32 ++++++++++++++++---------------- src/Fl_File_Icon2.cxx | 10 +++++----- src/Fl_File_Input.cxx | 3 ++- src/Fl_Help_View.cxx | 12 ++++++------ src/filename_absolute.cxx | 4 ++-- src/filename_isdir.cxx | 2 +- src/filename_setext.cxx | 2 +- src/fl_file_dir.cxx | 4 ++-- src/fl_open_uri.cxx | 2 +- src/forms_fselect.cxx | 4 ++-- 11 files changed, 39 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/Fl_File_Browser.cxx b/src/Fl_File_Browser.cxx index d194214bc..a421b73d2 100644 --- a/src/Fl_File_Browser.cxx +++ b/src/Fl_File_Browser.cxx @@ -536,7 +536,7 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load // UNIX code uses /etc/fstab or similar... // FILE *mtab; // /etc/mtab or /etc/mnttab file - char line[1024]; // Input line + char line[FL_PATH_MAX]; // Input line // // Open the file that contains a list of mounted filesystems... diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index 08a35c67e..d3d0d05cb 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -460,7 +460,7 @@ Fl_File_Chooser::directory(const char *d)// I - Directory to change to #ifdef WIN32 // See if the filename contains backslashes... char *slash; // Pointer to slashes - char fixpath[1024]; // Path with slashes converted + char fixpath[FL_PATH_MAX]; // Path with slashes converted if (strchr(d, '\\')) { // Convert backslashes to slashes... strlcpy(fixpath, d, sizeof(fixpath)); @@ -524,8 +524,8 @@ void Fl_File_Chooser::favoritesButtonCB() { int v; // Current selection - char pathname[1024], // Pathname - menuname[2048]; // Menu name + char pathname[FL_PATH_MAX], // Pathname + menuname[FL_PATH_MAX]; // Menu name v = favoritesButton->value(); @@ -691,7 +691,7 @@ void Fl_File_Chooser::fileListCB() { char *filename, // New filename - pathname[1024]; // Full pathname to file + pathname[FL_PATH_MAX]; // Full pathname to file filename = (char *)fileList->text(fileList->value()); @@ -792,8 +792,8 @@ Fl_File_Chooser::fileNameCB() { char *filename, // New filename *slash, // Pointer to trailing slash - pathname[1024], // Full pathname to file - matchname[256]; // Matching filename + pathname[FL_PATH_MAX], // Full pathname to file + matchname[FL_PATH_MAX]; // Matching filename int i, // Looping var min_match, // Minimum number of matching chars max_match, // Maximum number of matching chars @@ -890,7 +890,7 @@ Fl_File_Chooser::fileNameCB() directory(pathname); if (filename[0]) { - char tempname[1024]; + char tempname[FL_PATH_MAX]; snprintf(tempname, sizeof(tempname), "%s/%s", directory_, filename); fileName->value(tempname); @@ -1001,7 +1001,7 @@ Fl_File_Chooser::filter(const char *p) // I - Pattern(s) *start, // Start of pattern *end; // End of pattern int allfiles; // Do we have a "*" pattern? - char temp[1024]; // Temporary pattern string + char temp[FL_PATH_MAX]; // Temporary pattern string // Make sure we have a pattern... @@ -1048,7 +1048,7 @@ void Fl_File_Chooser::newdir() { const char *dir; // New directory name - char pathname[1024]; // Full path of directory + char pathname[FL_PATH_MAX]; // Full path of directory // Get a directory name from the user @@ -1129,7 +1129,7 @@ Fl_File_Chooser::previewCB(Fl_File_Chooser *fc) { // I - File chooser void Fl_File_Chooser::rescan() { - char pathname[1024]; // New pathname for filename field + char pathname[FL_PATH_MAX]; // New pathname for filename field // Clear the current filename @@ -1167,7 +1167,7 @@ void Fl_File_Chooser::rescan_keep_filename() } int i; - char pathname[1024]; // New pathname for filename field + char pathname[FL_PATH_MAX]; // New pathname for filename field strlcpy(pathname, fn, sizeof(pathname)); // Build the file list... @@ -1213,7 +1213,7 @@ Fl_File_Chooser::showChoiceCB() const char *item, // Selected item *patstart; // Start of pattern char *patend; // End of pattern - char temp[1024]; // Temporary string for pattern + char temp[FL_PATH_MAX]; // Temporary string for pattern item = showChoice->text(showChoice->value()); @@ -1250,7 +1250,7 @@ void Fl_File_Chooser::update_favorites() { int i; // Looping var - char pathname[1024], // Pathname + char pathname[FL_PATH_MAX], // Pathname menuname[2048]; // Menu name const char *home; // Home directory @@ -1456,7 +1456,7 @@ Fl_File_Chooser::value(int f) // I - File number int i; // Looping var int fcount; // Number of selected files const char *name; // Current filename - static char pathname[1024]; // Filename + directory + static char pathname[FL_PATH_MAX]; // Filename + directory name = fileName->value(); @@ -1503,7 +1503,7 @@ Fl_File_Chooser::value(const char *filename) int i, // Looping var fcount; // Number of items in list char *slash; // Directory separator - char pathname[1024]; // Local copy of filename + char pathname[FL_PATH_MAX]; // Local copy of filename // printf("Fl_File_Chooser::value(\"%s\")\n", filename == NULL ? "(null)" : filename); @@ -1519,7 +1519,7 @@ Fl_File_Chooser::value(const char *filename) #ifdef WIN32 // See if the filename contains backslashes... - char fixpath[1024]; // Path with slashes converted + char fixpath[FL_PATH_MAX]; // Path with slashes converted if (strchr(filename, '\\')) { // Convert backslashes to slashes... strlcpy(fixpath, filename, sizeof(fixpath)); diff --git a/src/Fl_File_Icon2.cxx b/src/Fl_File_Icon2.cxx index 4e4f2d11c..443496cb2 100644 --- a/src/Fl_File_Icon2.cxx +++ b/src/Fl_File_Icon2.cxx @@ -600,8 +600,8 @@ void Fl_File_Icon::load_system_icons(void) { int i; // Looping var Fl_File_Icon *icon; // New icons - char filename[1024]; // Filename - char icondir[1024]; // Icon directory + char filename[FL_PATH_MAX]; // Filename + char icondir[FL_PATH_MAX]; // Icon directory static int init = 0; // Have the icons been initialized? const char * const icondirs[] = { "Bluecurve", // Icon directories to look for, in order @@ -811,7 +811,7 @@ load_kde_icons(const char *directory, // I - Directory to load int i; // Looping var int n; // Number of entries in directory dirent **entries; // Entries in directory - char full[1024]; // Full name of file + char full[FL_PATH_MAX]; // Full name of file entries = (dirent **)0; @@ -841,11 +841,11 @@ load_kde_mimelnk(const char *filename, // I - mimelnk filename const char *icondir) { // I - Location of icons FILE *fp; char tmp[1024]; - char iconfilename[1024]; + char iconfilename[FL_PATH_MAX]; char pattern[1024]; char mimetype[1024]; char *val; - char full_iconfilename[1024]; + char full_iconfilename[FL_PATH_MAX]; Fl_File_Icon *icon; diff --git a/src/Fl_File_Input.cxx b/src/Fl_File_Input.cxx index f1f3d2858..f22cc021f 100644 --- a/src/Fl_File_Input.cxx +++ b/src/Fl_File_Input.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "flstring.h" @@ -240,7 +241,7 @@ Fl_File_Input::handle_button(int event) // I - Event X; // Current X position char *start, // Start of path component *end; // End of path component - char newvalue[1024]; // New value + char newvalue[FL_PATH_MAX]; // New value // Figure out which button is being pressed... diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx index 7bf8360ac..caa25b46a 100644 --- a/src/Fl_Help_View.cxx +++ b/src/Fl_Help_View.cxx @@ -2606,8 +2606,8 @@ Fl_Help_View::get_color(const char *n, // I - Color name Fl_Shared_Image * Fl_Help_View::get_image(const char *name, int W, int H) { const char *localname; // Local filename - char dir[1024]; // Current directory - char temp[1024], // Temporary filename + char dir[FL_PATH_MAX]; // Current directory + char temp[FL_PATH_MAX], // Temporary filename *tempptr; // Pointer into temporary name Fl_Shared_Image *ip; // Image pointer... @@ -2703,8 +2703,8 @@ void Fl_Help_View::follow_link(Fl_Help_Link *linkp) if (strcmp(linkp->filename, filename_) != 0 && linkp->filename[0]) { - char dir[1024]; // Current directory - char temp[1024], // Temporary filename + char dir[FL_PATH_MAX]; // Current directory + char temp[FL_PATH_MAX], // Temporary filename *tempptr; // Pointer into temporary filename @@ -3115,7 +3115,7 @@ Fl_Help_View::load(const char *f)// I - Filename to load (may also have target) char *slash; // Directory separator const char *localname; // Local filename char error[1024]; // Error buffer - char newname[1024]; // New filename buffer + char newname[FL_PATH_MAX]; // New filename buffer // printf("load(%s)\n",f); fflush(stdout); @@ -3125,7 +3125,7 @@ Fl_Help_View::load(const char *f)// I - Filename to load (may also have target) strncmp(f, "ipp:", 4) == 0 || strncmp(f, "mailto:", 7) == 0 || strncmp(f, "news:", 5) == 0) { - char urimsg[256]; + char urimsg[FL_PATH_MAX]; if ( fl_open_uri(f, urimsg, sizeof(urimsg)) == 0 ) { clear_selection(); diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx index 477fe2d56..4381a2dbe 100644 --- a/src/filename_absolute.cxx +++ b/src/filename_absolute.cxx @@ -121,7 +121,7 @@ int fl_filename_absolute(char *to, int tolen, const char *from) { [..] chdir("/var/tmp/somedir"); // set cwd to /var/tmp/somedir [..] - char out[1024]; + char out[FL_PATH_MAX]; fl_filename_relative(out, sizeof(out), "/var/tmp/somedir/foo.txt"); // out="foo.txt", return=1 fl_filename_relative(out, sizeof(out), "/var/tmp/foo.txt"); // out="../foo.txt", return=1 fl_filename_relative(out, sizeof(out), "foo.txt"); // out="foo.txt", return=0 (no change) @@ -139,7 +139,7 @@ fl_filename_relative(char *to, // O - Relative filename const char *from) {// I - Absolute filename char *newslash; // Directory separator const char *slash; // Directory separator - char cwd_buf[1024]; // Current directory + char cwd_buf[FL_PATH_MAX]; // Current directory char *cwd = cwd_buf; diff --git a/src/filename_isdir.cxx b/src/filename_isdir.cxx index be037e289..964854e60 100644 --- a/src/filename_isdir.cxx +++ b/src/filename_isdir.cxx @@ -60,7 +60,7 @@ int _fl_filename_isdir_quick(const char* n) { */ int fl_filename_isdir(const char* n) { struct stat s; - char fn[1024]; + char fn[FL_PATH_MAX]; int length; length = strlen(n); diff --git a/src/filename_setext.cxx b/src/filename_setext.cxx index 3f77455f9..3f803b849 100644 --- a/src/filename_setext.cxx +++ b/src/filename_setext.cxx @@ -40,7 +40,7 @@ \code #include [..] - char buf[1024] = "/path/myfile.cxx"; + char buf[FL_PATH_MAX] = "/path/myfile.cxx"; fl_filename_setext(buf, sizeof(buf), ".txt"); // buf[] becomes "/path/myfile.txt" \endcode diff --git a/src/fl_file_dir.cxx b/src/fl_file_dir.cxx index 023562be7..591b54c5c 100644 --- a/src/fl_file_dir.cxx +++ b/src/fl_file_dir.cxx @@ -80,7 +80,7 @@ fl_file_chooser(const char *message, // I - Message in titlebar const char *pat, // I - Filename pattern const char *fname, // I - Initial filename selection int relative) { // I - 0 for absolute path - static char retname[1024]; // Returned filename + static char retname[FL_PATH_MAX]; // Returned filename if (!fc) { if (!fname || !*fname) fname = "."; @@ -163,7 +163,7 @@ fl_dir_chooser(const char *message, // I - Message for titlebar const char *fname, // I - Initial directory name int relative) // I - 0 for absolute { - static char retname[1024]; // Returned directory name + static char retname[FL_PATH_MAX]; // Returned directory name if (!fc) { if (!fname || !*fname) fname = "."; diff --git a/src/fl_open_uri.cxx b/src/fl_open_uri.cxx index 932a1e3f0..b093850d7 100644 --- a/src/fl_open_uri.cxx +++ b/src/fl_open_uri.cxx @@ -152,7 +152,7 @@ fl_open_uri(const char *uri, char *msg, int msglen) { // BROWSER environment variables because we have no idea whether // we need to run the listed commands in a terminal program. - char command[1024], // Command to run... + char command[FL_PATH_MAX], // Command to run... *argv[4], // Command-line arguments remote[1024]; // Remote-mode command... const char * const *commands; // Array of commands to check... diff --git a/src/forms_fselect.cxx b/src/forms_fselect.cxx index 7abe749bb..ee2f00a5f 100644 --- a/src/forms_fselect.cxx +++ b/src/forms_fselect.cxx @@ -30,9 +30,9 @@ #include #include "flstring.h" -static char fl_directory[1024]; +static char fl_directory[FL_PATH_MAX]; static const char *fl_pattern; // assumed passed value is static -static char fl_filename[1024]; +static char fl_filename[FL_PATH_MAX]; char* fl_show_file_selector(const char *message,const char *dir, const char *pat,const char *fname) { -- cgit v1.2.3