]> git.sur5r.net Git - bacula/bacula/commitdiff
Restore old split path in sql.c
authorKern Sibbald <kern@sibbald.com>
Sat, 20 Mar 2004 08:02:14 +0000 (08:02 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Mar 2004 08:02:14 +0000 (08:02 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1144 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/sql.c
bacula/src/console/conio.c
bacula/src/count-lines
bacula/src/version.h

index 50b96467c799156d35af27248ec06191ebccc48e..26144925acbda794b8aafa645c3067149b5a28bb 100644 (file)
@@ -299,20 +299,55 @@ void db_end_transaction(JCR *jcr, B_DB *mdb)
  */
 void split_path_and_file(JCR *jcr, B_DB *mdb, const char *fname)
 {
-   split_path_and_filename(fname, &mdb->path, &mdb->pnl, &mdb->fname, &mdb->fnl);
-   if (mdb->fnl == 0) {
+   const char *p, *f;
+
+   /* Find path without the filename.  
+    * I.e. everything after the last / is a "filename".
+    * OK, maybe it is a directory name, but we treat it like
+    * a filename. If we don't find a / then the whole name
+    * must be a path name (e.g. c:).
+    */
+   for (p=f=fname; *p; p++) {
+      if (*p == '/') {
+        f = p;                       /* set pos of last slash */
+      }
+   }
+   if (*f == '/') {                   /* did we find a slash? */
+      f++;                           /* yes, point to filename */
+   } else {                          /* no, whole thing must be path name */
+      f = p;
+   }
+
+   /* If filename doesn't exist (i.e. root directory), we
+    * simply create a blank name consisting of a single 
+    * space. This makes handling zero length filenames
+    * easier.
+    */
+   mdb->fnl = p - f;
+   if (mdb->fnl > 0) {
+      mdb->fname = check_pool_memory_size(mdb->fname, mdb->fnl+1);
+      memcpy(mdb->fname, f, mdb->fnl);   /* copy filename */
+      mdb->fname[mdb->fnl] = 0;
+   } else {
       mdb->fname[0] = ' ';            /* blank filename */
       mdb->fname[1] = 0;
       mdb->fnl = 1;
    }
-   if (mdb->pnl == 0) {   
+
+   mdb->pnl = f - fname;    
+   if (mdb->pnl > 0) {
+      mdb->path = check_pool_memory_size(mdb->path, mdb->pnl+1);
+      memcpy(mdb->path, fname, mdb->pnl);
+      mdb->path[mdb->pnl] = 0;
+   } else {
       Mmsg1(&mdb->errmsg, _("Path length is zero. File=%s\n"), fname);
       Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
       mdb->path[0] = ' ';
       mdb->path[1] = 0;
       mdb->pnl = 1;
    }
-   Dmsg2(400, "split path=%s file=%s\n", mdb->path, mdb->fname);
+
+   Dmsg2(100, "sllit path=%s file=%s\n", mdb->path, mdb->fname);
 }
 
 /*
index 7447ead95e44beaa45364eab00605c762aad0e5a..88eb1865e50b660c56a283d9bec9db0d55d86bb1 100755 (executable)
@@ -43,8 +43,9 @@
 
 #endif
 
-#include <termios.h>
+#ifdef HAVE_TERMCAP_H
 #include <termcap.h>
+#endif
 #include "func.h"
 
 
index f2c989bb3bdc298f10ccbfbe51cebc9129a8b777..0afd52dd4ea1e4f5f52e9888b6cf6407fe53fa5b 100755 (executable)
@@ -2,7 +2,7 @@
 rm -f 1
 touch 1
 for i in . console gnome-console cats dird filed filed/win32 win32 findlib lib stored tools; do
-  ls -1 $i/*.c $i/*.cpp $i/*.h $i/*.in >>1
+  ls -1 $i/*.c $i/*.cpp $i/*.h $i/*.in 2>/dev/null >>1
 done
 cat 1 | $HOME/bin/lines
 # rm -f 1
index 14779d9cc0759bba87cb83a9aed5643f0ae1b581..a1c8b2294395f2a008634c6f31da7b6d7d93a5cd 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.33.4"
 #define VSTRING "1"
-#define BDATE   "19 Mar 2004"
-#define LSMDATE "19Mar04"
+#define BDATE   "20 Mar 2004"
+#define LSMDATE "20Mar04"
 
 /* Debug flags */
 #undef  DEBUG