TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: DARIN MCBRIDE
from: Jasen Betts
date: 1998-12-16 18:54:00
subject: (C_PLUSPLUS) PORTABLE DF1

>>>>>>>>>> CSplit: Version 2.3
>>>>>>>>>>
>>>>>>>>>> CSplit: Begin part 1/2 of mkpatch
>>>>>>>>>>
>>>>>>>>>> CSplit: Begin file MKPATCH.C
>>>>>>>>>>
/*   ,  , .   _     ___  _
     |\/| |/ |_) /\  |  / `|_|  Produces patch files for use with
     |  | |\ |  /~~\ |  \_,| |  apply.c  ******  Version 0.8 Beta
*/

#include 
#include 
#include 

#define BUFFERSIZE (0x8000) /* 32 Kbuffer */
#define LENGTH (1000) /* line length */

enum operations { NEW,END,INS,DEL,REP, NUM_OPERATIONS};
const char* keyword[NUM_OPERATIONS]={
 "In file: %s\n",
 "End of file: %s, with %d line%s\n",
 "At line number %d insert the following %d line%s.\n",
 "At line number %d delete %d line%s.\n",
 "At line number %d delete %d line%s, and insert the following %d \
\
line%s.\n",
 };

#define PLURAL(x) x,("s"+(x==1))

int (*MyStrcmp)(const char*,const char*)=strcmp;

char* MyFgets(char *s,int n,FILE *f){ /* like fgets only nulls string \
\
on error */
 *s='\0';
 if(feof(f))return NULL;
 return fgets(s,n,f);
 }


void resync(FILE*f1,FILE*f2,int matches){

 /* attempts to resynchronise two file pointers,
 ** succeeds with both pointing to the next matching line
 ** fails with poth pointing to EOF - could be considered succes.
 */

 /* I'm too lasy to use an array or other struct to hold the lines,
 ** i've initialised the files with a huge buffer and decided to
 ** let the library handle all that messy stuff.
 */

 long po1,po2,pm1,pm2,pl1,pl2;
 int  n,depth=1,y;

 static char l1[LENGTH],l2[LENGTH],lc1[LENGTH],lc2[LENGTH];
 /* static to save the stack */

 po1=ftell(f1);
 po2=ftell(f2);

 for(depth=1;1;depth++){

   /* assertion: for all n,m <= depth :  line[f1,m] != line[f2,n] *
    * so read the next line from file1 and compare it with the    *
    * depth lines from file2 starting at po2                      */

  pl1=ftell(f1);
  MyFgets(l1,LENGTH,f1);
   fseek(f2,po2,SEEK_SET);

   for(y=1;y=matches) {            /* success! */
         fseek(f1,pl1,SEEK_SET);
         fseek(f2,pl2,SEEK_SET);
     return ;
         }
       fseek(f1,pm1,SEEK_SET);   /* failure: restore pointers, keep \
\
looking */
       fseek(f2,pm2,SEEK_SET);
       }
     }

  pl2=ftell(f2);                 /* this section is a mirror image of \
\
the */
   MyFgets(l2,LENGTH,f2);        /* section above, check for a match \
\
from */
   fseek(f1,po1,SEEK_SET);       /* from the other side                 \
\
  */

   for(y=1;y>>>>>>>>> CSplit: End part 1/2 crc: 3181
>>>>>>>>>>
                        

--- EzyQwk V1.20 01fa018d
* Origin: CSS Brisbane, Qld, Australia. [61-7-3367-3890] (3:640/350)
SEEN-BY: 396/1 632/0 371 633/260 262 267 270 371 634/397 635/506 728 639/252
SEEN-BY: 670/218
@PATH: 640/350 201 270/101 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.