Ull
This commit is contained in:
parent
920364cfa7
commit
79129a9d7d
22
isspam.c
22
isspam.c
@ -44,8 +44,8 @@ bool file_exists(char * path){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sld(sl *lst) {
|
void sld(sl *lst) {
|
||||||
for (uint i = 0; i < lst->count; i++) {
|
for (ulonglong i = 0; i < lst->count; i++) {
|
||||||
printf("<%u:%s>\n", i, lst->strings[i]);
|
printf("<%llu:%s>\n", i, lst->strings[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +68,10 @@ char *remove_preserved_chars(char *content) {
|
|||||||
|
|
||||||
char *slds(sl *lst) {
|
char *slds(sl *lst) {
|
||||||
str_t *buffer = strn(1337);
|
str_t *buffer = strn(1337);
|
||||||
for (uint i = 0; i < lst->count; i++) {
|
for (ulonglong i = 0; i < lst->count; i++) {
|
||||||
char *temp = (char *)malloc(strlen(lst->strings[i]) + 20);
|
char *temp = (char *)malloc(strlen(lst->strings[i]) + 20);
|
||||||
char *cc = remove_preserved_chars(lst->strings[i]);
|
char *cc = remove_preserved_chars(lst->strings[i]);
|
||||||
sprintf(temp, "<%u:%s>\n", i, cc);
|
sprintf(temp, "<%llu:%s>\n", i, cc);
|
||||||
free(cc);
|
free(cc);
|
||||||
stra(buffer, temp);
|
stra(buffer, temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
@ -275,8 +275,8 @@ void analyze(FILE *f) {
|
|||||||
|
|
||||||
// All capitalized words
|
// All capitalized words
|
||||||
sl *capitalized_words = get_capitalized_words(data);
|
sl *capitalized_words = get_capitalized_words(data);
|
||||||
uint capitalized_words_count = capitalized_words->count;
|
ulonglong capitalized_words_count = capitalized_words->count;
|
||||||
printf("Capitalized words: %u\n", capitalized_words_count);
|
printf("Capitalized words: %llu\n", capitalized_words_count);
|
||||||
if(show_capitalized)
|
if(show_capitalized)
|
||||||
sld(capitalized_words);
|
sld(capitalized_words);
|
||||||
sbuf = slds(capitalized_words);
|
sbuf = slds(capitalized_words);
|
||||||
@ -286,7 +286,7 @@ void analyze(FILE *f) {
|
|||||||
sl *sentences = get_sentences(data);
|
sl *sentences = get_sentences(data);
|
||||||
|
|
||||||
// All sentences
|
// All sentences
|
||||||
printf("Sentences: %u\n", sentences->count);
|
printf("Sentences: %llu\n", sentences->count);
|
||||||
if(show_sentences)
|
if(show_sentences)
|
||||||
sld(sentences);
|
sld(sentences);
|
||||||
sbuf = slds(sentences);
|
sbuf = slds(sentences);
|
||||||
@ -296,7 +296,7 @@ void analyze(FILE *f) {
|
|||||||
sl *words = get_words(data);
|
sl *words = get_words(data);
|
||||||
|
|
||||||
// All words
|
// All words
|
||||||
printf("Words: %u\n", words->count);
|
printf("Words: %llu\n", words->count);
|
||||||
if(show_words)
|
if(show_words)
|
||||||
sld(words);
|
sld(words);
|
||||||
sbuf = slds(words);
|
sbuf = slds(words);
|
||||||
@ -305,7 +305,7 @@ void analyze(FILE *f) {
|
|||||||
|
|
||||||
// Numbers
|
// Numbers
|
||||||
sl *numbers = get_numbers(data);
|
sl *numbers = get_numbers(data);
|
||||||
printf("Numbers: %u\n", numbers->count);
|
printf("Numbers: %llu\n", numbers->count);
|
||||||
if(show_numbers)
|
if(show_numbers)
|
||||||
sld(numbers);
|
sld(numbers);
|
||||||
sbuf = slds(numbers);
|
sbuf = slds(numbers);
|
||||||
@ -314,7 +314,7 @@ void analyze(FILE *f) {
|
|||||||
|
|
||||||
// Forbidden words
|
// Forbidden words
|
||||||
sl *fw = get_forbidden_words(data);
|
sl *fw = get_forbidden_words(data);
|
||||||
printf("Forbidden words: %u\n", fw->count);
|
printf("Forbidden words: %llu\n", fw->count);
|
||||||
if(show_forbidden_words)
|
if(show_forbidden_words)
|
||||||
sld(fw);
|
sld(fw);
|
||||||
sbuf = slds(fw);
|
sbuf = slds(fw);
|
||||||
@ -322,7 +322,7 @@ void analyze(FILE *f) {
|
|||||||
free(sbuf);
|
free(sbuf);
|
||||||
strd(all);
|
strd(all);
|
||||||
uint word_count_per_sentence = words->count / sentences->count;
|
uint word_count_per_sentence = words->count / sentences->count;
|
||||||
printf("Word count per sentence: %u\n", word_count_per_sentence);
|
printf("Word count per sentence: %llu\n", word_count_per_sentence);
|
||||||
|
|
||||||
slf(capitalized_words);
|
slf(capitalized_words);
|
||||||
slf(sentences);
|
slf(sentences);
|
||||||
|
@ -185,7 +185,7 @@ void *rfree(void *obj) {
|
|||||||
char *rmalloc_lld_format(ulonglong num) {
|
char *rmalloc_lld_format(ulonglong num) {
|
||||||
char res[100];
|
char res[100];
|
||||||
res[0] = 0;
|
res[0] = 0;
|
||||||
sprintf(res, "%lld", num);
|
sprintf(res, "%'llu", num);
|
||||||
char *resp = res;
|
char *resp = res;
|
||||||
while (*resp) {
|
while (*resp) {
|
||||||
if (*resp == ',')
|
if (*resp == ',')
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct rstring_list_t {
|
typedef struct rstring_list_t {
|
||||||
unsigned int size;
|
unsigned long long size;
|
||||||
unsigned int count;
|
unsigned long long count;
|
||||||
char **strings;
|
char **strings;
|
||||||
} rstring_list_t;
|
} rstring_list_t;
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ rstring_list_t *rstring_list_new() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void rstring_list_free(rstring_list_t *rsl) {
|
void rstring_list_free(rstring_list_t *rsl) {
|
||||||
for (uint i = 0; i < rsl->size; i++) {
|
for (unsigned long long i = 0; i < rsl->size; i++) {
|
||||||
free(rsl->strings[i]);
|
free(rsl->strings[i]);
|
||||||
}
|
}
|
||||||
if (rsl->strings)
|
if (rsl->strings)
|
||||||
@ -34,7 +36,7 @@ void rstring_list_add(rstring_list_t *rsl, char *str) {
|
|||||||
rsl->count++;
|
rsl->count++;
|
||||||
}
|
}
|
||||||
bool rstring_list_contains(rstring_list_t *rsl, char *str) {
|
bool rstring_list_contains(rstring_list_t *rsl, char *str) {
|
||||||
for (uint i = 0; i < rsl->count; i++) {
|
for (unsigned long long i = 0; i < rsl->count; i++) {
|
||||||
if (!strcmp(rsl->strings[i], str))
|
if (!strcmp(rsl->strings[i], str))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user