There's no point having unused files in CVS, and there are several points against.
Can we remove support/strerror.C too ? What uses it when ? regards john -- "I never understood what's so hard about picking a unique first and last name - and not going beyond the 6 character limit." - Toon Moene
diff -u -r1.105 ChangeLog --- src/support/ChangeLog 22 May 2002 01:16:37 -0000 1.105 +++ src/support/ChangeLog 22 May 2002 23:13:19 -0000 @@ -1,3 +1,22 @@ +2002-05-22 John Levon <[EMAIL PROTECTED]> + + * Makefile.am: + * date.C: + * getUserName.C: + * fileblocks.c: + * StrPool.h: + * StrPool.C: remove unused files + + * lyxalgo.h: + * lyxlib.h: + * mkdir.C: + * path.h: + * path.C: + * systemcall.C: + * textutils.h: + * translator.h: + * types.h: document and small cleanups + 2002-05-22 Lars Gullik Bjønnes <[EMAIL PROTECTED]> * forkedcall.h: use more specific smart_ptr header. diff -u -r1.44 Makefile.am --- src/support/Makefile.am 25 Mar 2002 11:15:27 -0000 1.44 +++ src/support/Makefile.am 22 May 2002 23:13:19 -0000 @@ -29,13 +29,10 @@ LSubstring.h \ os.C \ os.h \ - StrPool.C \ - StrPool.h \ abort.C \ atoi.C \ chdir.C \ copy.C \ - date.C \ filetools.C \ filetools.h \ fmt.C \ @@ -43,7 +40,6 @@ forkedcall.h \ forkedcontr.C \ forkedcontr.h \ - getUserName.C \ getcwd.C \ kill.C \ lstrings.C \ Index: src/support/StrPool.C =================================================================== RCS file: src/support/StrPool.C diff -N src/support/StrPool.C --- src/support/StrPool.C 21 Mar 2002 17:06:35 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,41 +0,0 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000-2001 Jean-Marc Lasgouttes - * - * ======================================================*/ - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include <config.h> -#include "StrPool.h" - - -StrPool::~StrPool() -{ - for (Pool::const_iterator cit = pool_.begin(); - cit != pool_.end() ; ++cit) { - delete[] (*cit); - } -} - -/* One interesting thing here would be to store the strings in a map, - so that one string is only stored once. This would make things a - bit slower, but memory requirements would be lower in the long run. - I expect that it would be fast enough anyway. (Lgb) -*/ -char const * StrPool::add(string const & str) -{ - string::size_type s = str.length(); - char * buf = new char [s + 1]; - str.copy(buf, s); - buf[s] = '\0'; - pool_.push_back(buf); - return buf; -} - -//StrPool strPool; Index: src/support/StrPool.h =================================================================== RCS file: src/support/StrPool.h diff -N src/support/StrPool.h --- src/support/StrPool.h 21 Mar 2002 17:06:35 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,39 +0,0 @@ -// -*- C++ -*- -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 2000-2001 Jean-Marc Lasgouttes - * - * ======================================================*/ - - -#ifndef STRPOOL_H -#define STRPOOL_H - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "LString.h" -#include <vector> - -/// -class StrPool { -public: - /// delete all the strings that have been allocated by add() - ~StrPool(); - /// Make a copy of the string, and remember it in the pool - char const * add(string const & str); - -private: - /// - typedef std::vector<char const *> Pool; - /// - Pool pool_; -}; - -//extern StrPool strPool; - -#endif Index: src/support/date.C =================================================================== RCS file: src/support/date.C diff -N src/support/date.C --- src/support/date.C 17 Jan 2000 21:01:30 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,14 +0,0 @@ -#include <config.h> - -#include <time.h> - -#include "support/lyxlib.h" - -char * lyx::date() -{ - time_t tid; - if ((tid = ::time(0)) == static_cast<time_t>(-1)) - return 0; - else - return ::ctime(&tid); -} Index: src/support/fileblocks.c =================================================================== RCS file: src/support/fileblocks.c diff -N src/support/fileblocks.c --- src/support/fileblocks.c 2 Oct 1999 16:21:10 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,70 +0,0 @@ -/* Convert file size to number of blocks on System V-like machines. - Copyright (C) 1990 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/* Written by Brian L. Matthews, [EMAIL PROTECTED] */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#if !defined (HAVE_ST_BLOCKS) && !defined(_POSIX_VERSION) -# include <sys/types.h> -# include <sys/param.h> - -# ifndef NINDIR -/* Some SysV's, like Irix, seem to lack these. Hope they're correct. */ -/* Size of a indirect block, in bytes. */ -# ifndef BSIZE -# define BSIZE 1024 -# endif - -/* Number of inode pointers per indirect block. */ -# define NINDIR (BSIZE/sizeof(daddr_t)) -# endif /* !NINDIR */ - -/* Number of direct block addresses in an inode. */ -# define NDIR 10 - -/* Return the number of 512-byte blocks in a file of SIZE bytes. */ - -long -st_blocks (size) - long size; -{ - long datablks = (size + 512 - 1) / 512; - long indrblks = 0; - - if (datablks > NDIR) - { - indrblks = (datablks - NDIR - 1) / NINDIR + 1; - - if (datablks > NDIR + NINDIR) - { - indrblks += (datablks - NDIR - NINDIR - 1) / (NINDIR * NINDIR) + 1; - - if (datablks > NDIR + NINDIR + NINDIR * NINDIR) - indrblks++; - } - } - - return datablks + indrblks; -} -#else -/* This declaration is solely to ensure that after preprocessing - this file is never empty. */ -extern int textutils_fileblocks_unused; -#endif diff -N src/support/getUserName.C --- src/support/getUserName.C 14 Sep 2000 17:53:12 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,15 +0,0 @@ -#include <config.h> - -#include "support/lyxlib.h" -#include "support/filetools.h" -#include "gettext.h" - -string const lyx::getUserName() -{ - string userName(GetEnv("LOGNAME")); - if (userName.empty()) - userName = GetEnv("USER"); - if (userName.empty()) - userName = _("unknown"); - return userName; -} diff -u -r1.8 lyxalgo.h --- src/support/lyxalgo.h 21 Mar 2002 17:06:35 -0000 1.8 +++ src/support/lyxalgo.h 22 May 2002 23:13:23 -0000 @@ -1,4 +1,15 @@ // -*- C++ -*- +/** + * \file lyxalgo.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING + * + * A variety of useful templates. + * + * \author unknown + */ + + #ifndef LYX_ALGO_H #define LYX_ALGO_H @@ -44,6 +55,10 @@ }; +/** + * copy elements in the given range to the output iterator + * if the predicate evaluates as true + */ template <class InputIter, class OutputIter, class Func> OutputIter copy_if(InputIter first, InputIter last, OutputIter result, Func func) @@ -74,4 +89,4 @@ } // namespace lyx -#endif +#endif // LYX_ALGO_H Index: src/support/lyxlib.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/lyxlib.h,v retrieving revision 1.27 diff -u -r1.27 lyxlib.h --- src/support/lyxlib.h 21 Mar 2002 17:06:35 -0000 1.27 +++ src/support/lyxlib.h 22 May 2002 23:13:23 -0000 @@ -1,67 +1,58 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file lyxlib.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor + * A selection of useful system functions made + * handy for C++ usage. * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * \author unknown + */ #ifndef LYX_LIB_H #define LYX_LIB_H #include "LString.h" -// Where can I put this? I found the occurence of the same code -// three/four times. Don't you think it better to use a macro definition -// (an inlined member of some class)? - -// Use a namespace if we can, a struct otherwise namespace lyx { -/// +/// get the current working directory string const getcwd(); -/// +/// change to a directory, 0 is returned on success. int chdir(string const & name); -/// Returns false if it fails +/** + * rename a file, returns false if it fails. + * It can handle renames across partitions. + */ bool rename(string const & from, string const & to); -/// Returns false it it fails +/// copy a file, returns false it it fails bool copy(string const & from, string const & to); -/// generates a checksum +/// generates a checksum of a file unsigned long sum(string const & file); -/// returns a date string (not used currently) -char * date(); -/// returns the name of the user (not used currently) -string const getUserName(); -/// +/// FIXME: some point to this hmm ? int kill(int pid, int sig); -/// +/// FIXME: same here void abort(); -/// +/// create the given directory with the given mode int mkdir(string const & pathname, unsigned long int mode); -/// +/// put a C string into the environment int putenv(char const * str); -/// +/// unlink the given file int unlink(string const & file); -/// +/// remove the given directory int rmdir(string const & file); -/// +/// convert the given string to an integer int atoi(string const & nstr); -/// +/// (securely) create a temporary file in the given dir with the given prefix string const tempName(string const & dir = string(), string const & mask = string()); -/** Returns true if var is approximately equal to number with allowed error +/** + * Returns true if var is approximately equal to number with allowed error * of 'error'. * - * Reason: A float can be very close to the number, yet still need not be - * exactly equal, you can have exp(-10) which is very close to zero but not - * zero. If you only need an approximate equality (you usually do), use this - * template. - * * Usage: if (float_equal(var, number, 0.0001)) { } * * This will check if 'var' is approx. equal to 'number' with error of 1/1000 @@ -72,4 +63,5 @@ } } // namespace lyx + #endif /* LYX_LIB_H */ Index: src/support/mkdir.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/mkdir.C,v retrieving revision 1.5 diff -u -r1.5 mkdir.C --- src/support/mkdir.C 19 Oct 2000 10:04:36 -0000 1.5 +++ src/support/mkdir.C 22 May 2002 23:13:23 -0000 @@ -11,5 +11,6 @@ int lyx::mkdir(string const & pathname, unsigned long int mode) { + // FIXME: why don't we have mode_t in lyx::mkdir prototype ?? return ::mkdir(pathname.c_str(), mode_t(mode)); } Index: src/support/path.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path.C,v retrieving revision 1.4 diff -u -r1.4 path.C --- src/support/path.C 21 Mar 2002 17:06:35 -0000 1.4 +++ src/support/path.C 22 May 2002 23:13:23 -0000 @@ -1,3 +1,11 @@ +/** + * \file path.C + * Copyright 1995-2002 the LyX Team + * Read the file COPYING + * + * \author unknown + */ + #include <config.h> #ifdef __GNUG__ @@ -11,21 +19,14 @@ if (popped_) { // should throw an exception // throw logical_error(); - // The use of WriteFSAlerrt makes this impossible - // to inline. - //Alert::err_alert(_("Error: Dir already popped: "), - // pushedDir_); return 0; } + if (lyx::chdir(pushedDir_)) { // should throw an exception // throw DirChangeError(); - // The use of Alert::err_alert makes this impossible - // to inline. - //Alert::err_alert( - // _("Error: Could not change to directory: "), - // pushedDir_); } popped_ = true; + return 0; } Index: src/support/path.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path.h,v retrieving revision 1.14 diff -u -r1.14 path.h --- src/support/path.h 21 Mar 2002 17:06:35 -0000 1.14 +++ src/support/path.h 22 May 2002 23:13:23 -0000 @@ -1,4 +1,12 @@ // -*- C++ -*- +/** + * \file path.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING + * + * \author unknown + */ + #ifndef PATH_H #define PATH_H @@ -11,39 +19,48 @@ #pragma interface #endif -/// + +/** + * Path - utility closs for stackable working directories + * + * You can use a local variable of this type to temporarily + * change to a directory as the cwd, for example : + * + * if (blah) { + * Path p("/tmp/blah"); + * ... + * } + * + * At the end of p's scope the cwd is reset to its previous value. + */ class Path : boost::noncopyable { public: - /// + /// change to the given directory explicit Path(string const & path) : popped_(false) { - if (!path.empty()) { - pushedDir_ = lyx::getcwd(); // GetCWD(); - if (pushedDir_.empty() || lyx::chdir(path)) { - // should throw an exception - // throw DirChangeError(); - // The use of Alert::err_alert makes this - // impossible to inline. - //Alert::err_alert(_("Error: Could not change to directory: "), - // path); - } + if (!path.empty()) { + pushedDir_ = lyx::getcwd(); + if (pushedDir_.empty() || lyx::chdir(path)) + /* FIXME: throw */; } else { popped_ = true; } } - /// + + /// set cwd to the previous value if needed ~Path() { if (!popped_) pop(); } - /// + + /// set cwd to the previous value if needed int pop(); private: - /// + /// whether we are in the new cwd or not bool popped_; - /// + /// the previous cwd string pushedDir_; }; @@ -55,4 +72,4 @@ #define Path(x) unnamed_Path; // Tip gotten from Bobby Schmidt's column in C/C++ Users Journal -#endif +#endif // PATH_H diff -u -r1.1 systemcall.C --- src/support/systemcall.C 18 Feb 2002 19:13:48 -0000 1.1 +++ src/support/systemcall.C 22 May 2002 23:13:23 -0000 @@ -7,13 +7,6 @@ * * Interface cleaned up by * \author Angus Leeming <[EMAIL PROTECTED]> - * - * Class Systemcall uses "system" to launch the child process. - * The user can choose to wait or not wait for the process to complete, but no - * callback is invoked upon completion of the child. - * - * The child process is not killed when the Systemcall instance goes out of - * scope. */ #include <config.h> @@ -25,15 +18,7 @@ #include "systemcall.h" #include "os.h" -#include <cstdlib> //for ::system - - -#if 0 -Systemcall::Systemcall(Starttype how, string const & what) -{ - startscript(how, what); -} -#endif +#include <cstdlib> // Reuse of instance Index: src/support/systemcall.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/systemcall.h,v retrieving revision 1.2 diff -u -r1.2 systemcall.h --- src/support/systemcall.h 21 Mar 2002 17:06:35 -0000 1.2 +++ src/support/systemcall.h 22 May 2002 23:13:23 -0000 @@ -8,15 +8,6 @@ * * Interface cleaned up by * \author Angus Leeming <[EMAIL PROTECTED]> - * - * An instance of Class Systemcall represents a single child process. - * - * Class Systemcall uses system() to launch the child process. - * The user can choose to wait or not wait for the process to complete, but no - * callback is invoked upon completion of the child. - * - * The child process is not killed when the Systemcall instance goes out of - * scope. */ #ifndef SYSTEMCALL_H @@ -28,27 +19,24 @@ #pragma interface #endif +/** + * An instance of Class Systemcall represents a single child process. + * + * Class Systemcall uses system() to launch the child process. + * The user can choose to wait or not wait for the process to complete, but no + * callback is invoked upon completion of the child. + * + * The child process is not killed when the Systemcall instance goes out of + * scope. + */ class Systemcall { public: - /// + /// whether to wait for completion enum Starttype { - /// - Wait, - /// - DontWait + Wait, //< wait for completion before returning from startscript() + DontWait //< don't wait for completion }; - -#if 0 - /// - Systemcall() {} - - /** Generate instance and start child process. - * The string "what" contains a commandline with arguments separated - * by spaces. - */ - Systemcall(Starttype how, string const & what); -#endif - + /** Start child process. * The string "what" contains a commandline with arguments separated * by spaces. diff -u -r1.17 textutils.h --- src/support/textutils.h 21 Mar 2002 17:06:35 -0000 1.17 +++ src/support/textutils.h 22 May 2002 23:13:23 -0000 @@ -1,52 +1,53 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file textutils.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * \author unknown + */ +// FIXME: I can think of a better name for this file ... + #ifndef TEXTUTILS_H #define TEXTUTILS_H -/// +/// return true if the char is a meta-character newline inline bool IsNewlineChar(char c) { return (c == Paragraph::META_NEWLINE); } -/// +/// return true if the char is a word separator inline bool IsSeparatorChar(char c) { return (c == ' '); } -/// +/// return true if the char is a line separator +inline +bool IsLineSeparatorChar(char c) { + return (c == ' '); +} + + +/// return true if the char is a meta-character for hfill inline bool IsHfillChar(char c) { return (c == Paragraph::META_HFILL); } -/// +/// return true if the char is a meta-character for an inset inline bool IsInsetChar(char c) { return (c == Paragraph::META_INSET); } -/// -inline -bool IsLineSeparatorChar(char c) { - return (c == ' '); -} - -/// +/// return true if the char is "punctuation" inline bool IsKommaChar(char c) { return (c == ',' @@ -77,7 +78,7 @@ } -/// +/// return true if a char is alphabetical (including accented chars) inline bool IsLetterChar(unsigned char c) { return ((c >= 'A' && c <= 'Z') @@ -86,21 +87,21 @@ } -/// +/// return true if the char is printable (masked to 7-bit ASCII) inline bool IsPrintable(unsigned char c) { return ((c & 127) >= ' '); } -/// +/// return true if the char is printable and not a space (masked to 7-bit ASCII) inline bool IsPrintableNonspace(unsigned char c) { return IsPrintable(c) && (c != ' '); } -/// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset. +/// return true if the char forms part of a word inline bool IsWordChar(unsigned char c) { return !(IsSeparatorChar(c) @@ -110,7 +111,7 @@ } -/// +/// completely pointless FIXME inline bool IsDigit(unsigned char ch) { @@ -118,10 +119,11 @@ } -/// +/// return true if the char is alphanumeric inline bool IsLetterCharOrDigit(unsigned char ch) { return IsLetterChar(ch) || IsDigit(ch); } -#endif + +#endif // TEXTUTILS_H Index: src/support/translator.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/translator.h,v retrieving revision 1.12 diff -u -r1.12 translator.h --- src/support/translator.h 5 Apr 2002 19:54:17 -0000 1.12 +++ src/support/translator.h 22 May 2002 23:13:23 -0000 @@ -1,13 +1,11 @@ // -*- C++ -*- -/* This file is part of - * ================================================= +/** + * \file translator.h + * Copyright 1995-2002 the LyX Team + * Read the file COPYING * - * LyX, The Document Processor - * Copyright 1995 Matthias Ettrich. - * Copyright 1995-2001 The LyX Team. - * - * This file Copyright 2000 Baruch Even - * ================================================= */ + * \author Baruch Even <[EMAIL PROTECTED]> + */ #ifndef TRANSLATOR_H #define TRANSLATOR_H @@ -19,12 +17,13 @@ #include "support/LAssert.h" #include "support/lyxfunctional.h" -/** This class template is used to translate between two elements, specifically - it was worked out to translate between an enum and strings when reading - the lyx file. - - The two template arguments should be of different types. -*/ +/** + * This class template is used to translate between two elements, specifically + * it was worked out to translate between an enum and strings when reading + * the lyx file. + * + * The two template arguments should be of different types. + */ template<typename T1, typename T2> class Translator { public: @@ -99,4 +98,4 @@ T2 const default_t2; }; -#endif +#endif // TRANSLATOR_H Index: src/support/types.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/types.h,v retrieving revision 1.5 diff -u -r1.5 types.h --- src/support/types.h 21 Mar 2002 17:06:35 -0000 1.5 +++ src/support/types.h 22 May 2002 23:13:23 -0000 @@ -1,11 +1,18 @@ +/** + * \file types.h + * Copyright 2002 the LyX Team + * Read the file COPYING + * + * Provide a set of typedefs for commonly used things like sizes and + * indices wile trying to stay compatible with types used + * by the standard containers. + * + * \author unknown + */ + #ifndef LYX_TYPES_H #define LYX_TYPES_H -// provide a set of typedefs for commonly used things like sizes and -// indices while trying to stay compatible with types used by the standard -// containers. - - // this probably could be improved by using <cstddef>... #include <vector> @@ -62,4 +69,4 @@ } -#endif +#endif // LYX_TYPES_H