/// 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());
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
istream & operator>>(istream & is, lyxstring & s)
{
-#if 1
+#if 0
// very bad solution
char * nome = new char[1024];
is >> nome;
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)) {
s += c;
if (--w == 1) break;
}
- if (s.empty()) is.setstate(ios::failbit);
+ if (s.empty()) is.setstate(std::ios::failbit);
#endif
return is;
}