Beispiel #1
0
int main() {
	RStrpool *p = r_strpool_new (1024);
	printf ("%d\n", r_strpool_append (p, "Hello World"));
	printf ("%d\n", r_strpool_append (p, "Patata Barata"));
	printf ("%s\n", r_strpool_get (p, 12));
	r_strpool_fit (p);
	r_strpool_free (p);
	return 0;
}
Beispiel #2
0
R_API void r_core_log_add(RCore *core, const char *msg) {
	static bool inProcess = false;
	r_strpool_append (core->log->sp, msg);
	core->log->last++;
	if (core->cmdlog && *core->cmdlog) {
		if (inProcess) {
			// avoid infinite recursive calls
			return;
		}
		inProcess = true;
		r_core_cmd0 (core, core->cmdlog);
		inProcess = false;
	}
}
Beispiel #3
0
static void color_line(const char *line, RStrpool *p, RRegexMatch *ms){
	int i, m_len;
	int offset = 0;
	char *m_addr;
	char *inv[2] = {R_CONS_INVERT(R_TRUE, R_TRUE),
			R_CONS_INVERT(R_FALSE, R_TRUE)};
	int linv[2] = {strlen(inv[0]), strlen(inv[1])};

	r_strpool_empty(p);
	for (i = 0; i < NMATCHES; i++) {
		if (ms[i].rm_eo && (i < NMATCHES - 1)) {
			/* highlight a match */
			r_strpool_memcat (p, line + offset,
					  ms[i].rm_so - offset);
			r_strpool_memcat (p, inv[0], linv[0]);

			m_len = ms[i].rm_eo - ms[i].rm_so;
			m_addr = r_str_ndup (line + ms[i].rm_so, m_len);
			if (m_addr) {
				if(r_str_ansi_chrn (m_addr, m_len) - m_addr < m_len ){
					/* there's a CSI in the middle of this match*/
					m_len = r_str_ansi_filter(m_addr,
							NULL, NULL, m_len);
				}
				r_strpool_memcat (p, m_addr, m_len);
				r_strpool_memcat (p, inv[1], linv[1]);
				offset = ms[i].rm_eo;
				free(m_addr);
			}
		} else {
			/* append final part of string w/o matches */
			r_strpool_append(p, line + offset);
			break;
		}
	}
}
Beispiel #4
0
R_API void r_core_log_add(RCore *core, const char *msg) {
	r_strpool_append (core->log->sp, msg);
	core->log->last++;
}