#define NB_MC_Fields 1 typedef struct _E_Q_FIELDS_ { char * FieldRTF; char * MyField; } EQField; EQField TAB_MC_Fields[NB_MC_Fields]= { { "eq", "\\pzpeq" } }; /************************************************************************************************** ** Function name : filtrefields ** ** Description : Recupere un champ field et le prepare a etre analyse par yylex ** Input : void ** Output : void **************************************************************************************************/ void filtrefields(void) { int c; int i=0; int j=0; int k=0; int l=0; int FLAG_Moulinne_Eq=0; int FFlongeur=5000; char FFcalutemp; char * FFtableau; char * FFtableautemp; char * MCField; FFtableau=(char *) malloc (FFlongeur); fclose(auxiliaire); if ((auxiliaire=fopen(nomsort,"r"))==NULL) { fprintf(stderr,"FATAL ERROR: Could not open Auxiliary File:%s\n",nomsort); fclose(entree); fclose(sortie); exit(0); } rewind(auxiliaire); c=fgetc(auxiliaire); while(c!=EOF) { if (i==FFlongeur) { FFlongeur*=2; FFtableau=(char * ) realloc (FFtableau, FFlongeur + 1); } if (c!='\n') /* On supprime les retours a la ligne a l'interieur des fields */ FFtableau[i++]=c; c=fgetc(auxiliaire); } FFtableau[i-1]='\0'; /* i-1 car le dernier caractere est une accolade fermante qui sera reprise dans le fichier d'entree standard... (bidouille du a la procedure Avance_Sauve_Champ */ fclose(auxiliaire); if ((auxiliaire=fopen(nomsort,"w"))==NULL) { fprintf(stderr,"FATAL ERROR: Could not open Auxiliary File:%s\n",nomsort); exit(0); fclose(entree); fclose(sortie); } /* On a recupere le fiels dans le sale format de RTF. On essaye de le purifier.*/ /* Recuperation du mot de commande */ /* On saute tous les espaces */ i=0; while( i< strlen(FFtableau) && FFtableau[i]==' ') i++; j=i; FFtableautemp=(char *) malloc (strlen(FFtableau)); /* Si le premier caractere n'est pas '{' on recupere le mot directement */ if ( FFtableau[i]!='{' ) { while( i< strlen(FFtableau) && (FFtableau[i]=='=' || ( FFtableau[i]>='a' && FFtableau[i]<='z' ) || ( FFtableau[i]>='A' && FFtableau[i]<='Z' ) ) ) i++; if (i==j) { /* Il s'est produit une erreur: On n'a pas trouve de mot de commande fprintf(stderr,"ERREUR dans filtrefields : %s \n",FFtableau );*/ yyerror("Fields Error"); } MCField=(char *) malloc (25+i+1); strncpy(MCField,&FFtableau[j],i-j); MCField[i-j]='\0'; strcpy(FFtableautemp,&FFtableau[i]); } /* Sinon, on l'extrait du bloc */ else { k=1; i++; while(k!=0) { if (FFtableau[i]=='{') k++; if (FFtableau[i]=='}') k--; i++; } MCField=(char *) malloc (25+i+1); strncpy(MCField,&FFtableau[j],i-j); MCField[i-j]='\0'; strcpy(FFtableautemp,&FFtableau[i]); /* Dans MCField on a le bloc contenant le mot de commande du field */ /* On le recupere et le remplace au bloc entier */ }; /* Transformation du mot de commande */ /* On compare avec la table de mots de commande de fields et on cherche un equivalent en pseudo-RTF */ l=0; while(l