home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume5 / gdiff.msdos < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  28.8 KB

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