]> git.lyx.org Git - lyx.git/commitdiff
fix a lyxstring bug and ws change
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 6 Apr 2002 12:42:42 +0000 (12:42 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Sat, 6 Apr 2002 12:42:42 +0000 (12:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3916 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/filetools.C
src/support/lyxstring.C

index 746a141da98427050f71f0f14fb5208fda23079a..878e1e7b7bc244abded5aab5d62749a77bf4b0d9 100644 (file)
@@ -1007,9 +1007,10 @@ string const GetExtension(string const & name)
 /// return the "extension" which belongs to the contents.
 /// for no knowing contents return the extension. Without
 /// an extension and unknown contents we return "user"
-string const getExtFromContents(string const & filename) {
+string const getExtFromContents(string const & filename)
+{
+       // paranoia check
        if (filename.empty() || !IsFileReadable(filename))
-               // paranoia check
                return string();
 
        ifstream ifs(filename.c_str());
index 42a9811cf5ea0926c3bee88ab64aea9c5979efb5..621239d640f9a0514ffe3188c58c51985ff278c4 100644 (file)
@@ -663,10 +663,13 @@ lyxstring & lyxstring::assign(const_iterator first, const_iterator last)
 lyxstring::const_reference lyxstring::operator[](size_type pos) const
 {
 #if 0
+       // This is actually what the standard requires,
        lyx::Assert(pos <= rep->sz); // OURS!
        static char helper = '\0';
        return pos == rep->sz ? helper : rep->s[pos];
 #else
+       // but we use this one since it is stricter
+       // and more according to the real intent of std::string.
        lyx::Assert(pos < rep->sz); // OURS!
        return rep->s[pos];
 #endif
@@ -1731,7 +1734,7 @@ void swap(lyxstring & str1, lyxstring & str2)
 
 istream & operator>>(istream & is, lyxstring & s)
 {
-#if 1
+#if 0
        // very bad solution
        char * nome = new char[1024];
        is >> nome;
@@ -1740,7 +1743,7 @@ istream & operator>>(istream & is, lyxstring & s)
        if (!tmp.empty()) s = tmp;
 #else
        // better solution
-       int w = is.widdth(0);
+       int w = is.width(0);
        s.clear();
        char c = 0;
        while (is.get(c)) {
@@ -1748,7 +1751,7 @@ istream & operator>>(istream & is, lyxstring & s)
                s += c;
                if (--w == 1) break;
        }
-       if (s.empty()) is.setstate(ios::failbit);
+       if (s.empty()) is.setstate(std::ios::failbit);
 #endif
        return is;
 }