Rizin
unix-like reverse engineering framework and cli tools
rust.c File Reference
#include "demangler_util.h"
#include <rz_libdemangle.h>

Go to the source code of this file.

Macros

#define RS(from, to)
 

Functions

static bool replace_seq (const char **in, char **out, const char *seq, char value)
 
char * libdemangle_handler_rust (const char *sym)
 

Macro Definition Documentation

◆ RS

#define RS (   from,
  to 
)
Value:
if (replace_seq((const char **)&in, &out, (const char *)(from), to)) \
continue
const lzma_allocator const uint8_t * in
Definition: block.h:527
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
static bool replace_seq(const char **in, char **out, const char *seq, char value)
Definition: rust.c:10
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125

Definition at line 6 of file rust.c.

Function Documentation

◆ libdemangle_handler_rust()

char* libdemangle_handler_rust ( const char *  sym)

Definition at line 25 of file rust.c.

25  {
26  int len;
27  char *str = NULL, *out, *in;
28 
29  str = libdemangle_handler_cxx(sym);
30 
31  if (!str) {
32  return str;
33  }
34 
35  out = in = str;
36  len = strlen(str);
37 
38  if (*in == '_') {
39  in++;
40  len--;
41  }
42 
43  while ((len = strlen(in)) > 0) {
44  if (*in == '$') {
45  RS("$SP$", '@');
46  RS("$BP$", '*');
47  RS("$RF$", '&');
48  RS("$LT$", '<');
49  RS("$GT$", '>');
50  RS("$LP$", '(');
51  RS("$RP$", ')');
52  RS("$C$", ',');
53  // maybe a good idea to replace all utf-sequences by regexp \$u[0-9a-f]{2}\$ or so
54  RS("$u20$", ' ');
55  RS("$u22$", '\"');
56  RS("$u27$", '\'');
57  RS("$u2b$", '+');
58  RS("$u3b$", ';');
59  RS("$u5b$", '[');
60  RS("$u5d$", ']');
61  RS("$u7e$", '~');
62  }
63  if (*in == '.') {
64  if (len > 0 && in[1] == '.') {
65  in += 2;
66  *out++ = ':';
67  *out++ = ':';
68  len--;
69  } else {
70  in += 1;
71  *out = '-';
72  }
73  } else {
74  *out++ = *in++;
75  }
76  }
77  *out = '\0';
78 
79  return str;
80 }
size_t len
Definition: 6502dis.c:15
#define NULL
Definition: cris-opc.c:27
#define RS(from, to)
Definition: rust.c:6

References in, len, NULL, out, RS, and cmd_descs_generate::str.

Referenced by rz_demangler_rust().

◆ replace_seq()

static bool replace_seq ( const char **  in,
char **  out,
const char *  seq,
char  value 
)
static

Definition at line 10 of file rust.c.

10  {
11  size_t len = strlen(seq);
12 
13  if (strncmp(*in, seq, len)) {
14  return false;
15  }
16 
17  **out = value;
18 
19  *in += len;
20  *out += 1;
21 
22  return true;
23 }
static int value
Definition: cmd_api.c:93

References in, len, out, and value.