diff options
Diffstat (limited to 'src/symutil.cpp')
-rw-r--r-- | src/symutil.cpp | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/src/symutil.cpp b/src/symutil.cpp index 6f5e42f..5556f1d 100644 --- a/src/symutil.cpp +++ b/src/symutil.cpp @@ -17,40 +17,40 @@ char dotReplacementChar = '@'; int dsym2c(const BYTE* p, BYTE len, char* cname, int maxclen)
{
- int zlen, zpos, cpos = 0; - - // decompress symbol - while (len-- > 0) - { - int ch = *p++; - if (ch == 0x80) - { - if (len-- <= 0) - break; - zlen = *p++ & 0x7f; - if (len-- <= 0) - break; - zpos = *p++ & 0x7f; - if (zpos > cpos) - break; - for(int z = 0; z < zlen; z++) - cname[cpos + z] = cname[cpos - zpos + z]; - cpos += zlen; - break; - } - else if (ch > 0x80) - { - zlen = (ch & 0x7) + 1; - zpos = ((ch >> 3) & 0xf) - 7; // + zlen; - for(int z = 0; z < zlen; z++) - cname[cpos + z] = cname[cpos - zpos + z]; - cpos += zlen; - } - else - cname[cpos++] = ch; - } - - cname[cpos] = 0; + int zlen, zpos, cpos = 0;
+
+ // decompress symbol
+ while (len-- > 0)
+ {
+ int ch = *p++;
+ if (ch == 0x80)
+ {
+ if (len-- <= 0)
+ break;
+ zlen = *p++ & 0x7f;
+ if (len-- <= 0)
+ break;
+ zpos = *p++ & 0x7f;
+ if (zpos > cpos)
+ break;
+ for(int z = 0; z < zlen; z++)
+ cname[cpos + z] = cname[cpos - zpos + z];
+ cpos += zlen;
+ break;
+ }
+ else if (ch > 0x80)
+ {
+ zlen = (ch & 0x7) + 1;
+ zpos = ((ch >> 3) & 0xf) - 7; // + zlen;
+ for(int z = 0; z < zlen; z++)
+ cname[cpos + z] = cname[cpos - zpos + z];
+ cpos += zlen;
+ }
+ else
+ cname[cpos++] = ch;
+ }
+
+ cname[cpos] = 0;
if (cname[0] == '_' && cname[1] == 'D' && isdigit(cname[2]))
d_demangle(cname, cname, maxclen, true);
@@ -60,21 +60,21 @@ int dsym2c(const BYTE* p, BYTE len, char* cname, int maxclen) cname[i] = dotReplacementChar;
#endif
- return cpos; + return cpos;
}
char* p2c(const BYTE* p, int idx)
{
- static char cname[4][2560]; - int len = *p++; - -#if 1 - memcpy(cname[idx], p, len); - cname[idx][len] = 0; -#else - dsym2c(p, len, cname[idx], 2560); -#endif - return cname[idx]; + static char cname[4][2560];
+ int len = *p++;
+
+#if 1
+ memcpy(cname[idx], p, len);
+ cname[idx][len] = 0;
+#else
+ dsym2c(p, len, cname[idx], 2560);
+#endif
+ return cname[idx];
}
char* p2c(const p_string& p, int idx)
@@ -133,9 +133,9 @@ int pstrcpy_v(bool v3, BYTE* d, const BYTE* s) return pstrcpy(d, s);
int len = *s++;
- int clen = dsym2c(s, len, (char*) d, 1000) + 1; - - return clen; + int clen = dsym2c(s, len, (char*) d, 1000) + 1;
+
+ return clen;
}
int cstrcpy_v(bool v3, BYTE* d, const char* s)
@@ -147,6 +147,6 @@ int cstrcpy_v(bool v3, BYTE* d, const char* s) assert(len < 256);
memcpy(d, s, len + 1);
- return len + 1; + return len + 1;
}
|