File:  [local] / rpl / src / completion.c
Revision 1.67: download - view: text, annotated - select for diffs - revision graph
Fri Jan 10 11:15:41 2020 UTC (4 years, 3 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_32, HEAD
Modification du copyright.

    1: /*
    2: ================================================================================
    3:   RPL/2 (R) version 4.1.32
    4:   Copyright (C) 1989-2020 Dr. BERTRAND Joël
    5: 
    6:   This file is part of RPL/2.
    7: 
    8:   RPL/2 is free software; you can redistribute it and/or modify it
    9:   under the terms of the CeCILL V2 License as published by the french
   10:   CEA, CNRS and INRIA.
   11:  
   12:   RPL/2 is distributed in the hope that it will be useful, but WITHOUT
   13:   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14:   FITNESS FOR A PARTICULAR PURPOSE.  See the CeCILL V2 License
   15:   for more details.
   16:  
   17:   You should have received a copy of the CeCILL License
   18:   along with RPL/2. If not, write to info@cecill.info.
   19: ================================================================================
   20: */
   21: 
   22: 
   23: #include "rpl-conv.h"
   24: 
   25: 
   26: /*
   27: ================================================================================
   28:   Procédures de contrôle de la complétion automatique
   29: ================================================================================
   30:   Entrée :
   31: --------------------------------------------------------------------------------
   32:   Sortie :
   33: --------------------------------------------------------------------------------
   34:   Effets de bord : néant
   35: ================================================================================
   36: */
   37: 
   38: void
   39: initialisation_completion()
   40: {
   41:     rl_attempted_completion_function = (rl_completion_func_t *) completion_rpl;
   42: }
   43: 
   44: 
   45: char **
   46: completion_rpl(char *texte, int debut, int fin)
   47: {
   48:     return rl_completion_matches(texte, generateur_commandes);
   49: }
   50: 
   51: 
   52: char *
   53: generateur_commandes(char *texte, int etat)
   54: {
   55:     char                *nom;
   56:     char                *tampon;
   57: 
   58:     static int          indice;
   59:     static size_t       longueur;
   60: 
   61: #   define COMPLETION
   62: #   include "completion-conv.h"
   63: 
   64:     if (!etat)
   65:     {
   66:         indice = 0;
   67:         longueur = strlen(texte);
   68:     }
   69: 
   70:     while((nom = commandes[indice]) != NULL)
   71:     {
   72:         indice++;
   73: 
   74:         if (strncmp(nom, texte, longueur) == 0)
   75:         {
   76:             tampon = sys_malloc((strlen(nom) + 1) * sizeof(char));
   77: 
   78:             if (tampon == NULL)
   79:             {
   80:                 return(NULL);
   81:             }
   82:             else
   83:             {
   84:                 return(strcpy(tampon, nom));
   85:             }
   86:         }
   87:     }
   88: 
   89:     return((char *) NULL);
   90: }
   91: 
   92: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>