Projet mkd/find.c
De Wiki EELL.
(Différences entre les versions)
JPL (discuter | contributions) m (a revoir ...) |
JPL (discuter | contributions) m (→find (included file) : !!) |
||
| (8 versions intermédiaires masquées) | |||
| Ligne 2 : | Ligne 2 : | ||
== find (included file) == | == find (included file) == | ||
| - | {{Boîte déroulante/début|titre=find.inc.c, find.inc.h}} | + | |
| + | Ce fichier find.inc.c n'est pas un fichier de fonction. Il doit être inclus dans le fichier source mkd.c avec la directive contenue dans find.inc.h selon que le fichier de projet est reconnu ou non. | ||
| + | |||
| + | {{Boîte déroulante/début|titre=find.inc.c, find.inc.h 2013-05-09}} | ||
* find.inc.h | * find.inc.h | ||
<pre style="color:orange"> | <pre style="color:orange"> | ||
| Ligne 13 : | Ligne 16 : | ||
//P maj R 130509 alpha | //P maj R 130509 alpha | ||
{ /*S find */ | { /*S find */ | ||
| + | /*O mettre les drapeaux (options ABC... ) a 0 */ | ||
| + | A=B=C=F=P=S=0; | ||
L=0; | L=0; | ||
// c is a register int defined in mkd.c | // c is a register int defined in mkd.c | ||
| Ligne 95 : | Ligne 100 : | ||
#ifdef UNIX_ONLY // C strict not in use with mkd see version.h | #ifdef UNIX_ONLY // C strict not in use with mkd see version.h | ||
| - | else if((c=='c | + | else if((c=='c'||c=='h')&&d=='\0') |
{L=1;C=1;printf("C strict\n");} | {L=1;C=1;printf("C strict\n");} | ||
#endif | #endif | ||
| Ligne 105 : | Ligne 110 : | ||
{L=1;j=1;printf("Project file\n");} | {L=1;j=1;printf("Project file\n");} | ||
#endif | #endif | ||
| - | |||
| - | |||
} /*S chercher */ | } /*S chercher */ | ||
| + | |||
/*O si le langage n'est pas trouvé: */ | /*O si le langage n'est pas trouvé: */ | ||
if(!L) | if(!L) | ||
| Ligne 131 : | Ligne 135 : | ||
else if(c=='p')p=1; | else if(c=='p')p=1; | ||
else | else | ||
| - | { /*S*/printf("\n.Exit 2\n"); exit(2 | + | { /*S*/ |
| - | + | printf("\n.Exit 2\n"); exit(2); | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
} /*S*/ | } /*S*/ | ||
| + | printf("\n"); | ||
| + | L=A+B+C+F+P+S; | ||
| + | /*O si aucun drapeau langage n'est positionne envoyer BEL */ | ||
| + | if(!(L==1||p||l))putch(0x7); | ||
| + | putch('\n'); | ||
| + | } /*S*/ | ||
} /*S find */ | } /*S find */ | ||
| + | </pre> | ||
| + | |||
| + | * find.inc.i preprocessed file | ||
| + | <pre> | ||
| + | # 1 "find.inc.c" | ||
| + | # 1 "<interne>" | ||
| + | # 1 "<command-line>" | ||
| + | # 1 "find.inc.c" | ||
| + | |||
| + | |||
| + | { | ||
| + | |||
| + | A=B=C=F=P=S=0; | ||
| + | L=0; | ||
| + | |||
| + | int d; | ||
| + | int e, f, g; | ||
| + | if(v) printf("Find Souce File Language, \'%s\': ",fsrc); | ||
| + | if(k) | ||
| + | { | ||
| + | |||
| + | c = tolower(fsrc[k+1]); | ||
| + | if (c!='\0') d = tolower(fsrc[k+2]); else d='\0'; | ||
| + | if (d!='\0') e = tolower(fsrc[k+3]); else e='\0'; | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | if(c=='a'&&d=='s'&&(e=='m'||e=='i')) | ||
| + | {L=1;A=1;printf("ASM\n");} | ||
| + | |||
| + | else if( (c=='b'&&d=='a'&&e=='s') || | ||
| + | (c=='v'&&d=='b'&&e=='\0') || | ||
| + | (c=='b'&&d=='a'&&e=='t') | ||
| + | ) | ||
| + | {L=1;B=1;printf("BASIC\n");} | ||
| + | |||
| + | else if( | ||
| + | ( ((c=='c'||'h')&&d=='+'&&e=='+') || | ||
| + | ((c=='c'||'h')&&d=='-'&&e=='-') || | ||
| + | ((c=='c'||'h')&&d=='p'&&e=='p') || | ||
| + | (c=='c'&&d=='s'&&e=='s') || | ||
| + | (c=='c'&&d=='c'&&e=='\0') || | ||
| + | (c=='h'&&d=='h'&&e=='\0') || | ||
| + | (c=='c'&&d=='p'&&e=='\0') || | ||
| + | (c=='c'&&d=='s'&&e=='\0') || | ||
| + | (c=='c'&&d=='#'&&e=='\0') || | ||
| + | (c=='c'&&d=='\0') || | ||
| + | (c=='h'&&d=='\0') || | ||
| + | (c=='d'&&d=='\0') || | ||
| + | (c=='p'&&d=='r')&&e=='o') || | ||
| + | |||
| + | (c=='p'&&d=='h'&&e=='p') || | ||
| + | (c=='j'&&d=='a'&&e=='v') || | ||
| + | (c=='j'&&d=='s'&&e=='e') || | ||
| + | (c=='j'&&d=='s'&&e=='\0') | ||
| + | ) | ||
| + | {L=1;C=1;printf("C or PROLOG\n");} | ||
| + | |||
| + | else if(c=='f'&&d=='o'&&e=='r') | ||
| + | {L=1;F=1;printf("FORTRAN\n");} | ||
| + | |||
| + | else if(c=='p'&&d=='a'&&e=='s') | ||
| + | {L=1;P=1;printf("PASCAL\n");} | ||
| + | |||
| + | |||
| + | |||
| + | if(c=='s'&&d=='\0') | ||
| + | {L=1;A=1;printf("Assembler\n");} | ||
| + | |||
| + | else if(c=='f'&&d=='\0') | ||
| + | {L=1;F=1;printf("Fortran\n");} | ||
| + | |||
| + | else if(c=='p'&&d=='\0') | ||
| + | {L=1;P=1;printf("Pascal\n");} | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | else if( (c=='s'&&d=='h'&&e=='\0') || | ||
| + | (c=='c'&&d=='s'&&e=='h') || | ||
| + | (c=='p'&&d=='l'&&e=='\0') || | ||
| + | (c=='r'&&d=='b'&&e=='\0') || | ||
| + | (c=='p'&&d=='y'&&e=='\0') || | ||
| + | (c=='p'&&d=='y'&&e=='w') || | ||
| + | (c=='r'&&d=='\0') | ||
| + | ) | ||
| + | {L=1;S=1;printf("Shell\n");} | ||
| + | # 93 "find.inc.c" | ||
| + | else if( (c=='p'&&d=='r'&&e=='j') || | ||
| + | (c=='p'&&d=='j'&&e=='\0') | ||
| + | ) | ||
| + | {L=1;j=1;printf("Project file\n");} | ||
| + | |||
| + | } | ||
| + | |||
| + | |||
| + | if(!L) | ||
| + | |||
| + | { | ||
| + | |||
| + | A=B=C=F=P=S=0; | ||
| + | |||
| + | printf("\n*** Source file: language not found. (Enter A,B,C,F,P,S,l or p)\n"); | ||
| + | |||
| + | if(!j)printf("*** For project file: exit and use option -j.\n"); | ||
| + | |||
| + | printf("Enter ESCAPE for exit ?:"); | ||
| + | if(j)printf("\b\bor space_bar for Ignore ?: "); | ||
| + | if((c=getch())==0x1B){ printf("\n.Exit 1\n");exit(1);} | ||
| + | else if(c=='A'||c=='a')A=1; | ||
| + | else if(c=='B'||c=='b')B=1; | ||
| + | else if(c=='C'||c=='c')C=1; | ||
| + | else if(c=='F'||c=='f')F=1; | ||
| + | else if(c=='P'||c=='p')P=1; | ||
| + | else if(c=='S'||c=='s')S=1; | ||
| + | else if (c=='l')l=1; | ||
| + | else if(c=='p')p=1; | ||
| + | else | ||
| + | { | ||
| + | printf("\n.Exit 2\n"); exit(2); | ||
| + | } | ||
| + | printf("\n"); | ||
| + | L=A+B+C+F+P+S; | ||
| + | |||
| + | if(!(L==1||p||l))putch(0x7); | ||
| + | putch('\n'); | ||
| + | } | ||
| + | } | ||
</pre> | </pre> | ||
{{Boîte déroulante/fin}} | {{Boîte déroulante/fin}} | ||
== Fichier de commande des tests == | == Fichier de commande des tests == | ||
| + | |||
| + | {{Boîte déroulante/début|titre=MAKE_Tests_U, CLEAN_Tests_U, Make_Tests_files, KONSOLE}} | ||
| + | |||
| + | * File: MAKE_Tests_U | ||
| + | <pre style = "color:black"> | ||
| + | #!/bin/bash | ||
| + | #O ../../mkd tests under Linux. | ||
| + | #O Epreuve de vérification de la fonction find.inc.c() avec ../../mkd | ||
| + | rm test_find.txt | ||
| + | ../../mkd -svwfj '**' test_find.prj test_find.txt > test.stdout | ||
| + | gedit test_find.txt test.stdout | ||
| + | </pre> | ||
| + | |||
| + | * File: CLEAN_Tests_U | ||
| + | <pre style = "color:black"> | ||
| + | #!/bin/dash | ||
| + | #O File Tests_Clean | ||
| + | #O Delete files created with Make_Tets_files under Linux. | ||
| + | rm test.* | ||
| + | </pre> | ||
| + | |||
| + | * File: Make_Tests_files | ||
| + | <pre style = "color:blue">> | ||
| + | #!/bin/dash | ||
| + | echo "; assembler" > test.ASM | ||
| + | echo "REM basic" > test.BAS | ||
| + | echo "REM batch" > test.BAT | ||
| + | echo "C fortran" > test.FOR | ||
| + | echo "{ pascal }" > test.PAS | ||
| + | echo "' visual basic" > test.vb | ||
| + | echo "/* c++ */" > test.c++ | ||
| + | echo "// c++" > test.h++ | ||
| + | echo "/* c-- */ " > test.c-- | ||
| + | echo "// c--" > test.h-- | ||
| + | echo "/* c++ */" > test.cpp | ||
| + | echo "// c++" > test.hpp | ||
| + | echo "/* css */" > test.css | ||
| + | echo "/* c++ */" > test.cc | ||
| + | echo "/* c sharp */" > test.cp | ||
| + | echo "// c sharp" > test.cs | ||
| + | echo "// c sharp" > test.c# | ||
| + | echo "/* C */" > test.C | ||
| + | echo "// C" > test.h | ||
| + | echo "/* D */" > test.D | ||
| + | echo "/* prolog */" > test.pro | ||
| + | echo "// php" > test.php | ||
| + | echo "/* java */" > test.jav | ||
| + | echo "/* javasript */" > test.jse | ||
| + | echo "// javasript " > test.js | ||
| + | #w echo "mkd" > test.prj not a programming language | ||
| + | #w echo "mkd" > test.pj not a programming language | ||
| + | # UNIX | ||
| + | echo "; assembler" > test.s | ||
| + | echo "C fortran" > test.f | ||
| + | echo "(* pascal *)" > test.p | ||
| + | echo "# ratfor" > test.r | ||
| + | echo "# shell" > test.sh | ||
| + | echo "# cshell" > test.csh | ||
| + | echo "# perl" > test.pl | ||
| + | echo "# ruby" > test.rb | ||
| + | echo "/* python */" > test.py | ||
| + | echo "# python" > test.pyw | ||
| + | # C strict | ||
| + | echo "/* C strict src */" > test.c | ||
| + | echo "/* C strict header */" > test.h | ||
| + | # Make prj file | ||
| + | # ls -1 > test_find.prj | ||
| + | </pre> | ||
| + | |||
| + | * File: KONSOLE | ||
| + | <pre style = "color:red"> | ||
| + | #!/bin/bash | ||
| + | echo -e '\E['32';'01'm'"click on New Line to 'start' the Konsole" | ||
| + | # echo -e '\E['31';'01'm' "not 'start in a terminal'" | ||
| + | echo -e '\E['32';'01'm'"click on Ctrl-C to exit" | ||
| + | tput sgr0 # Reset text attributes to normal without clear | ||
| + | read pwd | ||
| + | pwd | ||
| + | echo $pwd | ||
| + | tput sgr0 # Reset text attributes to normal without clear | ||
| + | /usr/bin/konsole background-mode --workdir pwd dir | ||
| + | read | ||
| + | </pre> | ||
| + | {{Boîte déroulante/fin}} | ||
== Analyse des test konsole == | == Analyse des test konsole == | ||
| + | |||
| + | Très souvent les fichiers de prgrammation se rapportent à un des styles précodés. | ||
| + | |||
| + | Cependant, Un certain nombre de noms de fichiers ne sont pas pris en compte dans cette version 2013-05; notament, prévus dans les versions ultérieures: | ||
| + | * '''Ada''' | ||
| + | * '''HTML''' | ||
| + | * '''Tex, LaTex, PostScript, Mathlab''' que l'on peut décoder avec l'option -l et avec l'option de compilation '''''#define CD1 '%'''''' dans l'entête vercion.h | ||
| + | * '''Fortan 90 et ultérieurs''' avec l'option de compilation '''''#define CD3 '!'''''' dans le fichier d'entête version.h et l'option -l en ligne de commande | ||
| + | |||
| + | {{Modèle:Boîte déroulante/début|titre=Analyse}} | ||
| + | * Fichier des tests: | ||
| + | Les fichiers suivants sont bien reconnus: | ||
| + | <pre> | ||
| + | Options a=0 f=1 j=1 l=0 n=0 p=0 s=1 t=0 w=1 | ||
| + | fichier doc : 'test_find.txt' | ||
| + | fichier de projet : 'test_find.prj' | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.ASM' | ||
| + | Find Souce File Language, 'test.ASM': ASM | ||
| + | |||
| + | |||
| + | (fichier test.ASM :) | ||
| + | ; assembler | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.BAS' | ||
| + | Find Souce File Language, 'test.BAS': BASIC | ||
| + | |||
| + | |||
| + | (fichier test.BAS :) | ||
| + | REM basic | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.BAT' | ||
| + | Find Souce File Language, 'test.BAT': BASIC | ||
| + | |||
| + | |||
| + | (fichier test.BAT :) | ||
| + | REM batch | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.c' | ||
| + | Find Souce File Language, 'test.c': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.c :) | ||
| + | /* C strict src */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.c--' | ||
| + | Find Souce File Language, 'test.c--': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.c-- :) | ||
| + | /* c-- */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.c#' | ||
| + | Find Souce File Language, 'test.c#': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.c# :) | ||
| + | // c sharp | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.c++' | ||
| + | Find Souce File Language, 'test.c++': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.c++ :) | ||
| + | /* c++ */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.C' | ||
| + | Find Souce File Language, 'test.C': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.C :) | ||
| + | /* C */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.cc' | ||
| + | Find Souce File Language, 'test.cc': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.cc :) | ||
| + | /* c++ */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.cp' | ||
| + | Find Souce File Language, 'test.cp': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.cp :) | ||
| + | /* c sharp */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.cpp' | ||
| + | Find Souce File Language, 'test.cpp': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.cpp :) | ||
| + | /* c++ */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.cs' | ||
| + | Find Souce File Language, 'test.cs': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.cs :) | ||
| + | // c sharp | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.csh' | ||
| + | Find Souce File Language, 'test.csh': Shell | ||
| + | |||
| + | |||
| + | (fichier test.csh :) | ||
| + | # cshell | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.css' | ||
| + | Find Souce File Language, 'test.css': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.css :) | ||
| + | /* css */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.D' | ||
| + | Find Souce File Language, 'test.D': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.D :) | ||
| + | /* D */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.f' | ||
| + | Find Souce File Language, 'test.f': Fortran | ||
| + | |||
| + | |||
| + | (fichier test.f :) | ||
| + | C fortran | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.FOR' | ||
| + | Find Souce File Language, 'test.FOR': FORTRAN | ||
| + | |||
| + | |||
| + | (fichier test.FOR :) | ||
| + | C fortran | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.h' | ||
| + | Find Souce File Language, 'test.h': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.h :) | ||
| + | /* C strict header */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.h--' | ||
| + | Find Souce File Language, 'test.h--': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.h-- :) | ||
| + | // c-- | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.h++' | ||
| + | Find Souce File Language, 'test.h++': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.h++ :) | ||
| + | // c++ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.hpp' | ||
| + | Find Souce File Language, 'test.hpp': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.hpp :) | ||
| + | // c++ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.jav' | ||
| + | Find Souce File Language, 'test.jav': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.jav :) | ||
| + | /* java */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.js' | ||
| + | Find Souce File Language, 'test.js': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.js :) | ||
| + | // javasript | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.jse' | ||
| + | Find Souce File Language, 'test.jse': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.jse :) | ||
| + | /* javasript */ | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.p' | ||
| + | Find Souce File Language, 'test.p': Pascal | ||
| + | |||
| + | |||
| + | (fichier test.p :) | ||
| + | (* pascal *) | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.PAS' | ||
| + | Find Souce File Language, 'test.PAS': PASCAL | ||
| + | |||
| + | |||
| + | (fichier test.PAS :) | ||
| + | { pascal } | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.php' | ||
| + | Find Souce File Language, 'test.php': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.php :) | ||
| + | // php | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.pl' | ||
| + | Find Souce File Language, 'test.pl': Shell | ||
| + | |||
| + | |||
| + | (fichier test.pl :) | ||
| + | # perl | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.pro' | ||
| + | Find Souce File Language, 'test.pro': C or PROLOG | ||
| + | |||
| + | |||
| + | (fichier test.pro :) | ||
| + | /* prolog /*ÿ | ||
| + | |||
| + | fichier pour doc: 'test.py' | ||
| + | Find Souce File Language, 'test.py': Shell | ||
| + | |||
| + | |||
| + | (fichier test.py :) | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.pyw' | ||
| + | Find Souce File Language, 'test.pyw': Shell | ||
| + | |||
| + | |||
| + | (fichier test.pyw :) | ||
| + | # python | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.r' | ||
| + | Find Souce File Language, 'test.r': Shell | ||
| + | |||
| + | |||
| + | (fichier test.r :) | ||
| + | # ratfor | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.rb' | ||
| + | Find Souce File Language, 'test.rb': Shell | ||
| + | |||
| + | |||
| + | (fichier test.rb :) | ||
| + | # ruby | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.s' | ||
| + | Find Souce File Language, 'test.s': Assembler | ||
| + | |||
| + | |||
| + | (fichier test.s :) | ||
| + | ; assembler | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.sh' | ||
| + | Find Souce File Language, 'test.sh': Shell | ||
| + | |||
| + | |||
| + | (fichier test.sh :) | ||
| + | # shell | ||
| + | |||
| + | |||
| + | fichier pour doc: 'test.vb' | ||
| + | Find Souce File Language, 'test.vb': BASIC | ||
| + | |||
| + | |||
| + | (fichier test.vb :) | ||
| + | ' visual basic | ||
| + | |||
| + | |||
| + | DOC test_find.txt FIN | ||
| + | </pre> | ||
| + | {{Modèle:Boîte déroulante/fin}} | ||
== Fichiers sources des tests == | == Fichiers sources des tests == | ||
| + | |||
| + | Le fichier de projet test_find.prj permet de vérifier que tous les commentaires soient reconnus en fonction de l'extension du nom de fichier. | ||
| + | |||
| + | {{Modèle:Boîte déroulante/début|titre=test_find.prj}} | ||
| + | * File: test_find.prj | ||
| + | <pre> | ||
| + | test.ASM | ||
| + | test.BAS | ||
| + | test.BAT | ||
| + | test.c | ||
| + | test.c-- | ||
| + | test.c# | ||
| + | test.c++ | ||
| + | test.C | ||
| + | test.cc | ||
| + | test.cp | ||
| + | test.cpp | ||
| + | test.cs | ||
| + | test.csh | ||
| + | test.css | ||
| + | test.D | ||
| + | test.f | ||
| + | test.FOR | ||
| + | test.h | ||
| + | test.h-- | ||
| + | test.h++ | ||
| + | test.hpp | ||
| + | test.jav | ||
| + | test.js | ||
| + | test.jse | ||
| + | test.p | ||
| + | test.PAS | ||
| + | test.php | ||
| + | test.pl | ||
| + | test.pro | ||
| + | test.py | ||
| + | test.pyw | ||
| + | test.r | ||
| + | test.rb | ||
| + | test.s | ||
| + | test.sh | ||
| + | test.vb | ||
| + | </pre> | ||
| + | {{Modèle:Boîte déroulante/fin}} | ||
[[Catégorie:Générateurs de documentation]] | [[Catégorie:Générateurs de documentation]] | ||
Version actuelle en date du 10 mai 2013 à 13:24
Retour aux fichiers en développement →
Sommaire |
find (included file)
Ce fichier find.inc.c n'est pas un fichier de fonction. Il doit être inclus dans le fichier source mkd.c avec la directive contenue dans find.inc.h selon que le fichier de projet est reconnu ou non.
find.inc.c, find.inc.h 2013-05-09
- find.inc.h
#define ARGS_EXAM
- find.inc.c
//P maj R3.11 04/01/91 par JPL
//P maj R 130509 alpha
{ /*S find */
/*O mettre les drapeaux (options ABC... ) a 0 */
A=B=C=F=P=S=0;
L=0;
// c is a register int defined in mkd.c
int d; // local variables
int e, f, g;
if(v) printf("Find Souce File Language, \'%s\': ",fsrc);
if(k)
{ /*S chercher */
//T char buffer[10]; //T tests only
c = tolower(fsrc[k+1]);
if (c!='\0') d = tolower(fsrc[k+2]); else d='\0';
if (d!='\0') e = tolower(fsrc[k+3]); else e='\0';
// if (e!='\0') f = tolower(fsrc[k+4]); else f='\0';
// if (f!='\0') g = tolower(fsrc[k+4]); else g='\0';
// if (g!='\0') h = tolower(fsrc[k+3]); else h='\0';
//T buffer[0]=c; buffer[1]=d; buffer[2]=e; buffer[3]='\0'; //T Tests only
//T printf("\nTests: **** tolower extension = %s\n",buffer); //T tests only
#ifndef UNIX_ONLY // OK for PC and UNIX / LINUX. Not OK for C strict
if(c=='a'&&d=='s'&&(e=='m'||e=='i'))
{L=1;A=1;printf("ASM\n");}
else if( (c=='b'&&d=='a'&&e=='s') || // bas
(c=='v'&&d=='b'&&e=='\0') || // Visual bacic
(c=='b'&&d=='a'&&e=='t') // bat
)
{L=1;B=1;printf("BASIC\n");}
else if(
( ((c=='c'||'h')&&d=='+'&&e=='+') || // c++, h++
((c=='c'||'h')&&d=='-'&&e=='-') || // c--, h--
((c=='c'||'h')&&d=='p'&&e=='p') || // cpp, hpp
(c=='c'&&d=='s'&&e=='s') || // css
(c=='c'&&d=='c'&&e=='\0') || // cc
(c=='h'&&d=='h'&&e=='\0') || // hh
(c=='c'&&d=='p'&&e=='\0') || // cp=c#
(c=='c'&&d=='s'&&e=='\0') || // cs=c#
(c=='c'&&d=='#'&&e=='\0') || // c#
(c=='c'&&d=='\0') || // C
(c=='h'&&d=='\0') || // h
(c=='d'&&d=='\0') || // D
(c=='p'&&d=='r')&&e=='o') || // pro prolog
//w see forward (c=='p'&&d=='l')&&d=='\0') || // pl perl, prolog
(c=='p'&&d=='h'&&e=='p') || // PHP
(c=='j'&&d=='a'&&e=='v') || // jav java
(c=='j'&&d=='s'&&e=='e') || // jse javascript
(c=='j'&&d=='s'&&e=='\0') // js javascript
)
{L=1;C=1;printf("C or PROLOG\n");}
else if(c=='f'&&d=='o'&&e=='r')
{L=1;F=1;printf("FORTRAN\n");}
else if(c=='p'&&d=='a'&&e=='s')
{L=1;P=1;printf("PASCAL\n");}
#endif
#ifndef PC_ONLY // OK for UNIX / LINUX
if(c=='s'&&d=='\0')
{L=1;A=1;printf("Assembler\n");}
else if(c=='f'&&d=='\0')
{L=1;F=1;printf("Fortran\n");}
else if(c=='p'&&d=='\0')
{L=1;P=1;printf("Pascal\n");}
/*w Attention, il n'est pas coutumier de donner des extensions aux fichiers
shell. Il serait utile de vérifier la première ligne si c est NULL. Pour
cela il faudrait ouvrir et refermer le fichier source. */
else if( (c=='s'&&d=='h'&&e=='\0') || // sh
(c=='c'&&d=='s'&&e=='h') || // csh
(c=='p'&&d=='l'&&e=='\0') || // pl perl
(c=='r'&&d=='b'&&e=='\0') || // rb ruby
(c=='p'&&d=='y'&&e=='\0') || // py python
(c=='p'&&d=='y'&&e=='w') || // pyw python
(c=='r'&&d=='\0') // ratfor
)
{L=1;S=1;printf("Shell\n");}
#endif
#ifdef UNIX_ONLY // C strict not in use with mkd see version.h
else if((c=='c'||c=='h')&&d=='\0')
{L=1;C=1;printf("C strict\n");}
#endif
#ifndef ARGS_EXAM
else if( (c=='p'&&d=='r'&&e=='j') || // prj mkd
(c=='p'&&d=='j'&&e=='\0') // pj mkd
)
{L=1;j=1;printf("Project file\n");}
#endif
} /*S chercher */
/*O si le langage n'est pas trouvé: */
if(!L)
/*O alors: */
{ /*S*/
/*O mettre les drapeaux (options ABC... ) a 0 */
A=B=C=F=P=S=0;
/*O demander le type de langage du fichier et positionner le drapeau */
printf("\n*** Source file: language not found. (Enter A,B,C,F,P,S,l or p)\n");
#ifndef ARGS_EXAM
if(!j)printf("*** For project file: exit and use option -j.\n");
#endif
printf("Enter ESCAPE for exit ?:");
if(j)printf("\b\bor space_bar for Ignore ?: ");
if((c=getch())==0x1B){ /*S*/ printf("\n.Exit 1\n");exit(1);} /*S*/
else if(c=='A'||c=='a')A=1;
else if(c=='B'||c=='b')B=1;
else if(c=='C'||c=='c')C=1;
else if(c=='F'||c=='f')F=1;
else if(c=='P'||c=='p')P=1;
else if(c=='S'||c=='s')S=1;
else if (c=='l')l=1;
else if(c=='p')p=1;
else
{ /*S*/
printf("\n.Exit 2\n"); exit(2);
} /*S*/
printf("\n");
L=A+B+C+F+P+S;
/*O si aucun drapeau langage n'est positionne envoyer BEL */
if(!(L==1||p||l))putch(0x7);
putch('\n');
} /*S*/
} /*S find */
- find.inc.i preprocessed file
# 1 "find.inc.c"
# 1 "<interne>"
# 1 "<command-line>"
# 1 "find.inc.c"
{
A=B=C=F=P=S=0;
L=0;
int d;
int e, f, g;
if(v) printf("Find Souce File Language, \'%s\': ",fsrc);
if(k)
{
c = tolower(fsrc[k+1]);
if (c!='\0') d = tolower(fsrc[k+2]); else d='\0';
if (d!='\0') e = tolower(fsrc[k+3]); else e='\0';
if(c=='a'&&d=='s'&&(e=='m'||e=='i'))
{L=1;A=1;printf("ASM\n");}
else if( (c=='b'&&d=='a'&&e=='s') ||
(c=='v'&&d=='b'&&e=='\0') ||
(c=='b'&&d=='a'&&e=='t')
)
{L=1;B=1;printf("BASIC\n");}
else if(
( ((c=='c'||'h')&&d=='+'&&e=='+') ||
((c=='c'||'h')&&d=='-'&&e=='-') ||
((c=='c'||'h')&&d=='p'&&e=='p') ||
(c=='c'&&d=='s'&&e=='s') ||
(c=='c'&&d=='c'&&e=='\0') ||
(c=='h'&&d=='h'&&e=='\0') ||
(c=='c'&&d=='p'&&e=='\0') ||
(c=='c'&&d=='s'&&e=='\0') ||
(c=='c'&&d=='#'&&e=='\0') ||
(c=='c'&&d=='\0') ||
(c=='h'&&d=='\0') ||
(c=='d'&&d=='\0') ||
(c=='p'&&d=='r')&&e=='o') ||
(c=='p'&&d=='h'&&e=='p') ||
(c=='j'&&d=='a'&&e=='v') ||
(c=='j'&&d=='s'&&e=='e') ||
(c=='j'&&d=='s'&&e=='\0')
)
{L=1;C=1;printf("C or PROLOG\n");}
else if(c=='f'&&d=='o'&&e=='r')
{L=1;F=1;printf("FORTRAN\n");}
else if(c=='p'&&d=='a'&&e=='s')
{L=1;P=1;printf("PASCAL\n");}
if(c=='s'&&d=='\0')
{L=1;A=1;printf("Assembler\n");}
else if(c=='f'&&d=='\0')
{L=1;F=1;printf("Fortran\n");}
else if(c=='p'&&d=='\0')
{L=1;P=1;printf("Pascal\n");}
else if( (c=='s'&&d=='h'&&e=='\0') ||
(c=='c'&&d=='s'&&e=='h') ||
(c=='p'&&d=='l'&&e=='\0') ||
(c=='r'&&d=='b'&&e=='\0') ||
(c=='p'&&d=='y'&&e=='\0') ||
(c=='p'&&d=='y'&&e=='w') ||
(c=='r'&&d=='\0')
)
{L=1;S=1;printf("Shell\n");}
# 93 "find.inc.c"
else if( (c=='p'&&d=='r'&&e=='j') ||
(c=='p'&&d=='j'&&e=='\0')
)
{L=1;j=1;printf("Project file\n");}
}
if(!L)
{
A=B=C=F=P=S=0;
printf("\n*** Source file: language not found. (Enter A,B,C,F,P,S,l or p)\n");
if(!j)printf("*** For project file: exit and use option -j.\n");
printf("Enter ESCAPE for exit ?:");
if(j)printf("\b\bor space_bar for Ignore ?: ");
if((c=getch())==0x1B){ printf("\n.Exit 1\n");exit(1);}
else if(c=='A'||c=='a')A=1;
else if(c=='B'||c=='b')B=1;
else if(c=='C'||c=='c')C=1;
else if(c=='F'||c=='f')F=1;
else if(c=='P'||c=='p')P=1;
else if(c=='S'||c=='s')S=1;
else if (c=='l')l=1;
else if(c=='p')p=1;
else
{
printf("\n.Exit 2\n"); exit(2);
}
printf("\n");
L=A+B+C+F+P+S;
if(!(L==1||p||l))putch(0x7);
putch('\n');
}
}
Fichier de commande des tests
MAKE_Tests_U, CLEAN_Tests_U, Make_Tests_files, KONSOLE
- File: MAKE_Tests_U
#!/bin/bash #O ../../mkd tests under Linux. #O Epreuve de vérification de la fonction find.inc.c() avec ../../mkd rm test_find.txt ../../mkd -svwfj '**' test_find.prj test_find.txt > test.stdout gedit test_find.txt test.stdout
- File: CLEAN_Tests_U
#!/bin/dash #O File Tests_Clean #O Delete files created with Make_Tets_files under Linux. rm test.*
- File: Make_Tests_files
>
#!/bin/dash
echo "; assembler" > test.ASM
echo "REM basic" > test.BAS
echo "REM batch" > test.BAT
echo "C fortran" > test.FOR
echo "{ pascal }" > test.PAS
echo "' visual basic" > test.vb
echo "/* c++ */" > test.c++
echo "// c++" > test.h++
echo "/* c-- */ " > test.c--
echo "// c--" > test.h--
echo "/* c++ */" > test.cpp
echo "// c++" > test.hpp
echo "/* css */" > test.css
echo "/* c++ */" > test.cc
echo "/* c sharp */" > test.cp
echo "// c sharp" > test.cs
echo "// c sharp" > test.c#
echo "/* C */" > test.C
echo "// C" > test.h
echo "/* D */" > test.D
echo "/* prolog */" > test.pro
echo "// php" > test.php
echo "/* java */" > test.jav
echo "/* javasript */" > test.jse
echo "// javasript " > test.js
#w echo "mkd" > test.prj not a programming language
#w echo "mkd" > test.pj not a programming language
# UNIX
echo "; assembler" > test.s
echo "C fortran" > test.f
echo "(* pascal *)" > test.p
echo "# ratfor" > test.r
echo "# shell" > test.sh
echo "# cshell" > test.csh
echo "# perl" > test.pl
echo "# ruby" > test.rb
echo "/* python */" > test.py
echo "# python" > test.pyw
# C strict
echo "/* C strict src */" > test.c
echo "/* C strict header */" > test.h
# Make prj file
# ls -1 > test_find.prj
- File: KONSOLE
#!/bin/bash echo -e '\E['32';'01'm'"click on New Line to 'start' the Konsole" # echo -e '\E['31';'01'm' "not 'start in a terminal'" echo -e '\E['32';'01'm'"click on Ctrl-C to exit" tput sgr0 # Reset text attributes to normal without clear read pwd pwd echo $pwd tput sgr0 # Reset text attributes to normal without clear /usr/bin/konsole background-mode --workdir pwd dir read
Analyse des test konsole
Très souvent les fichiers de prgrammation se rapportent à un des styles précodés.
Cependant, Un certain nombre de noms de fichiers ne sont pas pris en compte dans cette version 2013-05; notament, prévus dans les versions ultérieures:
- Ada
- HTML
- Tex, LaTex, PostScript, Mathlab que l'on peut décoder avec l'option -l et avec l'option de compilation #define CD1 '%' dans l'entête vercion.h
- Fortan 90 et ultérieurs avec l'option de compilation #define CD3 '!' dans le fichier d'entête version.h et l'option -l en ligne de commande
Analyse
- Fichier des tests:
Les fichiers suivants sont bien reconnus:
Options a=0 f=1 j=1 l=0 n=0 p=0 s=1 t=0 w=1
fichier doc : 'test_find.txt'
fichier de projet : 'test_find.prj'
fichier pour doc: 'test.ASM'
Find Souce File Language, 'test.ASM': ASM
(fichier test.ASM :)
; assembler
fichier pour doc: 'test.BAS'
Find Souce File Language, 'test.BAS': BASIC
(fichier test.BAS :)
REM basic
fichier pour doc: 'test.BAT'
Find Souce File Language, 'test.BAT': BASIC
(fichier test.BAT :)
REM batch
fichier pour doc: 'test.c'
Find Souce File Language, 'test.c': C or PROLOG
(fichier test.c :)
/* C strict src */
fichier pour doc: 'test.c--'
Find Souce File Language, 'test.c--': C or PROLOG
(fichier test.c-- :)
/* c-- */
fichier pour doc: 'test.c#'
Find Souce File Language, 'test.c#': C or PROLOG
(fichier test.c# :)
// c sharp
fichier pour doc: 'test.c++'
Find Souce File Language, 'test.c++': C or PROLOG
(fichier test.c++ :)
/* c++ */
fichier pour doc: 'test.C'
Find Souce File Language, 'test.C': C or PROLOG
(fichier test.C :)
/* C */
fichier pour doc: 'test.cc'
Find Souce File Language, 'test.cc': C or PROLOG
(fichier test.cc :)
/* c++ */
fichier pour doc: 'test.cp'
Find Souce File Language, 'test.cp': C or PROLOG
(fichier test.cp :)
/* c sharp */
fichier pour doc: 'test.cpp'
Find Souce File Language, 'test.cpp': C or PROLOG
(fichier test.cpp :)
/* c++ */
fichier pour doc: 'test.cs'
Find Souce File Language, 'test.cs': C or PROLOG
(fichier test.cs :)
// c sharp
fichier pour doc: 'test.csh'
Find Souce File Language, 'test.csh': Shell
(fichier test.csh :)
# cshell
fichier pour doc: 'test.css'
Find Souce File Language, 'test.css': C or PROLOG
(fichier test.css :)
/* css */
fichier pour doc: 'test.D'
Find Souce File Language, 'test.D': C or PROLOG
(fichier test.D :)
/* D */
fichier pour doc: 'test.f'
Find Souce File Language, 'test.f': Fortran
(fichier test.f :)
C fortran
fichier pour doc: 'test.FOR'
Find Souce File Language, 'test.FOR': FORTRAN
(fichier test.FOR :)
C fortran
fichier pour doc: 'test.h'
Find Souce File Language, 'test.h': C or PROLOG
(fichier test.h :)
/* C strict header */
fichier pour doc: 'test.h--'
Find Souce File Language, 'test.h--': C or PROLOG
(fichier test.h-- :)
// c--
fichier pour doc: 'test.h++'
Find Souce File Language, 'test.h++': C or PROLOG
(fichier test.h++ :)
// c++
fichier pour doc: 'test.hpp'
Find Souce File Language, 'test.hpp': C or PROLOG
(fichier test.hpp :)
// c++
fichier pour doc: 'test.jav'
Find Souce File Language, 'test.jav': C or PROLOG
(fichier test.jav :)
/* java */
fichier pour doc: 'test.js'
Find Souce File Language, 'test.js': C or PROLOG
(fichier test.js :)
// javasript
fichier pour doc: 'test.jse'
Find Souce File Language, 'test.jse': C or PROLOG
(fichier test.jse :)
/* javasript */
fichier pour doc: 'test.p'
Find Souce File Language, 'test.p': Pascal
(fichier test.p :)
(* pascal *)
fichier pour doc: 'test.PAS'
Find Souce File Language, 'test.PAS': PASCAL
(fichier test.PAS :)
{ pascal }
fichier pour doc: 'test.php'
Find Souce File Language, 'test.php': C or PROLOG
(fichier test.php :)
// php
fichier pour doc: 'test.pl'
Find Souce File Language, 'test.pl': Shell
(fichier test.pl :)
# perl
fichier pour doc: 'test.pro'
Find Souce File Language, 'test.pro': C or PROLOG
(fichier test.pro :)
/* prolog /*ÿ
fichier pour doc: 'test.py'
Find Souce File Language, 'test.py': Shell
(fichier test.py :)
fichier pour doc: 'test.pyw'
Find Souce File Language, 'test.pyw': Shell
(fichier test.pyw :)
# python
fichier pour doc: 'test.r'
Find Souce File Language, 'test.r': Shell
(fichier test.r :)
# ratfor
fichier pour doc: 'test.rb'
Find Souce File Language, 'test.rb': Shell
(fichier test.rb :)
# ruby
fichier pour doc: 'test.s'
Find Souce File Language, 'test.s': Assembler
(fichier test.s :)
; assembler
fichier pour doc: 'test.sh'
Find Souce File Language, 'test.sh': Shell
(fichier test.sh :)
# shell
fichier pour doc: 'test.vb'
Find Souce File Language, 'test.vb': BASIC
(fichier test.vb :)
' visual basic
DOC test_find.txt FIN
Fichiers sources des tests
Le fichier de projet test_find.prj permet de vérifier que tous les commentaires soient reconnus en fonction de l'extension du nom de fichier.
test_find.prj
- File: test_find.prj
test.ASM test.BAS test.BAT test.c test.c-- test.c# test.c++ test.C test.cc test.cp test.cpp test.cs test.csh test.css test.D test.f test.FOR test.h test.h-- test.h++ test.hpp test.jav test.js test.jse test.p test.PAS test.php test.pl test.pro test.py test.pyw test.r test.rb test.s test.sh test.vb

