mirror of
https://github.com/holub/mame
synced 2025-04-26 02:07:14 +03:00
re-added excessive strlen() usage to astring since it causes mysterious formating issues in debugger for people with non-standard font (no whatsnew)
This commit is contained in:
parent
fb45d3b66f
commit
7d0cc68ac0
@ -81,7 +81,6 @@ bool astring::ensure_room(int length)
|
|||||||
// swap in the new buffer and free the old one
|
// swap in the new buffer and free the old one
|
||||||
char *oldbuf = (m_text == m_smallbuf) ? NULL : m_text;
|
char *oldbuf = (m_text == m_smallbuf) ? NULL : m_text;
|
||||||
m_text = strcpy(newbuf, m_text);
|
m_text = strcpy(newbuf, m_text);
|
||||||
m_len = strlen(m_text);
|
|
||||||
m_alloclen = alloclen;
|
m_alloclen = alloclen;
|
||||||
delete[] oldbuf;
|
delete[] oldbuf;
|
||||||
|
|
||||||
@ -134,7 +133,6 @@ astring &astring::init()
|
|||||||
m_text = m_smallbuf;
|
m_text = m_smallbuf;
|
||||||
m_alloclen = ARRAY_LENGTH(m_smallbuf);
|
m_alloclen = ARRAY_LENGTH(m_smallbuf);
|
||||||
m_smallbuf[0] = 0;
|
m_smallbuf[0] = 0;
|
||||||
m_len = 0;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +167,6 @@ astring &astring::cpy(const char *src, int count)
|
|||||||
if (count > 0 && m_text != src)
|
if (count > 0 && m_text != src)
|
||||||
memcpy(m_text, src, count);
|
memcpy(m_text, src, count);
|
||||||
m_text[count] = 0;
|
m_text[count] = 0;
|
||||||
m_len = count;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +178,7 @@ astring &astring::cpy(const char *src, int count)
|
|||||||
|
|
||||||
astring &astring::cpysubstr(const astring &src, int start, int count)
|
astring &astring::cpysubstr(const astring &src, int start, int count)
|
||||||
{
|
{
|
||||||
normalize_substr(start, count, src.len());
|
normalize_substr(start, count, strlen(src.m_text));
|
||||||
return cpy(src.m_text + start, count);
|
return cpy(src.m_text + start, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +203,6 @@ astring &astring::ins(int insbefore, const char *src, int count)
|
|||||||
memmove(m_text + insbefore + count, m_text + insbefore, dstlength - insbefore);
|
memmove(m_text + insbefore + count, m_text + insbefore, dstlength - insbefore);
|
||||||
memcpy(m_text + insbefore, src, count);
|
memcpy(m_text + insbefore, src, count);
|
||||||
m_text[dstlength + count] = 0;
|
m_text[dstlength + count] = 0;
|
||||||
m_len = dstlength + count;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +214,7 @@ astring &astring::ins(int insbefore, const char *src, int count)
|
|||||||
|
|
||||||
astring &astring::inssubstr(int insbefore, const astring &src, int start, int count)
|
astring &astring::inssubstr(int insbefore, const astring &src, int start, int count)
|
||||||
{
|
{
|
||||||
normalize_substr(start, count, src.len());
|
normalize_substr(start, count, strlen(src.m_text));
|
||||||
return ins(insbefore, src.m_text + start, count);
|
return ins(insbefore, src.m_text + start, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,13 +231,12 @@ astring &astring::substr(int start, int count)
|
|||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
// normalize parameters
|
// normalize parameters
|
||||||
normalize_substr(start, count, len());
|
normalize_substr(start, count, strlen(m_text));
|
||||||
|
|
||||||
// move the data and NULL-terminate
|
// move the data and NULL-terminate
|
||||||
if (count > 0 && start > 0)
|
if (count > 0 && start > 0)
|
||||||
memmove(m_text, m_text + start, count);
|
memmove(m_text, m_text + start, count);
|
||||||
m_text[count] = 0;
|
m_text[count] = 0;
|
||||||
m_len = count;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,14 +253,13 @@ astring &astring::del(int start, int count)
|
|||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
// normalize parameters
|
// normalize parameters
|
||||||
int strlength = len();
|
int strlength = strlen(m_text);
|
||||||
normalize_substr(start, count, strlength);
|
normalize_substr(start, count, strlength);
|
||||||
|
|
||||||
// move the data and NULL-terminate
|
// move the data and NULL-terminate
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
memmove(m_text + start, m_text + start + count, strlength - (start + count));
|
memmove(m_text + start, m_text + start + count, strlength - (start + count));
|
||||||
m_text[strlength - count] = 0;
|
m_text[strlength - count] = 0;
|
||||||
m_len = strlength - count;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +329,7 @@ int astring::cmp(const char *str2, int count) const
|
|||||||
|
|
||||||
int astring::cmpsubstr(const astring &str2, int start, int count) const
|
int astring::cmpsubstr(const astring &str2, int start, int count) const
|
||||||
{
|
{
|
||||||
normalize_substr(start, count, str2.len());
|
normalize_substr(start, count, strlen(str2.m_text));
|
||||||
return cmp(str2.m_text + start, count);
|
return cmp(str2.m_text + start, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +361,7 @@ int astring::icmp(const char *str2, int count) const
|
|||||||
|
|
||||||
int astring::icmpsubstr(const astring &str2, int start, int count) const
|
int astring::icmpsubstr(const astring &str2, int start, int count) const
|
||||||
{
|
{
|
||||||
normalize_substr(start, count, str2.len());
|
normalize_substr(start, count, strlen(str2.m_text));
|
||||||
return icmp(str2.m_text + start, count);
|
return icmp(str2.m_text + start, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +439,6 @@ astring &astring::delchr(int ch)
|
|||||||
if (*src != ch)
|
if (*src != ch)
|
||||||
*dst++ = *src;
|
*dst++ = *src;
|
||||||
*dst = 0;
|
*dst = 0;
|
||||||
m_len = strlen(m_text);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +492,7 @@ astring &astring::makelower()
|
|||||||
astring &astring::trimspace()
|
astring &astring::trimspace()
|
||||||
{
|
{
|
||||||
// first remove stuff from the end
|
// first remove stuff from the end
|
||||||
for (char *ptr = m_text + len() - 1; ptr >= m_text && (!(*ptr & 0x80) && isspace(UINT8(*ptr))); ptr--)
|
for (char *ptr = m_text + strlen(m_text) - 1; ptr >= m_text && (!(*ptr & 0x80) && isspace(UINT8(*ptr))); ptr--)
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
||||||
// then count how much to remove from the beginning
|
// then count how much to remove from the beginning
|
||||||
|
@ -111,7 +111,7 @@ public:
|
|||||||
astring &expand(int length) { ensure_room(length); return *this; }
|
astring &expand(int length) { ensure_room(length); return *this; }
|
||||||
|
|
||||||
// length query
|
// length query
|
||||||
int len() const { return m_len; }
|
int len() const { return strlen(m_text); }
|
||||||
|
|
||||||
// copy helpers
|
// copy helpers
|
||||||
astring &cpy(const char *src, int count);
|
astring &cpy(const char *src, int count);
|
||||||
@ -184,7 +184,6 @@ private:
|
|||||||
char * m_text;
|
char * m_text;
|
||||||
int m_alloclen;
|
int m_alloclen;
|
||||||
char m_smallbuf[64];
|
char m_smallbuf[64];
|
||||||
int m_len;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user