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
This commit is contained in:
Matthias Melcher 2010-12-19 21:20:10 +00:00
parent dc0c85b964
commit 9092dccab8
25 changed files with 89 additions and 81 deletions

View File

@ -54,8 +54,8 @@ private:
static Fl_Preferences prefs_;
void (*callback_)(Fl_File_Chooser*, void *);
void *data_;
char directory_[1024];
char pattern_[1024];
char directory_[FL_PATH_MAX];
char pattern_[FL_PATH_MAX];
char preview_text_[2048];
int type_;
void favoritesButtonCB();

View File

@ -43,8 +43,8 @@
class FL_EXPORT Fl_Help_Dialog {
int index_;
int max_;
int line_[100];
char file_[100][256];
int line_[100]; // FIXME: we must remove those static numbers
char file_[100][FL_PATH_MAX]; // FIXME: we must remove those static numbers
int find_pos_;
public:
Fl_Help_Dialog();

View File

@ -42,6 +42,7 @@
# include "Fl_Scrollbar.H"
# include "fl_draw.H"
# include "Fl_Shared_Image.H"
# include "filename.H"
//
@ -235,8 +236,8 @@ class FL_EXPORT Fl_Help_View : public Fl_Group // Help viewer widget
atargets_; ///< Allocated targets
Fl_Help_Target *targets_; ///< Targets
char directory_[1024]; ///< Directory for current file
char filename_[1024]; ///< Current filename
char directory_[FL_PATH_MAX];///< Directory for current file
char filename_[FL_PATH_MAX]; ///< Current filename
int topline_, ///< Top line in document
leftline_, ///< Lefthand position
size_, ///< Total document length

View File

@ -41,7 +41,7 @@
File names and URI functions defined in <FL/filename.H>
@{ */
# define FL_PATH_MAX 256 /**< all path buffers should use this length */
# define FL_PATH_MAX 2048 /**< all path buffers should use this length */
/** Gets the file name from a path.
Similar to basename(3), exceptions shown below.
\code

View File

@ -1107,7 +1107,7 @@ void Fl_Comment_Type::open() {
comment_in_header->value(in_h_);
comment_panel->show();
const char* message = 0;
char itempath[256]; itempath[0] = 0;
char itempath[FL_PATH_MAX]; itempath[0] = 0;
int last_selected_item = 0;
for (;;) { // repeat as long as there are errors
if (message) fl_alert("%s", message);
@ -1350,7 +1350,7 @@ void Fl_Class_Type::read_property(const char *c) {
void Fl_Class_Type::open() {
if (!class_panel) make_class_panel();
char fullname[1024]="";
char fullname[FL_PATH_MAX]="";
if (prefix() && strlen(prefix()))
sprintf(fullname,"%s %s",prefix(),name());
else

View File

@ -37,6 +37,9 @@ decl {\#include <FL/Fl_Text_Buffer.H>} {public local
decl {\#include <FL/Fl_Text_Display.H>} {public local
}
decl {\#include <FL/filename.H>} {selected public local
}
decl {extern void load_history();} {public local
}
@ -119,7 +122,7 @@ Function {make_project_window()} {open
xywh {0 0 100 20}
}
MenuItem {} {
label {GNU gettext} selected
label {GNU gettext}
xywh {0 0 100 20}
}
MenuItem {} {

View File

@ -105,8 +105,8 @@ int show_comments = 1;
int show_coredevmenus = 1;
// File history info...
char absolute_history[10][1024];
char relative_history[10][1024];
char absolute_history[10][FL_PATH_MAX];
char relative_history[10][FL_PATH_MAX];
void load_history();
void update_history(const char *);
@ -133,11 +133,11 @@ void goto_source_dir() {
if (!filename || !*filename) return;
const char *p = fl_filename_name(filename);
if (p <= filename) return; // it is in the current directory
char buffer[1024];
char buffer[FL_PATH_MAX];
strlcpy(buffer, filename, sizeof(buffer));
int n = p-filename; if (n>1) n--; buffer[n] = 0;
if (!pwd) {
pwd = getcwd(0,1024);
pwd = getcwd(0,FL_PATH_MAX);
if (!pwd) {fprintf(stderr,"getwd : %s\n",strerror(errno)); return;}
}
if (chdir(buffer)<0) {fprintf(stderr, "Can't chdir to %s : %s\n",
@ -182,7 +182,7 @@ Fl_Window *main_window;
Fl_Menu_Bar *main_menubar;
static char* cutfname(int which = 0) {
static char name[2][1024];
static char name[2][FL_PATH_MAX];
static char beenhere = 0;
if (!beenhere) {
@ -263,14 +263,14 @@ void save_template_cb(Fl_Widget *, void *) {
if (!c || !*c) return;
// Convert template name to filename_with_underscores
char safename[1024], *safeptr;
char safename[FL_PATH_MAX], *safeptr;
strlcpy(safename, c, sizeof(safename));
for (safeptr = safename; *safeptr; safeptr ++) {
if (isspace(*safeptr)) *safeptr = '_';
}
// Find the templates directory...
char filename[1024];
char filename[FL_PATH_MAX];
fluid_prefs.getUserdataPath(filename, sizeof(filename));
strlcat(filename, "templates", sizeof(filename));
@ -653,15 +653,15 @@ const char* i18n_include = "";
const char* i18n_function = "";
const char* i18n_file = "";
const char* i18n_set = "";
char i18n_program[1024] = "";
char i18n_program[FL_PATH_MAX] = "";
void write_cb(Fl_Widget *, void *) {
if (!filename) {
save_cb(0,0);
if (!filename) return;
}
char cname[1024];
char hname[1024];
char cname[FL_PATH_MAX];
char hname[FL_PATH_MAX];
strlcpy(i18n_program, fl_filename_name(filename), sizeof(i18n_program));
fl_filename_setext(i18n_program, sizeof(i18n_program), "");
if (*code_file_name == '.' && strchr(code_file_name, '/') == NULL) {
@ -698,7 +698,7 @@ void write_strings_cb(Fl_Widget *, void *) {
save_cb(0,0);
if (!filename) return;
}
char sname[1024];
char sname[FL_PATH_MAX];
strlcpy(sname, fl_filename_name(filename), sizeof(sname));
fl_filename_setext(sname, sizeof(sname), exts[i18n_type]);
if (!compile_only) goto_source_dir();
@ -848,14 +848,14 @@ void about_cb(Fl_Widget *, void *) {
void show_help(const char *name) {
const char *docdir;
char helpname[1024];
char helpname[FL_PATH_MAX];
if (!help_dialog) help_dialog = new Fl_Help_Dialog();
if ((docdir = getenv("FLTK_DOCDIR")) == NULL) {
#ifdef __EMX__
// Doesn't make sense to have a hardcoded fallback
static char fltk_docdir[1024];
static char fltk_docdir[FL_PATH_MAX];
strlcpy(fltk_docdir, __XOS2RedirRoot("/XFree86/lib/X11/fltk/doc"),
sizeof(fltk_docdir));
@ -1152,7 +1152,7 @@ void print_menu_cb(Fl_Widget *, void *) {
// Quote a string for PostScript printing
static const char *ps_string(const char *s) {
char *bufptr;
static char buffer[2048];
static char buffer[FL_PATH_MAX];
if (!s) {
@ -1853,7 +1853,7 @@ void load_history() {
// Update file history from preferences...
void update_history(const char *flname) {
int i; // Looping var
char absolute[1024];
char absolute[FL_PATH_MAX];
int max_files;
@ -2241,7 +2241,7 @@ void update_sourceview_timer(void*)
// Set the "modified" flag and update the title of the main window...
void set_modflag(int mf) {
const char *basename;
static char title[1024];
static char title[FL_PATH_MAX];
modflag = mf;

View File

@ -30,6 +30,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Preferences.H>
#include <FL/filename.H>
typedef char Fl_UUID[40];
@ -81,7 +82,7 @@ public:
class Fl_File_Prefs : public Fl_Preferences {
char pPath[1024];
char pPath[FL_PATH_MAX];
char pName[80];
char pFullName[100];
char pExt[20];

View File

@ -91,7 +91,7 @@ template_name->value(template_browser->text(item));
template_delete->activate();
char pngfile[1024], *ext;
char pngfile[FL_PATH_MAX], *ext;
strlcpy(pngfile, flfile, sizeof(pngfile));
if ((ext = strrchr(pngfile, '.')) == NULL) return;
@ -222,7 +222,7 @@ template_browser->do_callback();
void template_load() {
int i;
char name[1024], filename[1024], path[1024], *ptr;
char name[FL_PATH_MAX], filename[FL_PATH_MAX], path[FL_PATH_MAX], *ptr;
struct dirent **files;
int num_files;

View File

@ -29,6 +29,7 @@
#include "Fl_Type.h"
#include "undo.h"
#include <FL/Fl_Preferences.H>
#include <FL/filename.H>
#include "../src/flstring.h"
#if defined(WIN32) && !defined(__CYGWIN__)
# include <io.h>
@ -68,7 +69,7 @@ static int undo_paused = 0; // Undo checkpointing paused?
// Return the undo filename
static char *undo_filename(int level, char *buf, int bufsize) {
static char undo_path[1024] = ""; // Undo path
static char undo_path[FL_PATH_MAX] = ""; // Undo path
if (!undo_path[0]) fluid_prefs.getUserdataPath(undo_path, sizeof(undo_path));
@ -80,7 +81,7 @@ static char *undo_filename(int level, char *buf, int bufsize) {
// Redo menu callback
void redo_cb(Fl_Widget *, void *) {
char filename[1024]; // Undo checkpoint file
char filename[FL_PATH_MAX]; // Undo checkpoint file
if (undo_current >= undo_last) return;
@ -103,7 +104,7 @@ void redo_cb(Fl_Widget *, void *) {
// Undo menu callback
void undo_cb(Fl_Widget *, void *) {
char filename[1024]; // Undo checkpoint file
char filename[FL_PATH_MAX]; // Undo checkpoint file
if (undo_current <= 0) return;
@ -131,7 +132,7 @@ void undo_cb(Fl_Widget *, void *) {
// Save current file to undo buffer
void undo_checkpoint() {
char filename[1024]; // Undo checkpoint filename
char filename[FL_PATH_MAX]; // Undo checkpoint filename
// printf("undo_checkpoint(): undo_current=%d, undo_paused=%d, modflag=%d\n",
// undo_current, undo_paused, modflag);
@ -162,7 +163,7 @@ void undo_checkpoint() {
// Clear undo buffer
void undo_clear() {
char filename[1024]; // Undo checkpoint filename
char filename[FL_PATH_MAX]; // Undo checkpoint filename
// Remove old checkpoint files...

View File

@ -8420,6 +8420,7 @@
isa = PBXProject;
buildConfigurationList = 615453DB5B8EBEE070930DA7 /* Build configuration list for PBXProject "FLTK" */;
compatibilityVersion = "Xcode 3.0";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,

View File

@ -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...

View File

@ -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));

