int main(int argc, char** argv) { printf("KEY META TESTS\n"); printf("==================\n\n"); init (argc, argv); test_basic(); test_iterate(); test_size(); test_uid(); test_dup(); test_comment(); test_owner(); test_mode(); test_type(); test_examples(); test_copy(); test_ro(); test_new(); test_copyall(); printf("\ntest_ks RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError); return nbError; }
type_noeud_comment *validate_comments(type_noeud_comment *anchor_comment, GtkWidget * entry) { GtkTextIter start, end, iter; GtkTextBuffer *buffer; char *text; gboolean is_not_the_end; type_noeud_comment *pt_comment; int longueur; type_noeud_comment *pt_prec = NULL, *pt_fin = NULL; pt_comment = anchor_comment; buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)); gtk_text_buffer_get_line_count(buffer); gtk_text_buffer_get_bounds(buffer, &start, &end); iter = start; do { is_not_the_end = gtk_text_iter_forward_line(&iter); text = gtk_text_iter_get_text(&start, &iter); start = iter; if (pt_comment == NULL) { pt_comment = ALLOCATION(type_noeud_comment); pt_comment->suiv = NULL; if (anchor_comment == NULL) { anchor_comment = pt_comment; } else { pt_prec->suiv = pt_comment; } } longueur = strlen(text) + 1; if (longueur > TAILLE_CHAINE) { printf("WARNING: la chaine de char: %s a ete tronquee dans validate_comments car sa taille est superieure a %d\n", text, TAILLE_CHAINE); longueur = TAILLE_CHAINE; } /* recopie dans le champs comment en rajoutant un % au debut s'il a ete oublie */ /* on ne fait rien pour les lignes vides */ if (test_comment(text) == 1 || empty_line(text) == 1) { memcpy(pt_comment->chaine, text, longueur * sizeof(char)); } else { pt_comment->chaine[0] = '%'; memcpy(&(pt_comment->chaine[1]), text, longueur * sizeof(char)); } pt_prec = pt_comment; pt_comment = pt_comment->suiv; g_free (text); } while (is_not_the_end == TRUE); if (strlen(pt_prec->chaine) > 0 && pt_prec->chaine[strlen(pt_prec->chaine)-1] != '\n') { strcat(pt_prec->chaine, "\n"); } /* Suppression des donnees du buffer */ gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_get_end_iter(buffer, &end); gtk_text_buffer_delete(buffer, &start, &end); /* Suppression du reste de la liste chainee des commentaire ==> utile si on a supprime des commentaires*/ pt_fin = pt_prec; while (pt_comment != NULL) { pt_prec = pt_comment; pt_comment = pt_comment->suiv; free(pt_prec); } pt_fin->suiv = NULL; return anchor_comment; }