Aggiunta funzione add_plural e supportato WATCOM C++

git-svn-id: svn://10.65.10.50/trunk@1133 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1995-03-16 09:12:40 +00:00
parent 1f6a353587
commit b7c2e821d1
2 changed files with 36 additions and 7 deletions

View File

@ -513,6 +513,29 @@ TString& TString::lower()
return *this;
}
// Certified 50%
TString& TString::add_plural(long num, const char* name)
{
const TFixed_string n(name);
const char last = n[n.len()-1];
if (num < 1)
{
*this << "nessun";
if (toupper(last) == 'A' || toupper(n[0]) == 'Z' ||
toupper(n[0]) == 'S' && strchr("aeiouAEIOU", n[1]) == NULL)
*this << tolower(last);
*this << ' ' << name;
}
else
{
*this << num << ' ' << name;
if (num > 1)
_str[len()-1] = (last == 'a') ? 'e' : 'i';
}
return *this;
}
// Certified 90%
TString& TString::overwrite(const char* s, int pos)
@ -614,8 +637,6 @@ TString& TFixed_string::format(const char* fmt, ...)
// Filename
///////////////////////////////////////////////////////////
inline bool is_not_slash(char s)
{ return s != '\\' && s != '/'; }
// Certified 90%
const char* TFilename::ext() const
@ -769,10 +790,10 @@ const TFilename& TFilename::tempdir()
putenv(_tempdir);
}
return set(_tempdir.mid(4));
set(_tempdir.mid(4));
return *this;
}
// Certified 50%
const TFilename& TFilename::temp(const char* prefix)
{
@ -800,6 +821,7 @@ const TFilename& TFilename::temp(const char* prefix)
else cut(0);
char* t = tempnam(NULL, (char*)_str);
CHECK(t != NULL, "Can't execute tempnam");
set(t);
free(t);

View File

@ -103,12 +103,16 @@ public:
TString& left_just(int n = -1, char c = ' '); // Giustifica a sinistra
TString& picture(const char* pic, const char* s);
virtual TString& format(const char* fmt, ...);
#ifndef __WATCOMC__
virtual
#endif
TString& format(const char* fmt, ...);
TString& cut(int n); // Inserisce un '\0' alla posizione n-esima.
TString& upper(); // Mette la stringa in maiuscolo
TString& lower(); // Mette la stringa in minuscolo
TString& lower(); // Mette la stringa in minuscolo
TString& add_plural(long num, const char * name); // aggiunge il plurale di name
///////////////////////////////////////////////////////////
// @DES Standard operators
@ -154,7 +158,10 @@ public:
TFixed_string(const char* str, int size = -1);
virtual ~TFixed_string();
virtual TString& format(const char* fmt, ...);
#ifndef __WATCOMC__
virtual
#endif
TString& format(const char* fmt, ...);
const TString& operator =(const TString& s) { return set((const char*)s); }
const TString& operator=(const char* str) { return set(str); }