strcmp
This commit is contained in:
parent
32760601af
commit
3bbb476505
71
src/nm.c
71
src/nm.c
|
@ -144,31 +144,7 @@ int strcmp_nm(void *a, void *b) {
|
||||||
t_entry *bb = (t_entry *)b;
|
t_entry *bb = (t_entry *)b;
|
||||||
char *s1 = aa->symbol;
|
char *s1 = aa->symbol;
|
||||||
char *s2 = bb->symbol;
|
char *s2 = bb->symbol;
|
||||||
size_t a_i = 0;
|
return ft_strcmp(s1, s2);
|
||||||
size_t b_i = 0;
|
|
||||||
while (s1[a_i] && s2[b_i]) {
|
|
||||||
bool is_okay = true;
|
|
||||||
char c = s1[a_i] & 0x11101111;
|
|
||||||
if (!(c >= 'a' && c <= 'z')) {
|
|
||||||
++a_i;
|
|
||||||
is_okay = false;
|
|
||||||
}
|
|
||||||
c = s2[b_i] & 0x11101111;
|
|
||||||
if (!(c >= 'a' && c <= 'z')) {
|
|
||||||
is_okay = false;
|
|
||||||
++b_i;
|
|
||||||
}
|
|
||||||
if (is_okay) {
|
|
||||||
printf("comparing %c and %c\n", s1[a_i], s2[b_i]);
|
|
||||||
if ((s1[a_i] & 0x11101111) != (s2[b_i] & 0x11101111)) {
|
|
||||||
return s1[a_i] - s2[b_i];
|
|
||||||
} else {
|
|
||||||
a_i++;
|
|
||||||
b_i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return s1[a_i] - s2[b_i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int reverse(void *a, void *b) {
|
int reverse(void *a, void *b) {
|
||||||
|
@ -184,29 +160,6 @@ int nosort(void *a, void *b) {
|
||||||
void put_entry(void *data) {
|
void put_entry(void *data) {
|
||||||
t_node *node = (t_node *)data;
|
t_node *node = (t_node *)data;
|
||||||
t_entry *entry = (t_entry *)node->data;
|
t_entry *entry = (t_entry *)node->data;
|
||||||
/* if (node->parent) {
|
|
||||||
ft_putstr("node has parent: ");
|
|
||||||
t_node *parent = (t_node *)node->parent;
|
|
||||||
t_entry *lol = (t_entry *)parent->data;
|
|
||||||
ft_putstr(lol->string);
|
|
||||||
}
|
|
||||||
if (node->left) {
|
|
||||||
ft_putstr("node has left: ");
|
|
||||||
t_node *left = (t_node *)node->left;
|
|
||||||
t_entry *lol = (t_entry *)left->data;
|
|
||||||
ft_putstr(lol->string);
|
|
||||||
}
|
|
||||||
if (node->right) {
|
|
||||||
ft_putstr("node has right: ");
|
|
||||||
t_node *right = (t_node *)node->right;
|
|
||||||
t_entry *lol = (t_entry *)right->data;
|
|
||||||
ft_putstr(lol->string);
|
|
||||||
}
|
|
||||||
if (node->color == RED) {
|
|
||||||
ft_putstr("RED NODE: ");
|
|
||||||
} else {
|
|
||||||
ft_putstr("BLACK NODE: ");
|
|
||||||
}*/
|
|
||||||
ft_putstr(entry->string);
|
ft_putstr(entry->string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,28 +277,6 @@ int nm64(t_mapped_file mapped_file, char *path, t_verbosity verbosity, t_orderin
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
// ici on affiche tout ou no symbols en cas de list vide
|
// ici on affiche tout ou no symbols en cas de list vide
|
||||||
/* char buffer[16384];
|
|
||||||
size_t buf_i = 0;
|
|
||||||
size_t entry_string_len = 0;
|
|
||||||
if (list) {
|
|
||||||
while (list) {
|
|
||||||
t_entry *my_entry = (t_entry *)list->content;
|
|
||||||
entry_string_len = ft_strlen(my_entry->string);
|
|
||||||
if (buf_i + entry_string_len < 16384) {
|
|
||||||
ft_memcpy(buffer + buf_i, my_entry->string, entry_string_len);
|
|
||||||
buf_i += entry_string_len;
|
|
||||||
} else {
|
|
||||||
buffer[buf_i] = '\0';
|
|
||||||
ft_putstr(buffer);
|
|
||||||
buf_i = 0;
|
|
||||||
}
|
|
||||||
//ft_putstr(my_entry->string);
|
|
||||||
list = list->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ft_printf("sss", "nm: ", path, ": no symbols\n");
|
|
||||||
}*/
|
|
||||||
if (tree) {
|
if (tree) {
|
||||||
ft_putrbt(tree, &put_entry);
|
ft_putrbt(tree, &put_entry);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue