From: Kern Sibbald Date: Sat, 20 Mar 2004 08:02:14 +0000 (+0000) Subject: Restore old split path in sql.c X-Git-Tag: Release-1.34.0~40 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=edc565f84969772d34b22be2e2ecf199b0a76ab5;p=bacula%2Fbacula Restore old split path in sql.c git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1144 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 50b96467c7..26144925ac 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -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); } /* diff --git a/bacula/src/console/conio.c b/bacula/src/console/conio.c index 7447ead95e..88eb1865e5 100755 --- a/bacula/src/console/conio.c +++ b/bacula/src/console/conio.c @@ -43,8 +43,9 @@ #endif -#include +#ifdef HAVE_TERMCAP_H #include +#endif #include "func.h" diff --git a/bacula/src/count-lines b/bacula/src/count-lines index f2c989bb3b..0afd52dd4e 100755 --- a/bacula/src/count-lines +++ b/bacula/src/count-lines @@ -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 diff --git a/bacula/src/version.h b/bacula/src/version.h index 14779d9cc0..a1c8b22943 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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