View File

@ -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;

View File

@ -30,6 +30,7 @@
#include <FL/Fl_File_Input.H>
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include <FL/filename.H>
#include <stdio.h>
#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...

View File

@ -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();

View File

@ -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;

View File

@ -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);

View File

@ -40,7 +40,7 @@
\code
#include <FL/filename.H>
[..]
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

View File

@ -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 = ".";

View File

@ -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...

View File

@ -30,9 +30,9 @@
#include <FL/forms.H>
#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) {

View File

@ -498,7 +498,7 @@ int load_the_menu(const char* fname)
int main(int argc, char **argv) {
putenv((char *)"FLTK_DOCDIR=../documentation/html");
char buf[256];
char buf[FL_PATH_MAX];
strcpy(buf, argv[0]);
#if ( defined _MSC_VER || defined __MWERKS__ ) && defined _DEBUG
// MS_VisualC appends a 'd' to debugging executables. remove it.

View File

@ -55,8 +55,8 @@
int changed = 0;
char filename[256] = "";
char title[256];
char filename[FL_PATH_MAX] = "";
char title[FL_PATH_MAX];
Fl_Text_Buffer *textbuf = 0;

View File

@ -253,8 +253,8 @@ pdf_check(const char *name, // I - Name of file
int) // I - Length of header data (unused)
{
const char *home; // Home directory
char preview[1024], // Preview filename
command[1024]; // Command
char preview[FL_PATH_MAX], // Preview filename
command[FL_PATH_MAX]; // Command
if (memcmp(header, "%PDF", 4) != 0)
@ -284,9 +284,9 @@ ps_check(const char *name, // I - Name of file
int) // I - Length of header data (unused)
{
const char *home; // Home directory
char preview[1024], // Preview filename
outname[1024], // Preview PS file
command[1024]; // Command
char preview[FL_PATH_MAX], // Preview filename
outname[FL_PATH_MAX], // Preview PS file
command[FL_PATH_MAX]; // Command
FILE *in, // Input file
*out; // Output file
int page; // Current page
@ -346,7 +346,7 @@ show_callback(void)
{
int i; // Looping var
int count; // Number of files selected
char relative[1024]; // Relative filename
char relative[FL_PATH_MAX]; // Relative filename
if (filter->value()[0])