Print this page
Rich's feedback
*** 8,30 ****
* Source Licenses. See LICENSE.TXT for details.
*
*/
/*
! * Copyright 2017 Jason King.
*/
#include <ctype.h>
#include <errno.h>
#include <locale.h>
#include <string.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/isa_defs.h>
#include <sys/debug.h>
! #include "sysdemangle.h"
! #include "sysdemangle_int.h"
#include "cxx.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
#endif
--- 8,31 ----
* Source Licenses. See LICENSE.TXT for details.
*
*/
/*
! * Copyright 2018 Jason King.
*/
#include <ctype.h>
#include <errno.h>
#include <locale.h>
+ #include <note.h>
#include <string.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/isa_defs.h>
#include <sys/debug.h>
! #include "demangle-sys.h"
! #include "demangle_int.h"
#include "cxx.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
#endif
*** 49,60 ****
locale_t cpp_loc;
} cpp_db_t;
#define CK(x) \
do { \
! if (!(x)) \
longjmp(db->cpp_jmp, 1); \
} while (0)
#define TOP_L(db) (&(name_top(&(db)->cpp_name)->strp_l))
#define RLEN(f, l) ((size_t)((l) - (f)))
#define NAMT(db, n) (nlen(db) - n)
--- 50,63 ----
locale_t cpp_loc;
} cpp_db_t;
#define CK(x) \
do { \
! if (!(x)) { \
longjmp(db->cpp_jmp, 1); \
+ } \
+ NOTE(CONSTCOND) \
} while (0)
#define TOP_L(db) (&(name_top(&(db)->cpp_name)->strp_l))
#define RLEN(f, l) ((size_t)((l) - (f)))
#define NAMT(db, n) (nlen(db) - n)
*** 213,223 ****
(void) memcpy(result, s->str_s, s->str_len);
}
done:
! if (getenv("DEMANGLE_DEBUG") != NULL)
dump(&db, stdout);
db_fini(&db);
return (result);
}
--- 216,226 ----
(void) memcpy(result, s->str_s, s->str_len);
}
done:
! if (demangle_debug)
dump(&db, stdout);
db_fini(&db);
return (result);
}
*** 287,297 ****
return (last);
}
/*
* _block_invoke
! * _block_invoke<digit>+ XXX: should it be <digit>* ?
* _block_invoke_<digit>+
*/
static const char *
parse_block_invoke(const char *first, const char *last, cpp_db_t *db)
{
--- 290,300 ----
return (last);
}
/*
* _block_invoke
! * _block_invoke<digit>*
* _block_invoke_<digit>+
*/
static const char *
parse_block_invoke(const char *first, const char *last, cpp_db_t *db)
{
*** 376,386 ****
goto fail;
str_pair_t *sp = name_top(&db->cpp_name);
if (str_length(&sp->strp_r) == 0)
! str_append(&sp->strp_l, " ", 1);
nfmt(db, "{0:L}{1:L}", "{1:R}{0:R}");
t = t2;
}
--- 379,389 ----
goto fail;
str_pair_t *sp = name_top(&db->cpp_name);
if (str_length(&sp->strp_r) == 0)
! (void) str_append(&sp->strp_l, " ", 1);
nfmt(db, "{0:L}{1:L}", "{1:R}{0:R}");
t = t2;
}
*** 390,402 ****
size_t n = nlen(db);
if (t[0] == 'v') {
t++;
} else {
!
! /*CONSTCOND*/
! while (1) {
t2 = parse_type(t, last, db);
if (t2 == t || t == last)
break;
t = t2;
--- 393,403 ----
size_t n = nlen(db);
if (t[0] == 'v') {
t++;
} else {
! for (;;) {
t2 = parse_type(t, last, db);
if (t2 == t || t == last)
break;
t = t2;
*** 1539,1553 ****
str_t *l = &sp->strp_l;
str_t *r = &sp->strp_r;
if (str_length(r) > 1 &&
r->str_s[0] == ' ' && r->str_s[1] == '[') {
! str_append(l, " (", 2);
! str_insert(r, 0, ")", 1);
} else if (str_length(r) > 0 && r->str_s[0] == '(') {
! str_append(l, "(", 1);
! str_insert(r, 0, ")", 1);
}
}
/* BEGIN CSTYLED */
/*
--- 1540,1554 ----
str_t *l = &sp->strp_l;
str_t *r = &sp->strp_r;
if (str_length(r) > 1 &&
r->str_s[0] == ' ' && r->str_s[1] == '[') {
! (void) str_append(l, " (", 2);
! (void) str_insert(r, 0, ")", 1);
} else if (str_length(r) > 0 && r->str_s[0] == '(') {
! (void) str_append(l, "(", 1);
! (void) str_insert(r, 0, ")", 1);
}
}
/* BEGIN CSTYLED */
/*
*** 1611,1621 ****
case 'C':
t = parse_type(first + 1, last, db);
if (t == first + 1 || NAMT(db, n) == 0)
return (first);
! str_append(TOP_L(db), " complex", 8);
save_top(db, 1);
return (t);
case 'F':
t = parse_function_type(first, last, db);
--- 1612,1622 ----
case 'C':
t = parse_type(first + 1, last, db);
if (t == first + 1 || NAMT(db, n) == 0)
return (first);
! (void) str_append(TOP_L(db), " complex", 8);
save_top(db, 1);
return (t);
case 'F':
t = parse_function_type(first, last, db);
*** 1627,1637 ****
case 'G':
t = parse_type(first + 1, last, db);
if (t == first + 1 || NAMT(db, n) == 0)
return (first);
! str_append(TOP_L(db), " imaginary", 10);
save_top(db, 1);
return (t);
case 'M':
t = parse_pointer_to_member_type(first, last, db);
--- 1628,1638 ----
case 'G':
t = parse_type(first + 1, last, db);
if (t == first + 1 || NAMT(db, n) == 0)
return (first);
! (void) str_append(TOP_L(db), " imaginary", 10);
save_top(db, 1);
return (t);
case 'M':
t = parse_pointer_to_member_type(first, last, db);
*** 1648,1658 ****
sp = name_at(&db->cpp_name, amt - 1);
for (size_t i = 0; i < amt; i++, sp++) {
paren(sp);
if (str_pair_len(sp) > 0)
! str_append(&sp->strp_l, "&&", 2);
}
save_top(db, amt);
return (t);
--- 1649,1659 ----
sp = name_at(&db->cpp_name, amt - 1);
for (size_t i = 0; i < amt; i++, sp++) {
paren(sp);
if (str_pair_len(sp) > 0)
! (void) str_append(&sp->strp_l, "&&", 2);
}
save_top(db, amt);
return (t);
*** 1670,1683 ****
continue;
paren(sp);
if (first[1] != 'U' ||
strncmp(l->str_s, "objc_object<", 12) != 0) {
! str_append(l, "*", 1);
} else {
! str_erase(l, 0, 11);
! str_insert(l, 0, "id", 2);
}
}
save_top(db, amt);
return (t);
--- 1671,1684 ----
continue;
paren(sp);
if (first[1] != 'U' ||
strncmp(l->str_s, "objc_object<", 12) != 0) {
! (void) str_append(l, "*", 1);
} else {
! (void) str_erase(l, 0, 11);
! (void) str_insert(l, 0, "id", 2);
}
}
save_top(db, amt);
return (t);
*** 1692,1702 ****
if (str_length(&sp->strp_l) == 0 &&
str_length(&sp->strp_r) == 0)
continue;
paren(sp);
! str_append(&sp->strp_l, "&", 1);
}
save_top(db, amt);
return (t);
--- 1693,1703 ----
if (str_length(&sp->strp_l) == 0 &&
str_length(&sp->strp_r) == 0)
continue;
paren(sp);
! (void) str_append(&sp->strp_l, "&", 1);
}
save_top(db, amt);
return (t);
*** 1874,1888 ****
if (str_length(s) == 0)
continue;
if (cv & 1)
! str_append(s, " const", 6);
if (cv & 2)
! str_append(s, " volatile", 9);
if (cv & 4)
! str_append(s, " restrict", 9);
continue;
}
s = &sp->strp_r;
--- 1875,1889 ----
if (str_length(s) == 0)
continue;
if (cv & 1)
! (void) str_append(s, " const", 6);
if (cv & 2)
! (void) str_append(s, " volatile", 9);
if (cv & 4)
! (void) str_append(s, " restrict", 9);
continue;
}
s = &sp->strp_r;
*** 1893,1911 ****
if (s->str_s[pos - 1] == '&')
pos--;
}
if (cv & 1) {
! str_insert(s, pos, " const", 6);
pos += 6;
}
if (cv & 2) {
! str_insert(s, pos, " volatile", 9);
pos += 9;
}
if (cv & 4) {
! str_insert(s, pos, " restrict", 9);
}
}
save_top(db, amt);
return (t1);
--- 1894,1912 ----
if (s->str_s[pos - 1] == '&')
pos--;
}
if (cv & 1) {
! (void) str_insert(s, pos, " const", 6);
pos += 6;
}
if (cv & 2) {
! (void) str_insert(s, pos, " volatile", 9);
pos += 9;
}
if (cv & 4) {
! (void) str_insert(s, pos, " restrict", 9);
}
}
save_top(db, amt);
return (t1);
*** 2630,2640 ****
case '0':
case '1':
case '2':
case '5':
basename(db);
! str_insert(TOP_L(db), 0, "~", 1);
break;
default:
return (first);
}
break;
--- 2631,2641 ----
case '0':
case '1':
case '2':
case '5':
basename(db);
! (void) str_insert(TOP_L(db), 0, "~", 1);
break;
default:
return (first);
}
break;
*** 2787,2797 ****
str_fini(&num);
return (first);
}
num.str_len = n;
! name_add_str(&db->cpp_name, &num, NULL);
return (t + 1);
}
/*
--- 2788,2798 ----
str_fini(&num);
return (first);
}
num.str_len = n;
! (void) name_add_str(&db->cpp_name, &num, NULL);
return (t + 1);
}
/*
*** 3401,3411 ****
* if we have " [xxx]" already, want new result to be
* " [yyy][xxx]"
*/
str_t *r = &name_top(&db->cpp_name)->strp_r;
if (r->str_len > 1 && r->str_s[0] == ' ' && r->str_s[1] == '[')
! str_erase(r, 0, 1);
nfmt(db, "{0:L}", " [{1}]{0:R}");
return (t1);
}
--- 3402,3412 ----
* if we have " [xxx]" already, want new result to be
* " [yyy][xxx]"
*/
str_t *r = &name_top(&db->cpp_name)->strp_r;
if (r->str_len > 1 && r->str_s[0] == ' ' && r->str_s[1] == '[')
! (void) str_erase(r, 0, 1);
nfmt(db, "{0:L}", " [{1}]{0:R}");
return (t1);
}
*** 3483,3493 ****
if (t != t2) {
if (global) {
if (nempty(db))
return (first);
! str_insert(TOP_L(db), 0, "::", 2);
}
return (t2);
}
if (t[0] != 's' || t[1] != 'r' || last - t < 2)
--- 3484,3494 ----
if (t != t2) {
if (global) {
if (nempty(db))
return (first);
! (void) str_insert(TOP_L(db), 0, "::", 2);
}
return (t2);
}
if (t[0] != 's' || t[1] != 'r' || last - t < 2)