File:  [local] / rpl / src / instructions_h1.c
Revision 1.72: download - view: text, annotated - select for diffs - revision graph
Fri Jan 10 11:15:45 2020 UTC (4 years, 3 months ago) by bertrand
Branches: MAIN
CVS tags: 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:   Fonction 'hex'
   29: ================================================================================
   30:   Entrées :
   31: --------------------------------------------------------------------------------
   32:   Sorties :
   33: --------------------------------------------------------------------------------
   34:   Effets de bord : néant
   35: ================================================================================
   36: */
   37: 
   38: void
   39: instruction_hex(struct_processus *s_etat_processus)
   40: {
   41:     (*s_etat_processus).erreur_execution = d_ex;
   42: 
   43:     if ((*s_etat_processus).affichage_arguments == 'Y')
   44:     {
   45:         printf("\n  HEX ");
   46: 
   47:         if ((*s_etat_processus).langue == 'F')
   48:         {
   49:             printf("(base hexadécimale)\n\n");
   50:             printf("  Aucun argument\n");
   51:         }
   52:         else
   53:         {
   54:             printf("(hexadecimal base)\n\n");
   55:             printf("  No argument\n");
   56:         }
   57: 
   58:         return;
   59:     }
   60:     else if ((*s_etat_processus).test_instruction == 'Y')
   61:     {
   62:         (*s_etat_processus).nombre_arguments = -1;
   63:         return;
   64:     }
   65: 
   66:     sf(s_etat_processus, 43);
   67:     sf(s_etat_processus, 44);
   68: 
   69:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
   70:     {
   71:         if (empilement_pile_last(s_etat_processus, 0) == d_erreur)
   72:         {
   73:             return;
   74:         }
   75:     }
   76: 
   77:     return;
   78: }
   79: 
   80: 
   81: /*
   82: ================================================================================
   83:   Fonction 'HMS->'
   84: ================================================================================
   85:   Entrées : structure processus
   86: --------------------------------------------------------------------------------
   87:   Sorties :
   88: --------------------------------------------------------------------------------
   89:   Effets de bord : néant
   90: ================================================================================
   91: */
   92: 
   93: void
   94: instruction_hms_fleche(struct_processus *s_etat_processus)
   95: {
   96:     struct_objet                    *s_copie;
   97:     struct_objet                    *s_objet;
   98: 
   99:     (*s_etat_processus).erreur_execution = d_ex;
  100: 
  101:     if ((*s_etat_processus).affichage_arguments == 'Y')
  102:     {
  103:         printf("\n  HMS-> ");
  104: 
  105:         if ((*s_etat_processus).langue == 'F')
  106:         {
  107:             printf("(conversion décimale)\n\n");
  108:         }
  109:         else
  110:         {
  111:             printf("(conversion from hours minutes seconds to decimal)\n\n");
  112:         }
  113: 
  114:         printf("    1: %s\n", d_INT);
  115:         printf("->  1: %s\n\n", d_INT);
  116: 
  117:         printf("    1: %s\n", d_REL);
  118:         printf("->  1: %s\n", d_REL);
  119: 
  120:         return;
  121:     }
  122:     else if ((*s_etat_processus).test_instruction == 'Y')
  123:     {
  124:         (*s_etat_processus).nombre_arguments = -1;
  125:         return;
  126:     }
  127: 
  128:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  129:     {
  130:         if (empilement_pile_last(s_etat_processus, 1) == d_erreur)
  131:         {
  132:             return;
  133:         }
  134:     }
  135: 
  136:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  137:             &s_objet) == d_erreur)
  138:     {
  139:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  140:         return;
  141:     }
  142: 
  143: /*
  144: --------------------------------------------------------------------------------
  145:   Argument entier
  146: --------------------------------------------------------------------------------*/
  147: 
  148:     if ((*s_objet).type == INT)
  149:     {
  150:         /*
  151:          * On ne fait rien...
  152:          */
  153:     }
  154: 
  155: /*
  156: --------------------------------------------------------------------------------
  157:   Argument réel
  158: --------------------------------------------------------------------------------
  159: */
  160: 
  161:     else if ((*s_objet).type == REL)
  162:     {
  163:         if ((s_copie = copie_objet(s_etat_processus, s_objet, 'O')) == NULL)
  164:         {
  165:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  166:             return;
  167:         }
  168: 
  169:         liberation(s_etat_processus, s_objet);
  170:         s_objet = s_copie;
  171: 
  172:         conversion_hms_vers_decimal((real8 *) (*s_objet).objet);
  173:     }
  174: 
  175: /*
  176: --------------------------------------------------------------------------------
  177:   Argument invalide
  178: --------------------------------------------------------------------------------
  179: */
  180: 
  181:     else
  182:     {
  183:         liberation(s_etat_processus, s_objet);
  184: 
  185:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  186:         return;
  187:     }
  188: 
  189:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  190:             s_objet) == d_erreur)
  191:     {
  192:         return;
  193:     }
  194: 
  195:     return;
  196: }
  197: 
  198: 
  199: /*
  200: ================================================================================
  201:   Fonction 'HMS+'
  202: ================================================================================
  203:   Entrées : structure processus
  204: --------------------------------------------------------------------------------
  205:   Sorties :
  206: --------------------------------------------------------------------------------
  207:   Effets de bord : néant
  208: ================================================================================
  209: */
  210: 
  211: void
  212: instruction_hms_plus(struct_processus *s_etat_processus)
  213: {
  214:     integer8                        tampon;
  215: 
  216:     struct_objet                    *s_objet_argument_1;
  217:     struct_objet                    *s_objet_argument_2;
  218:     struct_objet                    *s_objet_resultat;
  219: 
  220:     (*s_etat_processus).erreur_execution = d_ex;
  221: 
  222:     if ((*s_etat_processus).affichage_arguments == 'Y')
  223:     {
  224:         printf("\n  HMS+ ");
  225: 
  226:         if ((*s_etat_processus).langue == 'F')
  227:         {
  228:             printf("(addition sexadécimale)\n\n");
  229:         }
  230:         else
  231:         {
  232:             printf("(addition in hours minutes seconds format)\n\n");
  233:         }
  234: 
  235:         printf("    2: %s\n", d_INT);
  236:         printf("    1: %s\n", d_INT);
  237:         printf("->  1: %s, %s\n\n", d_INT, d_REL);
  238: 
  239:         printf("    2: %s, %s\n", d_INT, d_REL);
  240:         printf("    1: %s, %s\n", d_INT, d_REL);
  241:         printf("->  1: %s\n", d_REL);
  242: 
  243:         return;
  244:     }
  245:     else if ((*s_etat_processus).test_instruction == 'Y')
  246:     {
  247:         (*s_etat_processus).nombre_arguments = -1;
  248:         return;
  249:     }
  250: 
  251:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  252:     {
  253:         if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
  254:         {
  255:             return;
  256:         }
  257:     }
  258: 
  259:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  260:             &s_objet_argument_1) == d_erreur)
  261:     {
  262:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  263:         return;
  264:     }
  265: 
  266:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  267:             &s_objet_argument_2) == d_erreur)
  268:     {
  269:         liberation(s_etat_processus, s_objet_argument_1);
  270:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  271:         return;
  272:     }
  273: 
  274: /*
  275: --------------------------------------------------------------------------------
  276:   Arguments entiers
  277: --------------------------------------------------------------------------------*/
  278: 
  279:     if (((*s_objet_argument_1).type == INT) &&
  280:             ((*s_objet_argument_2).type == INT))
  281:     {
  282:         if (depassement_addition((integer8 *) (*s_objet_argument_1).objet,
  283:                 (integer8 *) (*s_objet_argument_2).objet, &tampon) ==
  284:                 d_absence_erreur)
  285:         {
  286:             if ((s_objet_resultat = allocation(s_etat_processus, INT))
  287:                     == NULL)
  288:             {
  289:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  290:                 return;
  291:             }
  292: 
  293:             (*((integer8 *) (*s_objet_resultat).objet)) = tampon;
  294:         }
  295:         else
  296:         {
  297:             if ((s_objet_resultat = allocation(s_etat_processus, REL))
  298:                     == NULL)
  299:             {
  300:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  301:                 return;
  302:             }
  303: 
  304:             (*((real8 *) (*s_objet_resultat).objet)) = ((real8)
  305:                     (*((integer8 *) (*s_objet_argument_1).objet))) + ((real8)
  306:                     (*((integer8 *) (*s_objet_argument_2).objet)));
  307:         }
  308:     }
  309: 
  310: /*
  311: --------------------------------------------------------------------------------
  312:   Au moins un argument réel
  313: --------------------------------------------------------------------------------
  314: */
  315: 
  316:     else if (((*s_objet_argument_1).type == REL) &&
  317:             ((*s_objet_argument_2).type == INT))
  318:     {
  319:         conversion_hms_vers_decimal((real8 *) (*s_objet_argument_1).objet);
  320: 
  321:         if ((s_objet_resultat = allocation(s_etat_processus, REL))
  322:                 == NULL)
  323:         {
  324:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  325:             return;
  326:         }
  327: 
  328:         (*((real8 *) (*s_objet_resultat).objet)) = ((real8) (*((integer8 *)
  329:                 (*s_objet_argument_2).objet))) + (*((real8 *)
  330:                 (*s_objet_argument_1).objet));
  331: 
  332:         conversion_decimal_vers_hms((real8 *) (*s_objet_resultat).objet);
  333:     }
  334:     else if (((*s_objet_argument_1).type == INT) &&
  335:             ((*s_objet_argument_2).type == REL))
  336:     {
  337:         conversion_hms_vers_decimal((real8 *) (*s_objet_argument_2).objet);
  338: 
  339:         if ((s_objet_resultat = allocation(s_etat_processus, REL))
  340:                 == NULL)
  341:         {
  342:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  343:             return;
  344:         }
  345: 
  346:         (*((real8 *) (*s_objet_resultat).objet)) = (*((real8 *)
  347:                 (*s_objet_argument_2).objet)) + ((real8) (*((integer8 *)
  348:                 (*s_objet_argument_1).objet)));
  349: 
  350:         conversion_decimal_vers_hms((real8 *) (*s_objet_resultat).objet);
  351:     }
  352:     else if (((*s_objet_argument_1).type == REL) &&
  353:             ((*s_objet_argument_2).type == REL))
  354:     {
  355:         conversion_hms_vers_decimal((real8 *) (*s_objet_argument_1).objet);
  356:         conversion_hms_vers_decimal((real8 *) (*s_objet_argument_2).objet);
  357: 
  358:         if ((s_objet_resultat = allocation(s_etat_processus, REL))
  359:                 == NULL)
  360:         {
  361:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  362:             return;
  363:         }
  364: 
  365:         (*((real8 *) (*s_objet_resultat).objet)) = (*((real8 *)
  366:                 (*s_objet_argument_2).objet)) + (*((real8 *)
  367:                 (*s_objet_argument_1).objet));
  368: 
  369:         conversion_decimal_vers_hms((real8 *) (*s_objet_resultat).objet);
  370:     }
  371: 
  372: /*
  373: --------------------------------------------------------------------------------
  374:   Argument invalide
  375: --------------------------------------------------------------------------------
  376: */
  377: 
  378:     else
  379:     {
  380:         liberation(s_etat_processus, s_objet_argument_1);
  381:         liberation(s_etat_processus, s_objet_argument_2);
  382: 
  383:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  384:         return;
  385:     }
  386: 
  387:     liberation(s_etat_processus, s_objet_argument_1);
  388:     liberation(s_etat_processus, s_objet_argument_2);
  389: 
  390:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  391:             s_objet_resultat) == d_erreur)
  392:     {
  393:         return;
  394:     }
  395: 
  396:     return;
  397: }
  398: 
  399: 
  400: /*
  401: ================================================================================
  402:   Fonction 'HMS-'
  403: ================================================================================
  404:   Entrées : structure processus
  405: --------------------------------------------------------------------------------
  406:   Sorties :
  407: --------------------------------------------------------------------------------
  408:   Effets de bord : néant
  409: ================================================================================
  410: */
  411: 
  412: void
  413: instruction_hms_moins(struct_processus *s_etat_processus)
  414: {
  415:     integer8                        tampon;
  416: 
  417:     struct_objet                    *s_objet_argument_1;
  418:     struct_objet                    *s_objet_argument_2;
  419:     struct_objet                    *s_objet_resultat;
  420: 
  421:     (*s_etat_processus).erreur_execution = d_ex;
  422: 
  423:     if ((*s_etat_processus).affichage_arguments == 'Y')
  424:     {
  425:         printf("\n  HMS- ");
  426: 
  427:         if ((*s_etat_processus).langue == 'F')
  428:         {
  429:             printf("(soustraction sexadécimale)\n\n");
  430:         }
  431:         else
  432:         {
  433:             printf("(substraction in hours minutes seconds format)\n\n");
  434:         }
  435: 
  436:         printf("    2: %s\n", d_INT);
  437:         printf("    1: %s\n", d_INT);
  438:         printf("->  1: %s, %s\n\n", d_INT, d_REL);
  439: 
  440:         printf("    2: %s, %s\n", d_INT, d_REL);
  441:         printf("    1: %s, %s\n", d_INT, d_REL);
  442:         printf("->  1: %s\n", d_REL);
  443: 
  444:         return;
  445:     }
  446:     else if ((*s_etat_processus).test_instruction == 'Y')
  447:     {
  448:         (*s_etat_processus).nombre_arguments = -1;
  449:         return;
  450:     }
  451: 
  452:     if (test_cfsf(s_etat_processus, 31) == d_vrai)
  453:     {
  454:         if (empilement_pile_last(s_etat_processus, 2) == d_erreur)
  455:         {
  456:             return;
  457:         }
  458:     }
  459: 
  460:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  461:             &s_objet_argument_1) == d_erreur)
  462:     {
  463:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  464:         return;
  465:     }
  466: 
  467:     if (depilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  468:             &s_objet_argument_2) == d_erreur)
  469:     {
  470:         liberation(s_etat_processus, s_objet_argument_1);
  471:         (*s_etat_processus).erreur_execution = d_ex_manque_argument;
  472:         return;
  473:     }
  474: 
  475: /*
  476: --------------------------------------------------------------------------------
  477:   Arguments entiers
  478: --------------------------------------------------------------------------------*/
  479: 
  480:     if (((*s_objet_argument_1).type == INT) &&
  481:             ((*s_objet_argument_2).type == INT))
  482:     {
  483:         if (depassement_soustraction((integer8 *) (*s_objet_argument_2).objet,
  484:                 (integer8 *) (*s_objet_argument_1).objet, &tampon) ==
  485:                 d_absence_erreur)
  486:         {
  487:             if ((s_objet_resultat = allocation(s_etat_processus, INT))
  488:                     == NULL)
  489:             {
  490:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  491:                 return;
  492:             }
  493: 
  494:             (*((integer8 *) (*s_objet_resultat).objet)) = tampon;
  495:         }
  496:         else
  497:         {
  498:             if ((s_objet_resultat = allocation(s_etat_processus, REL))
  499:                     == NULL)
  500:             {
  501:                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  502:                 return;
  503:             }
  504: 
  505:             (*((real8 *) (*s_objet_resultat).objet)) = ((real8)
  506:                     (*((integer8 *) (*s_objet_argument_2).objet))) - ((real8)
  507:                     (*((integer8 *) (*s_objet_argument_1).objet)));
  508:         }
  509:     }
  510: 
  511: /*
  512: --------------------------------------------------------------------------------
  513:   Au moins un argument réel
  514: --------------------------------------------------------------------------------
  515: */
  516: 
  517:     else if (((*s_objet_argument_1).type == REL) &&
  518:             ((*s_objet_argument_2).type == INT))
  519:     {
  520:         conversion_hms_vers_decimal((real8 *) (*s_objet_argument_1).objet);
  521: 
  522:         if ((s_objet_resultat = allocation(s_etat_processus, REL))
  523:                 == NULL)
  524:         {
  525:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  526:             return;
  527:         }
  528: 
  529:         (*((real8 *) (*s_objet_resultat).objet)) = ((real8) (*((integer8 *)
  530:                 (*s_objet_argument_2).objet))) - (*((real8 *)
  531:                 (*s_objet_argument_1).objet));
  532: 
  533:         conversion_decimal_vers_hms((real8 *) (*s_objet_resultat).objet);
  534:     }
  535:     else if (((*s_objet_argument_1).type == INT) &&
  536:             ((*s_objet_argument_2).type == REL))
  537:     {
  538:         conversion_hms_vers_decimal((real8 *) (*s_objet_argument_2).objet);
  539: 
  540:         if ((s_objet_resultat = allocation(s_etat_processus, REL))
  541:                 == NULL)
  542:         {
  543:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  544:             return;
  545:         }
  546: 
  547:         (*((real8 *) (*s_objet_resultat).objet)) = (*((real8 *)
  548:                 (*s_objet_argument_2).objet)) - ((real8) (*((integer8 *)
  549:                 (*s_objet_argument_1).objet)));
  550: 
  551:         conversion_decimal_vers_hms((real8 *) (*s_objet_resultat).objet);
  552:     }
  553:     else if (((*s_objet_argument_1).type == REL) &&
  554:             ((*s_objet_argument_2).type == REL))
  555:     {
  556:         conversion_hms_vers_decimal((real8 *) (*s_objet_argument_1).objet);
  557:         conversion_hms_vers_decimal((real8 *) (*s_objet_argument_2).objet);
  558: 
  559:         if ((s_objet_resultat = allocation(s_etat_processus, REL))
  560:                 == NULL)
  561:         {
  562:             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
  563:             return;
  564:         }
  565: 
  566:         (*((real8 *) (*s_objet_resultat).objet)) = (*((real8 *)
  567:                 (*s_objet_argument_2).objet)) - (*((real8 *)
  568:                 (*s_objet_argument_1).objet));
  569: 
  570:         conversion_decimal_vers_hms((real8 *) (*s_objet_resultat).objet);
  571:     }
  572: 
  573: /*
  574: --------------------------------------------------------------------------------
  575:   Argument invalide
  576: --------------------------------------------------------------------------------
  577: */
  578: 
  579:     else
  580:     {
  581:         liberation(s_etat_processus, s_objet_argument_1);
  582:         liberation(s_etat_processus, s_objet_argument_2);
  583: 
  584:         (*s_etat_processus).erreur_execution = d_ex_erreur_type_argument;
  585:         return;
  586:     }
  587: 
  588:     liberation(s_etat_processus, s_objet_argument_1);
  589:     liberation(s_etat_processus, s_objet_argument_2);
  590: 
  591:     if (empilement(s_etat_processus, &((*s_etat_processus).l_base_pile),
  592:             s_objet_resultat) == d_erreur)
  593:     {
  594:         return;
  595:     }
  596: 
  597:     return;
  598: }
  599: 
  600: 
  601: /*
  602: ================================================================================
  603:   Fonction 'halt'
  604: ================================================================================
  605:   Entrées :
  606: --------------------------------------------------------------------------------
  607:   Sorties :
  608: --------------------------------------------------------------------------------
  609:   Effets de bord : néant
  610: ================================================================================
  611: */
  612: 
  613: void
  614: instruction_halt(struct_processus *s_etat_processus)
  615: {
  616:     (*s_etat_processus).erreur_execution = d_ex;
  617: 
  618:     if ((*s_etat_processus).affichage_arguments == 'Y')
  619:     {
  620:         printf("\n  HALT ");
  621: 
  622:         if ((*s_etat_processus).langue == 'F')
  623:         {
  624:             printf("(arrêt du programme)\n\n");
  625:             printf("  Aucun argument\n");
  626:         }
  627:         else
  628:         {
  629:             printf("(program halt)\n\n");
  630:             printf("  No argument\n");
  631:         }
  632: 
  633:         return;
  634:     }
  635:     else if ((*s_etat_processus).test_instruction == 'Y')
  636:     {
  637:         (*s_etat_processus).nombre_arguments = -1;
  638:         return;
  639:     }
  640: 
  641:     (*s_etat_processus).debug_programme = d_vrai;
  642: 
  643:     return;
  644: }
  645: 
  646: 
  647: /*
  648: ================================================================================
  649:   Fonction 'histogram'
  650: ================================================================================
  651:   Entrées :
  652: --------------------------------------------------------------------------------
  653:   Sorties :
  654: --------------------------------------------------------------------------------
  655:   Effets de bord : néant
  656: ================================================================================
  657: */
  658: 
  659: void
  660: instruction_histogram(struct_processus *s_etat_processus)
  661: {
  662:     (*s_etat_processus).erreur_execution = d_ex;
  663: 
  664:     if ((*s_etat_processus).affichage_arguments == 'Y')
  665:     {
  666:         printf("\n  HISTOGRAM ");
  667: 
  668:         if ((*s_etat_processus).langue == 'F')
  669:         {
  670:             printf("(graphique statistique de type histogramme)\n\n");
  671:             printf("  Aucun argument\n");
  672:         }
  673:         else
  674:         {
  675:             printf("(histogram statistical graphic)\n\n");
  676:             printf("  No argument\n");
  677:         }
  678: 
  679:         return;
  680:     }
  681:     else if ((*s_etat_processus).test_instruction == 'Y')
  682:     {
  683:         (*s_etat_processus).nombre_arguments = -1;
  684:         return;
  685:     }
  686: 
  687:     strcpy((*s_etat_processus).type_trace_sigma, "HISTOGRAMME");
  688: 
  689:     return;
  690: }
  691: 
  692: 
  693: /*
  694: ================================================================================
  695:   Fonction 'help'
  696: ================================================================================
  697:   Entrées :
  698: --------------------------------------------------------------------------------
  699:   Sorties :
  700: --------------------------------------------------------------------------------
  701:   Effets de bord : néant
  702: ================================================================================
  703: */
  704: 
  705: void
  706: instruction_help(struct_processus *s_etat_processus)
  707: {
  708:     unsigned char           *fonction;
  709:     unsigned char           ligne[80 + 1];
  710:     unsigned char           *pointeur;
  711:     unsigned char           **ptr;
  712:     unsigned char           *registre;
  713: 
  714: #   undef COMPLETION
  715: #   include "completion-conv.h"
  716: #   include "usages-conv.h"
  717: 
  718:     if ((*s_etat_processus).test_instruction == 'Y')
  719:     {
  720:         (*s_etat_processus).nombre_arguments = -1;
  721:         return;
  722:     }
  723: 
  724:     (*s_etat_processus).erreur_execution = d_ex;
  725: 
  726:     printf("\n");
  727: 
  728:     if ((*s_etat_processus).langue == 'F')
  729:     {
  730:         printf("Liste alphabétique des fonctions intrinsèques :\n\n");
  731:     }
  732:     else
  733:     {
  734:         printf("Alphabetical list of intrinsic functions :\n\n");
  735:     }
  736: 
  737:     ptr = commandes;
  738:     *ligne = d_code_fin_chaine;
  739: 
  740:     while(*ptr != (unsigned char *) NULL)
  741:     {
  742:         if (strcmp((*ptr), COMPLETION_RC) == 0)
  743:         {
  744:             printf("%s\n\n", ligne);
  745:             *ligne = d_code_fin_chaine;
  746:         }
  747:         else if ((strlen(ligne) + strlen(*ptr) + 2) > 80)
  748:         {
  749:             printf("%s\n", ligne);
  750:             *ligne = d_code_fin_chaine;
  751:             strcpy(ligne, "    ");
  752:             strcat(ligne, *ptr);
  753: 
  754:             if (*(ptr + 1) != NULL)
  755:             {
  756:                 strcat(ligne, ", ");
  757:             }
  758:         }
  759:         else
  760:         {
  761:             if (*ligne == d_code_fin_chaine)
  762:             {
  763:                 strcat(ligne, "  ");
  764:             }
  765: 
  766:             strcat(ligne, *ptr);
  767: 
  768:             if (*(ptr + 1) != NULL)
  769:             {
  770:                 strcat(ligne, ", ");
  771:             }
  772:         }
  773: 
  774:         ptr++;
  775:     }
  776: 
  777:     if (strlen(ligne) != 0)
  778:     {
  779:         printf("%s\n", ligne);
  780:     }
  781: 
  782:     printf("\n");
  783: 
  784:     if ((*s_etat_processus).langue == 'F')
  785:     {
  786:         printf("Délimiteurs :\n\n");
  787:         printf("  aucun   : scalaire, nombre entier ou réel ;\n");
  788:         printf("  ( )     : nombre complexe ;\n");
  789:         printf("  #       : entier binaire ;\n");
  790:         printf("  << >>   : fonction utilisateur ou équation en notation "
  791:                 "polonaise inversée ;\n");
  792:         printf("  ' '     : équation en notation algébrique ou nom de "
  793:                 "variable ;\n");
  794:         printf("  [ ]     : vecteur ;\n");
  795:         printf("  [[ ]]   : matrice ;\n");
  796:         printf("  <[ ]>   : table ;\n");
  797:         printf("  \" \"     : chaîne de caractères ;\n");
  798:         printf("  { }     : liste ;\n");
  799:         printf("  /* */   : commentaire ;\n");
  800:         printf("  //      : commentaire allant jusqu'à la fin de la ligne."
  801:                 "\n\n");
  802:         printf("Fonctions classées par usage :\n");
  803:         printf("(les instructions écrites en majuscules sont insensibles à "
  804:                 "la casse)\n\n");
  805:     }
  806:     else
  807:     {
  808:         printf("Delimiters :\n\n");
  809:         printf("  none    : scalar, integer or real number ;\n");
  810:         printf("  ( )     : complex number ;\n");
  811:         printf("  #       : binary integer ;\n");
  812:         printf("  << >>   : user-defined function, or equation expressed in "
  813:                 "RPN ;\n");
  814:         printf("  ' '     : algebraic equation or variable name ;\n");
  815:         printf("  [ ]     : scalar vector ;\n");
  816:         printf("  [[ ]]   : scalar matrix ;\n");
  817:         printf("  <[ ]>   : table ;\n");
  818:         printf("  \" \"     : character string ;\n");
  819:         printf("  { }     : list ;\n");
  820:         printf("  /* */   : comment ;\n");
  821:         printf("  //      : comment running to the end of the line.\n\n");
  822:         printf("Functions ordre by usage :\n");
  823:         printf("(instructions written in upper case are case-unsensitive)\n\n");
  824:     }
  825: 
  826:     ptr = usages;
  827:     *ligne = d_code_fin_chaine;
  828: 
  829:     while(*ptr != (unsigned char *) NULL)
  830:     {
  831:         if (strcmp((*ptr), USAGES_RC) == 0)
  832:         {
  833:             printf("    %s\n\n", ligne);
  834:             *ligne = d_code_fin_chaine;
  835:         }
  836:         else if (strcmp((*ptr), USAGES_TITRE) == 0)
  837:         {
  838:             ptr++;
  839: 
  840:             if ((*s_etat_processus).langue == 'F')
  841:             {
  842:                 ptr++;
  843:                 printf("  %s\n", *ptr);
  844:             }
  845:             else
  846:             {
  847:                 printf("  %s\n", *ptr);
  848:                 ptr++;
  849:             }
  850:         }
  851:         else if ((strlen(ligne) + strlen(*ptr) + 2) > 76)
  852:         {
  853:             printf("    %s\n", ligne);
  854:             *ligne = d_code_fin_chaine;
  855:             strcat(ligne, *ptr);
  856: 
  857:             if (*(ptr + 1) != NULL)
  858:             {
  859:                 strcat(ligne, ", ");
  860:             }
  861:         }
  862:         else
  863:         {
  864:             strcat(ligne, *ptr);
  865: 
  866:             if (*(ptr + 1) != NULL)
  867:             {
  868:                 strcat(ligne, ", ");
  869:             }
  870:         }
  871: 
  872:         ptr++;
  873:     }
  874: 
  875:     if (strlen(ligne) != 0)
  876:     {
  877:         printf("    %s\n", ligne);
  878:     }
  879: 
  880:     printf("\n");
  881: 
  882:     if ((*s_etat_processus).langue == 'F')
  883:     {
  884:         printf("Processus asynchrones :\n");
  885:         printf("  CTRL+c : interruption de l'instruction en cours ;\n");
  886:         printf("  CTRL+d : en mode interactif, provoque un ABORT\n");
  887:         printf("  CTRL+g : en mode interactif, provoque l'annulation de la "
  888:                 "commande en cours ;\n");
  889:         printf("  CTRL+z : en cours d'exécution, provoque un HALT "
  890:                 "asynchrone.\n\n");
  891: 
  892:         printf("Drapeaux (valeurs par défaut) :\n");
  893:         printf("  1 à 30  : drapeaux banalisés (désarmés)\n");
  894:         printf("  31      : pile LAST active (armé en mode interactif, "
  895:                 "désarmé sinon)\n");
  896:         printf("  32      : impression automatique (désarmé)\n");
  897:         printf("  33      : retour à la ligne automatique invalidé "
  898:                 "(désarmé)\n");
  899:         printf("  34      : évaluation des caractères de contrôle (armé)\n");
  900:         printf("  35      : évaluation symbolique des constantes (armé)\n");
  901:         printf("  36      : évaluation symbolique des fonctions (armé)\n");
  902:         printf("  37 à 42 : taille des entiers binaires, bit de poids faible "
  903:                 "en tête (armés)\n");
  904:         printf("  43 à 44 : base de numérotation binaire (désarmés)\n");
  905:         printf("  45      : affichage multiligne (armé)\n");
  906:         printf("  46      : simplification automatique des expression "
  907:                 "(désarmé)\n");
  908:         printf("  47      : réservé (désarmé)\n");
  909:         printf("  48      : virgule comme séparateur décimal (désarmé)\n");
  910:         printf("  49 à 50 : format des nombres (désarmés)\n");
  911:         printf("  51      : tonalité désactivée (désarmé)\n");
  912:         printf("  52      : mise à jour automatique des graphiques désactivée "
  913:                 "(désarmé)\n");
  914:         printf("  53 à 56 : nombre de chiffres décimaux, bit de poids fort "
  915:                 "en tête (désarmés)\n");
  916:         printf("  57 à 59 : réservés (désarmés)\n");
  917:         printf("  60      : radian et non degré comme unité angulaire "
  918:                 "(armé)\n");
  919:         printf("  61 à 64 : réservés (désarmés)\n");
  920:     }
  921:     else
  922:     {
  923:         printf("Hot keys :\n");
  924:         printf("  CTRL+c : interruption ;\n");
  925:         printf("  CTRL+d : in interactive mode only sends ABORT on empty "
  926:                 "command line ;\n");
  927:         printf("  CTRL+g : in interactive mode only, nullifies current "
  928:                 "command line ;\n");
  929:         printf("  CTRL+z : HALT.\n\n");
  930: 
  931:         printf("Flags (default values) :\n");
  932:         printf("  1 to 30  : user flags (cleared)\n");
  933:         printf("  31       : LAST stack enabled (set in interactive mode, "
  934:                 "cleared if not)\n");
  935:         printf("  32       : automatic printing (cleared)\n");
  936:         printf("  33       : automatic carriage return disabled "
  937:                 "(cleared)\n");
  938:         printf("  34       : control characters evaluation (set)\n");
  939:         printf("  35       : constant symbolic evaluation (set)\n");
  940:         printf("  36       : function symbolic evaluation (set)\n");
  941:         printf("  37 to 42 : size of binary integers, while starting with "
  942:                 "less significant bit\n");
  943:         printf("             (set)\n");
  944:         printf("  43 to 44 : binary integer basis (cleared)\n");
  945:         printf("  45       : multiline conversion (set)\n");
  946:         printf("  46       : expression simplification (cleared)\n");
  947:         printf("  47       : reserved (cleared)\n");
  948:         printf("  48       : comma as decimal separator (cleared)\n");
  949:         printf("  49 to 50 : numbers format (cleared)\n");
  950:         printf("  51       : visual bell disabled (cleared)\n");
  951:         printf("  52       : graphic automatic redrawing disabled "
  952:                 "(cleared)\n");
  953:         printf("  53 to 56 : precision, while starting with "
  954:                 "less significant bit (cleared)\n");
  955:         printf("  57 to 59 : reserved (cleared)\n");
  956:         printf("  60       : radian mode instead of degree one (set)\n");
  957:         printf("  61 to 64 : reserved (cleared)\n");
  958:     }
  959: 
  960:     printf("\n");
  961: 
  962:     if ((*s_etat_processus).langue == 'F')
  963:     {
  964:         printf("Types d'arguments :\n\n");
  965:         printf("    %s              : entier (64 bits)\n", d_INT);
  966:         printf("    %s                 : réel (64 bits)\n", d_REL);
  967:         printf("    %s              : complexe (128 bits)\n", d_CPL);
  968:         printf("    %s          : vecteur entier\n", d_VIN);
  969:         printf("    %s             : vecteur réel\n", d_VRL);
  970:         printf("    %s          : vecteur complexe\n", d_VCX);
  971:         printf("    %s        : matrice entière\n", d_MIN);
  972:         printf("    %s           : matrice réelle\n", d_MRL);
  973:         printf("    %s        : matrice complexe\n", d_MCX);
  974:         printf("    %s          : table\n", d_TAB);
  975:         printf("    %s       : entier binaire\n", d_BIN);
  976:         printf("    %s               : nom\n", d_NOM);
  977:         printf("    %s             : chaîne de caractères\n", d_CHN);
  978:         printf("    %s             : liste\n", d_LST);
  979:         printf("    %s          : expression algébrique\n", d_ALG);
  980:         printf("    %s            : expression RPN\n", d_RPN);
  981:         printf("    %s   : descripteur de fichier\n", d_FCH);
  982:         printf("    %s : socket\n", d_SCK);
  983:         printf("    %s           : descripteur de bibliothèque\n", d_SLB);
  984:         printf("    %s           : processus\n", d_PRC);
  985:         printf("    %s        : connexion à une base de données SQL\n", d_SQL);
  986:         printf("    %s             : mutex\n", d_MTX);
  987:         printf("    %s  : sémaphore nommé\n", d_SPH);
  988:         printf("    %s         : enregistrement\n", d_REC);
  989:     }
  990:     else
  991:     {
  992:         printf("Types :\n\n");
  993:         printf("    %s              : integer (64 bits)\n", d_INT);
  994:         printf("    %s                 : real (64 bits)\n", d_REL);
  995:         printf("    %s              : complex (128 bits)\n", d_CPL);
  996:         printf("    %s          : integer vector\n", d_VIN);
  997:         printf("    %s             : real vector\n", d_VRL);
  998:         printf("    %s          : complex vector\n", d_VCX);
  999:         printf("    %s        : integer matrix\n", d_MIN);
 1000:         printf("    %s           : real matrix\n", d_MRL);
 1001:         printf("    %s        : complex matrix\n", d_MCX);
 1002:         printf("    %s          : table\n", d_TAB);
 1003:         printf("    %s       : binary integer\n", d_BIN);
 1004:         printf("    %s               : name\n", d_NOM);
 1005:         printf("    %s             : string of chars\n", d_CHN);
 1006:         printf("    %s             : list\n", d_LST);
 1007:         printf("    %s          : algebraic expression\n", d_ALG);
 1008:         printf("    %s            : RPN expression\n", d_RPN);
 1009:         printf("    %s   : file descriptor\n", d_FCH);
 1010:         printf("    %s : socket\n", d_SCK);
 1011:         printf("    %s           : library descriptor\n", d_SLB);
 1012:         printf("    %s           : process\n", d_PRC);
 1013:         printf("    %s        : connection to SQL database\n", d_SQL);
 1014:         printf("    %s             : mutex\n", d_MTX);
 1015:         printf("    %s  : named semaphore\n", d_SPH);
 1016:         printf("    %s         : record\n", d_REC);
 1017:     }
 1018: 
 1019:     /*
 1020:      * HELP ne doit pas être récursif sous peine de boucler indéfiniment
 1021:      * dans la fonction.
 1022:      */
 1023: 
 1024:     if ((*s_etat_processus).affichage_arguments == 'Y')
 1025:     {
 1026:         return;
 1027:     }
 1028: 
 1029:     printf("\n");
 1030: 
 1031:     registre = (*s_etat_processus).instruction_courante;
 1032: 
 1033:     flockfile(stdin);
 1034:     flockfile(stdout);
 1035: 
 1036:     while((fonction = readline("HELP> ")) != NULL)
 1037:     {
 1038:         if (strcmp(fonction, "") == 0)
 1039:         {
 1040:             break;
 1041:         }
 1042: 
 1043:         funlockfile(stdin);
 1044:         funlockfile(stdout);
 1045: 
 1046:         /*
 1047:          * Élimination des blancs précédents l'instruction
 1048:          */
 1049: 
 1050:         pointeur = fonction;
 1051: 
 1052:         while(((*pointeur) == d_code_tabulation) ||
 1053:                 ((*pointeur) == d_code_espace))
 1054:         {
 1055:             pointeur++;
 1056:         }
 1057: 
 1058:         (*s_etat_processus).instruction_courante = pointeur;
 1059: 
 1060:         /*
 1061:          * Élimination des blancs et caractères suivant la première
 1062:          * instruction.
 1063:          */
 1064: 
 1065:         while(((*pointeur) != d_code_tabulation) &&
 1066:                 ((*pointeur) != d_code_espace) &&
 1067:                 ((*pointeur) != d_code_fin_chaine))
 1068:         {
 1069:             pointeur++;
 1070:         }
 1071: 
 1072:         (*pointeur) = d_code_fin_chaine;
 1073: 
 1074:         add_history(pointeur);
 1075:         stifle_history(ds_longueur_historique);
 1076: 
 1077:         (*s_etat_processus).test_instruction = 'Y';
 1078:         analyse(s_etat_processus, NULL);
 1079:         (*s_etat_processus).test_instruction = 'N';
 1080: 
 1081:         if ((*s_etat_processus).instruction_valide == 'Y')
 1082:         {
 1083:             (*s_etat_processus).affichage_arguments = 'Y';
 1084:             analyse(s_etat_processus, NULL);
 1085:             (*s_etat_processus).affichage_arguments = 'N';
 1086: 
 1087:             printf("\n");
 1088:         }
 1089:         else
 1090:         {
 1091:             if ((*s_etat_processus).langue == 'F')
 1092:             {
 1093:                 printf("Fonction inconnue.\n");
 1094:             }
 1095:             else
 1096:             {
 1097:                 printf("Unknown function\n");
 1098:             }
 1099:         }
 1100: 
 1101:         free(fonction);
 1102:         flockfile(stdin);
 1103:         flockfile(stdout);
 1104:     }
 1105: 
 1106:     funlockfile(stdin);
 1107:     funlockfile(stdout);
 1108: 
 1109:     if (fonction == NULL)
 1110:     {
 1111:         printf("\n");
 1112:     }
 1113: 
 1114:     (*s_etat_processus).instruction_courante = registre;
 1115: 
 1116:     /*
 1117:      * Évite l'empilement de 'HELP()' dans la pile opérationnelle dans le
 1118:      * cas où la dernière commande entrée à l'invite "HELP> " n'existe pas.
 1119:      */
 1120: 
 1121:     (*s_etat_processus).instruction_valide = 'Y';
 1122: 
 1123:     return;
 1124: }
 1125: 
 1126: // vim: ts=4

CVSweb interface <joel.bertrand@systella.fr>