summaryrefslogtreecommitdiff
path: root/src/filename_absolute.cxx
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/filename_absolute.cxx
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/filename_absolute.cxx')
-rw-r--r--src/filename_absolute.cxx29
1 files changed, 11 insertions, 18 deletions
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 $".
//