<commit_before>#include <stdio.h>

#include "leb.h"

unsigned leb128_length(unsigned long long value, int is_signed)
{
	unsigned len = 1;

	if(is_signed){
		signed long long sv = value;

		for(;;){
			sv >>= 7;

			if(!sv || sv == -1)
				break;
			len++;
		}
	}else{
		for(;;){
			value >>= 7;

			if(!value) /* more */
				break;
			len++;
		}
	}
	return len;
}

unsigned leb128_out(FILE *f, unsigned long long v, int sig)
{
	const char *join = "";
	unsigned len = 1;

	if(sig){
		signed long long sv = v;

		for(;;){
			unsigned char byte = sv & 0x7f;<commit_msg>Fix sign-bit checking for signed LEB128 length calc<commit_after>#include <stdio.h>

#include "leb.h"

unsigned leb128_length(unsigned long long value, int is_signed)
{
	unsigned len = 1;

	if(is_signed){
		signed long long sv = value;

		for(;;){
			int sign_bit_set = !!(sv & 0x40);

			sv >>= 7;

			if((sv == 0 && !sign_bit_set)
			|| (sv == -1 && sign_bit_set))
			{
				break;
			}

			len++;
		}
	}else{
		for(;;){
			value >>= 7;

			if(!value) /* more */
				break;
			len++;
		}
	}
	return len;
}

unsigned leb128_out(FILE *f, unsigned long long v, int sig)
{
	const char *join = "";
	unsigned len = 1;

	if(sig){
		signed long long sv = v;

		for(;;){
			unsigned char byte = sv & 0x7f;
{'fraction_non_alphanumeric': 0.16785431512272367, 'fraction_numerical': 0.026128266033254157, 'mean_word_length': 2.773134328358209, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7175092', 'n_tokens_mistral': 605, 'n_tokens_neox': 502, 'n_words': 143}