/*******************************************************************/ /* Funciones para RMan - (c) SPDsoft 92,1993 Ultima modificacion: 30 septiembre 1993 9 enero 1994 /*******************************************************************/ /* correccion: verificacion de anidamiento final 12/02/93 */ /* correccion: MAC 26/02/93 */ /*#define MACOS*/ #define OSErr int #define TRUE 1 #define FALSE 0 #define R_DEL 0x0004 #include #include /*#include */ #define MAXL 512 char err[256]; char strbegin[256] = "Begin"; char strend[256] = "End"; OSErr ru_indent( char* FNameIn, char* FNameOut, char* TabStr, short int flags ); static void gournin(char* s); main(int argc, char **argv) { exit( ru_indent(argv[1],argv[2],"\t",0)); } static void gournin(char* s) { fprintf(stderr,"%s\n",s); } static int find( char* where, char* what ) { char *found; if ( NULL!=(found=strstr(where,what))) { for( found-- ; found>=where; found-- ) if (*found=='#') return (FALSE); } else return FALSE; return TRUE; } OSErr ru_indent( char* FNameIn, char* FNameOut, char* TabStr, short int flags ) { FILE *RibFileIn,*RibFileOut; char buffer[MAXL]; int IndStatus, i, nLine; char done; RibFileIn=fopen(FNameIn,"r"); if(RibFileIn==NULL){ sprintf(err,"error en fopen %s",FNameIn); gournin(err); exit(1); } RibFileOut=fopen(FNameOut,"w"); if(RibFileOut==NULL){ sprintf(err,"error en fopen %s",FNameOut); gournin(err); exit(1); } IndStatus=0; done=0; nLine=0; do { fgets((char *)buffer,MAXL,RibFileIn); nLine++; if ((done=feof(RibFileIn))) break; if (buffer[strlen(buffer)-1]!='\n') { done=-1; break; } if ( find((char*)buffer,strend)) IndStatus--; if (IndStatus<0) { done=-2; break; } for(i=0;i