summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2002-05-16 12:47:44 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2002-05-16 12:47:44 +0000
commit88d54cd78bf73348e4f207ab3f741aa374f28b1c (patch)
treed9310acf36b480d31f0c1527520fe7376f7953ca /src
parent36546824762618bbe76d4ac72b632ca9927acd9f (diff)
Massive update to use strlcpy() and strlcat() instead of strncpy()
and strncat() in almost all places (there are still a few strncpy's that need to be used...) Added configure check for strlcat() and strlcpy(). Added emulation code for strlcat() and strlcpy(). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2239 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Chart.cxx13
-rw-r--r--src/Fl_File_Browser.cxx11
-rw-r--r--src/Fl_File_Chooser2.cxx43
-rw-r--r--src/Fl_File_Input.cxx8
-rw-r--r--src/Fl_Help_Dialog.cxx6
-rw-r--r--src/Fl_Help_Dialog.fl20
-rw-r--r--src/Fl_Help_View.cxx24
-rw-r--r--src/Fl_Preferences.cxx43
-rw-r--r--src/Fl_Text_Buffer.cxx7
-rw-r--r--src/Fl_display.cxx9
-rw-r--r--src/Fl_get_system_colors.cxx9
-rw-r--r--src/Makefile8
-rw-r--r--src/filename_absolute.cxx29
-rw-r--r--src/filename_expand.cxx10
-rw-r--r--src/filename_setext.cxx7
-rw-r--r--src/fl_draw.cxx10
-rw-r--r--src/fl_file_dir.cxx9
-rw-r--r--src/fl_set_fonts_mac.cxx8
-rw-r--r--src/fl_set_fonts_x.cxx26
-rw-r--r--src/flstring.c105
-rw-r--r--src/flstring.h21
-rw-r--r--src/forms_fselect.cxx14
-rw-r--r--src/makedepend27
23 files changed, 265 insertions, 202 deletions
diff --git a/src/Fl_Chart.cxx b/src/Fl_Chart.cxx
index 7fcb643d5..b3eabadc5 100644
--- a/src/Fl_Chart.cxx
+++ b/src/Fl_Chart.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Chart.cxx,v 1.5.2.6.2.6 2002/04/11 11:52:41 easysw Exp $"
+// "$Id: Fl_Chart.cxx,v 1.5.2.6.2.7 2002/05/16 12:47:43 easysw Exp $"
//
// Forms-compatible chart widget for the Fast Light Tool Kit (FLTK).
//
@@ -312,8 +312,7 @@ void Fl_Chart::add(double val, const char *str, unsigned col) {
entries[numb].val = float(val);
entries[numb].col = col;
if (str) {
- strncpy(entries[numb].str,str,FL_CHART_LABEL_MAX);
- entries[numb].str[FL_CHART_LABEL_MAX] = 0;
+ strlcpy(entries[numb].str,str,FL_CHART_LABEL_MAX + 1);
} else {
entries[numb].str[0] = 0;
}
@@ -336,8 +335,7 @@ void Fl_Chart::insert(int index, double val, const char *str, unsigned col) {
entries[index-1].val = float(val);
entries[index-1].col = col;
if (str) {
- strncpy(entries[index-1].str,str,FL_CHART_LABEL_MAX);
- entries[index-1].str[FL_CHART_LABEL_MAX] = 0;
+ strlcpy(entries[index-1].str,str,FL_CHART_LABEL_MAX+1);
} else {
entries[index-1].str[0] = 0;
}
@@ -349,8 +347,7 @@ void Fl_Chart::replace(int index,double val, const char *str, unsigned col) {
entries[index-1].val = float(val);
entries[index-1].col = col;
if (str) {
- strncpy(entries[index-1].str,str,FL_CHART_LABEL_MAX);
- entries[index-1].str[FL_CHART_LABEL_MAX] = 0;
+ strlcpy(entries[index-1].str,str,FL_CHART_LABEL_MAX+1);
} else {
entries[index-1].str[0] = 0;
}
@@ -378,5 +375,5 @@ void Fl_Chart::maxsize(int m) {
}
//
-// End of "$Id: Fl_Chart.cxx,v 1.5.2.6.2.6 2002/04/11 11:52:41 easysw Exp $".
+// End of "$Id: Fl_Chart.cxx,v 1.5.2.6.2.7 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Fl_File_Browser.cxx b/src/Fl_File_Browser.cxx
index debffaec5..dbd800290 100644
--- a/src/Fl_File_Browser.cxx
+++ b/src/Fl_File_Browser.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Browser.cxx,v 1.1.2.15 2002/05/06 04:11:50 easysw Exp $"
+// "$Id: Fl_File_Browser.cxx,v 1.1.2.16 2002/05/16 12:47:43 easysw Exp $"
//
// Fl_File_Browser routines.
//
@@ -540,7 +540,7 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load
if (sscanf(line, "%*s%4095s", filename) != 1)
continue;
- strncat(filename, "/", sizeof(filename) - 1);
+ strlcat(filename, "/", sizeof(filename));
// printf("Fl_File_Browser::load() - adding \"%s\" to list...\n", filename);
add(filename, icon);
@@ -561,15 +561,14 @@ Fl_File_Browser::load(const char *directory,// I - Directory to load
//
#if (defined(WIN32) && !defined(__CYGWIN__)) || defined(__EMX__)
- strncpy(filename, directory_, sizeof(filename) - 1);
- filename[sizeof(filename) - 1] = '\0';
+ strlcpy(filename, directory_, sizeof(filename));
i = strlen(filename) - 1;
if (i == 2 && filename[1] == ':' &&
(filename[2] == '/' || filename[2] == '\\'))
filename[2] = '/';
else if (filename[i] != '/' && filename[i] != '\\')
- strcat(filename, "/");
+ strlcat(filename, "/", sizeof(filename));
num_files = fl_filename_list(filename, &files, sort);
#else
@@ -638,5 +637,5 @@ Fl_File_Browser::filter(const char *pattern) // I - Pattern string
//
-// End of "$Id: Fl_File_Browser.cxx,v 1.1.2.15 2002/05/06 04:11:50 easysw Exp $".
+// End of "$Id: Fl_File_Browser.cxx,v 1.1.2.16 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx
index f3efbdcb0..81940478f 100644
--- a/src/Fl_File_Chooser2.cxx
+++ b/src/Fl_File_Chooser2.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.12 2002/05/02 15:24:34 easysw Exp $"
+// "$Id: Fl_File_Chooser2.cxx,v 1.1.2.13 2002/05/16 12:47:43 easysw Exp $"
//
// More Fl_File_Chooser routines.
//
@@ -100,10 +100,7 @@ Fl_File_Chooser::directory(const char *d)// I - Directory to change to
#endif /* WIN32 || __EMX__ */
fl_filename_absolute(directory_, d);
else
- {
- strncpy(directory_, d, sizeof(directory_) - 1);
- directory_[sizeof(directory_) - 1] = '\0';
- }
+ strlcpy(directory_, d, sizeof(directory_));
// Strip any trailing slash and/or period...
dirptr = directory_ + strlen(directory_) - 1;
@@ -180,10 +177,7 @@ Fl_File_Chooser::count()
if (directory_[0] != '\0')
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
else
- {
- strncpy(pathname, filename, sizeof(pathname) - 1);
- pathname[sizeof(pathname) - 1] = '\0';
- }
+ strlcpy(pathname, filename, sizeof(pathname));
if (fl_filename_isdir(pathname))
return (0);
@@ -199,10 +193,7 @@ Fl_File_Chooser::count()
if (directory_[0] != '\0')
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
else
- {
- strncpy(pathname, filename, sizeof(pathname) - 1);
- pathname[sizeof(pathname) - 1] = '\0';
- }
+ strlcpy(pathname, filename, sizeof(pathname));
if (!fl_filename_isdir(pathname))
count ++;
@@ -244,8 +235,7 @@ Fl_File_Chooser::value(int f) // I - File number
if (directory_[0]) {
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, name);
} else {
- strncpy(pathname, name, sizeof(pathname) - 1);
- pathname[sizeof(pathname) - 1] = '\0';
+ strlcpy(pathname, name, sizeof(pathname));
}
if (!fl_filename_isdir(pathname))
@@ -385,10 +375,7 @@ Fl_File_Chooser::newdir()
#endif /* WIN32 || __EMX__ */
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, dir);
else
- {
- strncpy(pathname, dir, sizeof(pathname) - 1);
- pathname[sizeof(pathname) - 1] = '\0';
- }
+ strlcpy(pathname, dir, sizeof(pathname));
// Create the directory; ignore EEXIST errors...
#if defined(WIN32) && ! defined (__CYGWIN__)
@@ -419,10 +406,9 @@ Fl_File_Chooser::rescan()
// printf("Fl_File_Chooser::rescan(); directory = \"%s\"\n", directory_);
// Clear the current filename
- pathname[sizeof(pathname) - 1] = '\0';
- strncpy(pathname, directory_, sizeof(pathname) - 1);
+ strlcpy(pathname, directory_, sizeof(pathname));
if (pathname[strlen(pathname) - 1] != '/') {
- strncat(pathname, "/", sizeof(pathname) - 1);
+ strlcat(pathname, "/", sizeof(pathname));
}
fileName->value(pathname);
okButton->deactivate();
@@ -451,10 +437,7 @@ Fl_File_Chooser::fileListCB()
if (directory_[0] != '\0')
snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
else
- {
- strncpy(pathname, filename, sizeof(pathname) - 1);
- pathname[sizeof(pathname) - 1] = '\0';
- }
+ strlcpy(pathname, filename, sizeof(pathname));
if (Fl::event_clicks())
{
@@ -539,8 +522,7 @@ Fl_File_Chooser::fileNameCB()
value(pathname);
} else if (filename != pathname) {
// Finally, make sure that we have a writable copy...
- strncpy(pathname, filename, sizeof(pathname) - 1);
- pathname[sizeof(pathname) - 1] = '\0';
+ strlcpy(pathname, filename, sizeof(pathname));
}
filename = pathname;
@@ -627,8 +609,7 @@ Fl_File_Chooser::fileNameCB()
if (max_match == 100000)
{
// First match; copy stuff over...
- strncpy(matchname, file, sizeof(matchname) - 1);
- matchname[sizeof(matchname) - 1] = '\0';
+ strlcpy(matchname, file, sizeof(matchname));
max_match = strlen(matchname);
// Strip trailing /, if any...
@@ -702,5 +683,5 @@ Fl_File_Chooser::fileNameCB()
//
-// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.12 2002/05/02 15:24:34 easysw Exp $".
+// End of "$Id: Fl_File_Chooser2.cxx,v 1.1.2.13 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Fl_File_Input.cxx b/src/Fl_File_Input.cxx
index 54a54d98e..03dca8722 100644
--- a/src/Fl_File_Input.cxx
+++ b/src/Fl_File_Input.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_File_Input.cxx,v 1.1.2.1 2002/04/30 21:50:16 easysw Exp $"
+// "$Id: Fl_File_Input.cxx,v 1.1.2.2 2002/05/16 12:47:43 easysw Exp $"
//
// File_Input header file for the Fast Light Tool Kit (FLTK).
//
@@ -24,7 +24,6 @@
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//
-//#include <FL/Fl_File_Input.H>
#include <FL/Fl.H>
#include <FL/Fl_File_Input.H>
#include <FL/fl_draw.H>
@@ -228,8 +227,7 @@ Fl_File_Input::handle_button(int event) // I - Event
if (!buttons_[i] || event != FL_RELEASE) return 1;
// Figure out where to truncate the path...
- strncpy(newvalue, value(), sizeof(newvalue) - 1);
- newvalue[sizeof(newvalue) - 1] = '\0';
+ strlcpy(newvalue, value(), sizeof(newvalue));
for (start = newvalue, end = start; start && i >= 0; start = end, i --) {
// printf(" start = \"%s\"\n", start);
@@ -255,5 +253,5 @@ Fl_File_Input::handle_button(int event) // I - Event
//
-// End of "$Id: Fl_File_Input.cxx,v 1.1.2.1 2002/04/30 21:50:16 easysw Exp $".
+// End of "$Id: Fl_File_Input.cxx,v 1.1.2.2 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Fl_Help_Dialog.cxx b/src/Fl_Help_Dialog.cxx
index 88ea74f41..2d1645555 100644
--- a/src/Fl_Help_Dialog.cxx
+++ b/src/Fl_Help_Dialog.cxx
@@ -1,6 +1,7 @@
// generated by Fast Light User Interface Designer (fluid) version 1.0100
#include "../FL/Fl_Help_Dialog.H"
+#include "flstring.h"
inline void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) {
if (view_->changed())
@@ -16,7 +17,7 @@ inline void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) {
max_ = index_;
- strcpy(file_[index_], view_->filename());
+ strlcpy(file_[index_], view_->filename(),sizeof(file_[0]));
line_[index_] = view_->topline();
if (index_ > 0)
@@ -29,8 +30,7 @@ inline void Fl_Help_Dialog::cb_view__i(Fl_Help_View*, void*) {
}
else if (view_->filename())
{
- strncpy(file_[index_], view_->filename(), 255);
- file_[index_][255] = '\0';
+ strlcpy(file_[index_], view_->filename(), sizeof(file_[0]));
line_[index_] = view_->topline();
};
}
diff --git a/src/Fl_Help_Dialog.fl b/src/Fl_Help_Dialog.fl
index bd333badc..99b676eef 100644
--- a/src/Fl_Help_Dialog.fl
+++ b/src/Fl_Help_Dialog.fl
@@ -1,10 +1,10 @@
# data file for the Fltk User Interface Designer (fluid)
version 1.0100
header_name {../FL/Fl_Help_Dialog.H}
-code_name {.cxx}
-gridx 5
-gridy 5
-snap 3
+code_name {.cxx}
+decl {\#include "flstring.h"} {selected
+}
+
class Fl_Help_Dialog {open
} {
decl {int index_;} {}
@@ -16,7 +16,7 @@ class Fl_Help_Dialog {open
Fl_Window window_ {
label {Help Dialog} open
private xywh {470 380 530 385} type Double resizable
- code0 {\#include <string.h>} visible
+ visible
} {
Fl_Group view_ {
callback {if (view_->changed())
@@ -32,7 +32,7 @@ class Fl_Help_Dialog {open
max_ = index_;
- strcpy(file_[index_], view_->filename());
+ strlcpy(file_[index_], view_->filename(),sizeof(file_[0]));
line_[index_] = view_->topline();
if (index_ > 0)
@@ -45,8 +45,7 @@ class Fl_Help_Dialog {open
}
else if (view_->filename())
{
- strncpy(file_[index_], view_->filename(), 255);
- file_[index_][255] = '\\0';
+ strlcpy(file_[index_], view_->filename(), sizeof(file_[0]));
line_[index_] = view_->topline();
}} open
private xywh {10 10 510 330} box DOWN_BOX resizable
@@ -146,10 +145,9 @@ window_->label(view_->title());} {}
} {
code {window_->show();} {}
}
- Function {show(int argc, char **argv)} {open return_type void
+ Function {show(int argc, char **argv)} {return_type void
} {
- code {window_->show(argc, argv);} {selected
- }
+ code {window_->show(argc, argv);} {}
}
Function {textsize(uchar s)} {return_type void
} {
diff --git a/src/Fl_Help_View.cxx b/src/Fl_Help_View.cxx
index be6696017..b2783539a 100644
--- a/src/Fl_Help_View.cxx
+++ b/src/Fl_Help_View.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Help_View.cxx,v 1.1.2.30 2002/04/11 10:46:19 easysw Exp $"
+// "$Id: Fl_Help_View.cxx,v 1.1.2.31 2002/05/16 12:47:43 easysw Exp $"
//
// Fl_Help_View widget routines.
//
@@ -207,14 +207,12 @@ Fl_Help_View::add_link(const char *n, // I - Name of link
temp->w = xx + ww;
temp->h = yy + hh;
- strncpy(temp->filename, n, sizeof(temp->filename) - 1);
- temp->filename[sizeof(temp->filename) - 1] = '\0';
+ strlcpy(temp->filename, n, sizeof(temp->filename));
if ((target = strrchr(temp->filename, '#')) != NULL)
{
*target++ = '\0';
- strncpy(temp->name, target, sizeof(temp->name) - 1);
- temp->name[sizeof(temp->name) - 1] = '\0';
+ strlcpy(temp->name, target, sizeof(temp->name));
}
else
temp->name[0] = '\0';
@@ -247,8 +245,7 @@ Fl_Help_View::add_target(const char *n, // I - Name of target
temp = targets_ + ntargets_;
temp->y = yy;
- strncpy(temp->name, n, sizeof(temp->name) - 1);
- temp->name[sizeof(temp->name) - 1] = '\0';
+ strlcpy(temp->name, n, sizeof(temp->name));
ntargets_ ++;
}
@@ -960,10 +957,7 @@ Fl_Help_View::format()
add_target(attr, yy - size - 2);
if (get_attr(attrs, "HREF", attr, sizeof(attr)) != NULL)
- {
- strncpy(link, attr, sizeof(link) - 1);
- link[sizeof(link) - 1] = '\0';
- }
+ strlcpy(link, attr, sizeof(link));
}
else if (strcasecmp(buf, "/A") == 0)
link[0] = '\0';
@@ -2136,8 +2130,7 @@ Fl_Help_View::handle(int event) // I - Event to handle
{
fl_cursor(FL_CURSOR_DEFAULT);
- strncpy(target, link->name, sizeof(target) - 1);
- target[sizeof(target) - 1] = '\0';
+ strlcpy(target, link->name, sizeof(target));
set_changed();
@@ -2391,8 +2384,7 @@ Fl_Help_View::topline(const char *n) // I - Target name
if (ntargets_ == 0)
return;
- strncpy(key.name, n, sizeof(key.name) - 1);
- key.name[sizeof(key.name) - 1] = '\0';
+ strlcpy(key.name, n, sizeof(key.name));
target = (Fl_Help_Target *)bsearch(&key, targets_, ntargets_, sizeof(Fl_Help_Target),
(compare_func_t)compare_targets);
@@ -2623,5 +2615,5 @@ hscrollbar_callback(Fl_Widget *s, void *)
//
-// End of "$Id: Fl_Help_View.cxx,v 1.1.2.30 2002/04/11 10:46:19 easysw Exp $".
+// End of "$Id: Fl_Help_View.cxx,v 1.1.2.31 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Fl_Preferences.cxx b/src/Fl_Preferences.cxx
index 9f9c4288e..f0c44b0c8 100644
--- a/src/Fl_Preferences.cxx
+++ b/src/Fl_Preferences.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Preferences.cxx,v 1.1.2.12 2002/05/16 08:01:12 spitzak Exp $"
+// "$Id: Fl_Preferences.cxx,v 1.1.2.13 2002/05/16 12:47:43 easysw Exp $"
//
// Preferences methods for the Fast Light Tool Kit (FLTK).
//
@@ -318,28 +318,15 @@ static char *decodeText( const char *src )
char Fl_Preferences::get( const char *key, char *text, const char *defaultValue, int maxSize )
{
const char *v = node->get( key );
- if ( v && strchr( v, '\\' ) )
- {
+ if ( v && strchr( v, '\\' ) ) {
char *w = decodeText( v );
- strncpy( text, w, maxSize );
- if ( (int)strlen(w) >= maxSize ) text[maxSize] = 0;
+ strlcpy(text, w, maxSize);
free( w );
return 1;
- }
- if ( !v ) v = defaultValue;
- if ( v )
- {
- int vLen = strlen( v );
- if ( vLen >= maxSize )
- {
- strncpy( text, v, maxSize );
- text[maxSize] = 0;
- }
- else
- strcpy( text, v );
}
- else
- text = 0;
+ if ( !v ) v = defaultValue;
+ if ( v ) strlcpy(text, v, maxSize);
+ else text = 0;
return ( v != defaultValue );
}
@@ -676,13 +663,12 @@ Fl_Preferences::RootNode::RootNode( Fl_Preferences *prefs, Root root, const char
switch (root) {
case USER:
if ((e = getenv("HOME")) != NULL) {
- strncpy(filename, e, sizeof(filename) - 1);
- filename[sizeof(filename) - 1] = '\0';
+ strlcpy(filename, e, sizeof(filename));
if (filename[strlen(filename)-1] != '/') {
- strncat(filename, "/.fltk/", sizeof(filename) - 1);
+ strlcat(filename, "/.fltk/", sizeof(filename));
} else {
- strncat(filename, ".fltk/", sizeof(filename) - 1);
+ strlcat(filename, ".fltk/", sizeof(filename));
}
break;
}
@@ -776,8 +762,7 @@ int Fl_Preferences::RootNode::write()
// get the path to the preferences directory
char Fl_Preferences::RootNode::getPath( char *path, int pathlen )
{
- strncpy( path, filename_, pathlen - 1 );
- path[pathlen - 1] = '\0';
+ strlcpy( path, filename_, pathlen);
char *s;
for ( s = path; *s; s++ ) if ( *s == '\\' ) *s = '/';
@@ -928,8 +913,7 @@ void Fl_Preferences::Node::set( const char *line )
const char *c = strchr( line, ':' );
if ( c )
{
- strncpy( nameBuffer, line, c-line );
- nameBuffer[ c-line ] = 0;
+ strlcpy( nameBuffer, line, c-line+1);
set( nameBuffer, c+1 );
}
else
@@ -1000,7 +984,8 @@ Fl_Preferences::Node *Fl_Preferences::Node::find( const char *path )
}
const char *s = path+len+1;
const char *e = strchr( s, '/' );
- if ( e ) { strncpy( nameBuffer, s, e-s ); nameBuffer[ e-s ] = 0; } else strcpy( nameBuffer, s );
+ if (e) strlcpy( nameBuffer, s, e-s+1 );
+ else strlcpy( nameBuffer, s, sizeof(nameBuffer));
nd = new Node( nameBuffer );
nd->setParent( this );
return nd->find( path );
@@ -1081,5 +1066,5 @@ char Fl_Preferences::Node::remove()
//
-// End of "$Id: Fl_Preferences.cxx,v 1.1.2.12 2002/05/16 08:01:12 spitzak Exp $".
+// End of "$Id: Fl_Preferences.cxx,v 1.1.2.13 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx
index fba4d4800..68aafd9a8 100644
--- a/src/Fl_Text_Buffer.cxx
+++ b/src/Fl_Text_Buffer.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Text_Buffer.cxx,v 1.9.2.5 2002/05/03 20:30:19 easysw Exp $"
+// "$Id: Fl_Text_Buffer.cxx,v 1.9.2.6 2002/05/16 12:47:43 easysw Exp $"
//
// Copyright 2001-2002 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@@ -2034,8 +2034,7 @@ static char *copyLine( const char *text, int *lineLen ) {
for ( c = text; *c != '\0' && *c != '\n'; c++ )
len++;
outStr = (char *)malloc( len + 1 );
- strncpy( outStr, text, len );
- outStr[ len ] = '\0';
+ strlcpy( outStr, text, len + 1);
*lineLen = len;
return outStr;
}
@@ -2285,5 +2284,5 @@ Fl_Text_Buffer::outputfile(const char *file, int start, int end, int buflen) {
//
-// End of "$Id: Fl_Text_Buffer.cxx,v 1.9.2.5 2002/05/03 20:30:19 easysw Exp $".
+// End of "$Id: Fl_Text_Buffer.cxx,v 1.9.2.6 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Fl_display.cxx b/src/Fl_display.cxx
index f8b9b2aec..ddd2ac4b6 100644
--- a/src/Fl_display.cxx
+++ b/src/Fl_display.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_display.cxx,v 1.4.2.3.2.4 2002/04/11 11:52:42 easysw Exp $"
+// "$Id: Fl_display.cxx,v 1.4.2.3.2.5 2002/05/16 12:47:43 easysw Exp $"
//
// Display function for the Fast Light Tool Kit (FLTK).
//
@@ -36,11 +36,10 @@ void Fl::display(const char *d) {
#else
static char e[1024];
strcpy(e,"DISPLAY=");
- strncat(e,d,sizeof(e) - 1);
- e[sizeof(e) - 1] = '\0';
+ strlcat(e,d,sizeof(e));
for (char *c = e+8; *c!=':'; c++) {
if (!*c) {
- strncat(e,":0.0",sizeof(e) - 1);
+ strlcat(e,":0.0",sizeof(e));
break;
}
}
@@ -49,5 +48,5 @@ void Fl::display(const char *d) {
}
//
-// End of "$Id: Fl_display.cxx,v 1.4.2.3.2.4 2002/04/11 11:52:42 easysw Exp $".
+// End of "$Id: Fl_display.cxx,v 1.4.2.3.2.5 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Fl_get_system_colors.cxx b/src/Fl_get_system_colors.cxx
index 2ac699e3f..eb1a6e170 100644
--- a/src/Fl_get_system_colors.cxx
+++ b/src/Fl_get_system_colors.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.9 2002/04/27 19:35:18 easysw Exp $"
+// "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.10 2002/05/16 12:47:43 easysw Exp $"
//
// System color support for the Fast Light Tool Kit (FLTK).
//
@@ -233,10 +233,7 @@ int Fl::scheme(const char *s) {
// inherit it...
static char e[1024];
strcpy(e,"FLTK_SCHEME=");
- if (s) {
- strncat(e,s,sizeof(e) - 1);
- e[sizeof(e) - 1] = '\0';
- }
+ if (s) strlcat(e,s,sizeof(e));
putenv(e);
// Load the scheme...
@@ -316,5 +313,5 @@ int Fl::reload_scheme() {
//
-// End of "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.9 2002/04/27 19:35:18 easysw Exp $".
+// End of "$Id: Fl_get_system_colors.cxx,v 1.6.2.7.2.10 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/Makefile b/src/Makefile
index 5edf01141..33e2fba25 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile,v 1.18.2.14.2.42 2002/05/08 12:44:52 easysw Exp $"
+# "$Id: Makefile,v 1.18.2.14.2.43 2002/05/16 12:47:43 easysw Exp $"
#
# Library makefile for the Fast Light Tool Kit (FLTK).
#
@@ -170,9 +170,9 @@ GLCPPFILES = \
glut_compatability.cxx \
glut_font.cxx
-CFILES = fl_call_main.c scandir.c numericsort.c vsnprintf.c
+CFILES = fl_call_main.c flstring.c scandir.c numericsort.c vsnprintf.c
-CLEAN = core cmap
+CLEAN = core* cmap
################################################################
@@ -433,5 +433,5 @@ uninstall:
#
-# End of "$Id: Makefile,v 1.18.2.14.2.42 2002/05/08 12:44:52 easysw Exp $".
+# End of "$Id: Makefile,v 1.18.2.14.2.43 2002/05/16 12:47:43 easysw Exp $".
#
diff --git a/src/filename_absolute.cxx b/src/filename_absolute.cxx
index 1bce5fa9d..3f0f76bb8 100644
--- a/src/filename_absolute.cxx
+++ b/src/filename_absolute.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: filename_absolute.cxx,v 1.5.2.4.2.7 2002/03/25 21:08:42 easysw Exp $"
+// "$Id: filename_absolute.cxx,v 1.5.2.4.2.8 2002/05/16 12:47:43 easysw Exp $"
//
// Filename expansion routines for the Fast Light Tool Kit (FLTK).
//
@@ -55,8 +55,7 @@ int fl_filename_absolute(char *to, int tolen, const char *from) {
|| from[1]==':'
#endif
) {
- strncpy(to, from, tolen - 1);
- to[tolen - 1] = '\0';
+ strlcpy(to, from, tolen);
return 0;
}
@@ -66,8 +65,7 @@ int fl_filename_absolute(char *to, int tolen, const char *from) {
a = getcwd(temp, tolen);
if (!a) {
- strncpy(to, from, tolen - 1);
- to[tolen - 1] = '\0';
+ strlcpy(to, from, tolen);
delete[] temp;
return 0;
}
@@ -95,11 +93,9 @@ int fl_filename_absolute(char *to, int tolen, const char *from) {
}
*a++ = '/';
- strncpy(a,start,tolen - (a - temp) - 1);
- temp[tolen - 1] = '\0';
+ strlcpy(a,start,tolen - (a - temp));
- strncpy(to, temp, tolen - 1);
- to[tolen - 1] = '\0';
+ strlcpy(to, temp, tolen);
delete[] temp;
@@ -120,14 +116,12 @@ fl_filename_relative(char *to, // O - Relative filename
if (from[0] == '\0' || !isdirsep(*from)) {
- strncpy(to, from, tolen - 1);
- to[tolen - 1] = '\0';
+ strlcpy(to, from, tolen);
return 0;
}
if (!getcwd(cwd, sizeof(cwd))) {
- strncpy(to, from, tolen - 1);
- to[tolen - 1] = '\0';
+ strlcpy(to, from, tolen);
return 0;
}
@@ -150,8 +144,7 @@ fl_filename_relative(char *to, // O - Relative filename
#if defined(WIN32) || defined(__EMX__)
if (isalpha(slash[0]) && slash[1] == ':') {
- strncpy(to, from, tolen - 1);
- to[tolen - 1] = '\0';
+ strlcpy(to, from, tolen);
return 0; /* Different drive letter... */
}
#endif /* WIN32 || __EMX__ */
@@ -163,17 +156,17 @@ fl_filename_relative(char *to, // O - Relative filename
to[tolen - 1] = '\0';
while (*newslash != '\0') {
- if (isdirsep(*newslash)) strncat(to, "../", tolen - 1);
+ if (isdirsep(*newslash)) strlcat(to, "../", tolen);
newslash ++;
}
- strncat(to, slash, tolen - 1);
+ strlcat(to, slash, tolen);
return 1;
}
//
-// End of "$Id: filename_absolute.cxx,v 1.5.2.4.2.7 2002/03/25 21:08:42 easysw Exp $".
+// End of "$Id: filename_absolute.cxx,v 1.5.2.4.2.8 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/filename_expand.cxx b/src/filename_expand.cxx
index f50e06cf7..5165f3e5d 100644
--- a/src/filename_expand.cxx
+++ b/src/filename_expand.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: filename_expand.cxx,v 1.4.2.4.2.5 2002/04/11 11:52:42 easysw Exp $"
+// "$Id: filename_expand.cxx,v 1.4.2.4.2.6 2002/05/16 12:47:43 easysw Exp $"
//
// Filename expansion routines for the Fast Light Tool Kit (FLTK).
//
@@ -46,8 +46,7 @@ static inline int isdirsep(char c) {return c=='/' || c=='\\';}
int fl_filename_expand(char *to,int tolen, const char *from) {
char *temp = new char[tolen];
- strncpy(temp,from, tolen - 1);
- temp[tolen - 1] = '\0';
+ strlcpy(temp,from, tolen);
char *start = temp;
char *end = temp+strlen(temp);
@@ -96,8 +95,7 @@ int fl_filename_expand(char *to,int tolen, const char *from) {
}
}
- strncpy(to, start, tolen - 1);
- to[tolen - 1] = '\0';
+ strlcpy(to, start, tolen);
delete[] temp;
@@ -106,5 +104,5 @@ int fl_filename_expand(char *to,int tolen, const char *from) {
//
-// End of "$Id: filename_expand.cxx,v 1.4.2.4.2.5 2002/04/11 11:52:42 easysw Exp $".
+// End of "$Id: filename_expand.cxx,v 1.4.2.4.2.6 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/filename_setext.cxx b/src/filename_setext.cxx
index e2e9b8990..39fb3ee3a 100644
--- a/src/filename_setext.cxx
+++ b/src/filename_setext.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: filename_setext.cxx,v 1.4.2.3.2.4 2002/04/11 11:52:42 easysw Exp $"
+// "$Id: filename_setext.cxx,v 1.4.2.3.2.5 2002/05/16 12:47:43 easysw Exp $"
//
// Filename extension routines for the Fast Light Tool Kit (FLTK).
//
@@ -33,13 +33,12 @@
char *fl_filename_setext(char *buf, int buflen, const char *ext) {
char *q = (char *)fl_filename_ext(buf);
if (ext) {
- strncpy(q,ext,buflen - (q - buf) - 1);
- buf[buflen - 1] = '\0';
+ strlcpy(q,ext,buflen - (q - buf));
} else *q = 0;
return(buf);
}
//
-// End of "$Id: filename_setext.cxx,v 1.4.2.3.2.4 2002/04/11 11:52:42 easysw Exp $".
+// End of "$Id: filename_setext.cxx,v 1.4.2.3.2.5 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/fl_draw.cxx b/src/fl_draw.cxx
index 0e0463943..535bbcc46 100644
--- a/src/fl_draw.cxx
+++ b/src/fl_draw.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_draw.cxx,v 1.6.2.4.2.11 2002/04/11 11:52:42 easysw Exp $"
+// "$Id: fl_draw.cxx,v 1.6.2.4.2.12 2002/05/16 12:47:43 easysw Exp $"
//
// Label drawing code for the Fast Light Tool Kit (FLTK).
//
@@ -144,8 +144,7 @@ void fl_draw(
}
if (str && (p = strrchr(str, '@')) != NULL && p > (str + 1)) {
- strncpy(symbol[1], p, sizeof(symbol[1]) - 1);
- symbol[1][sizeof(symbol[1]) - 1] = '\0';
+ strlcpy(symbol[1], p, sizeof(symbol[1]));
symwidth[1] = min(w,h);
}
}
@@ -300,8 +299,7 @@ void fl_measure(const char* str, int& w, int& h, int draw_symbols) {
}
if (str && (p = strrchr(str, '@')) != NULL && p > (str + 1)) {
- strncpy(symbol[1], p, sizeof(symbol[1]) - 1);
- symbol[1][sizeof(symbol[1]) - 1] = '\0';
+ strlcpy(symbol[1], p, sizeof(symbol[1]));
symwidth[1] = min(w,h);
}
@@ -327,5 +325,5 @@ void fl_measure(const char* str, int& w, int& h, int draw_symbols) {
}
//
-// End of "$Id: fl_draw.cxx,v 1.6.2.4.2.11 2002/04/11 11:52:42 easysw Exp $".
+// End of "$Id: fl_draw.cxx,v 1.6.2.4.2.12 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/fl_file_dir.cxx b/src/fl_file_dir.cxx
index 1d3899a53..97c60a9a1 100644
--- a/src/fl_file_dir.cxx
+++ b/src/fl_file_dir.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_file_dir.cxx,v 1.1.2.11 2002/05/01 13:52:25 easysw Exp $"
+// "$Id: fl_file_dir.cxx,v 1.1.2.12 2002/05/16 12:47:43 easysw Exp $"
//
// File chooser widget for the Fast Light Tool Kit (FLTK).
//
@@ -23,7 +23,7 @@
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//
-#include <config.h>
+#include "flstring.h"
#include <FL/filename.H>
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_File_Chooser.H>
@@ -68,8 +68,7 @@ fl_file_chooser(const char *message, // I - Message in titlebar
if (fc->filter() != pat && (!pat || !fc->filter() ||
strcmp(pat, fc->filter())) && fc->value()) {
// if pattern is different, remove name but leave old directory:
- strncpy(retname, fc->value(), sizeof(retname) - 1);
- retname[sizeof(retname) - 1] = '\0';
+ strlcpy(retname, fc->value(), sizeof(retname));
char *p = strrchr(retname, '/');
@@ -143,5 +142,5 @@ fl_dir_chooser(const char *message, // I - Message for titlebar
//
-// End of "$Id: fl_file_dir.cxx,v 1.1.2.11 2002/05/01 13:52:25 easysw Exp $".
+// End of "$Id: fl_file_dir.cxx,v 1.1.2.12 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/fl_set_fonts_mac.cxx b/src/fl_set_fonts_mac.cxx
index 40502aff8..c35c1cf6f 100644
--- a/src/fl_set_fonts_mac.cxx
+++ b/src/fl_set_fonts_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_set_fonts_mac.cxx,v 1.1.2.5 2002/04/27 18:37:15 easysw Exp $"
+// "$Id: fl_set_fonts_mac.cxx,v 1.1.2.6 2002/05/16 12:47:43 easysw Exp $"
//
// MacOS font utilities for the Fast Light Tool Kit (FLTK).
//
@@ -107,7 +107,9 @@ int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
if (!s->name) s = fl_fonts; // empty slot in table, use entry 0
Str255 name;
- int len = strlen( s->name ); strncpy( (char*)(name+1), s->name+1, len ); name[0] = len-1;
+ int len = strlen( s->name );
+ memcpy(((char*)name)+1, s->name+1, len );
+ name[0] = len-1;
FMFontFamily family = FMGetFontFamilyFromName( name );
if ( family == kInvalidFontFamily ) return 0;
@@ -152,5 +154,5 @@ int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
}
//
-// End of "$Id: fl_set_fonts_mac.cxx,v 1.1.2.5 2002/04/27 18:37:15 easysw Exp $".
+// End of "$Id: fl_set_fonts_mac.cxx,v 1.1.2.6 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/fl_set_fonts_x.cxx b/src/fl_set_fonts_x.cxx
index 48fa9bffa..833715d86 100644
--- a/src/fl_set_fonts_x.cxx
+++ b/src/fl_set_fonts_x.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_set_fonts_x.cxx,v 1.1.2.2 2002/03/06 19:42:30 easysw Exp $"
+// "$Id: fl_set_fonts_x.cxx,v 1.1.2.3 2002/05/16 12:47:43 easysw Exp $"
//
// X11 font utilities for the Fast Light Tool Kit (FLTK).
//
@@ -115,7 +115,9 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
return p;
}
const char *e = fl_font_word(x,1);
- strncpy(o,x,e-x); o += e-x;
+ // MRS: we want strncpy here, not strlcpy...
+ strncpy(o,x,e-x);
+ o += e-x;
// collect all the attribute words:
int type = 0;
@@ -123,8 +125,12 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
// get the next word:
if (*e) e++; x = e; e = fl_font_word(x,1);
int t = attribute(n,x);
- if (t < 0) {*o++ = ' '; strncpy(o,x,e-x); o += e-x;}
- else type |= t;
+ if (t < 0) {
+ *o++ = ' ';
+ // MRS: we want strncpy here, not strlcpy...
+ strncpy(o,x,e-x);
+ o += e-x;
+ } else type |= t;
}
// skip over the '*' for the size and get the registry-encoding:
@@ -213,7 +219,7 @@ static int ultrasort(const void *aa, const void *bb) {
}
// converts a X font name to a standard starname, returns point size:
-static int to_canonical(char *to, const char *from) {
+static int to_canonical(char *to, const char *from, size_t tolen) {
char* c = fl_find_fontsize((char*)from);
if (!c) return -1; // no point size found...
const char* endptr;
@@ -227,9 +233,11 @@ static int to_canonical(char *to, const char *from) {
if (*endptr && !use_registry(endptr+1)) endptr = "";
}
int n = c-from;
+ // MRS: we want strncpy here, not strlcpy...
+ if (n > (int)(tolen - 1)) return -1;
strncpy(to,from,n);
to[n++] = '*';
- strcpy(to+n,endptr);
+ strlcpy(to+n,endptr, tolen - n);
return size;
}
@@ -253,13 +261,13 @@ Fl_Font Fl::set_fonts(const char* xstarname) {
int first_xlist = i;
const char *p = xlist[i++];
char canon[1024];
- int size = to_canonical(canon, p);
+ int size = to_canonical(canon, p, sizeof(canon));
if (size >= 0) {
for (;;) { // find all matching fonts:
if (i >= xlistsize) break;
const char *q = xlist[i];
char this_canon[1024];
- if (to_canonical(this_canon, q) < 0) break;
+ if (to_canonical(this_canon, q, sizeof(this_canon)) < 0) break;
if (strcmp(canon, this_canon)) break;
i++;
}
@@ -322,5 +330,5 @@ int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
}
//
-// End of "$Id: fl_set_fonts_x.cxx,v 1.1.2.2 2002/03/06 19:42:30 easysw Exp $".
+// End of "$Id: fl_set_fonts_x.cxx,v 1.1.2.3 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/flstring.c b/src/flstring.c
new file mode 100644
index 000000000..d456e391e
--- /dev/null
+++ b/src/flstring.c
@@ -0,0 +1,105 @@
+/*
+ * "$Id: flstring.c,v 1.1.2.1 2002/05/16 12:47:43 easysw Exp $"
+ *
+ * BSD string functions for the Fast Light Tool Kit (FLTK).
+ *
+ * Copyright 1998-2002 by Bill Spitzak and others.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ * Please report all bugs and problems to "fltk-bugs@fltk.org".
+ */
+
+#include "flstring.h"
+
+# if !HAVE_STRLCAT
+/*
+ * 'fl_strlcat()' - Safely concatenate two strings.
+ */
+
+size_t /* O - Length of string */
+fl_strlcat(char *dst, /* O - Destination string */
+ const char *src, /* I - Source string */
+ size_t size) { /* I - Size of destination string buffer */
+ size_t srclen; /* Length of source string */
+ size_t dstlen; /* Length of destination string */
+
+
+ /*
+ * Figure out how much room is left...
+ */
+
+ dstlen = strlen(dst);
+ size -= dstlen + 1;
+
+ if (!size) return (dstlen); /* No room, return immediately... */
+
+ /*
+ * Figure out how much room is needed...
+ */
+
+ srclen = strlen(src);
+
+ /*
+ * Copy the appropriate amount...
+ */
+
+ if (srclen > size) srclen = size;
+
+ memcpy(dst + dstlen, src, srclen);
+ dst[dstlen + srclen] = '\0';
+
+ return (dstlen + srclen);
+}
+# endif /* !HAVE_STRLCAT */
+
+# if !HAVE_STRLCPY
+/*
+ * 'fl_strlcat()' - Safely copy two strings.
+ */
+
+size_t /* O - Length of string */
+fl_strlcpy(char *dst, /* O - Destination string */
+ const char *src, /* I - Source string */
+ size_t size) { /* I - Size of destination string buffer */
+ size_t srclen; /* Length of source string */
+
+
+ /*
+ * Figure out how much room is needed...
+ */
+
+ size --;
+
+ srclen = strlen(src);
+
+ /*
+ * Copy the appropriate amount...
+ */
+
+ if (srclen > size) srclen = size;
+
+ memcpy(dst, src, srclen);
+ dst[srclen] = '\0';
+
+ return (srclen);
+}
+# endif /* !HAVE_STRLCPY */
+
+
+/*
+ * End of "$Id: flstring.c,v 1.1.2.1 2002/05/16 12:47:43 easysw Exp $".
+ */
diff --git a/src/flstring.h b/src/flstring.h
index f92404a5a..e3f612623 100644
--- a/src/flstring.h
+++ b/src/flstring.h
@@ -1,9 +1,9 @@
/*
- * "$Id: flstring.h,v 1.1.2.5 2002/04/29 20:56:19 easysw Exp $"
+ * "$Id: flstring.h,v 1.1.2.6 2002/05/16 12:47:43 easysw Exp $"
*
* Common string header file for the Fast Light Tool Kit (FLTK).
*
- * Copyright 1998-2001 by Bill Spitzak and others.
+ * Copyright 1998-2002 by Bill Spitzak and others.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -66,11 +66,26 @@ extern int fl_vsnprintf(char *, size_t, const char *, va_list ap);
# define vsnprintf fl_vsnprintf
# endif /* !HAVE_VSNPRINTF */
+/*
+ * strlcpy() and strlcat() are some really useful BSD string functions
+ * that work the way strncpy() and strncat() *should* have worked.
+ */
+
+# if !HAVE_STRLCAT
+extern size_t fl_strlcat(char *, const char *, size_t);
+# define strlcat fl_strlcat
+# endif /* !HAVE_STRLCAT */
+
+# if !HAVE_STRLCPY
+extern size_t fl_strlcpy(char *, const char *, size_t);
+# define strlcpy fl_strlcpy
+# endif /* !HAVE_STRLCPY */
+
# ifdef __cplusplus
}
# endif /* __cplusplus */
#endif /* !flstring_h */
/*
- * End of "$Id: flstring.h,v 1.1.2.5 2002/04/29 20:56:19 easysw Exp $".
+ * End of "$Id: flstring.h,v 1.1.2.6 2002/05/16 12:47:43 easysw Exp $".
*/
diff --git a/src/forms_fselect.cxx b/src/forms_fselect.cxx
index 7570b0479..50fb8728e 100644
--- a/src/forms_fselect.cxx
+++ b/src/forms_fselect.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: forms_fselect.cxx,v 1.4.2.3.2.3 2002/04/11 11:52:43 easysw Exp $"
+// "$Id: forms_fselect.cxx,v 1.4.2.3.2.4 2002/05/16 12:47:43 easysw Exp $"
//
// Forms file selection routines for the Fast Light Tool Kit (FLTK).
//
@@ -34,21 +34,21 @@ static char fl_filename[256];
char* fl_show_file_selector(const char *message,const char *dir,
const char *pat,const char *fname) {
- if (dir && dir[0]) strncpy(fl_directory,dir,1023);
+ if (dir && dir[0]) strlcpy(fl_directory,dir,sizeof(fl_directory));
if (pat && pat[0]) fl_pattern = pat;
- if (fname && fname[0]) strncpy(fl_filename,fname,255);
+ if (fname && fname[0]) strlcpy(fl_filename,fname,sizeof(fl_filename));
char *p = fl_directory+strlen(fl_directory);
if (p > fl_directory && *(p-1)!='/'
#ifdef WIN32
&& *(p-1)!='\\' && *(p-1)!=':'
#endif
) *p++ = '/';
- strcpy(p,fl_filename);
+ strlcpy(p,fl_filename,sizeof(fl_directory) - (p - fl_directory));
const char *q = fl_file_chooser(message,fl_pattern,fl_directory);
if (!q) return 0;
- strcpy(fl_directory, q);
+ strlcpy(fl_directory, q, sizeof(fl_directory));
p = (char *)fl_filename_name(fl_directory);
- strcpy(fl_filename, p);
+ strlcpy(fl_filename, p, sizeof(fl_directory));
if (p > fl_directory+1) p--;
*p = 0;
return (char *)q;
@@ -61,5 +61,5 @@ char* fl_get_pattern() {return (char *)fl_pattern;}
char* fl_get_filename() {return fl_filename;}
//
-// End of "$Id: forms_fselect.cxx,v 1.4.2.3.2.3 2002/04/11 11:52:43 easysw Exp $".
+// End of "$Id: forms_fselect.cxx,v 1.4.2.3.2.4 2002/05/16 12:47:43 easysw Exp $".
//
diff --git a/src/makedepend b/src/makedepend
index 6b4ee93a6..a46285408 100644
--- a/src/makedepend
+++ b/src/makedepend
@@ -116,7 +116,7 @@ Fl_Help_Dialog.o: ../FL/Fl_Window.H ../FL/Fl_Help_View.H ../FL/Fl.H
Fl_Help_Dialog.o: ../FL/Fl_Group.H ../FL/Fl_Widget.H ../FL/Fl_Scrollbar.H
Fl_Help_Dialog.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/fl_draw.H
Fl_Help_Dialog.o: ../FL/Fl_Shared_Image.H ../FL/Fl_Image.H ../FL/x.H
-Fl_Help_Dialog.o: ../FL/Fl_Button.H
+Fl_Help_Dialog.o: ../FL/Fl_Button.H flstring.h ../config.h
Fl_Help_View.o: ../FL/Fl_Help_View.H ../FL/Fl.H ../FL/Enumerations.H
Fl_Help_View.o: ../FL/Fl_Export.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
Fl_Help_View.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
@@ -339,19 +339,19 @@ fl_draw_pixmap.o: ../FL/Fl_Export.H ../FL/fl_draw.H ../FL/x.H
fl_draw_pixmap.o: ../FL/Fl_Window.H flstring.h
fl_engraved_label.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_engraved_label.o: ../FL/Fl_Widget.H ../FL/fl_draw.H
-fl_file_dir.o: ../config.h ../FL/filename.H ../FL/Fl_File_Chooser.H
-fl_file_dir.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
-fl_file_dir.o: ../FL/Fl_Window.H ../FL/Fl_Group.H ../FL/Fl_Widget.H
-fl_file_dir.o: ../FL/Fl_Choice.H ../FL/Fl_Menu_.H ../FL/Fl_Menu_Item.H
-fl_file_dir.o: ../FL/Fl_Button.H ../FL/fl_ask.H ../FL/Fl_File_Browser.H
-fl_file_dir.o: ../FL/Fl_Browser.H ../FL/Fl_Browser_.H ../FL/Fl_Scrollbar.H
-fl_file_dir.o: ../FL/Fl_Slider.H ../FL/Fl_Valuator.H ../FL/Fl_File_Icon.H
-fl_file_dir.o: ../FL/Fl.H ../FL/filename.H ../FL/Fl_File_Input.H
-fl_file_dir.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/Fl_Return_Button.H
-fl_file_dir.o: ../FL/Fl_Button.H
+fl_file_dir.o: flstring.h ../config.h ../FL/filename.H
+fl_file_dir.o: ../FL/Fl_File_Chooser.H ../FL/Fl.H ../FL/Enumerations.H
+fl_file_dir.o: ../FL/Fl_Export.H ../FL/Fl_Window.H ../FL/Fl_Group.H
+fl_file_dir.o: ../FL/Fl_Widget.H ../FL/Fl_Choice.H ../FL/Fl_Menu_.H
+fl_file_dir.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Button.H ../FL/fl_ask.H
+fl_file_dir.o: ../FL/Fl_File_Browser.H ../FL/Fl_Browser.H ../FL/Fl_Browser_.H
+fl_file_dir.o: ../FL/Fl_Scrollbar.H ../FL/Fl_Slider.H ../FL/Fl_Valuator.H
+fl_file_dir.o: ../FL/Fl_File_Icon.H ../FL/Fl.H ../FL/filename.H
+fl_file_dir.o: ../FL/Fl_File_Input.H ../FL/Fl_Input.H ../FL/Fl_Input_.H
+fl_file_dir.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H
fl_font.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_font.o: ../FL/fl_draw.H ../FL/x.H ../FL/Fl_Window.H Fl_Font.H flstring.h
-fl_font.o: fl_font_xft.cxx
+fl_font.o: fl_font_x.cxx
fl_labeltype.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_labeltype.o: ../FL/Fl_Widget.H ../FL/Fl_Group.H ../FL/fl_draw.H
fl_labeltype.o: ../FL/Fl_Image.H ../FL/x.H ../FL/Fl_Window.H
@@ -375,7 +375,7 @@ fl_set_font.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_set_font.o: ../FL/x.H ../FL/Fl_Window.H Fl_Font.H flstring.h
fl_set_fonts.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_set_fonts.o: ../FL/x.H ../FL/Fl_Window.H Fl_Font.H flstring.h
-fl_set_fonts.o: fl_set_fonts_xft.cxx
+fl_set_fonts.o: fl_set_fonts_x.cxx
fl_scroll_area.o: ../FL/x.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_scroll_area.o: ../FL/Fl_Window.H
fl_shadow_box.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
@@ -412,6 +412,7 @@ glut_compatability.o: ../FL/Fl_Menu_Item.H ../FL/Fl_Widget.H
glut_font.o: ../config.h ../FL/glut.H ../FL/gl.h ../FL/Enumerations.H
glut_font.o: ../FL/Fl_Export.H ../FL/Fl.H ../FL/Fl_Gl_Window.H
glut_font.o: ../FL/Fl_Window.H
+flstring.o: flstring.h ../config.h
scandir.o: flstring.h ../config.h
numericsort.o: ../config.h ../FL/filename.H
vsnprintf.o: flstring.h ../config.h