home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume05 / gdiffdif.ms < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  29.0 KB

  1. From decwrl!labrea!agate!pasteur!ames!ncar!tank!nic.MR.NET!hal!ncoast!allbery Sun Dec 11 17:12:32 PST 1988
  2. Article 752 of comp.sources.misc:
  3. Path: granite!decwrl!labrea!agate!pasteur!ames!ncar!tank!nic.MR.NET!hal!ncoast!allbery
  4. From: kent@ncoast.UUCP (Kent Williams)
  5. Newsgroups: comp.sources.misc
  6. Subject: v05i077: gnu diff for MSDOS
  7. Keywords: diff gnu MSDOS
  8. Message-ID: <13228@ncoast.UUCP>
  9. Date: 10 Dec 88 02:12:51 GMT
  10. Sender: allbery@ncoast.UUCP
  11. Reply-To: kent@ncoast.UUCP (Kent Williams)
  12. Organization: Cleveland Public Access UN*X, Cleveland, OH
  13. Lines: 1044
  14. Approved: allbery@ncoast.UUCP
  15.  
  16. Posting-number: Volume 5, Issue 77
  17. Submitted-by: "Kent Williams" <kent@ncoast.UUCP>
  18. Archive-name: gdiff.diff.ms
  19.  
  20. [You need to get the GnuDiff distribution to use this.  ++bsa]
  21.  
  22. This is the readme file for the MSDOS porting kit for GNU DIFF.
  23.  
  24. In order to produce a working MSDOS version, follow these steps:
  25.  
  26. 1. Get the distribution of gnu diff.  This is archived various places
  27. around the networks.  I got it by ftp to prep.ai.mit.edu.  If you
  28. can't find it, contact me as a last resort.  I believe it is also
  29. available from uunet.
  30.  
  31. The following steps can be performed either on a Unix system, or on a
  32. DOS system, if you have the DOS versions of patch and tar.
  33.  
  34. 2. Unpack the tar.  The standard distribution tar creates a directory
  35. called diff in the current working directory.
  36.  
  37. 3. Apply the patch file included below in the diff directory.
  38.  
  39. The following steps happen on your target DOS or OS/2 system.
  40.  
  41. 4. Copy the directory from the Unix system to the MSDOS system, if
  42. necessary.
  43.  
  44. 5. Add the msdos makefile, proto.h and getopt.c to the directory.
  45.  
  46. 6. Run make.
  47.  
  48. This is a minimal delta port -- i.e. as few changes as possible.  I
  49. used the Microsoft C compiler V 5.1, though you should be able to get
  50. it to work with any compiler that supports a huge model.
  51.  
  52. As far as I know, this should work fine under OS/2 also.
  53.  
  54. That being the case, it can't work on really large files, since it
  55. keeps both of the files being compared in core.  This works fine for
  56. virtual memory operating systems, but it's a little tough on an 8088.
  57. I had to go to the huge data model because of some pointer arithmetic
  58. problem in compact model -- if you compile it compact model, diffs of
  59. single files work fine, but if you diff two directories, the program
  60. runs out of memory and crashes DOS.  If someone figures out what the
  61. problem is, please let me know.
  62.  
  63. Another fixer-upper opportunity is diff3.  I did the minimum in order
  64. to get a clean compile, and it doesn't cooperate by working
  65. correctly.
  66.  
  67. I have included the standard getopt.c from comp.sources.unix, as that
  68. isn't available in the Microsoft Standard Library.
  69.  
  70. Questions/Comments/Suggestions to:
  71. Kent Williams
  72. 722 Rundell Street
  73. Iowa City, IA 52240
  74. internet: williams@umaxc.weeg.uiowa.edu
  75. (319) 338-6053 (If you call from Australia, please compute the time
  76. difference!)
  77. -----------------------------CUT HERE-------OUCH------------------------
  78. # This is a shell archive.  Save this into a file, edit it
  79. # and delete all lines above this comment.  Then give this
  80. # file to sh by executing the command "sh file".  The files
  81. # will be extracted into the current directory owned by
  82. # you with default permissions.
  83. #
  84. # The files contained herein are:
  85. #    makefile.dos   difpatch.dos       getopt.c        proto.h
  86. #
  87. echo 'x - makefile.dos'
  88. sed 's/^X//' <<'________This_Is_The_END________' >>makefile.dos
  89. X
  90. X#
  91. X# MSDOS makefile for gnu-diff
  92. X#
  93. XMODEL = H
  94. XCFLAGS = -nologo -Zi -W2 -DUSG
  95. XOPT = -Ox
  96. X.SUFFIXES: .obj .c
  97. X
  98. X.c.obj:
  99. X    cl -c $(CFLAGS) -A$(MODEL) $(OPT) $<
  100. X
  101. XSRC=analyze.c context.c diff.c dir.c ed.c getopt.c io.c normal.c\
  102. X    regex.c util.c
  103. XOBJ=$(SRC:.c=.obj)
  104. X
  105. Xdiff.exe : $(OBJ)
  106. X    link $(OBJ) $(LIB)\setargv ,$@ /CO/NOE/ST:32000 ,;
  107. X
  108. Xdiff3.exe : diff3.obj getopt.obj
  109. X    link diff3 getopt $(LIB)\setargv /CO/NOE ,;
  110. X
  111. Xproto.h : $(SRC)
  112. X    @-del $@
  113. X    ! cl -Zg -DMAKING_PROTO_H $(CFLAGS) $? >> $@
  114. X
  115. X$(OBJ) : diff.h
  116. X
  117. Xclean :
  118. X    rm *.bak *.obj *.map
  119. ________This_Is_The_END________
  120. echo 'x - difpatch.dos'
  121. sed 's/^X//' <<'________This_Is_The_END________' >>difpatch.dos
  122. X
  123. X*** analyze.c    Mon Sep 26 23:57:10 1988
  124. X--- diff/analyze.c    Tue Dec 06 10:38:50 1988
  125. X***************
  126. X*** 116,119 ****
  127. X--- 116,120 ----
  128. X        bmin > dmin ? bd[--bmin - 1] = INT_MAX : ++bmin;
  129. X        bmax < dmax ? bd[++bmax + 1] = INT_MAX : --bmax;
  130. X+ 
  131. X        for (d = bmax; d >= bmin; d -= 2)
  132. X      {
  133. X***************
  134. X*** 387,392 ****
  135. X--- 388,401 ----
  136. X  
  137. X          /* Cancel provisional discards at the end, and shrink the run.  */
  138. X+ #if    defined(MSC_BUG)
  139. X          while (j > i && discards[j - 1] == 2)
  140. X            discards[j - 1] = 0, --provisional;
  141. X+ #else
  142. X+         {
  143. X+             int index = j - 1;
  144. X+           while (j > i && discards[index] == 2)
  145. X+             discards[index] = 0, --provisional;
  146. X+         }
  147. X+ #endif
  148. X  
  149. X          /* Now we have the length of a run of discardable lines
  150. X***************
  151. X*** 652,658 ****
  152. X--- 661,673 ----
  153. X       If so, we know they are identical without actually reading them.  */
  154. X  
  155. X+ #if !defined(MSDOS)
  156. X+     /*
  157. X+     ** since MSC always sets the inode and dev fields to zero under DOS
  158. X+     ** this test will always think two files are the same.
  159. X+     */
  160. X    if (filevec[0].stat.st_ino == filevec[1].stat.st_ino
  161. X        && filevec[0].stat.st_dev == filevec[1].stat.st_dev)
  162. X      return 0;
  163. X+ #endif /* MSDOS */
  164. X  
  165. X    binary = read_files (filevec);
  166. X***************
  167. X*** 664,670 ****
  168. X--- 679,711 ----
  169. X    if (binary)
  170. X      {
  171. X+ #if !defined(MSDOS)
  172. X        int differs = (filevec[0].buffered_chars != filevec[1].buffered_chars
  173. X               || bcmp (filevec[0].buffer, filevec[1].buffer,
  174. X                    filevec[1].buffered_chars));
  175. X+ #else
  176. X+     int differs;
  177. X+     if(filevec[0].buffered_chars != filevec[1].buffered_chars)
  178. X+         differs = 1;
  179. X+     else {
  180. X+         /*
  181. X+         ** we've got to do it in chunks because of our
  182. X+         ** poor 16 bit processor
  183. X+         */
  184. X+         char huge *b0 = filevec[0].buffer,
  185. X+               *b1 = filevec[1].buffer;
  186. X+         long int count;
  187. X+         unsigned int delta;
  188. X+         count = filevec[0].buffered_chars;
  189. X+         while(count > 0) {
  190. X+             delta = (unsigned)(count > 65000 ? 65000 : count);
  191. X+             if(bcmp(b0,b1,delta) != 0)
  192. X+                 break;
  193. X+             count -= delta;
  194. X+             b0 += delta;
  195. X+             b1 += delta;
  196. X+         }
  197. X+         differs = count != 0;
  198. X+     }
  199. X+ #endif           
  200. X        if (differs) 
  201. X      message ("Binary files %s and %s differ\n",
  202. X***************
  203. X*** 775,780 ****
  204. X--- 816,826 ----
  205. X    for (i = 0; i < 2; ++i)
  206. X      {
  207. X+ #if !defined(MSDOS)
  208. X        if (filevec[i].buffer != 0)
  209. X      free (filevec[i].buffer);
  210. X+ #else    /* MSDOS */
  211. X+       if (filevec[i].buffer != 0)
  212. X+     hfree (filevec[i].buffer);
  213. X+ #endif
  214. X        free (filevec[i].linbuf);
  215. X      }
  216. X*** context.c    Wed Sep 28 21:19:18 1988
  217. X--- diff/context.c    Mon Dec 05 10:36:40 1988
  218. X***************
  219. X*** 253,257 ****
  220. X  
  221. X        /* If the change is ignorable, mark it.  */
  222. X!       script->ignore = (!deletes && !inserts);
  223. X  
  224. X        /* Advance to the following change.  */
  225. X--- 253,257 ----
  226. X  
  227. X        /* If the change is ignorable, mark it.  */
  228. X!       script->ignore = (char)(!deletes && !inserts);
  229. X  
  230. X        /* Advance to the following change.  */
  231. X*** diff.c    Fri Oct 07 00:18:42 1988
  232. X--- diff/diff.c    Tue Dec 06 10:25:02 1988
  233. X***************
  234. X*** 68,72 ****
  235. X  }
  236. X  
  237. X! main (argc, argv)
  238. X       int argc;
  239. X       char *argv[];
  240. X--- 68,72 ----
  241. X  }
  242. X  
  243. X! void main (argc, argv)
  244. X       int argc;
  245. X       char *argv[];
  246. X***************
  247. X*** 301,304 ****
  248. X--- 301,305 ----
  249. X  }
  250. X  
  251. X+ void
  252. X  specify_style (style)
  253. X       enum output_style style;
  254. X***************
  255. X*** 383,387 ****
  256. X      }
  257. X      }
  258. X! 
  259. X    /* See if the two named files are actually the same physical file.
  260. X       If so, we know they are identical without actually reading them.  */
  261. X--- 384,394 ----
  262. X      }
  263. X      }
  264. X! #if !defined(MSDOS)
  265. X!     /*
  266. X!     ** this stuff is real bad idea under MSDOS, at least for MSC 5.1
  267. X!     ** because the st_ino and st_dev fields are not supported by
  268. X!     ** MSDOS, and so stat sets them to zero; therefore
  269. X!     ** this test always succeeds.
  270. X!     */
  271. X    /* See if the two named files are actually the same physical file.
  272. X       If so, we know they are identical without actually reading them.  */
  273. X***************
  274. X*** 395,398 ****
  275. X--- 402,406 ----
  276. X        goto done;
  277. X      }
  278. X+ #endif    /* MSDOS */
  279. X  
  280. X    /* Open the files and record their descriptors.  */
  281. X***************
  282. X*** 411,415 ****
  283. X      {
  284. X        char *filename = inf[i].name;
  285. X! 
  286. X        inf[i].desc = open (filename, O_RDONLY, 0);
  287. X        if (0 > inf[i].desc)
  288. X--- 419,431 ----
  289. X      {
  290. X        char *filename = inf[i].name;
  291. X! #if !defined(MSDOS)
  292. X!       inf[i].desc = open (filename, O_RDONLY, 0);
  293. X!       if (0 > inf[i].desc)
  294. X!         {
  295. X!           perror_with_name (filename);
  296. X!           errorcount = 1;
  297. X!         }
  298. X! #else
  299. X!     if(inf[i].dir_p == 0) {
  300. X            inf[i].desc = open (filename, O_RDONLY, 0);
  301. X            if (0 > inf[i].desc)
  302. X***************
  303. X*** 418,421 ****
  304. X--- 434,440 ----
  305. X                errorcount = 1;
  306. X              }
  307. X+         } else
  308. X+             inf[i].desc = 0;
  309. X+ #endif    /* MSDOS */
  310. X      }
  311. X      }
  312. X*** diff.h    Wed Oct 12 00:51:24 1988
  313. X--- diff/diff.h    Mon Dec 05 10:40:14 1988
  314. X***************
  315. X*** 23,27 ****
  316. X--- 23,31 ----
  317. X  #include <stdio.h>
  318. X  #include <sys/types.h>
  319. X+ 
  320. X+ #if !defined(MSDOS)
  321. X  #include <sys/file.h>
  322. X+ #endif    /* MSDOS */
  323. X+ 
  324. X  #include <sys/stat.h>
  325. X  
  326. X***************
  327. X*** 28,32 ****
  328. X--- 32,40 ----
  329. X  #ifdef USG
  330. X  #include <time.h>
  331. X+ 
  332. X+ #if !defined(MSDOS)
  333. X  #include <dirent.h>
  334. X+ #endif /* MSDOS */
  335. X+ 
  336. X  #include <fcntl.h>
  337. X  #define direct dirent
  338. X***************
  339. X*** 43,47 ****
  340. X--- 51,57 ----
  341. X  #define bzero(s,n)    memset((s),0,(n))
  342. X  
  343. X+ #if !defined(MSDOS)
  344. X  #define dup2(f,t)    (close(t),fcntl((f),F_DUPFD,(t)))
  345. X+ #endif
  346. X  
  347. X  #define vfork    fork
  348. X***************
  349. X*** 50,57 ****
  350. X--- 60,75 ----
  351. X  #endif
  352. X  
  353. X+ #ifdef MSDOS
  354. X+ #include <process.h>
  355. X+ #include <stdlib.h>
  356. X+ #endif /* MSDOS */
  357. X+ 
  358. X  #include <errno.h>
  359. X+ 
  360. X+ #if !defined(MSDOS)
  361. X  extern int      errno;
  362. X  extern int      sys_nerr;
  363. X  extern char    *sys_errlist[];
  364. X+ #endif
  365. X  
  366. X  #define    EOS        (0)
  367. X***************
  368. X*** 59,64 ****
  369. X--- 77,84 ----
  370. X  #define TRUE        1
  371. X  
  372. X+ #if !defined(min)
  373. X  #define min(a,b) ((a) <= (b) ? (a) : (b))
  374. X  #define max(a,b) ((a) >= (b) ? (a) : (b))
  375. X+ #endif /* MSDOS */
  376. X  
  377. X  #ifndef PR_FILE_NAME
  378. X***************
  379. X*** 68,73 ****
  380. X--- 88,97 ----
  381. X  /* Support old-fashioned C compilers.  */
  382. X  #if defined (__STDC__) || defined (__GNUC__)
  383. X+ #if !defined(MSDOS)
  384. X  #include "limits.h"
  385. X  #else
  386. X+ #include <limits.h>
  387. X+ #endif    /* MSDOS */
  388. X+ #else
  389. X  #define INT_MAX 2147483647
  390. X  #define CHAR_BIT 8
  391. X***************
  392. X*** 74,79 ****
  393. X  #endif
  394. X  
  395. X  /* Support old-fashioned C compilers.  */
  396. X! #if !defined (__STDC__) && !defined (__GNUC__)
  397. X  #define const
  398. X  #endif
  399. X--- 98,117 ----
  400. X  #endif
  401. X  
  402. X+ #if defined(MSDOS)
  403. X+ #ifdef INT_MAX
  404. X+ #undef INT_MAX
  405. X+ #include <limits.h>
  406. X+ #endif
  407. X+ #if !defined(MAKING_PROTO_H)
  408. X+ #include "proto.h"
  409. X+ #endif
  410. X+ #include <malloc.h>
  411. X+ #include <io.h>
  412. X+ #include <memory.h>
  413. X+ extern int getopt(int nargc,char **nargv,char *ostr);
  414. X+ #endif
  415. X+ 
  416. X  /* Support old-fashioned C compilers.  */
  417. X! #if !defined (__STDC__) && !defined (__GNUC__) || defined(MSDOS)
  418. X  #define const
  419. X  #endif
  420. X***************
  421. X*** 215,223 ****
  422. X  
  423. X      /* Buffer in which text of file is read.  */
  424. X      char *        buffer;
  425. X      /* Allocated size of buffer.  */
  426. X      int            bufsize;
  427. X      /* Number of valid characters now in the buffer. */
  428. X!     int            buffered_chars;
  429. X  
  430. X      /* Array of data on analyzed lines of this chunk of this file.  */
  431. X--- 253,273 ----
  432. X  
  433. X      /* Buffer in which text of file is read.  */
  434. X+ #if !defined(MSDOS)
  435. X      char *        buffer;
  436. X+ 
  437. X      /* Allocated size of buffer.  */
  438. X      int            bufsize;
  439. X+ 
  440. X+     /* Number of valid characters now in the buffer. */
  441. X+     long int            buffered_chars;
  442. X+ #else    /* MSDOS */
  443. X+     char huge *buffer;
  444. X+ 
  445. X+     /* Allocated size of buffer.  */
  446. X+     long int        bufsize;
  447. X+ 
  448. X      /* Number of valid characters now in the buffer. */
  449. X!     long int            buffered_chars;
  450. X! #endif    /* MSDOS */
  451. X  
  452. X      /* Array of data on analyzed lines of this chunk of this file.  */
  453. X***************
  454. X*** 315,316 ****
  455. X--- 365,367 ----
  456. X  void message ();
  457. X  void print_message_queue ();
  458. X+ 
  459. X*** dir.c    Tue Sep 20 13:32:58 1988
  460. X--- diff/dir.c    Tue Dec 06 11:34:58 1988
  461. X***************
  462. X*** 32,35 ****
  463. X--- 32,94 ----
  464. X  };
  465. X  
  466. X+ #if defined(MSDOS)
  467. X+ /*
  468. X+ ** due to difference of opinion btw gnu and microsoft about what
  469. X+ ** const means, const is defined away in diff.h, which causes warnings
  470. X+ ** when compiling the headers.  This ugliness is avoided here.
  471. X+ */
  472. X+ #ifdef const
  473. X+ #undef const
  474. X+ #endif
  475. X+ #include <string.h>
  476. X+ #include <dos.h>
  477. X+ 
  478. X+ struct direct {
  479. X+     char d_name[14];
  480. X+ };
  481. X+ 
  482. X+ typedef struct _dir {
  483. X+     int first;
  484. X+     struct find_t dta;
  485. X+     struct direct current;
  486. X+ } DIR;
  487. X+ 
  488. X+ 
  489. X+ DIR *
  490. X+ opendir(char *name) {
  491. X+     char localname[65];
  492. X+     DIR *rval = malloc(sizeof(DIR));
  493. X+     strcpy(localname,name);
  494. X+     strcat(localname,"/*.*");
  495. X+     if(rval == NULL ||
  496. X+         _dos_findfirst(localname,_A_NORMAL|_A_SUBDIR,&rval->dta) != 0)
  497. X+         return NULL;
  498. X+     rval->first = 1;
  499. X+     return rval;
  500. X+ }
  501. X+ 
  502. X+ void
  503. X+ closedir(DIR *x) {
  504. X+     free(x);
  505. X+ }
  506. X+ 
  507. X+ struct direct *
  508. X+ readdir(DIR *thisdir) {
  509. X+     /*
  510. X+     ** first time through, we don't need to look for a file
  511. X+     */
  512. X+     if(!thisdir->first) {
  513. X+         if(_dos_findnext(&thisdir->dta) != 0)
  514. X+             return NULL;
  515. X+     } else
  516. X+         thisdir->first = 0;
  517. X+     strncpy(thisdir->current.d_name,thisdir->dta.name,13);
  518. X+     thisdir->current.d_name[13] = '\0';
  519. X+     strlwr(thisdir->current.d_name);
  520. X+     return &thisdir->current;
  521. X+ }
  522. X+         
  523. X+ #endif /* MSDOS */
  524. X+ 
  525. X  static struct dirdata
  526. X  dir_sort (dirname)
  527. X***************
  528. X*** 55,59 ****
  529. X      {
  530. X        pfatal_with_name (dirname);
  531. X!       return;
  532. X      }
  533. X  
  534. X--- 114,118 ----
  535. X      {
  536. X        pfatal_with_name (dirname);
  537. X!       return dirdata;
  538. X      }
  539. X  
  540. X***************
  541. X*** 124,128 ****
  542. X--- 183,195 ----
  543. X  diff_dirs (name1, name2, handle_file, depth)
  544. X       char *name1, *name2;
  545. X+ #if !defined(MSDOS)
  546. X       int (*handle_file) ();
  547. X+ #else
  548. X+     /* sorry, rms, I can't live with the assumption that
  549. X+     ** sizeof(char *) == sizeof(int)
  550. X+     */
  551. X+     int (*handle_file)(char *dir0,char *name0,
  552. X+         char *dir1,char *name1,int depth);
  553. X+ #endif
  554. X  {
  555. X    struct dirdata data1, data2;
  556. X***************
  557. X*** 176,180 ****
  558. X      {
  559. X        /* Next filename in dir 1 is less; that is a file in dir 1 only.  */
  560. X!       v1 = handle_file (name1, data1.files[i1], name2, 0, depth + 1);
  561. X        i1++;
  562. X      }
  563. X--- 243,248 ----
  564. X      {
  565. X        /* Next filename in dir 1 is less; that is a file in dir 1 only.  */
  566. X!       v1 = handle_file (name1, data1.files[i1], name2, (char *)0,
  567. X!           depth + 1);
  568. X        i1++;
  569. X      }
  570. X***************
  571. X*** 182,186 ****
  572. X      {
  573. X        /* Next filename in dir 2 is less; that is a file in dir 2 only.  */
  574. X!       v1 = handle_file (name1, 0, name2, data2.files[i2], depth + 1);
  575. X        i2++;
  576. X      }
  577. X--- 250,255 ----
  578. X      {
  579. X        /* Next filename in dir 2 is less; that is a file in dir 2 only.  */
  580. X!       v1 = handle_file (name1, (char *)0, name2, data2.files[i2],
  581. X!           depth + 1);
  582. X        i2++;
  583. X      }
  584. X*** io.c    Mon Sep 26 22:27:28 1988
  585. X--- diff/io.c    Tue Dec 06 11:19:24 1988
  586. X***************
  587. X*** 22,27 ****
  588. X--- 22,31 ----
  589. X  
  590. X  /* Rotate a value n bits to the left. */
  591. X+ #if !defined(MSDOS)
  592. X  #define UINT_BIT (sizeof (unsigned) * CHAR_BIT)
  593. X  #define ROL(v, n) ((v) << (n) | (v) >> UINT_BIT - (n))
  594. X+ #else
  595. X+ #define ROL(v,n)  ((v) << (n) | (v) >> (sizeof(v) * CHAR_BIT) - (n))
  596. X+ #endif
  597. X  
  598. X  /* Given a hash value and a new character, return a new hash value. */
  599. X***************
  600. X*** 62,65 ****
  601. X--- 66,70 ----
  602. X        current->buffer = 0;
  603. X      }
  604. X+ #if !defined(MSDOS)     
  605. X    /* If it's a regular file, we can just get the size out of the stat
  606. X       block and slurp it in all at once. */
  607. X***************
  608. X*** 70,76 ****
  609. X--- 75,97 ----
  610. X        current->buffered_chars
  611. X      = read (current->desc, current->buffer, current->bufsize);
  612. X+ #else    /* MSDOS */
  613. X+   else {
  614. X+       current->bufsize = current->stat.st_size + 1;
  615. X+     if((current->buffer = 
  616. X+         (char huge *)halloc(current->bufsize,sizeof(char))) == NULL)
  617. X+         fatal("virtual memory exhausted");
  618. X+     {
  619. X+         int count;
  620. X+         current->buffered_chars = 0;
  621. X+         while((count = read(current->desc,
  622. X+             current->buffer+current->buffered_chars,
  623. X+                 32000)) > 0)
  624. X+             current->buffered_chars += count;
  625. X+     }
  626. X+ #endif    /* MSDOS */
  627. X        if (current->buffered_chars < 0)
  628. X      pfatal_with_name (current->name);
  629. X      }
  630. X+ #if !defined(MSDOS)
  631. X    else
  632. X      {
  633. X***************
  634. X*** 97,100 ****
  635. X--- 118,122 ----
  636. X      pfatal_with_name (current->name);
  637. X      }
  638. X+ #endif /* MSDOS */
  639. X    
  640. X    /* Check first part of file to see if it's a binary file.  */
  641. X***************
  642. X*** 129,135 ****
  643. X--- 151,167 ----
  644. X  
  645. X    /* Attempt to get a good initial guess as to the number of lines. */
  646. X+ #if !defined(MSDOS)
  647. X    current->linbufsize = current->buffered_chars / 50 + 5;
  648. X    current->linbuf
  649. X      = (struct line_def *) xmalloc (current->linbufsize * sizeof (struct line_def));
  650. X+ #else
  651. X+     long int buffersize;
  652. X+     current->linbufsize = (int)
  653. X+         (buffersize = (long int)(current->buffered_chars / 50 + 5));
  654. X+     buffersize *= sizeof(struct line_def);
  655. X+     if(buffersize > 65535L)
  656. X+         fatal("Too many lines to compare");
  657. X+     current->linbuf = (struct line_def *) xmalloc((size_t)buffersize);
  658. X+ #endif
  659. X  
  660. X    if (function_regexp)
  661. X***************
  662. X*** 291,296 ****
  663. X    int lines;
  664. X    /* Number of bytes left to scan.  */
  665. X    int bytes = min (filevec[0].buffered_chars, filevec[1].buffered_chars);
  666. X! 
  667. X    /* Find identical prefix.  */
  668. X  
  669. X--- 323,331 ----
  670. X    int lines;
  671. X    /* Number of bytes left to scan.  */
  672. X+ #if !defined(MSDOS)
  673. X    int bytes = min (filevec[0].buffered_chars, filevec[1].buffered_chars);
  674. X! #else
  675. X!   long int bytes = min (filevec[0].buffered_chars, filevec[1].buffered_chars);
  676. X! #endif
  677. X    /* Find identical prefix.  */
  678. X  
  679. X***************
  680. X*** 388,391 ****
  681. X--- 423,427 ----
  682. X    32749,
  683. X    65521,
  684. X+ #if !defined MSDOS
  685. X    131071,
  686. X    262139,
  687. X***************
  688. X*** 399,402 ****
  689. X--- 435,439 ----
  690. X    67108859,            /* Preposterously large . . . */
  691. X    -1
  692. X+ #endif
  693. X  };
  694. X  
  695. X***************
  696. X*** 410,414 ****
  697. X       int n;
  698. X  {
  699. X!   int bucket = current->linbuf[n].hash % nbuckets;
  700. X    struct equivclass *b = buckets[bucket], *p = NULL;
  701. X  
  702. X--- 447,451 ----
  703. X       int n;
  704. X  {
  705. X!   int bucket = (int)(current->linbuf[n].hash % nbuckets);
  706. X    struct equivclass *b = buckets[bucket], *p = NULL;
  707. X  
  708. X*** regex.c    Sat Oct 08 01:16:56 1988
  709. X--- diff/regex.c    Thu Dec 08 08:20:48 1988
  710. X***************
  711. X*** 136,139 ****
  712. X--- 136,145 ----
  713. X  #endif
  714. X  
  715. X+ #ifdef MSDOS
  716. X+ #include <memory.h>
  717. X+ #include <malloc.h>
  718. X+ #include "diff.h"
  719. X+ #endif
  720. X+ 
  721. X  /*
  722. X   * Define the syntax stuff, so we can do the \<...\> things.
  723. X***************
  724. X*** 188,192 ****
  725. X  #ifndef NFAILURES
  726. X  #define NFAILURES 80
  727. X! #endif NFAILURES
  728. X  
  729. X  /* width of a byte in bits */
  730. X--- 194,198 ----
  731. X  #ifndef NFAILURES
  732. X  #define NFAILURES 80
  733. X! #endif /* NFAILURES */
  734. X  
  735. X  /* width of a byte in bits */
  736. X***************
  737. X*** 246,249 ****
  738. X--- 252,256 ----
  739. X  #define PATUNFETCH p--
  740. X  
  741. X+ #if !defined(MSDOS)
  742. X  #define EXTEND_BUFFER \
  743. X    { char *old_buffer = bufp->buffer; \
  744. X***************
  745. X*** 263,268 ****
  746. X        pending_exact += c; \
  747. X    }
  748. X! 
  749. X! static int store_jump (), insert_jump ();
  750. X  
  751. X  char *
  752. X--- 270,293 ----
  753. X        pending_exact += c; \
  754. X    }
  755. X! #else
  756. X! #define EXTEND_BUFFER \
  757. X!   { char *old_buffer = bufp->buffer; \
  758. X!     if (bufp->allocated == (1<<15)) goto too_big; \
  759. X!     bufp->allocated *= 2; \
  760. X!     if (bufp->allocated > (1<<15)) bufp->allocated = (1<<15); \
  761. X!     if (!(bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated))) \
  762. X!       goto memory_exhausted; \
  763. X!     c = bufp->buffer - old_buffer; \
  764. X!     b += c; \
  765. X!     if (fixup_jump) \
  766. X!       fixup_jump += c; \
  767. X!     if (laststart) \
  768. X!       laststart += c; \
  769. X!     begalt += c; \
  770. X!     if (pending_exact) \
  771. X!       pending_exact += c; \
  772. X!   }
  773. X! #endif
  774. X! static void store_jump (), insert_jump ();
  775. X  
  776. X  char *
  777. X***************
  778. X*** 345,350 ****
  779. X--- 370,379 ----
  780. X        else
  781. X      /* Caller did not allocate a buffer.  Do it for him */
  782. X+ #if !defined(MSDOS)
  783. X      bufp->buffer = (char *) malloc (28);
  784. X        if (!bufp->buffer) goto memory_exhausted;
  785. X+ #else
  786. X+     bufp->buffer = (char *) xmalloc(28);
  787. X+ #endif
  788. X        begalt = b = bufp->buffer;
  789. X      }
  790. X***************
  791. X*** 746,750 ****
  792. X    `opcode' is the opcode to store. */
  793. X  
  794. X! static int
  795. X  store_jump (from, opcode, to)
  796. X       char *from, *to;
  797. X--- 775,779 ----
  798. X    `opcode' is the opcode to store. */
  799. X  
  800. X! static void
  801. X  store_jump (from, opcode, to)
  802. X       char *from, *to;
  803. X***************
  804. X*** 752,757 ****
  805. X  {
  806. X    from[0] = opcode;
  807. X!   from[1] = (to - (from + 3)) & 0377;
  808. X!   from[2] = (to - (from + 3)) >> 8;
  809. X  }
  810. X  
  811. X--- 781,786 ----
  812. X  {
  813. X    from[0] = opcode;
  814. X!   from[1] = (char)((to - (from + 3)) & 0377);
  815. X!   from[2] = (char)((to - (from + 3)) >> 8);
  816. X  }
  817. X  
  818. X***************
  819. X*** 763,767 ****
  820. X     If you call this function, you must zero out pending_exact.  */
  821. X  
  822. X! static int
  823. X  insert_jump (op, from, to, current_end)
  824. X       char op;
  825. X--- 792,796 ----
  826. X     If you call this function, you must zero out pending_exact.  */
  827. X  
  828. X! static void
  829. X  insert_jump (op, from, to, current_end)
  830. X       char op;
  831. X***************
  832. X*** 1274,1278 ****
  833. X      case start_memory:
  834. X        regstart[*p] = d;
  835. X!        regstart_seg1[*p++] = (dend == end_match_1);
  836. X        break;
  837. X  
  838. X--- 1303,1307 ----
  839. X      case start_memory:
  840. X        regstart[*p] = d;
  841. X!        regstart_seg1[*p++] = (unsigned char)(dend == end_match_1);
  842. X        break;
  843. X  
  844. X***************
  845. X*** 1279,1283 ****
  846. X      case stop_memory:
  847. X        regend[*p] = d;
  848. X!        regend_seg1[*p++] = (dend == end_match_1);
  849. X        break;
  850. X  
  851. X--- 1308,1312 ----
  852. X      case stop_memory:
  853. X        regend[*p] = d;
  854. X!        regend_seg1[*p++] = (unsigned char)(dend == end_match_1);
  855. X        break;
  856. X  
  857. X***************
  858. X*** 1424,1428 ****
  859. X          /* p1[0] ... p1[2] are an on_failure_jump.
  860. X             Examine what follows that */
  861. X!         if (p1[3] == (unsigned char) exactn && p1[5] != c)
  862. X            p[-3] = (unsigned char) finalize_jump;
  863. X          else if (p1[3] == (unsigned char) charset
  864. X--- 1453,1457 ----
  865. X          /* p1[0] ... p1[2] are an on_failure_jump.
  866. X             Examine what follows that */
  867. X!         if (p1[3] == (char) exactn && p1[5] != (char)c)
  868. X            p[-3] = (unsigned char) finalize_jump;
  869. X          else if (p1[3] == (unsigned char) charset
  870. X***************
  871. X*** 1661,1669 ****
  872. X    if (!re_comp_buf.buffer)
  873. X      {
  874. X        if (!(re_comp_buf.buffer = (char *) malloc (200)))
  875. X      return "Memory exhausted";
  876. X-       re_comp_buf.allocated = 200;
  877. X        if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH)))
  878. X      return "Memory exhausted";
  879. X      }
  880. X    return re_compile_pattern (s, strlen (s), &re_comp_buf);
  881. X--- 1690,1703 ----
  882. X    if (!re_comp_buf.buffer)
  883. X      {
  884. X+ #if !defined(MSDOS)
  885. X        if (!(re_comp_buf.buffer = (char *) malloc (200)))
  886. X      return "Memory exhausted";
  887. X        if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH)))
  888. X      return "Memory exhausted";
  889. X+ #else
  890. X+     re_comp_buf.buffer = (char *) xmalloc(200);
  891. X+     re_comp_buf.fastmap = (char *) xmalloc(1 << BYTEWIDTH);
  892. X+ #endif
  893. X+       re_comp_buf.allocated = 200;
  894. X      }
  895. X    return re_compile_pattern (s, strlen (s), &re_comp_buf);
  896. X*** util.c    Fri Sep 30 11:04:10 1988
  897. X--- diff/util.c    Mon Dec 05 10:36:40 1988
  898. X***************
  899. X*** 131,134 ****
  900. X--- 131,135 ----
  901. X    strcat (name, name1);
  902. X  
  903. X+ #if !defined(MSDOS)
  904. X    if (paginate_flag)
  905. X      {
  906. X***************
  907. X*** 163,166 ****
  908. X--- 164,168 ----
  909. X      }
  910. X    else
  911. X+ #endif
  912. X      {
  913. X  
  914. X***************
  915. X*** 187,191 ****
  916. X--- 189,195 ----
  917. X      {
  918. X        fclose (outfile);
  919. X+ #if !defined(MSDOS)
  920. X        wait (0);
  921. X+ #endif
  922. X      }
  923. X  }
  924. X***************
  925. X*** 222,226 ****
  926. X  
  927. X    /* Undo the alteration.  */
  928. X!   s1->text[s1->length] = savechar;
  929. X  
  930. X    /* If the comparison stopped at the alteration,
  931. X--- 226,230 ----
  932. X  
  933. X    /* Undo the alteration.  */
  934. X!   s1->text[s1->length] = (char) savechar;
  935. X  
  936. X    /* If the comparison stopped at the alteration,
  937. X***************
  938. X*** 617,620 ****
  939. X--- 621,625 ----
  940. X  }
  941. X  
  942. X+ void
  943. X  debug_script (sp)
  944. X       struct change *sp;
  945. ________This_Is_The_END________
  946. echo 'x - getopt.c'
  947. sed 's/^X//' <<'________This_Is_The_END________' >>getopt.c
  948. X
  949. X#include <stdio.h>
  950. X/*
  951. X * get option letter from argument vector
  952. X */
  953. Xint    opterr = 1,        /* useless, never set or used */
  954. X    optind = 1,        /* index into parent argv vector */
  955. X    optopt;            /* character checked for validity */
  956. Xchar    *optarg;        /* argument associated with option */
  957. X#define BADCH    (int)'?'
  958. X#define EMSG    ""
  959. X#define tell(s)    fputs(*nargv,stderr);fputs(s,stderr); \
  960. X        fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);
  961. Xint
  962. Xgetopt(int nargc,char **nargv,char *ostr)
  963. X{
  964. X    static char    *place = EMSG;    /* option letter processing */
  965. X    register char    *oli;        /* option letter list index */
  966. X#ifdef USG
  967. X#define index    strchr
  968. X#endif
  969. X    char    *index();
  970. X    if(!*place) {            /* update scanning pointer */
  971. X        if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF);
  972. X        if (*place == '-') {    /* found "--" */
  973. X            ++optind;
  974. X            return(EOF);
  975. X        }
  976. X    }                /* option letter okay? */
  977. X    if ((optopt = (int)*place++) == (int)':' || !(oli = index(ostr,optopt))) {
  978. X        if(!*place) ++optind;
  979. X        tell(": illegal option -- ");
  980. X    }
  981. X    if (*++oli != ':') {        /* don't need argument */
  982. X        optarg = NULL;
  983. X        if (!*place) ++optind;
  984. X    }
  985. X    else {                /* need an argument */
  986. X        if (*place) optarg = place;    /* no white space */
  987. X        else if (nargc <= ++optind) {    /* no arg */
  988. X            place = EMSG;
  989. X            tell(": option requires an argument -- ");
  990. X        }
  991. X         else optarg = nargv[optind];    /* white space */
  992. X        place = EMSG;
  993. X        ++optind;
  994. X    }
  995. X    return(optopt);            /* dump back option letter */
  996. X}
  997. XSKELETON_BONES
  998. ________This_Is_The_END________
  999. echo 'x - proto.h'
  1000. sed 's/^X//' <<'________This_Is_The_END________' >>proto.h
  1001. X
  1002. Xextern  void discard_confusing_lines(struct file_data *filevec);
  1003. Xextern  int diff_2_files(struct file_data *filevec,int depth);
  1004. Xextern  void print_context_header(struct file_data *inf);
  1005. Xextern  void print_context_script(struct change *script);
  1006. Xextern  void main(int argc,char * *argv);
  1007. Xextern  void specify_style(enum output_style style);
  1008. Xextern  int compare_files(char *dir0,char *name0,char *dir1,char *name1,int depth);
  1009. Xextern  struct _dir *opendir(char *name);
  1010. Xextern  void closedir(struct _dir *x);
  1011. Xextern  struct dirent *readdir(struct _dir *thisdir);
  1012. Xextern  int diff_dirs(char *name1,char *name2,
  1013. X    int (*handle_file)(char *dir0,char *name0,
  1014. X        char *dir1,char *name1,int depth),int depth);
  1015. Xextern  void print_ed_script(struct change *script);
  1016. Xextern  void print_forward_ed_script(struct change *script);
  1017. Xextern  void print_rcs_script(struct change *script);
  1018. Xextern  void find_and_hash_each_line(void );
  1019. Xextern  int read_files(struct file_data *filevec);
  1020. Xextern  void print_normal_script(struct change *script);
  1021. Xextern  void print_normal_hunk(struct change *hunk);
  1022. Xextern  int re_set_syntax(int syntax);
  1023. Xextern  char *re_compile_pattern(char *pattern,int size,struct re_pattern_buffer *bufp);
  1024. Xextern  void re_compile_fastmap(struct re_pattern_buffer *bufp);
  1025. Xextern  int re_search(struct re_pattern_buffer *pbufp,char *string,int size,int startpos,int range,struct re_registers *regs);
  1026. Xextern  int re_search_2(struct re_pattern_buffer *pbufp,char *string1,int size1,char *string2,int size2,int startpos,int range,struct re_registers *regs,int mstop);
  1027. Xextern  int re_match(struct re_pattern_buffer *pbufp,char *string,int size,int pos,struct re_registers *regs);
  1028. Xextern  int re_match_2(struct re_pattern_buffer *pbufp,unsigned char *string1,int size1,unsigned char *string2,int size2,int pos,struct re_registers *regs,int mstop);
  1029. Xextern  char *re_comp(char *s);
  1030. Xextern  int re_exec(char *s);
  1031. Xextern  void perror_with_name(char *text);
  1032. Xextern  void pfatal_with_name(char *text);
  1033. Xextern  void error(char *format,...);
  1034. Xextern  void fatal(char *message);
  1035. Xextern  void message(char *format,char *arg1,char *arg2);
  1036. Xextern  void print_message_queue(void );
  1037. Xextern  void setup_output(char *name0,char *name1,int depth);
  1038. Xextern  void finish_output(void );
  1039. Xextern  int line_cmp(struct line_def *s1,struct line_def *s2);
  1040. Xextern  struct change *find_change(struct change *start);
  1041. Xextern  struct change *find_reverse_change(struct change *start);
  1042. Xextern  void print_script(struct change *script,struct change *(*hunkfun)(),void (*printfun)());
  1043. Xextern  void print_1_line(char *line_flag,struct line_def *line);
  1044. Xextern  int change_letter(int inserts,int deletes);
  1045. Xextern  int translate_line_number(struct file_data *file,int lnum);
  1046. Xextern  void translate_range(struct file_data *file,int a,int b,int *aptr,int *bptr);
  1047. Xextern  void print_number_range(char sepchar,struct file_data *file,int a,int b);
  1048. Xextern  void analyze_hunk(struct change *hunk,int *first0,int *last0,int *first1,int *last1,int *deletes,int *inserts);
  1049. Xextern  void *xmalloc(unsigned int size);
  1050. Xextern  void *xrealloc(void *old,unsigned int size);
  1051. Xextern  void *xcalloc(int nitems,int size);
  1052. Xextern  char *concat(char *s1,char *s2,char *s3);
  1053. Xextern  void debug_script(struct change *sp);
  1054. ________This_Is_The_END________
  1055. exit
  1056. -- 
  1057. Kent Williams
  1058.   {{harvard,mit-eddie}!necntc,well!hoptoad,sun!cwruecmp!hal}!ncoast!kent
  1059. ARPA: necntc!ncoas!kent@harvard.harvard.e
  1060.  
  1061.  
  1062.