/*----------------------------------------------------------------------*/ /* rtfhenv_sag.c Skiller seg fra rtfhenv.c ved at kilde ikke tagges, */ /* mens årstall tagges. */ /* */ /* Ver. 1.0 1997-05-21 Øyvind Eide/Dokumentasjonsprosjektet */ /* */ /*----------------------------------------------------------------------*/ #include #include void main(argc, argv) int argc; char **argv; { FILE *innfil, *utfil; char tegn, streng[1000], tilbake[1000]; int i, j, teller; printf("Innfil: %s utfil: %s OK?", argv[1], argv[2]); tegn= getchar(); if (tegn == 'J' || tegn == 'j') { innfil= fopen(argv[1], "r"); utfil= fopen(argv[2], "w"); teller= 0; printf("\n\nHenvisning: %5d", teller); tegn= getc(innfil); while (tegn != EOF) { if (tegn == 'I') { i=0; streng[i++]= tegn; tegn= getc(innfil); if (tegn == 'I' || tegn == ' ') /* Tar sjansen på at dette stemmer */ { printf("\b\b\b\b\b%5d", ++teller); streng[i++]= tegn; tegn= getc(innfil); while ((tegn >= 48 && tegn <= 57) || tegn == ' ' || tegn == 'f' || tegn == '.' || tegn == ',' || tegn == '\n') { streng[i++]= tegn; tegn= getc(innfil); } j= 0; while (streng[i-1] == ' ' || streng[i-1] == ',' || streng[i-1] == '.' || streng[i-1] == '\n') tilbake[j++]= streng[--i]; streng[i]= 0; fprintf(utfil, "%s", &streng[0]); for(i=j-1; i>=0; i--) putc(tilbake[i], utfil); } else putc(streng[0], utfil); } else if (tegn >= 48 && tegn <= 57) { streng[0]= tegn; tegn= getc(innfil); i=1; while (tegn >= 48 && tegn <= 57) { streng[i++]= tegn; tegn= getc(innfil); } streng[i]= 0; if (i == 4) fprintf(utfil, "%s", &streng[0], &streng[0]); else fprintf(utfil, "%s", &streng[0]); } putc(tegn, utfil); tegn= getc(innfil); } } }