Compare commits
No commits in common. "4823c4f3a4d48e5979b8e1349c62b47bd6d96c65" and "0952d2d60dec9b4c8a1d279f25c184467408163c" have entirely different histories.
4823c4f3a4
...
0952d2d60d
|
@ -1,31 +0,0 @@
|
||||||
|
|
||||||
#ifndef RR_BITFIELD_H
|
|
||||||
#define RR_BITFIELD_H
|
|
||||||
|
|
||||||
#include <librr/types.h>
|
|
||||||
|
|
||||||
/// @brief Tests whether a bit of an u64_t at a given index from the least significant bit is set.
|
|
||||||
/// @param buffer Buffer of which to test the presence of a bit.
|
|
||||||
/// @param index Index of the bit of which to test the presence.
|
|
||||||
/// The index starts at 0;0 is the least significant bit.
|
|
||||||
/// @return Whether the bit in 'buffer' at 'index' was set.
|
|
||||||
inline bool_t rr_is_bit_set(u64_t buffer, usz_t index);
|
|
||||||
|
|
||||||
/// @brief Sets a bit at a given index from the least significant bit in an u64_t and returns the new u64_t.
|
|
||||||
/// @param buffer The buffer to set the 'index'th bit of.
|
|
||||||
/// @param index Index of the bit in the buffer (as counted from the least significant bit) to set a bit of.
|
|
||||||
/// The index starts with 0; there will always be a bit set (except if the index is greater than 63).
|
|
||||||
/// @return The modified buffer with the bit set.
|
|
||||||
inline u64_t rr_set_bit(u64_t buffer, usz_t index);
|
|
||||||
|
|
||||||
/// @brief Returns a bitfield with a given number of bits set to 1, beginning with the least significant bit.
|
|
||||||
/// @param count Number of bits to set
|
|
||||||
/// @return The bitfield of which the bits were set.
|
|
||||||
u64_t rr_bitpad_lsb(usz_t count);
|
|
||||||
|
|
||||||
/// @brief Returns a bitfield with a given number of bits set to 1, beginning with the most significant bit.
|
|
||||||
/// @param count Number of bits to set
|
|
||||||
/// @return The bitfield of which the bits were set.
|
|
||||||
u64_t rr_bitpad_msb(usz_t count);
|
|
||||||
|
|
||||||
#endif // RR_BITFIELD_H
|
|
|
@ -1,29 +0,0 @@
|
||||||
#include <librr/bitfield.h>
|
|
||||||
|
|
||||||
inline bool_t rr_is_bit_set(u64_t buffer, usz_t index)
|
|
||||||
{
|
|
||||||
return !!(buffer & (1 << index));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline u64_t rr_set_bit(u64_t buffer, usz_t index)
|
|
||||||
{
|
|
||||||
return buffer | (1 << index);
|
|
||||||
}
|
|
||||||
|
|
||||||
u64_t rr_bitpad_lsb(usz_t count)
|
|
||||||
{
|
|
||||||
u64_t result = 0;
|
|
||||||
for(usz_t index = 0; index < count; ++index)
|
|
||||||
{
|
|
||||||
result |= 1 << index;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
u64_t rr_bitpad_msb(usz_t count)
|
|
||||||
{
|
|
||||||
u64_t result = 0;
|
|
||||||
for(usz_t index = 0; index < count; ++index)
|
|
||||||
{
|
|
||||||
result |= (1 << 63) >> index;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -76,12 +76,12 @@ rune_t rr_extract_utf8(const char *string, usz_t offset, usz_t *increase)
|
||||||
if(string[offset] == 0x00)
|
if(string[offset] == 0x00)
|
||||||
return ZERO;
|
return ZERO;
|
||||||
|
|
||||||
isz_t offset_into_rune = rr_distance_to_last_utf8_rune_start(string, offset);
|
usz_t offset_into_rune = rr_distance_to_last_utf8_rune_start(string, offset);
|
||||||
if(offset_into_rune < 0)
|
if(offset_into_rune < 0)
|
||||||
return ZERO;
|
return ZERO;
|
||||||
offset -= offset_into_rune;
|
offset -= offset_into_rune;
|
||||||
|
|
||||||
isz_t rune_length = rr_identify_utf8_rune_length(string, offset);
|
usz_t rune_length = rr_identify_utf8_rune_length(string, offset);
|
||||||
if(rune_length < 0)
|
if(rune_length < 0)
|
||||||
return ZERO;
|
return ZERO;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue