Rename RStr to RzStr

This commit is contained in:
Riccardo Schirone 2020-10-13 10:03:31 +02:00 committed by Riccardo Schirone
parent e732026202
commit 52ba3f8d39
20 changed files with 63 additions and 63 deletions

View file

@ -267,7 +267,7 @@ RZ_API void rz_test_asm_test_free(RzAsmTest *test) {
free (test);
}
static bool parse_asm_path(const char *path, RStrConstPool *strpool, const char **arch_out, const char **cpuout, int *bitsout) {
static bool parse_asm_path(const char *path, RzStrConstPool *strpool, const char **arch_out, const char **cpuout, int *bitsout) {
RzList *file_tokens = rz_str_split_duplist (path, RZ_SYS_DIR, true);
if (!file_tokens || rz_list_empty (file_tokens)) {
rz_list_free (file_tokens);
@ -307,7 +307,7 @@ static bool parse_asm_path(const char *path, RStrConstPool *strpool, const char
return true;
}
RZ_API RzPVector *rz_test_load_asm_test_file(RStrConstPool *strpool, const char *file) {
RZ_API RzPVector *rz_test_load_asm_test_file(RzStrConstPool *strpool, const char *file) {
const char *arch;
const char *cpu;
int bits;

View file

@ -121,7 +121,7 @@ typedef struct rz_test_test_t {
typedef struct rz_test_test_database_t {
RzPVector tests;
RStrConstPool strpool;
RzStrConstPool strpool;
} RzTestDatabase;
typedef struct rz_test_run_config_t {
@ -170,7 +170,7 @@ RZ_API RzPVector *rz_test_load_cmd_test_file(const char *file);
RZ_API RzAsmTest *rz_test_asm_test_new(void);
RZ_API void rz_test_asm_test_free(RzAsmTest *test);
RZ_API RzPVector *rz_test_load_asm_test_file(RStrConstPool *strpool, const char *file);
RZ_API RzPVector *rz_test_load_asm_test_file(RzStrConstPool *strpool, const char *file);
RZ_API RzJsonTest *rz_test_json_test_new(void);
RZ_API void rz_test_json_test_free(RzJsonTest *test);

View file

@ -5,7 +5,7 @@
#include <rz_cons.h>
#include "pager_private.h"
RZ_IPI void pager_color_line(const char *line, RStrpool *p, RzList *ml) {
RZ_IPI void pager_color_line(const char *line, RzStrpool *p, RzList *ml) {
int m_len, offset = 0;
char *m_addr;
RzListIter *it;
@ -53,7 +53,7 @@ RZ_IPI void pager_printpage(const char *line, int *index, RzList **mla, int from
return;
}
RStrpool *p = rz_strpool_new (0);
RzStrpool *p = rz_strpool_new (0);
if (!p) {
return;
}

View file

@ -1,7 +1,7 @@
#ifndef PAGER_PRIVATE_H
#define PAGER_PRIVATE_H
RZ_IPI void pager_color_line(const char *line, RStrpool *p, RzList *ml);
RZ_IPI void pager_color_line(const char *line, RzStrpool *p, RzList *ml);
RZ_IPI void pager_printpage(const char *line, int *index, RzList **mla, int from, int to, int w);
RZ_IPI int pager_next_match(int from, RzList **mla, int lcount);
RZ_IPI int pager_prev_match(int from, RzList **mla);

View file

@ -5,7 +5,7 @@
RZ_API int rz_core_log_list(RzCore *core, int n, int nth, char fmt) {
int printed = 0;
int count = 0, i, idx, id = core->log->first;
RStrpool *sp = core->log->sp;
RzStrpool *sp = core->log->sp;
char *str = sp->str;
if (fmt == 'j') {

View file

@ -167,7 +167,7 @@ typedef struct {
bool show_functions;
bool show_marks;
bool show_asciidot;
RStrEnc strenc;
RzStrEnc strenc;
int cursor;
int show_comment_right_default;
RSpace *flagspace_ports;
@ -3749,7 +3749,7 @@ static char *ds_esc_str(RDisasmState *ds, const char *str, int len, const char *
char *escstr = NULL;
const char *prefix = "";
bool esc_bslash = ds->core->print->esc_bslash;
RStrEnc strenc = ds->strenc;
RzStrEnc strenc = ds->strenc;
if (strenc == RZ_STRING_ENC_GUESS) {
strenc = rz_utf_bom_encoding ((ut8 *)str, len);
}
@ -3783,7 +3783,7 @@ static char *ds_esc_str(RDisasmState *ds, const char *str, int len, const char *
escstr = rz_str_escape_utf16le (str, len, ds->show_asciidot, esc_bslash);
prefix = "u";
} else if (str_len == 1 && len > 7 && !str[2] && !str[3] && str[4] && !str[5]) {
RStrEnc enc = RZ_STRING_ENC_UTF32LE;
RzStrEnc enc = RZ_STRING_ENC_UTF32LE;
RRune ch;
const char *ptr, *end;
end = (const char *)rz_mem_mem_aligned ((ut8 *)str, len, (ut8 *)"\0\0\0\0", 4, 4);
@ -3803,7 +3803,7 @@ static char *ds_esc_str(RDisasmState *ds, const char *str, int len, const char *
escstr = rz_str_escape_latin1 (str, ds->show_asciidot, esc_bslash, is_comment);
}
} else {
RStrEnc enc = RZ_STRING_ENC_LATIN1;
RzStrEnc enc = RZ_STRING_ENC_LATIN1;
const char *ptr = str, *end = str + str_len;
for (; ptr < end; ptr++) {
if (rz_utf8_decode ((ut8 *)ptr, end - ptr, NULL) > 1) {

View file

@ -684,7 +684,7 @@ typedef struct rz_anal_t {
REvent *ev;
RzList/*<char *>*/ *imports; // global imports
SetU *visited;
RStrConstPool constpool;
RzStrConstPool constpool;
RzList *leaddrs;
} RzAnal;

View file

@ -342,7 +342,7 @@ struct rz_bin_t {
bool verbose;
bool use_xtr; // use extract plugins when loading a file?
bool use_ldr; // use loader plugins when loading a file?
RStrConstPool constpool;
RzStrConstPool constpool;
bool is_reloc_patched; // used to indicate whether relocations were patched or not
};

View file

@ -362,7 +362,7 @@ typedef struct rz_cons_canvas_t {
int *bsize;
const char *attr; //The current attr (inserted on each write)
HtUP *attrs; // all the different attributes <key: unsigned int loc, const char *attr>
RStrConstPool constpool; // Pool for non-compile-time attrs
RzStrConstPool constpool; // Pool for non-compile-time attrs
int sx; // scrollx
int sy; // scrolly
int color;

View file

@ -131,7 +131,7 @@ typedef struct {
typedef struct rz_core_log_t {
int first;
int last;
RStrpool *sp;
RzStrpool *sp;
} RzCoreLog;
typedef struct rz_core_file_t {

View file

@ -17,9 +17,9 @@ typedef enum {
RZ_STRING_ENC_UTF16BE = 'b',
RZ_STRING_ENC_UTF32BE = 'B',
RZ_STRING_ENC_GUESS = 'g',
} RStrEnc;
} RzStrEnc;
typedef int (*RStrRangeCallback) (void *, int);
typedef int (*RzStrRangeCallback) (void *, int);
#define RZ_STR_ISEMPTY(x) (!(x) || !*(x))
#define RZ_STR_ISNOTEMPTY(x) ((x) && *(x))

View file

@ -11,17 +11,17 @@ extern "C" {
#endif
/*
* RStrConstPool is a pool of constant strings.
* References to strings will be valid as long as the RStrConstPool is alive.
* RzStrConstPool is a pool of constant strings.
* References to strings will be valid as long as the RzStrConstPool is alive.
*/
typedef struct rz_str_constpool_t {
HtPP *ht;
} RStrConstPool;
} RzStrConstPool;
RZ_API bool rz_str_constpool_init(RStrConstPool *pool);
RZ_API void rz_str_constpool_fini(RStrConstPool *pool);
RZ_API const char *rz_str_constpool_get(RStrConstPool *pool, const char *str);
RZ_API bool rz_str_constpool_init(RzStrConstPool *pool);
RZ_API void rz_str_constpool_fini(RzStrConstPool *pool);
RZ_API const char *rz_str_constpool_get(RzStrConstPool *pool, const char *str);
#ifdef __cplusplus
}

View file

@ -11,21 +11,21 @@ typedef struct {
char *str;
int len;
int size;
} RStrpool;
} RzStrpool;
RZ_API RStrpool* rz_strpool_new(int sz);
RZ_API char *rz_strpool_alloc(RStrpool *p, int l);
RZ_API int rz_strpool_memcat(RStrpool *p, const char *s, int len);
RZ_API int rz_strpool_ansi_chop(RStrpool *p, int n);
RZ_API int rz_strpool_append(RStrpool *p, const char *s);
RZ_API void rz_strpool_free(RStrpool *p);
RZ_API int rz_strpool_fit(RStrpool *p);
RZ_API char *rz_strpool_get(RStrpool *p, int index);
RZ_API char *rz_strpool_get_i(RStrpool *p, int index);
RZ_API int rz_strpool_get_index(RStrpool *p, const char *s);
RZ_API char *rz_strpool_next(RStrpool *p, int index);
RZ_API char *rz_strpool_slice(RStrpool *p, int index);
RZ_API char *rz_strpool_empty(RStrpool *p);
RZ_API RzStrpool* rz_strpool_new(int sz);
RZ_API char *rz_strpool_alloc(RzStrpool *p, int l);
RZ_API int rz_strpool_memcat(RzStrpool *p, const char *s, int len);
RZ_API int rz_strpool_ansi_chop(RzStrpool *p, int n);
RZ_API int rz_strpool_append(RzStrpool *p, const char *s);
RZ_API void rz_strpool_free(RzStrpool *p);
RZ_API int rz_strpool_fit(RzStrpool *p);
RZ_API char *rz_strpool_get(RzStrpool *p, int index);
RZ_API char *rz_strpool_get_i(RzStrpool *p, int index);
RZ_API int rz_strpool_get_index(RzStrpool *p, const char *s);
RZ_API char *rz_strpool_next(RzStrpool *p, int index);
RZ_API char *rz_strpool_slice(RzStrpool *p, int index);
RZ_API char *rz_strpool_empty(RzStrpool *p);
#ifdef __cplusplus
}

View file

@ -1,7 +1,7 @@
#ifndef RZ_UTF8_H
#define RZ_UTF8_H
/* For RStrEnc definition */
/* For RzStrEnc definition */
#include "rz_str.h"
typedef struct { ut32 from, to; const char *name; } RUtfBlock;
@ -19,7 +19,7 @@ RZ_API const char *rz_utf_block_name(int idx);
RZ_API wchar_t *rz_utf8_to_utf16_l(const char *cstring, int len);
RZ_API int rz_utf_block_idx (RRune ch);
RZ_API int *rz_utf_block_list (const ut8 *str, int len, int **freq_list);
RZ_API RStrEnc rz_utf_bom_encoding(const ut8 *ptr, int ptrlen);
RZ_API RzStrEnc rz_utf_bom_encoding(const ut8 *ptr, int ptrlen);
#define rz_utf16_to_utf8(wc) rz_utf16_to_utf8_l ((wchar_t *)wc, -1)
#define rz_utf8_to_utf16(cstring) rz_utf8_to_utf16_l ((char *)cstring, -1)
#if __WINDOWS__

View file

@ -1390,7 +1390,7 @@ RZ_API char *rz_str_escape_latin1(const char *buf, bool show_asciidot, bool esc_
return rz_str_escape_ (buf, false, colors, !colors, show_asciidot, esc_bslash);
}
static char *rz_str_escape_utf(const char *buf, int buf_size, RStrEnc enc, bool show_asciidot, bool esc_bslash, bool keep_printable) {
static char *rz_str_escape_utf(const char *buf, int buf_size, RzStrEnc enc, bool show_asciidot, bool esc_bslash, bool keep_printable) {
char *new_buf, *q;
const char *p, *end;
RRune ch;
@ -2533,7 +2533,7 @@ RZ_API int rz_str_write(int fd, const char *b) {
return write (fd, b, strlen (b));
}
RZ_API void rz_str_range_foreach(const char *r, RStrRangeCallback cb, void *u) {
RZ_API void rz_str_range_foreach(const char *r, RzStrRangeCallback cb, void *u) {
const char *p = r;
for (; *r; r++) {
if (*r == ',') {

View file

@ -6,16 +6,16 @@ static void kv_fini(HtPPKv *kv) {
free (kv->key);
}
RZ_API bool rz_str_constpool_init(RStrConstPool *pool) {
RZ_API bool rz_str_constpool_init(RzStrConstPool *pool) {
pool->ht = ht_pp_new (NULL, kv_fini, NULL);
return pool->ht != NULL;
}
RZ_API void rz_str_constpool_fini(RStrConstPool *pool) {
RZ_API void rz_str_constpool_fini(RzStrConstPool *pool) {
ht_pp_free (pool->ht);
}
RZ_API const char *rz_str_constpool_get(RStrConstPool *pool, const char *str) {
RZ_API const char *rz_str_constpool_get(RzStrConstPool *pool, const char *str) {
if (!str) {
return NULL;
}

View file

@ -2,8 +2,8 @@
#include <rz_util.h>
RZ_API RStrpool* rz_strpool_new (int sz) {
RStrpool *p = RZ_NEW (RStrpool);
RZ_API RzStrpool* rz_strpool_new (int sz) {
RzStrpool *p = RZ_NEW (RzStrpool);
if (!p) {
eprintf ("Malloc failed!\n");
return NULL;
@ -23,14 +23,14 @@ RZ_API RStrpool* rz_strpool_new (int sz) {
return p;
}
RZ_API char *rz_strpool_empty (RStrpool *p) {
RZ_API char *rz_strpool_empty (RzStrpool *p) {
p->len = 0;
p->str[0] = 0;
p->str[1] = 0;
return p->str;
}
RZ_API char *rz_strpool_alloc (RStrpool *p, int l) {
RZ_API char *rz_strpool_alloc (RzStrpool *p, int l) {
char *ret = p->str + p->len;
if ((p->len + l) >= p->size) {
ut64 osize = p->size;
@ -57,7 +57,7 @@ RZ_API char *rz_strpool_alloc (RStrpool *p, int l) {
return ret;
}
RZ_API int rz_strpool_memcat(RStrpool *p, const char *s, int len) {
RZ_API int rz_strpool_memcat(RzStrpool *p, const char *s, int len) {
char *ptr = rz_strpool_alloc (p, len);
if (!ptr) {
return -1;
@ -66,24 +66,24 @@ RZ_API int rz_strpool_memcat(RStrpool *p, const char *s, int len) {
return (size_t)(ptr - p->str);
}
RZ_API int rz_strpool_append(RStrpool *p, const char *s) {
RZ_API int rz_strpool_append(RzStrpool *p, const char *s) {
int l = strlen (s) + 1;
return rz_strpool_memcat (p, s, l);
}
RZ_API int rz_strpool_ansi_chop(RStrpool *p, int n){
RZ_API int rz_strpool_ansi_chop(RzStrpool *p, int n){
/* p->str need not be a c-string */
int i = rz_str_ansi_trim (p->str, p->len, n);
p->len = i;
return i;
}
RZ_API void rz_strpool_free (RStrpool *p) {
RZ_API void rz_strpool_free (RzStrpool *p) {
free (p->str);
free (p);
}
RZ_API int rz_strpool_fit(RStrpool *p) {
RZ_API int rz_strpool_fit(RzStrpool *p) {
char *s;
if (p->len == p->size) {
return false;
@ -100,14 +100,14 @@ RZ_API int rz_strpool_fit(RStrpool *p) {
return true;
}
RZ_API char *rz_strpool_get(RStrpool *p, int index) {
RZ_API char *rz_strpool_get(RzStrpool *p, int index) {
if (!p || !p->str || index < 0 || index >= p->len) {
return NULL;
}
return p->str + index;
}
RZ_API char *rz_strpool_get_i(RStrpool *p, int index) {
RZ_API char *rz_strpool_get_i(RzStrpool *p, int index) {
int i, n = 0;
if (index < 0 || index >= p->len) {
return NULL;
@ -119,12 +119,12 @@ RZ_API char *rz_strpool_get_i(RStrpool *p, int index) {
return p->str + n;
}
RZ_API int rz_strpool_get_index(RStrpool *p, const char *s) {
RZ_API int rz_strpool_get_index(RzStrpool *p, const char *s) {
int ret = (size_t)(s - p->str);
return (ret > 0) ? ret : 0;
}
RZ_API char *rz_strpool_next(RStrpool *p, int index) {
RZ_API char *rz_strpool_next(RzStrpool *p, int index) {
char *ptr = rz_strpool_get (p, index);
if (ptr) {
char *q = ptr + strlen (ptr) + 1;
@ -139,7 +139,7 @@ RZ_API char *rz_strpool_next(RStrpool *p, int index) {
return ptr;
}
RZ_API char *rz_strpool_slice (RStrpool *p, int index) {
RZ_API char *rz_strpool_slice (RzStrpool *p, int index) {
int idx, len;
char *o, *x = rz_strpool_get_i (p, index + 1);
if (!x || !*x) {
@ -161,7 +161,7 @@ RZ_API char *rz_strpool_slice (RStrpool *p, int index) {
#if TEST
int main() {
RStrpool *p = rz_strpool_new (1024);
RzStrpool *p = rz_strpool_new (1024);
printf ("%d\n", rz_strpool_append (p, "Hello World"));
printf ("%d\n", rz_strpool_append (p, "Patata Barata"));
printf ("%s\n", rz_strpool_get (p, 12));

View file

@ -786,7 +786,7 @@ RZ_API int *rz_utf_block_list(const ut8 *str, int len, int **freq_list) {
return list;
}
RZ_API RStrEnc rz_utf_bom_encoding(const ut8 *ptr, int ptrlen) {
RZ_API RzStrEnc rz_utf_bom_encoding(const ut8 *ptr, int ptrlen) {
if (ptrlen > 3) {
if (ptr[0] == 0xff && ptr[1] == 0xfe && !ptr[2] && !ptr[3]) {
return RZ_STRING_ENC_UTF32LE;

View file

@ -767,7 +767,7 @@ typedef struct rz_bin_java_obj_t {
Sdb *AllJavaBinObjs;
ut32 id;
RStrConstPool constpool;
RzStrConstPool constpool;
} RzBinJavaObj;
RZ_API RzList * U(rz_bin_java_get_interface_names)(RzBinJavaObj * bin);

View file

@ -379,7 +379,7 @@ bool test_rz_str_newf(void) {
}
bool test_rz_str_constpool(void) {
RStrConstPool pool;
RzStrConstPool pool;
bool s = rz_str_constpool_init (&pool);
mu_assert ("pool init success", s);