Ejemplo n.º 1
0
static void writebit (ut8 *dst, int i, bool c) {
	int byte = i / 8;
	int bit = (i % 8);
// eprintf ("Write %d %d = %d\n", byte, bit, c);
dst += byte;
	if (c) {
		//dst[byte] |= (1 << bit);
		R_BIT_SET (dst , bit);
	} else {
		//dst[byte] &= (1 << bit);
		R_BIT_UNSET (dst , bit);
	}
}
Ejemplo n.º 2
0
R_API const char *r_str_lastbut (const char *s, char ch, const char *but) {
	int idx, _b = 0;
	ut8 *b = (ut8*)&_b;
	const char *isbut, *p, *lp = NULL;
	const int bsz = sizeof (_b);
	if (!but)
		return r_str_lchr (s, ch);
	if (strlen (but) >= bsz) {
		eprintf ("r_str_lastbut: but string too long\n");
		return NULL;
	}
	for (p=s; *p; p++) {
		isbut = but? strchr (but, *p): NULL;
		if (isbut) {
			idx = (int)(size_t)(isbut-but);
			_b = R_BIT_CHK (b, idx)?
				R_BIT_UNSET (b, idx):
				R_BIT_SET (b, idx);
			continue;
		}
		if (*p == ch && !_b) lp = p;
	}
	return lp;
}