| 1 |
/* |
| 2 |
* Code to move the doc++ comments /// from the end of a line to |
| 3 |
* the beginning of previous line, in order that doc++ processes the |
| 4 |
* source file correctly. The name of the output reorganized file |
| 5 |
* has a suffix _r. |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
/* |
| 10 |
* Copyright (c) 1999 Jean-Alain Marck |
| 11 |
* |
| 12 |
* This file is part of LORENE. |
| 13 |
* |
| 14 |
* LORENE is free software; you can redistribute it and/or modify |
| 15 |
* it under the terms of the GNU General Public License version 2 |
| 16 |
* as published by the Free Software Foundation. |
| 17 |
* |
| 18 |
* LORENE is distributed in the hope that it will be useful, |
| 19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
* GNU General Public License for more details. |
| 22 |
* |
| 23 |
* You should have received a copy of the GNU General Public License |
| 24 |
* along with LORENE; if not, write to the Free Software |
| 25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 26 |
* |
| 27 |
*/ |
| 28 |
|
| 29 |
|
| 30 |
/* |
| 31 |
* $Id: reorg_comments.C,v 1.4 2014/10/06 15:05:46 j_novak Exp $ |
| 32 |
* $Log: reorg_comments.C,v $ |
| 33 |
* Revision 1.4 2014/10/06 15:05:46 j_novak |
| 34 |
* Modified #include directives to use c++ syntax. |
| 35 |
* |
| 36 |
* Revision 1.3 2003/10/15 08:43:32 e_gourgoulhon |
| 37 |
* Modif. comments. |
| 38 |
* |
| 39 |
* |
| 40 |
* |
| 41 |
* $Header: /cvsroot/Lorene/Inst_tools/reorg_comments.C,v 1.4 2014/10/06 15:05:46 j_novak Exp $ |
| 42 |
* |
| 43 |
*/ |
| 44 |
|
| 45 |
#include <cstdio> |
| 46 |
#include <cstring> |
| 47 |
#include <cstdlib> |
| 48 |
|
| 49 |
#include <iostream> |
| 50 |
using namespace std ; |
| 51 |
|
| 52 |
int main(int argc, char** argv) |
| 53 |
{ |
| 54 |
|
| 55 |
// Ouverture fichiers entree et sortie |
| 56 |
if(argc<2) { |
| 57 |
fprintf(stderr,"usage: reorg_comments filename(s) \n") ; |
| 58 |
abort() ; |
| 59 |
} |
| 60 |
|
| 61 |
char nom_sortie[1000] ; |
| 62 |
char nom_ori[1000] ; |
| 63 |
char ligne[300] ; |
| 64 |
|
| 65 |
// Boucle sur tous les fichiers |
| 66 |
|
| 67 |
for (int ific=1 ; ific < argc ; ific++) { |
| 68 |
|
| 69 |
strcpy( nom_ori, argv[ific]) ; |
| 70 |
cout << " reorganization of the /// comments of " << nom_ori |
| 71 |
<< endl ; |
| 72 |
|
| 73 |
strcpy( nom_sortie, nom_ori ) ; |
| 74 |
strcat( nom_sortie, "_r" ) ; |
| 75 |
|
| 76 |
FILE* inf = fopen(nom_ori,"r"); |
| 77 |
if(!inf) { |
| 78 |
fprintf(stderr,"reorg_comments: cannot open %s ! \n", nom_ori); |
| 79 |
abort() ; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
FILE* inf2 = fopen(nom_sortie,"w"); |
| 84 |
if(!inf2) { |
| 85 |
fprintf(stderr,"reorg_comments: cannot open %s ! \n", nom_sortie); |
| 86 |
abort() ; |
| 87 |
} |
| 88 |
|
| 89 |
// Lecture ligne a ligne |
| 90 |
while (fgets(ligne, 300, inf)) { |
| 91 |
|
| 92 |
// Recherche de /// dans la ligne |
| 93 |
char* triple_com = strstr(ligne, "///") ; |
| 94 |
if (triple_com != NULL) { // oui un triple com |
| 95 |
// est-ce un commentaire isole ? |
| 96 |
char ligne_tmp[80] ; |
| 97 |
sscanf(ligne,"%s",ligne_tmp) ; // vire les blancs... |
| 98 |
ligne_tmp[3] = 0 ; // fin de ligne_tmp |
| 99 |
char* occurence = strstr(ligne_tmp, "///") ; |
| 100 |
if (occurence != NULL) { // c'est un comm. isole |
| 101 |
fprintf(inf2, "%s", ligne) ; // la ligne entiere |
| 102 |
} |
| 103 |
else { // il faut travailler |
| 104 |
fprintf(inf2, "%s", triple_com) ; // Le commentaire d'abord |
| 105 |
triple_com[0] = 0 ; // raccourci la ligne |
| 106 |
fprintf(inf2, "%s\n", ligne) ; // la ligne raccourcie |
| 107 |
} |
| 108 |
} |
| 109 |
else { // non pas de triple com |
| 110 |
fprintf(inf2, "%s", ligne) ; // la ligne entiere |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
} // Fin de boucle sur les fichiers |
| 115 |
|
| 116 |
return 0 ; |
| 117 |
|
| 118 |
} |