From d7a20664dbe3d5540bede5fd5f7d1bc28e8bce75 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 20 Oct 2000 13:13:38 +0000 Subject: [PATCH] A small lyxlib.h cleanup git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1143 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 10 ++++++ src/support/chdir.C | 9 ----- src/support/lyxlib.h | 84 +++++++++++++------------------------------- src/support/lyxsum.C | 9 ++--- src/support/rename.C | 5 --- 5 files changed, 37 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index f0a9b7e52b..601957ebdd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-10-20 Jean-Marc Lasgouttes + + * src/support/lyxlib.h: unify namespace/struct implementation. + Remove extra declarations. + + * src/support/chdir.C (chdir): remove version taking char const * + argument. + * src/support/rename.C: ditto. + * src/support/lyxsum.C: ditto. + 2000-10-19 Angus Leeming * src/frontends/xforms/FormBase.[Ch]: diff --git a/src/support/chdir.C b/src/support/chdir.C index f80e989036..1f630a465d 100644 --- a/src/support/chdir.C +++ b/src/support/chdir.C @@ -4,15 +4,6 @@ #include "support/lyxlib.h" -int lyx::chdir(char const * name) -{ -#ifndef __EMX__ - return ::chdir(name); -#else - return ::_chdir2(name); -#endif -} - int lyx::chdir(string const & name) { #ifndef __EMX__ diff --git a/src/support/lyxlib.h b/src/support/lyxlib.h index acaa2b0e4e..befb7bd6f8 100644 --- a/src/support/lyxlib.h +++ b/src/support/lyxlib.h @@ -18,82 +18,48 @@ // three/four times. Don't you think it better to use a macro definition // (an inlined member of some class)? -// This should have been a namespace +// Use a namespace if we can, a struct otherwise #ifdef CXX_WORKING_NAMESPACES -/// +#define OPT_STATIC namespace lyx { +#else +#define OPT_STATIC static +struct lyx { +#endif /// - char * getcwd(char * buffer, size_t size); - /// - int chdir(char const * name); + OPT_STATIC char * getcwd(char * buffer, size_t size); /// - int chdir(string const & name); - /// Returns false it it fails - bool rename(char const * from, char const * to); + OPT_STATIC int chdir(string const & name); /// Returns false if it fails - bool rename(string const & from, string const & to); + OPT_STATIC bool rename(string const & from, string const & to); /// Returns false it it fails - bool copy(string const & from, string const & to); + OPT_STATIC bool copy(string const & from, string const & to); /// generates a checksum - unsigned long sum(char const * file); - /// generates a checksum - unsigned long sum(string const & file); + OPT_STATIC unsigned long sum(string const & file); /// returns a date string (not used currently) - char * date(); + OPT_STATIC char * date(); /// returns the name of the user (not used currently) - string const getUserName(); + OPT_STATIC string const getUserName(); /// - int kill(int pid, int sig); + OPT_STATIC int kill(int pid, int sig); /// - void abort(); + OPT_STATIC void abort(); /// - int mkdir(string const & pathname, unsigned long int mode); + OPT_STATIC int mkdir(string const & pathname, unsigned long int mode); /// - int putenv(char const * str); + OPT_STATIC int putenv(char const * str); /// - int unlink(string const & file); + OPT_STATIC int unlink(string const & file); /// - int rmdir(string const & file); + OPT_STATIC int rmdir(string const & file); /// - int atoi(string const & nstr); + OPT_STATIC int atoi(string const & nstr); +#ifdef CXX_WORKING_NAMESPACES } #else -/// -struct lyx { - /// - static char * getcwd(char * buffer, size_t size); - /// - static int chdir(char const * name); - /// - static int chdir(string const & name); - /// Returns false it it fails - static bool rename(char const * from, char const * to); - /// Returns false if it fails - static bool rename(string const & from, string const & to); - /// Returns false it it fails - static bool copy(string const & from, string const & to); - /// generates a checksum - static unsigned long sum(char const * file); - /// generates a checksum - static unsigned long sum(string const & file); - /// returns a date string (not used currently) - static char * date(); - /// returns the name of the user (not used currently) - static string const getUserName(); - /// - static int kill(int pid, int sig); - /// - static void abort(); - /// - static int mkdir(string const & pathname, unsigned long int mode); - /// - static int putenv(char const * str); - /// - static int unlink(string const & file); - /// - static int rmdir(string const & file); - /// - static int atoi(string const & nstr); }; -#endif // CXX_WORKING_NAMESPACES #endif + +#undef OPT_STATIC + +#endif /* LYX_LIB_H */ diff --git a/src/support/lyxsum.C b/src/support/lyxsum.C index 691ff2e71d..8980a3f8ae 100644 --- a/src/support/lyxsum.C +++ b/src/support/lyxsum.C @@ -106,9 +106,9 @@ unsigned long do_crc(InputIterator first, InputIterator last) // And this would be the file interface. -unsigned long lyx::sum(char const * file) +unsigned long lyx::sum(string const & file) { - ifstream ifs(file); + ifstream ifs(file.c_str()); if (!ifs) return 0; ifs.unsetf(ios::skipws); ostringstream ostr; @@ -119,8 +119,3 @@ unsigned long lyx::sum(char const * file) return do_crc(w.begin(), w.end()); } - -unsigned long lyx::sum(string const & file) -{ - return lyx::sum(file.c_str()); -} diff --git a/src/support/rename.C b/src/support/rename.C index 7a04be730a..bd619347e0 100644 --- a/src/support/rename.C +++ b/src/support/rename.C @@ -4,11 +4,6 @@ #include "support/lyxlib.h" -bool lyx::rename(char const * from, char const * to) -{ - return ::rename(from, to) != -1; -} - bool lyx::rename(string const & from, string const & to) { return ::rename(from.c_str(), to.c_str()) != -1; -- 2.39.5