[396] | 1 | /******************************************************************************/ |
---|
| 2 | /* */ |
---|
| 3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
| 4 | /* */ |
---|
[663] | 5 | /* Copyright or or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
| 6 | /* Cyril Mazauric (Cyril_Mazauric@yahoo.fr) */ |
---|
[530] | 7 | /* This software is governed by the CeCILL-C license under French law and */ |
---|
| 8 | /* abiding by the rules of distribution of free software. You can use, */ |
---|
| 9 | /* modify and/ or redistribute the software under the terms of the CeCILL-C */ |
---|
| 10 | /* license as circulated by CEA, CNRS and INRIA at the following URL */ |
---|
| 11 | /* "http://www.cecill.info". */ |
---|
[396] | 12 | /* */ |
---|
[530] | 13 | /* As a counterpart to the access to the source code and rights to copy, */ |
---|
| 14 | /* modify and redistribute granted by the license, users are provided only */ |
---|
| 15 | /* with a limited warranty and the software's author, the holder of the */ |
---|
| 16 | /* economic rights, and the successive licensors have only limited */ |
---|
| 17 | /* liability. */ |
---|
[396] | 18 | /* */ |
---|
[530] | 19 | /* In this respect, the user's attention is drawn to the risks associated */ |
---|
| 20 | /* with loading, using, modifying and/or developing or reproducing the */ |
---|
| 21 | /* software by the user in light of its specific status of free software, */ |
---|
| 22 | /* that may mean that it is complicated to manipulate, and that also */ |
---|
| 23 | /* therefore means that it is reserved for developers and experienced */ |
---|
| 24 | /* professionals having in-depth computer knowledge. Users are therefore */ |
---|
| 25 | /* encouraged to load and test the software's suitability as regards their */ |
---|
| 26 | /* requirements in conditions enabling the security of their systems and/or */ |
---|
| 27 | /* data to be ensured and, more generally, to use and operate it in the */ |
---|
| 28 | /* same conditions as regards security. */ |
---|
[396] | 29 | /* */ |
---|
[530] | 30 | /* The fact that you are presently reading this means that you have had */ |
---|
| 31 | /* knowledge of the CeCILL-C license and that you accept its terms. */ |
---|
[396] | 32 | /******************************************************************************/ |
---|
[663] | 33 | /* version 1.6 */ |
---|
[530] | 34 | /******************************************************************************/ |
---|
[396] | 35 | #include <stdio.h> |
---|
| 36 | #include <stdlib.h> |
---|
| 37 | #include <string.h> |
---|
| 38 | #include "decl.h" |
---|
| 39 | |
---|
| 40 | /******************************************************************************/ |
---|
| 41 | /* tofich_reste */ |
---|
| 42 | /******************************************************************************/ |
---|
| 43 | /* This subroutine is used to write the string s into the fileout */ |
---|
| 44 | /******************************************************************************/ |
---|
[663] | 45 | void tofich_reste (FILE * filout, char *s,int returnlineornot) |
---|
[396] | 46 | { |
---|
| 47 | char temp[61]; |
---|
| 48 | char *tmp; |
---|
| 49 | int size; |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | if (strlen (s) <= 60) |
---|
| 53 | { |
---|
| 54 | if ( returnlineornot == 0 ) fprintf (filout, " & %s", s); |
---|
[663] | 55 | else if ( returnlineornot == 2 ) fprintf (filout, "& %s", s); |
---|
| 56 | else if ( returnlineornot == 3 ) fprintf (filout, "& %s\n", s); |
---|
| 57 | else fprintf (filout, " & %s\n", s); |
---|
| 58 | if ( returnlineornot == 0 || |
---|
| 59 | returnlineornot == 2 ) colnum=colnum+strlen(s)+6; |
---|
[396] | 60 | else colnum=0; |
---|
| 61 | } |
---|
| 62 | else |
---|
| 63 | { |
---|
| 64 | strncpy (temp, s, 60); |
---|
| 65 | strcpy (&temp[60], "\0"); |
---|
| 66 | |
---|
| 67 | tmp = strrchr(temp, '+'); |
---|
| 68 | |
---|
| 69 | if ( !tmp || strlen(tmp) == 60 ) tmp = strrchr(temp, '-'); |
---|
| 70 | if ( !tmp || strlen(tmp) == 60 ) tmp = strrchr(temp, '/'); |
---|
| 71 | if ( !tmp || strlen(tmp) == 60 ) tmp = strrchr(temp, '*'); |
---|
| 72 | if ( !tmp || strlen(tmp) == 60 ) tmp = strrchr(temp, '%'); |
---|
[530] | 73 | if ( !tmp || strlen(tmp) == 60 ) tmp = strrchr(temp, ','); |
---|
[396] | 74 | if ( !tmp || strlen(tmp) == 60 ) tmp = strrchr(temp, ':'); |
---|
| 75 | if ( !tmp || strlen(tmp) == 60 ) tmp = strrchr(temp, ')'); |
---|
| 76 | if ( tmp ) |
---|
| 77 | { |
---|
| 78 | size = strlen(tmp); |
---|
| 79 | } |
---|
| 80 | else |
---|
| 81 | { |
---|
| 82 | size = 0 ; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | strcpy (&temp[60-size], "\0"); |
---|
| 86 | |
---|
[663] | 87 | if ( retour77 == 0 ) fprintf (filout, " & %s &\n", temp); |
---|
[396] | 88 | else fprintf (filout, " & %s \n", temp); |
---|
| 89 | colnum=0; |
---|
| 90 | tofich_reste (filout, (char *) &s[60-size],returnlineornot); |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | /******************************************************************************/ |
---|
| 95 | /* tofich */ |
---|
| 96 | /******************************************************************************/ |
---|
| 97 | /* This subroutine is used to write the string s into the fileout */ |
---|
| 98 | /******************************************************************************/ |
---|
[663] | 99 | void tofich (FILE * filout, char *s, int returnlineornot) |
---|
[396] | 100 | { |
---|
| 101 | char temp[61]; |
---|
| 102 | char *tmp; |
---|
| 103 | int size; |
---|
[663] | 104 | |
---|
[396] | 105 | if (strlen (s) <= 60) |
---|
| 106 | { |
---|
| 107 | if ( returnlineornot == 0 ) fprintf (filout, " %s", s); |
---|
[663] | 108 | else if ( returnlineornot == 2 ) fprintf (filout, "%s", s); |
---|
| 109 | else if ( returnlineornot == 3 ) fprintf (filout, "%s\n", s); |
---|
| 110 | else fprintf (filout, " %s\n", s); |
---|
| 111 | if ( returnlineornot == 0 || returnlineornot == 2 ) |
---|
| 112 | colnum=colnum+strlen(s)+6; |
---|
[396] | 113 | else colnum=0; |
---|
| 114 | } |
---|
| 115 | else |
---|
| 116 | { |
---|
| 117 | strncpy (temp, s, 60); |
---|
| 118 | strcpy (&temp[60], "\0"); |
---|
| 119 | |
---|
| 120 | tmp = strrchr(temp, ','); |
---|
| 121 | if ( !tmp || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, '+'); |
---|
| 122 | if ( !tmp || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, '-'); |
---|
| 123 | if ( !tmp || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, '/'); |
---|
| 124 | if ( !tmp || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, '*'); |
---|
| 125 | if ( !tmp || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, '%'); |
---|
[530] | 126 | if ( !tmp || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, ','); |
---|
[396] | 127 | if ( !tmp || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, ':'); |
---|
| 128 | if ( !tmp || strlen(tmp) == strlen(temp) ) tmp = strrchr(temp, ')'); |
---|
| 129 | if ( tmp ) |
---|
| 130 | { |
---|
| 131 | size = strlen(tmp); |
---|
| 132 | } |
---|
| 133 | else |
---|
| 134 | { |
---|
| 135 | size = 0 ; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | strcpy (&temp[60-size], "\0"); |
---|
| 139 | |
---|
[663] | 140 | if ( retour77 == 0 ) fprintf (filout, " %s &\n", temp); |
---|
[396] | 141 | else fprintf (filout, " %s \n", temp); |
---|
| 142 | colnum=0; |
---|
| 143 | tofich_reste (filout, (char *) &s[60-size], returnlineornot); |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | /******************************************************************************/ |
---|
| 148 | /* tofich_blanc */ |
---|
| 149 | /******************************************************************************/ |
---|
| 150 | /* This subroutine is used to write size blank into the fileout */ |
---|
| 151 | /******************************************************************************/ |
---|
| 152 | void tofich_blanc (FILE * filout, int size) |
---|
| 153 | { |
---|
| 154 | int i; |
---|
[663] | 155 | |
---|
| 156 | if (size <= 65) fprintf (filout, "%*s\n",size,EmptyChar); |
---|
[396] | 157 | else |
---|
[663] | 158 | { |
---|
[396] | 159 | i=0; |
---|
| 160 | do |
---|
| 161 | { |
---|
| 162 | fprintf (filout, "%*s\n",65,EmptyChar); |
---|
| 163 | i = i+1; |
---|
| 164 | } while ( i <= size / 65 ); |
---|
| 165 | fprintf (filout, "%*s\n",size%65,EmptyChar); |
---|
[663] | 166 | } |
---|
| 167 | |
---|
[396] | 168 | } |
---|
[663] | 169 | /******************************************************************************/ |
---|
| 170 | /* tofich_line */ |
---|
| 171 | /******************************************************************************/ |
---|
| 172 | /* This subroutine is used to write size blank into the fileout */ |
---|
| 173 | /******************************************************************************/ |
---|
| 174 | void tofich_line (FILE * filout, int size, int long position) |
---|
| 175 | { |
---|
| 176 | int i; |
---|
| 177 | int retour; |
---|
[396] | 178 | |
---|
[663] | 179 | if (size <= 65) fprintf (filout, "%*s",size,EmptyChar); |
---|
| 180 | else |
---|
| 181 | { |
---|
| 182 | i=0; |
---|
| 183 | do |
---|
| 184 | { |
---|
| 185 | fprintf (filout, "%*s",65,EmptyChar); |
---|
| 186 | i = i+1; |
---|
| 187 | } while ( i <= size / 65 ); |
---|
| 188 | fprintf (filout, "%*s",size%65,EmptyChar); |
---|
| 189 | } |
---|
[396] | 190 | |
---|
[663] | 191 | if ( !strstr(motparse1,"\n") ) retour=0; |
---|
| 192 | else retour=1; |
---|
| 193 | |
---|
| 194 | fseek(filout,position,SEEK_SET); |
---|
| 195 | if (retour == 1 ) fprintf (filout, "\n"); |
---|
| 196 | |
---|
| 197 | } |
---|
| 198 | |
---|
| 199 | |
---|
[396] | 200 | /******************************************************************************/ |
---|
[530] | 201 | /* RemoveWordSET_0 */ |
---|
[396] | 202 | /******************************************************************************/ |
---|
| 203 | /* This subroutine is used to remove a sentence in the file filout */ |
---|
| 204 | /******************************************************************************/ |
---|
[530] | 205 | void RemoveWordSET_0(FILE * filout, long int position, long int sizetoremove) |
---|
[396] | 206 | { |
---|
[663] | 207 | if ( firstpass == 0 && couldaddvariable == 1 ) |
---|
[530] | 208 | { |
---|
| 209 | fseek(filout,position,SEEK_SET); |
---|
[663] | 210 | tofich_line(filout,sizetoremove,position); |
---|
[530] | 211 | } |
---|
[396] | 212 | } |
---|
| 213 | |
---|
| 214 | |
---|
| 215 | /******************************************************************************/ |
---|
[530] | 216 | /* RemoveWordCUR_0 */ |
---|
[396] | 217 | /******************************************************************************/ |
---|
| 218 | /* This subroutine is used to remove a sentence in the file filout */ |
---|
| 219 | /******************************************************************************/ |
---|
[530] | 220 | void RemoveWordCUR_0(FILE * filout, long int position, long int sizetoremove) |
---|
[396] | 221 | { |
---|
[663] | 222 | if ( firstpass == 0 && couldaddvariable == 1 ) |
---|
[530] | 223 | { |
---|
| 224 | fseek(filout,position,SEEK_CUR); |
---|
| 225 | tofich_blanc(filout,sizetoremove); |
---|
| 226 | } |
---|
[396] | 227 | } |
---|