CVSROOT: /sources/gnash Module name: gnash Branch: release_0_8_1 Changes by: Sandro Santilli <strk> 07/08/20 18:09:29
Modified files: . : ChangeLog configure.ac doc/C/usermanual/usage: gnashrc.xml libbase : rc.cpp rc.h Log message: Tilde expansion (patch #6158) by Benjamin Wolsey <[EMAIL PROTECTED]>: * configure.ac: look for the pwd.h header * doc/C/usermanual/usage/gnashrc.xml: add info about tilde expansion. * libbase/rc.{cpp,h}: add support for tilde expansion in debugLog value. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.3971.2.47&r2=1.3971.2.48 http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.396.2.5&r2=1.396.2.6 http://cvs.savannah.gnu.org/viewcvs/gnash/doc/C/usermanual/usage/gnashrc.xml?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.5.2.1&r2=1.5.2.2 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.cpp?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.27.2.1&r2=1.27.2.2 http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.h?cvsroot=gnash&only_with_tag=release_0_8_1&r1=1.21.2.1&r2=1.21.2.2 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.3971.2.47 retrieving revision 1.3971.2.48 diff -u -b -r1.3971.2.47 -r1.3971.2.48 --- ChangeLog 20 Aug 2007 16:39:33 -0000 1.3971.2.47 +++ ChangeLog 20 Aug 2007 18:09:27 -0000 1.3971.2.48 @@ -1,3 +1,10 @@ +2007-08-20 Benjamin Wolsey <[EMAIL PROTECTED]> + + * configure.ac: look for the pwd.h header + * doc/C/usermanual/usage/gnashrc.xml: add info about tilde expansion. + * libbase/rc.{cpp,h}: add support for tilde expansion in debugLog + value. + 2007-08-20 Sandro Santilli <[EMAIL PROTECTED]> * libbase/log.{cpp,h}: print an error on stderr of the debug log file Index: configure.ac =================================================================== RCS file: /sources/gnash/gnash/configure.ac,v retrieving revision 1.396.2.5 retrieving revision 1.396.2.6 diff -u -b -r1.396.2.5 -r1.396.2.6 --- configure.ac 18 Aug 2007 12:37:18 -0000 1.396.2.5 +++ configure.ac 20 Aug 2007 18:09:28 -0000 1.396.2.6 @@ -15,7 +15,7 @@ dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA dnl -dnl $Id: configure.ac,v 1.396.2.5 2007/08/18 12:37:18 strk Exp $ +dnl $Id: configure.ac,v 1.396.2.6 2007/08/20 18:09:28 strk Exp $ AC_PREREQ(2.50) AC_INIT(gnash, 0.8.1) @@ -773,6 +773,7 @@ AC_CHECK_HEADERS(malloc.h) AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(libgen.h) +AC_CHECK_HEADERS(pwd.h) AC_CHECK_LIB(m, sqrt) dnl don't look for X11 when using a raw framebuffer for the GUI Index: doc/C/usermanual/usage/gnashrc.xml =================================================================== RCS file: /sources/gnash/gnash/doc/C/usermanual/usage/gnashrc.xml,v retrieving revision 1.5.2.1 retrieving revision 1.5.2.2 diff -u -b -r1.5.2.1 -r1.5.2.2 --- doc/C/usermanual/usage/gnashrc.xml 19 Aug 2007 20:22:03 -0000 1.5.2.1 +++ doc/C/usermanual/usage/gnashrc.xml 20 Aug 2007 18:09:28 -0000 1.5.2.2 @@ -117,7 +117,9 @@ <listitem> <para> This is the full path and name of debug logfile as - produced by Gnash. + produced by &app;. On systems with a UNIX-type shell, + a tilde prefix (~) will be expanded as by Posix shell requirements + (see http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_01). </para> </listitem> </varlistentry> Index: libbase/rc.cpp =================================================================== RCS file: /sources/gnash/gnash/libbase/rc.cpp,v retrieving revision 1.27.2.1 retrieving revision 1.27.2.2 diff -u -b -r1.27.2.1 -r1.27.2.2 --- libbase/rc.cpp 19 Aug 2007 20:22:03 -0000 1.27.2.1 +++ libbase/rc.cpp 20 Aug 2007 18:09:28 -0000 1.27.2.2 @@ -22,6 +22,10 @@ # include "config.h" #endif +#ifdef HAVE_PWD_H +# include <pwd.h> +#endif + #include <sys/types.h> #include <sys/stat.h> @@ -144,6 +148,65 @@ return *num; } +string +RcInitFile::expandTilde (std::string& unixpath) + +{ +string _expanded; + + //Only if path starts with "~" + if (unixpath.substr(0,1) == "~") { + const char *home = getenv("HOME"); + if (unixpath.substr(1,2) == "/") { + // Initial "~" followed by "/" + if (home) { + // if HOME set in env, replace ~ with HOME + _expanded = unixpath.replace(0,1,home); + } + //HOME not set in env: try using pwd + else { + struct passwd *password = getpwuid(getuid()); + const char *pwdhome = password->pw_dir; + if (home) { _expanded = unixpath.replace(0,1,pwdhome); } + //If all that fails, leave path alone + else _expanded = unixpath; + } + } + + //Initial "~" is not followed by "/" + else { + const char *userhome = NULL; + string::size_type first_slash = unixpath.find_first_of("/"); + string user; + if (first_slash != string::npos) { + // everything between initial ~ and / + user = unixpath.substr(1, first_slash - 1 ); + } + + //find user using pwd + struct passwd *password = getpwnam(user.c_str()); + if (password) { + //User found + userhome = password->pw_dir; + } + if (userhome) { + string foundhome(userhome); + _expanded = unixpath.replace(0,first_slash,foundhome); + } + else { + //User not found and/or pwd doesn't return homedir: + //Leave path alone. + _expanded = unixpath; + } + } + } + //Path doesn't start with ~, leave it alone. + else { + _expanded = unixpath; + } + return _expanded; +} + // Parse the config file and set the variables. bool RcInitFile::parseFile(const std::string& filespec) @@ -211,7 +274,14 @@ } if (variable == "debuglog") { + +#ifdef HAVE_PWD_H + _log = expandTilde (value); +#else +//For non-UNIX systems _log = value; +#endif + } if (variable == "documentroot") { Index: libbase/rc.h =================================================================== RCS file: /sources/gnash/gnash/libbase/rc.h,v retrieving revision 1.21.2.1 retrieving revision 1.21.2.2 diff -u -b -r1.21.2.1 -r1.21.2.2 --- libbase/rc.h 19 Aug 2007 20:22:03 -0000 1.21.2.1 +++ libbase/rc.h 20 Aug 2007 18:09:29 -0000 1.21.2.2 @@ -102,6 +102,8 @@ static int extractNumber(int *num, const char *pattern, std::string &variable, std::string &value); + static std::string expandTilde(std::string& unixpath); + const std::vector<std::string>& getWhiteList() const { return _whitelist; } const std::vector<std::string>& getBlackList() const { return _blacklist; } _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit