mirror of https://github.com/KLayout/klayout.git
Build fixed, basic bugs fixed and made unit test framework work. Added tests for tlString.
This commit is contained in:
parent
bbfcd9cf9e
commit
7ede06dca5
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = cif
|
||||
TARGET = cif_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = common
|
||||
TARGET = common_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = dxf
|
||||
TARGET = dxf_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = gds2
|
||||
TARGET = gds2_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = lefdef
|
||||
TARGET = lefdef_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = oasis
|
||||
TARGET = oasis_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = pcb
|
||||
TARGET = pcb_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = bool
|
||||
TARGET = bool_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = diff
|
||||
TARGET = diff_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = import
|
||||
TARGET = import_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = net_tracer
|
||||
TARGET = net_tracer_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
TARGET = xor
|
||||
TARGET = xor_ui
|
||||
DESTDIR = $$OUT_PWD/../../../../lay_plugins
|
||||
|
||||
include($$PWD/../../../lay_plugin.pri)
|
||||
|
|
|
|||
|
|
@ -51,16 +51,16 @@ static std::string trimmed_part (const std::string &part)
|
|||
const char *cp = part.c_str ();
|
||||
|
||||
#if defined(_WIN32)
|
||||
while (*cp && *cp != '\\' && *cp != '/') {
|
||||
while (*cp == '\\' || *cp == '/') {
|
||||
++cp;
|
||||
}
|
||||
#else
|
||||
while (*cp && *cp != '/') {
|
||||
while (*cp == '/') {
|
||||
++cp;
|
||||
}
|
||||
#endif
|
||||
|
||||
return std::string (part, 0, cp - part.c_str ());
|
||||
return std::string (cp);
|
||||
}
|
||||
|
||||
static bool is_part_with_separator (const std::string &part)
|
||||
|
|
@ -108,11 +108,15 @@ std::vector<std::string> split_path (const std::string &p)
|
|||
while (*cp && (!any || (*cp != '\\' && *cp != '/'))) {
|
||||
if (*cp != '\\' && *cp != '/') {
|
||||
any = true;
|
||||
} else {
|
||||
cp0 = cp;
|
||||
}
|
||||
++cp;
|
||||
}
|
||||
|
||||
parts.push_back (std::string (cp0, 0, cp - cp0));
|
||||
if (any) {
|
||||
parts.push_back (std::string (cp0, 0, cp - cp0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -126,6 +130,8 @@ std::vector<std::string> split_path (const std::string &p)
|
|||
while (*cp && (!any || *cp != '/')) {
|
||||
if (*cp != '/') {
|
||||
any = true;
|
||||
} else {
|
||||
cp0 = cp;
|
||||
}
|
||||
// backslash escape
|
||||
if (*cp == '\\' && cp[1]) {
|
||||
|
|
@ -134,7 +140,9 @@ std::vector<std::string> split_path (const std::string &p)
|
|||
++cp;
|
||||
}
|
||||
|
||||
parts.push_back (std::string (cp0, 0, cp - cp0));
|
||||
if (any) {
|
||||
parts.push_back (std::string (cp0, 0, cp - cp0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -254,9 +262,9 @@ std::vector<std::string> dir_entries (const std::string &s, bool with_files, boo
|
|||
bool mkdir (const std::string &path)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return _wunlink (tl::to_wstring (path).c_str ()) == 0;
|
||||
return _wmkdir (tl::to_wstring (path).c_str ()) == 0;
|
||||
#else
|
||||
return unlink (tl::to_local (path).c_str ()) == 0;
|
||||
return ::mkdir (tl::to_local (path).c_str (), 0777) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -600,13 +608,22 @@ std::string relative_path (const std::string &base, const std::string &p)
|
|||
return p;
|
||||
}
|
||||
|
||||
std::string normalize_path (const std::string &s)
|
||||
{
|
||||
return tl::join (tl::split_path (s), "");
|
||||
}
|
||||
|
||||
std::string combine_path (const std::string &p1, const std::string &p2)
|
||||
{
|
||||
if (p2.empty ()) {
|
||||
return p1;
|
||||
} else {
|
||||
#if defined(_WIN32)
|
||||
return p1 + "\\" + p2;
|
||||
return p1 + "\\" + p2;
|
||||
#else
|
||||
return p1 + "/" + p2;
|
||||
return p1 + "/" + p2;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool is_same_file (const std::string &a, const std::string &b)
|
||||
|
|
|
|||
|
|
@ -131,6 +131,13 @@ bool TL_PUBLIC is_same_file (const std::string &a, const std::string &b);
|
|||
*/
|
||||
std::string TL_PUBLIC relative_path (const std::string &base, const std::string &p);
|
||||
|
||||
/**
|
||||
* @brief Normalizes the path
|
||||
* This function will remove duplicate "/" or "\" and strip any trailing
|
||||
* "/" or "\".
|
||||
*/
|
||||
std::string TL_PUBLIC normalize_path (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Combines the two path components into one path
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -52,17 +52,17 @@ std::wstring to_wstring (const std::string &s)
|
|||
|
||||
uint32_t c32 = (unsigned char) *cp++;
|
||||
if (c32 >= 0xf0 && cp + 2 < cpe) {
|
||||
c32 = (c32 << 18) | ((uint32_t (cp [0]) & 0x3f) << 12) | ((uint32_t (cp [1]) & 0x3f) << 6) | (uint32_t (cp [2]) & 0x3f);
|
||||
c32 = ((c32 & 0x7) << 18) | ((uint32_t (cp [0]) & 0x3f) << 12) | ((uint32_t (cp [1]) & 0x3f) << 6) | (uint32_t (cp [2]) & 0x3f);
|
||||
cp += 3;
|
||||
} else if (c32 >= 0xe0 && cp + 1 < cpe) {
|
||||
c32 = (c32 << 12) | ((uint32_t (cp [0]) & 0x3f) << 6) | (uint32_t (cp [1]) & 0x3f);
|
||||
c32 = ((c32 & 0xf) << 12) | ((uint32_t (cp [0]) & 0x3f) << 6) | (uint32_t (cp [1]) & 0x3f);
|
||||
cp += 2;
|
||||
} else if (c32 >= 0xc0 && cp < cpe) {
|
||||
c32 = (c32 << 6) | (uint32_t (*cp) & 0x3f);
|
||||
c32 = ((c32 & 0x1f) << 6) | (uint32_t (*cp) & 0x3f);
|
||||
++cp;
|
||||
}
|
||||
|
||||
if (c32 >= 0x10000) {
|
||||
if (sizeof (wchar_t) == 2 && c32 >= 0x10000) {
|
||||
c32 -= 0x10000;
|
||||
ws += wchar_t (0xd800 + (c32 >> 10));
|
||||
ws += wchar_t (0xdc00 + (c32 & 0x3ff));
|
||||
|
|
@ -82,7 +82,7 @@ std::string to_string (const std::wstring &ws)
|
|||
for (std::wstring::const_iterator c = ws.begin (); c != ws.end (); ++c) {
|
||||
|
||||
uint32_t c32 = *c;
|
||||
if (c32 >= 0xd800 && c + 1 < ws.end ()) {
|
||||
if (sizeof (wchar_t) == 2 && c32 >= 0xd800 && c + 1 < ws.end ()) {
|
||||
++c;
|
||||
c32 = (c32 & 0x3ff) << 10;
|
||||
c32 |= uint32_t (*c) & 0x3ff;
|
||||
|
|
@ -97,13 +97,13 @@ std::string to_string (const std::wstring &ws)
|
|||
|
||||
} else if (c32 >= 0x800) {
|
||||
|
||||
s.push_back (0xf0 | ((c32 >> 12) & 0xf));
|
||||
s.push_back (0xe0 | ((c32 >> 12) & 0xf));
|
||||
s.push_back (0x80 | ((c32 >> 6) & 0x3f));
|
||||
s.push_back (0x80 | (c32 & 0x3f));
|
||||
|
||||
} else if (c32 >= 0x80) {
|
||||
|
||||
s.push_back (0xf0 | ((c32 >> 6) & 0xc));
|
||||
s.push_back (0xc0 | ((c32 >> 6) & 0x1f));
|
||||
s.push_back (0x80 | (c32 & 0x3f));
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -163,14 +163,14 @@ protected:
|
|||
* available.
|
||||
*/
|
||||
|
||||
#if defined(HVE_QT)
|
||||
#if defined(HAVE_QT)
|
||||
|
||||
template <class T>
|
||||
class TL_PUBLIC ThreadStorage
|
||||
: public QThreadStorage<T>
|
||||
{
|
||||
public:
|
||||
ThreadStorage () : QThreadStorage () { }
|
||||
ThreadStorage () : QThreadStorage<T> () { }
|
||||
};
|
||||
|
||||
#else
|
||||
|
|
@ -180,15 +180,16 @@ template <class T>
|
|||
class TL_PUBLIC ThreadStorage
|
||||
{
|
||||
public:
|
||||
ThreadStorage () : m_t () { }
|
||||
ThreadStorage () : m_t (), m_has_data (false) { }
|
||||
|
||||
bool hasLocalData () const { return true; }
|
||||
bool hasLocalData () const { return m_has_data; }
|
||||
T &localData () { return m_t; }
|
||||
T localData () const { return m_t; }
|
||||
void setLocalData (T data) { m_t = data; }
|
||||
void setLocalData (const T &data) { m_t = data; m_has_data = true; }
|
||||
|
||||
private:
|
||||
T m_t;
|
||||
bool m_has_data;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ Timer::start ()
|
|||
struct timespec spec;
|
||||
clock_gettime (CLOCK_REALTIME, &spec);
|
||||
|
||||
m_wall_ms = ms_time ();
|
||||
m_wall_ms += ms_time ();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -479,3 +479,17 @@ TEST(14)
|
|||
EXPECT_EQ (pad_string_left (6, "abc"), " abc");
|
||||
EXPECT_EQ (pad_string_left (4, ""), " ");
|
||||
}
|
||||
|
||||
// UTF-8 to wchar_t and local conversion
|
||||
TEST(15)
|
||||
{
|
||||
// NOTE: we don't know the local setting, but translation back and forth should work.
|
||||
EXPECT_EQ (tl::to_string_from_local (tl::to_local ("Hällo\tWörld!").c_str ()), "Hällo\tWörld!");
|
||||
EXPECT_EQ (std::string ("Ä").size (), size_t (2));
|
||||
EXPECT_EQ (tl::to_string (std::wstring (L"Ä")), "Ä");
|
||||
EXPECT_EQ (tl::to_wstring (std::string ("Ä")).size (), 1);
|
||||
EXPECT_EQ (tl::to_string (tl::to_wstring ("Utf8 supports emoticons: \xF0\x9F\x98\x81\nand Umlauts: äüö")).c_str (), "Utf8 supports emoticons: \xF0\x9F\x98\x81\nand Umlauts: äüö");
|
||||
|
||||
EXPECT_EQ (tl::to_upper_case ("äÄüÜöÖß"), "ÄÄÜÜÖÖß");
|
||||
EXPECT_EQ (tl::to_lower_case ("äÄüÜöÖß"), "ääüüööß");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue