<commit_before>#ifndef I0STRING_H
#define I0STRING_H

#include "stddef.h"

// NOTE: n must be 8*N, use b:sl to optimize
// Consider using memcmp which is more efficient
// TODO: use register to optimize
long strncmp(char *s1, char *s2, long n);

void memcpy(char* src, long len, char* dst);

// for internal implementation only for memcmp_se
long __memcmp_se(char* s1, char* s2, long n);

// To use this function, the program should define
// ENABLE_MEMCMP_SE
// before #include "libi0/string.h"; otherwise, the compilation fails.
// memcmp with side effect: registers are changed
// faster but need to save the registers by the program
#ifdef ENABLE_MEMCMP_SE
#define memcmp_se(s1, s2, n) __memcmp_se(s1, s2, n)
#else
#define memcmp_se(s1, s2, n) _Pragma ("GCC error \"To use memcmp_se, you must define ENABLE_MEMCMP_SE to indicate that you are aware its side effects.\"")
#endif

long memcmp(char* s1, char* s2, long n);

void memset0(char* m, long len);

long grep(char* s1, long n1, char* s2, long n2);

#endif // I0STRING_H
<commit_msg>add comment for grep() to explain its usage and semantic<commit_after>#ifndef I0STRING_H
#define I0STRING_H

#include "stddef.h"

// NOTE: n must be 8*N, use b:sl to optimize
// Consider using memcmp which is more efficient
// TODO: use register to optimize
long strncmp(char *s1, char *s2, long n);

void memcpy(char* src, long len, char* dst);

// for internal implementation only for memcmp_se
long __memcmp_se(char* s1, char* s2, long n);

// To use this function, the program should define
// ENABLE_MEMCMP_SE
// before #include "libi0/string.h"; otherwise, the compilation fails.
// memcmp with side effect: registers are changed
// faster but need to save the registers by the program
#ifdef ENABLE_MEMCMP_SE
#define memcmp_se(s1, s2, n) __memcmp_se(s1, s2, n)
#else
#define memcmp_se(s1, s2, n) _Pragma ("GCC error \"To use memcmp_se, you must define ENABLE_MEMCMP_SE to indicate that you are aware its side effects.\"")
#endif

long memcmp(char* s1, char* s2, long n);

void memset0(char* m, long len);

// grep needle of nlen from s of slen
// If needle is found in s, return the position of the 1st needle found
// If needle is not found in s, return -1
long grep(char* s, long slen, char* needle, long nlen);

#endif // I0STRING_H

{'fraction_non_alphanumeric': 0.10376532399299475, 'fraction_numerical': 0.01838879159369527, 'mean_word_length': 4.301624129930395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6836244', 'n_tokens_mistral': 804, 'n_tokens_neox': 795, 'n_words': 328}