/* ================================================================================ RPL/2 (R) version 4.1.20 Copyright (C) 1989-2015 Dr. BERTRAND Joël This file is part of RPL/2. RPL/2 is free software; you can redistribute it and/or modify it under the terms of the CeCILL V2 License as published by the french CEA, CNRS and INRIA. RPL/2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License for more details. You should have received a copy of the CeCILL License along with RPL/2. If not, write to info@cecill.info. ================================================================================ */ #include "rpl-conv.h" /* ================================================================================ Procédures de contrôle de la complétion automatique ================================================================================ Entrée : -------------------------------------------------------------------------------- Sortie : -------------------------------------------------------------------------------- Effets de bord : néant ================================================================================ */ void initialisation_completion() { rl_attempted_completion_function = (rl_completion_func_t *) completion_rpl; } char ** completion_rpl(char *texte, int debut, int fin) { return rl_completion_matches(texte, generateur_commandes); } char * generateur_commandes(char *texte, int etat) { char *nom; char *tampon; static int indice; static size_t longueur; # define COMPLETION # include "completion-conv.h" if (!etat) { indice = 0; longueur = strlen(texte); } while((nom = commandes[indice]) != NULL) { indice++; if (strncmp(nom, texte, longueur) == 0) { tampon = malloc((strlen(nom) + 1) * sizeof(char)); if (tampon == NULL) { return(NULL); } else { return(strcpy(tampon, nom)); } } } return((char *) NULL); } // vim: ts=4