home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / unix / diff32.zoo / patches.dif < prev    next >
Encoding:
Text File  |  1991-03-13  |  21.8 KB  |  915 lines

  1. diff +context=2 +new-file diff/analyze.c diff.new/analyze.c
  2. *** diff/analyze.c    Sun Jan  6 10:05:10 1991
  3. --- diff.new/analyze.c    Sat Jan 26 07:08:54 1991
  4. ***************
  5. *** 23,26 ****
  6. --- 23,32 ----
  7.   
  8.   #include "diff.h"
  9. + #if defined(DEBUG)
  10. + #undef DEBUG
  11. + #define DEBUG(x) x
  12. + #else
  13. + #define DEBUG(x)
  14. + #endif
  15.   
  16.   struct change *find_change ();
  17. ***************
  18. *** 729,733 ****
  19.     /* See if the two named files are actually the same physical file.
  20.        If so, we know they are identical without actually reading them.  */
  21.     if (output_style != OUTPUT_IFDEF
  22.         && filevec[0].stat.st_ino == filevec[1].stat.st_ino
  23. --- 735,739 ----
  24.     /* See if the two named files are actually the same physical file.
  25.        If so, we know they are identical without actually reading them.  */
  26. ! #if !defined(MSDOS)
  27.     if (output_style != OUTPUT_IFDEF
  28.         && filevec[0].stat.st_ino == filevec[1].stat.st_ino
  29. ***************
  30. *** 734,738 ****
  31.         && filevec[0].stat.st_dev == filevec[1].stat.st_dev)
  32.       return 0;
  33.     binary = read_files (filevec);
  34.   
  35. --- 740,744 ----
  36.         && filevec[0].stat.st_dev == filevec[1].stat.st_dev)
  37.       return 0;
  38. ! #endif /* MSDOS */
  39.     binary = read_files (filevec);
  40.   
  41. diff +context=2 +new-file diff/diff.c diff.new/diff.c
  42. *** diff/diff.c    Sun Jan  6 10:53:24 1991
  43. --- diff.new/diff.c    Sat Jan 26 07:08:54 1991
  44. ***************
  45. *** 26,30 ****
  46. --- 26,37 ----
  47.   #include "getopt.h"
  48.   
  49. + #if defined(DEBUG)
  50. + #undef DEBUG
  51. + #define DEBUG(x) x
  52. + #else
  53. + #define DEBUG(x)
  54. + #endif
  55.   
  56.   /* Nonzero for -r: if comparing two directories,
  57.      compare their common subdirectories recursively.  */
  58. ***************
  59. *** 447,451 ****
  60.     int errorcount = 0;
  61.     int stat_result[2];
  62.     /* If this is directory comparison, perhaps we have a file
  63.        that exists only in one of the directories.
  64. --- 454,459 ----
  65.     int errorcount = 0;
  66.     int stat_result[2];
  67. !   DEBUG(fprintf(stderr,"compare_files(%s,%s,%s,%s,%d)\n",
  68. !       dir0,name0,dir1,name1,depth);fflush(stderr);)
  69.     /* If this is directory comparison, perhaps we have a file
  70.        that exists only in one of the directories.
  71. ***************
  72. *** 506,510 ****
  73.       }
  74.       }
  75.     /* See if the two named files are actually the same physical file.
  76.        If so, we know they are identical without actually reading them.  */
  77. --- 514,518 ----
  78.       }
  79.       }
  80. ! #if !defined(MSDOS)
  81.     /* See if the two named files are actually the same physical file.
  82.        If so, we know they are identical without actually reading them.  */
  83. ***************
  84. *** 519,523 ****
  85.         goto done;
  86.       }
  87.     if (name0 == 0)
  88.       inf[0].dir_p = inf[1].dir_p;
  89. --- 527,531 ----
  90.         goto done;
  91.       }
  92. ! #endif
  93.     if (name0 == 0)
  94.       inf[0].dir_p = inf[1].dir_p;
  95. diff +context=2 +new-file diff/diff3.c diff.new/diff3.c
  96. *** diff/diff3.c    Sun Jan  6 10:58:12 1991
  97. --- diff.new/diff3.c    Wed Mar 13 04:00:46 1991
  98. ***************
  99. *** 48,52 ****
  100. --- 48,57 ----
  101.   
  102.   #else /* not USG */
  103. + #ifndef MSDOS
  104.   #include <sys/wait.h>
  105. + #else
  106. + #include <fcntl.h>
  107. + #include <std.h>
  108. + #endif
  109.   #endif /* not USG */
  110.   
  111. ***************
  112. *** 231,235 ****
  113. --- 236,244 ----
  114.   VOID *xrealloc ();
  115.   
  116. + #ifndef MSDOS
  117.   char diff_program[] = DIFF_PROGRAM;
  118. + #else
  119. + #define diff_program "diff"
  120. + #endif
  121.   
  122.   /*
  123. ***************
  124. *** 1166,1169 ****
  125. --- 1175,1179 ----
  126.   }
  127.   
  128. + #ifndef MSDOS
  129.   char *
  130.   read_diff (filea, fileb, output_placement)
  131. ***************
  132. *** 1241,1245 ****
  133. --- 1251,1319 ----
  134.     return diff_result + total;
  135.   }
  136. + #else
  137. + char *
  138. + addstr(char *oldstr,char *newstr) {
  139. +     int oldlen;
  140. +     if(oldstr == NULL) {
  141. +         oldstr = xmalloc(strlen(newstr)+1);
  142. +         strcpy(oldstr,newstr);
  143. +     } else {
  144. +         oldlen = strlen(oldstr);
  145. +         oldstr = xrealloc(oldstr,oldlen+strlen(newstr)+2);
  146. +         strcat(oldstr," ");
  147. +         strcat(oldstr,newstr);
  148. +     }
  149. +     return oldstr;
  150. + }
  151. + char *
  152. + read_diff (filea, fileb, output_placement)
  153. +      char *filea, *fileb;
  154. +      char **output_placement;
  155. + {
  156. +   char *diff_result;
  157. +   int current_chunk_size;
  158. +   int bytes;
  159. +   int total;
  160. +   char *buf = NULL;
  161. +   char *tmpname,tmpbuf[16];
  162. +   int diff_output;
  163. +   strcpy(tmpbuf,"XXXXXX");
  164. +   tmpname = mktemp(tmpbuf);
  165. +   buf = addstr(buf,diff_program);
  166. +   if (always_text)
  167. +     buf = addstr(buf,"-a");
  168. +   buf = addstr(buf,"--");
  169. +   buf = addstr(buf,filea);
  170. +   buf = addstr(buf,fileb);
  171. +   buf = addstr(buf,">");
  172. +   buf = addstr(buf,tmpname);
  173. +   system(buf);
  174. +   free(buf);
  175. +   if((diff_output = open(tmpname,O_RDONLY)) == -1)
  176. +     fatal ("Subsidiary diff failed");
  177. +   current_chunk_size = DIFF_CHUNK_SIZE;
  178. +   diff_result = (char *) xmalloc (current_chunk_size);
  179. +   total = 0;
  180. +   do {
  181. +     bytes = myread (diff_output,
  182. +             diff_result + total,
  183. +             current_chunk_size - total);
  184. +     total += bytes;
  185. +     if (total == current_chunk_size)
  186. +       diff_result = (char *) xrealloc (diff_result, (current_chunk_size *= 2));
  187. +   } while (bytes);
  188. +   if (total != 0 && diff_result[total-1] != '\n')
  189. +     fatal ("bad diff format; incomplete last line");
  190. +   *output_placement = diff_result;
  191.   
  192. +   close(diff_output);
  193. +   unlink(tmpname);
  194. +   return diff_result + total;
  195. + }
  196. + #endif
  197.   
  198.   /*
  199. diff +context=2 +new-file diff/dir.h diff.new/dir.h
  200. *** diff/dir.h
  201. --- diff.new/dir.h    Sat Mar  9 09:20:32 1991
  202. ***************
  203. *** 0 ****
  204. --- 1,36 ----
  205. + /*
  206. +  * @(#)msd_dir.h 1.4 87/11/06    Public Domain.
  207. +  *
  208. +  *  A public domain implementation of BSD directory routines for
  209. +  *  MS-DOS.  Written by Michael Rendell ({uunet,utai}michael@garfield),
  210. +  *  August 1897
  211. +  */
  212. + #define    rewinddir(dirp)    seekdir(dirp, 0L)
  213. + #define    MAXNAMLEN    12
  214. + struct direct {
  215. +     int    d_ino;            /* a bit of a farce */
  216. +     int    d_reclen;        /* more farce */
  217. +     int    d_namlen;        /* length of d_name */
  218. +     char    d_name[MAXNAMLEN + 1];        /* guarentee null termination */
  219. + };
  220. + struct _dircontents {
  221. +     char    *_d_entry;
  222. +     struct _dircontents    *_d_next;
  223. + };
  224. + typedef struct _dirdesc {
  225. +     int        dd_id;    /* uniquely identify each open directory */
  226. +     long        dd_loc;    /* where we are in directory entry is this */
  227. +     struct _dircontents    *dd_contents;    /* pointer to contents of dir */
  228. +     struct _dircontents    *dd_cp;    /* pointer to current position */
  229. + } DIR;
  230. + extern    DIR        *opendir(const char *name);
  231. + extern    struct direct    *readdir(DIR *dirp);
  232. + extern    void        seekdir(DIR *dirp,long off);
  233. + extern    long        telldir(DIR *dirp);
  234. + extern    void        closedir(DIR *dirp);
  235. diff +context=2 +new-file diff/getopt.c diff.new/getopt.c
  236. *** diff/getopt.c    Thu Nov 29 08:21:40 1990
  237. --- diff.new/getopt.c    Sat Jan 26 07:08:56 1991
  238. ***************
  239. *** 70,74 ****
  240.   
  241.   char *getenv ();
  242. - char *malloc ();
  243.   #endif
  244.   
  245. --- 70,73 ----
  246. ***************
  247. *** 249,253 ****
  248.   getopt (argc, argv, optstring)
  249.        int argc;
  250. !      char **argv;
  251.        CONST char *optstring;
  252.   {
  253. --- 248,252 ----
  254.   getopt (argc, argv, optstring)
  255.        int argc;
  256. !      CONST char **argv;
  257.        CONST char *optstring;
  258.   {
  259. diff +context=2 +new-file diff/getopt.h diff.new/getopt.h
  260. *** diff/getopt.h    Thu Nov 29 08:21:40 1990
  261. --- diff.new/getopt.h    Sat Jan 26 07:09:06 1991
  262. ***************
  263. *** 89,93 ****
  264.   
  265.   #ifdef __STDC__
  266. ! int getopt (int argc, char **argv, const char *shortopts);
  267.   int getopt_long (int argc, char **argv, const char *shortopts,
  268.            const struct option *longopts, int *longind);
  269. --- 89,93 ----
  270.   
  271.   #ifdef __STDC__
  272. ! int getopt (int argc, const char **argv, const char *shortopts);
  273.   int getopt_long (int argc, char **argv, const char *shortopts,
  274.            const struct option *longopts, int *longind);
  275. diff +context=2 +new-file diff/io.c diff.new/io.c
  276. *** diff/io.c    Thu Nov 29 08:15:42 1990
  277. --- diff.new/io.c    Sun Jan 27 06:13:22 1991
  278. ***************
  279. *** 20,23 ****
  280. --- 20,30 ----
  281.   #include "diff.h"
  282.   
  283. + #if defined(DEBUG)
  284. + #undef DEBUG
  285. + #define DEBUG(x) x
  286. + #else
  287. + #define DEBUG(x)
  288. + #endif
  289.   /* Rotate a value n bits to the left. */
  290.   #define UINT_BIT (sizeof (unsigned) * CHAR_BIT)
  291. ***************
  292. *** 89,92 ****
  293. --- 96,100 ----
  294.   slurp ()
  295.   {
  296. +   DEBUG(fprintf(stderr,"slurp(%s) ",current->name);fflush(stderr);)
  297.     /* If we have a nonexistent file at this stage, treat it as empty.  */
  298.     if (current->desc < 0)
  299. ***************
  300. *** 105,111 ****
  301.       {
  302.         current->bufsize = current->stat.st_size;
  303.         current->buffer = (char *) xmalloc (current->bufsize + 2);
  304.         current->buffered_chars
  305. !     = read (current->desc, current->buffer, current->bufsize);
  306.         if (current->buffered_chars < 0)
  307.       pfatal_with_name (current->name);
  308. --- 113,122 ----
  309.       {
  310.         current->bufsize = current->stat.st_size;
  311. +       DEBUG(fprintf(stderr," Regular file %ld bytes ",
  312. +           current->stat.st_size);)
  313.         current->buffer = (char *) xmalloc (current->bufsize + 2);
  314.         current->buffered_chars
  315. !     = readcr (current->desc, current->buffer, current->bufsize);
  316. !       DEBUG(fprintf(stderr," -- %ld bytes read\n",current->buffered_chars);)
  317.         if (current->buffered_chars < 0)
  318.       pfatal_with_name (current->name);
  319. ***************
  320. *** 114,118 ****
  321.       {
  322.         int cc;
  323.         current->bufsize = 4096;
  324.         current->buffer = (char *) xmalloc (current->bufsize + 2);
  325. --- 125,129 ----
  326.       {
  327.         int cc;
  328. !       DEBUG(fprintf(stderr,"Not a regular file -- reading in chunks ");)
  329.         current->bufsize = 4096;
  330.         current->buffer = (char *) xmalloc (current->bufsize + 2);
  331. ***************
  332. *** 121,125 ****
  333.         /* Not a regular file; read it in a little at a time, growing the
  334.        buffer as necessary. */
  335. !       while ((cc = read (current->desc,
  336.                current->buffer + current->buffered_chars,
  337.                current->bufsize - current->buffered_chars))
  338. --- 132,136 ----
  339.         /* Not a regular file; read it in a little at a time, growing the
  340.        buffer as necessary. */
  341. !       while ((cc = readcr (current->desc,
  342.                current->buffer + current->buffered_chars,
  343.                current->bufsize - current->buffered_chars))
  344. ***************
  345. *** 134,137 ****
  346. --- 145,149 ----
  347.           }
  348.       }
  349. +     DEBUG(fprintf(stderr,"read %d bytes\n",current->buffered_chars);)
  350.         if (cc < 0)
  351.       pfatal_with_name (current->name);
  352. diff +context=2 +new-file diff/makefile.pc diff.new/makefile.pc
  353. *** diff/makefile.pc
  354. --- diff.new/makefile.pc    Wed Mar 13 03:45:02 1991
  355. ***************
  356. *** 0 ****
  357. --- 1,47 ----
  358. + CC=gcc
  359. + CFLAGS = -DMSDOS -v -O -g
  360. + prefix=
  361. + .SUFFIXES: .od .o .c
  362. + .c.o:
  363. +     $(CC) $(CFLAGS) -c $< -o $*.o
  364. + .c.od:
  365. +     $(CC) $(CFLAGS) -c -g $< -o $*.od
  366. + # All source files
  367. + srcs=diff.c analyze.c io.c context.c ed.c normal.c ifdef.c util.c dir.c \
  368. +     version.c diff.h regex.c regex.h limits.h diff3.c \
  369. +     getopt.c getopt1.c getopt.h alloca.c
  370. + # Object files for diff only.
  371. + O1=diff.od analyze.o io.o context.o \
  372. +      ed.o normal.o util.o dir.o
  373. + O2=regex.o ifdef.o version.o \
  374. +      getopt.o getopt1.o
  375. + MSOBJ = msd_dir.o strlwr.o stat.o
  376. + objs = $(O1) $(O2) $(MSOBJ)
  377. + all: diff diff3
  378. + diff3: diff3.o
  379. +     $(CC) -o diff3  $(CFLAGS) $(LDFLAGS) diff3.o $(LIBS)
  380. + diff : $(objs) _obj
  381. +     $(CC) $(CFLAGS) -o $@ @_obj
  382. + _obj : makefile
  383. +     echo $(O1) > $@
  384. +     echo $(O2) >> $@
  385. +     echo $(MSOBJ) >> $@
  386. + $(objs): diff.h
  387. + context.o diff.o: regex.h
  388. + clean:
  389. +     rm -f *.o diff diff3 diff.tar diff.tar.Z
  390. diff +context=2 +new-file diff/msd_dir.c diff.new/msd_dir.c
  391. *** diff/msd_dir.c
  392. --- diff.new/msd_dir.c    Sat Mar  9 09:17:14 1991
  393. ***************
  394. *** 0 ****
  395. --- 1,167 ----
  396. + /*
  397. +  * @(#)msd_dir.c 1.4 87/11/06    Public Domain.
  398. +  *
  399. +  *  A public domain implementation of BSD directory routines for
  400. +  *  MS-DOS.  Written by Michael Rendell ({uunet,utai}michael@garfield),
  401. +  *  August 1897
  402. +  *
  403. +  * modified for use with GCC for DOS December 1990
  404. +  * williams@umaxc.weeg.uiowa.edu
  405. +  */
  406. + #include    <stdlib.h>
  407. + #include    <sys/types.h>
  408. + #include    <sys/stat.h>
  409. + #include     <sys/file.h>
  410. + #include    <sys/dir.h>
  411. + #include     <fcntl.h>
  412. + #include     <errno.h>
  413. + #include     <time.h>
  414. + #include    <dir.h>
  415. + #include    <string.h>
  416. + #ifndef    NULL
  417. + # define    NULL    0
  418. + #endif    /* NULL */
  419. + #ifndef    MAXPATHLEN
  420. + # define    MAXPATHLEN    255
  421. + #endif    /* MAXPATHLEN */
  422. + /* attribute stuff */
  423. + #define    A_RONLY        0x01
  424. + #define    A_HIDDEN    0x02
  425. + #define    A_SYSTEM    0x04
  426. + #define    A_LABEL        0x08
  427. + #define    A_DIR        0x10
  428. + #define    A_ARCHIVE    0x20
  429. + #define    Newisnull(a, t)        ((a = (t *) malloc(sizeof(t))) == (t *) NULL)
  430. + /* #define    ATTRIBUTES        (A_DIR | A_HIDDEN | A_SYSTEM) */
  431. + #define ATTRIBUTES    (A_RONLY | A_SYSTEM | A_DIR)
  432. + static    char    *getdirent();
  433. + static    void    free_dircontents();
  434. + static    struct ffblk        dtabuf;
  435. + static    struct ffblk        *dtapnt = &dtabuf;
  436. + static int _dos_errno;
  437. + DIR    *
  438. + opendir(const char *name)
  439. + {
  440. +     struct    stat        statb;
  441. +     DIR            *dirp;
  442. +     char            c;
  443. +     char            *s;
  444. +     struct _dircontents    *dp;
  445. +     char            nbuf[MAXPATHLEN + 1];
  446. +     
  447. +     if (stat(name, &statb) < 0 || (statb.st_mode & S_IFMT) != S_IFDIR)
  448. +         return (DIR *) NULL;
  449. +     if (Newisnull(dirp, DIR))
  450. +         return (DIR *) NULL;
  451. +     if (*name && (c = name[strlen(name) - 1]) != '\\' && c != '/')
  452. +         (void) strcat(strcpy(nbuf, name), "\\*.*");
  453. +     else
  454. +         (void) strcat(strcpy(nbuf, name), "*.*");
  455. +     dirp->dd_loc = 0;
  456. +     dirp->dd_contents = dirp->dd_cp = (struct _dircontents *) NULL;
  457. +     if ((s = getdirent(nbuf)) == (char *) NULL)
  458. +         return dirp;
  459. +     do {
  460. +         if (Newisnull(dp, struct _dircontents) || (dp->_d_entry =
  461. +             malloc((unsigned) (strlen(s) + 1))) == (char *) NULL)
  462. +         {
  463. +             if (dp)
  464. +                 free((char *) dp);
  465. +             free_dircontents(dirp->dd_contents);
  466. +             return (DIR *) NULL;
  467. +         }
  468. +         if (dirp->dd_contents)
  469. +             dirp->dd_cp = dirp->dd_cp->_d_next = dp;
  470. +         else
  471. +             dirp->dd_contents = dirp->dd_cp = dp;
  472. +         (void) strcpy(dp->_d_entry, s);
  473. +         dp->_d_next = (struct _dircontents *) NULL;
  474. +     } while ((s = getdirent((char *) NULL)) != (char *) NULL);
  475. +     dirp->dd_cp = dirp->dd_contents;
  476. +     return dirp;
  477. + }
  478. + void
  479. + closedir(DIR *dirp)
  480. + {
  481. +     free_dircontents(dirp->dd_contents);
  482. +     free((char *) dirp);
  483. + }
  484. + struct direct    *
  485. + readdir(DIR *dirp)
  486. + {
  487. +     static    struct direct    dp;
  488. +     
  489. +     if (dirp->dd_cp == (struct _dircontents *) NULL)
  490. +         return (struct direct *) NULL;
  491. +     dp.d_namlen = dp.d_reclen =
  492. +         strlen(strcpy(dp.d_name, dirp->dd_cp->_d_entry));
  493. +     strlwr(dp.d_name);        /* JF */
  494. +     dp.d_ino = 0;
  495. +     dirp->dd_cp = dirp->dd_cp->_d_next;
  496. +     dirp->dd_loc++;
  497. +     return &dp;
  498. + }
  499. + void
  500. + seekdir(DIR *dirp, long off)
  501. + {
  502. +     long            i = off;
  503. +     struct _dircontents    *dp;
  504. +     if (off < 0)
  505. +         return;
  506. +     for (dp = dirp->dd_contents ; --i >= 0 && dp ; dp = dp->_d_next)
  507. +         ;
  508. +     dirp->dd_loc = off - (i + 1);
  509. +     dirp->dd_cp = dp;
  510. + }
  511. + long
  512. + telldir(DIR    *dirp)
  513. + {
  514. +     return dirp->dd_loc;
  515. + }
  516. + static    void
  517. + free_dircontents(struct    _dircontents    *dp)
  518. + {
  519. +     struct _dircontents    *odp;
  520. +     while (dp) {
  521. +         if (dp->_d_entry)
  522. +             free(dp->_d_entry);
  523. +         dp = (odp = dp)->_d_next;
  524. +         free((char *) odp);
  525. +     }
  526. + }
  527. + static    char    *
  528. + getdirent(char *dir)
  529. + {
  530. +     int rval;
  531. +     if (dir != (char *) NULL) {        /* get first entry */
  532. +         rval = findfirst(dir,dtapnt,ATTRIBUTES);
  533. +     } else {                /* get next entry */
  534. +         rval = findnext(dtapnt);
  535. +     }
  536. +     if(rval != 0)
  537. +         return (char *) NULL;
  538. +     return dtabuf.ff_name;
  539. + }
  540. diff +context=2 +new-file diff/stat.c diff.new/stat.c
  541. *** diff/stat.c
  542. --- diff.new/stat.c    Fri Feb  8 06:19:12 1991
  543. ***************
  544. *** 0 ****
  545. --- 1,248 ----
  546. + #include <sys/types.h>
  547. + #include <sys/stat.h>
  548. + #include <sys/file.h>
  549. + #include <sys/dir.h>
  550. + #include <stdlib.h>
  551. + #include <fcntl.h>
  552. + #include <errno.h>
  553. + #include <time.h>
  554. + #include <dir.h>
  555. + #if defined(DEBUG)
  556. + #undef DEBUG
  557. + #define DEBUG(x) x
  558. + #else
  559. + #define DEBUG(x)
  560. + #endif
  561. + /* attribute stuff */
  562. + #define    A_RONLY        0x01
  563. + #define    A_HIDDEN    0x02
  564. + #define    A_SYSTEM    0x04
  565. + #define    A_LABEL        0x08
  566. + #define    A_DIR        0x10
  567. + #define    A_ARCHIVE    0x20
  568. + #define A_ALL        (A_HIDDEN|A_SYSTEM|A_DIR)
  569. + int
  570. + _mjd(int year, int month, int day)
  571. + {
  572. +   unsigned long int today;
  573. +   if ((month == 1) || (month == 2)) {
  574. +     month += 12;
  575. +     year  -= 1;
  576. +   }
  577. +   today    = (unsigned) ((36525 * year) / 100)
  578. +     + (unsigned) (year / 400)
  579. +     - (unsigned) (year / 100)
  580. +     + (unsigned) ((3059 * (month - 2)) / 100)
  581. +     + day
  582. +     - 678912;
  583. +   return today;
  584. + }
  585. + static time_t
  586. + _get_ftime(struct ffblk *f) {
  587. +     union {
  588. +         short time;
  589. +         struct _file_time {
  590. +             unsigned int seconds : 5;
  591. +             unsigned int minutes : 6;
  592. +             unsigned int hours   : 5;
  593. +         } ftime_parts;
  594. +     } ftime;
  595. +     union {
  596. +         short date;
  597. +         struct _file_date {
  598. +             unsigned int day : 5;
  599. +             unsigned int month : 4;
  600. +             unsigned int year : 7;
  601. +         } fdate_parts;
  602. +     } fdate;
  603. +     unsigned long int today;
  604. +     ftime.time = f->ff_ftime;
  605. +     fdate.date = f->ff_fdate;
  606. + #define    year    (fdate.fdate_parts.year + 1980)
  607. + #define    month    (fdate.fdate_parts.month)
  608. + #define    day        (fdate.fdate_parts.day)
  609. + #define    hour    (ftime.ftime_parts.hours)
  610. + #define    minute    (ftime.ftime_parts.minutes)
  611. + #define    second    (ftime.ftime_parts.seconds * 2)
  612. +   today = _mjd(year, month, day) - _mjd(1970, 1, 1);
  613. +   return ((today * 24 + hour) * 60 + minute)  * 60 + second;
  614. + }
  615. + static __inline__ int
  616. + _dos_get_device_information(int handle)
  617. + {
  618. +     int  result;
  619. +     asm volatile("
  620. +     movw %1,%%bx
  621. +     movw %2,%%ax
  622. +     int $0x21
  623. +     jnc 0f
  624. +     movl $-1,%0
  625. +     jmp 1f
  626. + 0:
  627. +     movl %%edx,%0
  628. + 1:"
  629. +     : "=r"(result)
  630. +     : "g"((unsigned short) handle), "i"(0x4400)
  631. +     : "ax", "bx", "dx");
  632. +     return  result;
  633. + }
  634. + static __inline__ int
  635. + _dos_open(char *path, int attributes)
  636. + {
  637. +     int  result;
  638. +     asm volatile("
  639. +     movl %1,%%edx
  640. +     movb %2,%%al
  641. +     movb %3,%%ah
  642. +     int $0x21
  643. +     jnc 0f
  644. +     movl $-1,%0
  645. +     jmp 1f
  646. + 0:
  647. +     movzwl %%ax,%0
  648. + 1:"
  649. +     : "=r"(result)
  650. +     : "g"(path), "g"((unsigned char) attributes), "i"(0x3d)
  651. +     : "ax", "dx");
  652. +     return  result;
  653. + }
  654. + static __inline__ int
  655. + _dos_close(int handle)
  656. + {
  657. +     register int  result;
  658. +     asm volatile("
  659. +     movw %1,%%bx
  660. +     movb %2,%%ah
  661. +     int $0x21
  662. +     jnc 0f
  663. +     movl $-1,%0
  664. +     jmp 1f
  665. + 0:
  666. +     movl $0,%1
  667. + 1:"
  668. +     : "=r"(result)
  669. +     : "g"((unsigned short) handle), "i"(0x3e)
  670. +     : "ax", "bx");
  671. +     return  result;
  672. + }
  673. + int
  674. + stat(const char *name,struct stat *sbuf) {
  675. +     int result;
  676. +     int fd,dos_att;
  677. +     struct ffblk dos_info;
  678. +     DEBUG(fprintf(stderr,"stat(%s)\n",name); fflush(stderr);)
  679. +     /*
  680. +     ** find out file information
  681. +     */
  682. +     result = findfirst(name,&dos_info,A_ALL);
  683. +     DEBUG(fprintf(stderr,"findfirst(%s,%p,%02x) = %d\n",
  684. +         name,&dos_info,A_ALL);)
  685. +     if(result == -1)
  686. +         return -1;
  687. +     DEBUG(fprintf(stderr,"%02x %04x %04x %08ld %s\n",
  688. +         dos_info.ff_attrib,dos_info.ff_ftime,dos_info.ff_fdate,
  689. +         dos_info.ff_fsize,dos_info.ff_name);)
  690. +     /*
  691. +     ** fill in fields that don't mean anything under DOS
  692. +     */
  693. +     sbuf->st_dev = sbuf->st_ino = sbuf->st_uid = 
  694. +         sbuf->st_gid = sbuf->st_rdev = 0;
  695. +     sbuf->st_nlink = 1;
  696. +     
  697. +     /*
  698. +     ** fill in size
  699. +     */
  700. +     sbuf->st_size = *((long *)&dos_info.ff_fsize);
  701. +     /*
  702. +     ** fill in mod time
  703. +     */
  704. +     sbuf->st_atime    =
  705. +     sbuf->st_mtime    =
  706. +     sbuf->st_ctime    = _get_ftime(&dos_info);
  707. +     sbuf->st_mode = 0;
  708. +     if((dos_info.ff_attrib & A_DIR) != 0)
  709. +         sbuf->st_mode |= S_IFDIR;
  710. +     else {
  711. +         /*
  712. +         ** if not a directory, then either a device or a real file.
  713. +         */
  714. +         fd = _dos_open(name,0);
  715. +         if(fd == -1)
  716. +             return -1;
  717. +         dos_att = _dos_get_device_information(fd);
  718. +         _dos_close(fd);
  719. +         if((dos_att & 0x80) == 0)
  720. +             sbuf->st_mode |= S_IFREG;
  721. +         else
  722. +             sbuf->st_mode |= S_IFCHR;
  723. +     }
  724. +     /*
  725. +     ** set access rights
  726. +     */
  727. +     if((dos_info.ff_attrib & A_RONLY) != 0)
  728. +         sbuf->st_mode |= 0444;
  729. +     else
  730. +         sbuf->st_mode |= 0666;
  731. +     return 0;
  732. + }
  733. + #if defined(TEST)
  734. + void
  735. + info(char *name) {
  736. +     struct stat statbuf;
  737. +     if(stat(name,&statbuf) == -1) {
  738. +         perror(name);
  739. +         return;
  740. +     }
  741. +     printf("%s : %ld bytes %s ",name,statbuf.st_size,
  742. +         asctime(localtime(&statbuf.st_mtime)));
  743. +     switch((statbuf.st_mode & S_IFMT)) {
  744. +     case S_IFDIR:
  745. +             printf("S_IFDIR\n"); break;
  746. +     case S_IFCHR:
  747. +             printf("S_IFCHR\n"); break;
  748. +     case S_IFBLK:
  749. +             printf("S_IFBLK\n"); break;
  750. +     case S_IFREG:
  751. +             printf("S_IFREG\n"); break;
  752. +     }
  753. +     
  754. + }
  755. + int
  756. + main(int argc,char **argv) {
  757. +     while(--argc)
  758. +         info(*++argv);
  759. +     return 0;
  760. + }
  761. + #endif
  762. diff +context=2 +new-file diff/strlwr.c diff.new/strlwr.c
  763. *** diff/strlwr.c
  764. --- diff.new/strlwr.c    Sat Jan 26 07:09:04 1991
  765. ***************
  766. *** 0 ****
  767. --- 1,17 ----
  768. + /*   Library program for GCC on DOS-Extender        
  769. +     (c) Copyright by Keisuke Yoshida, 1989, 1990  ver 1.00
  770. + */ 
  771. + #include <ctype.h>
  772. + #include <string.h>
  773. + char *
  774. + strlwr(char *d)
  775. + {
  776. +     char *s;
  777. +     for (s=d; *s; s++)
  778. +         *s = tolower(*s);
  779. +    return d;
  780. + }
  781. diff +context=2 +new-file diff/util.c diff.new/util.c
  782. *** diff/util.c    Sun Jan  6 10:14:14 1991
  783. --- diff.new/util.c    Sat Jan 26 07:09:04 1991
  784. ***************
  785. *** 129,133 ****
  786.     strcat (name, " ");
  787.     strcat (name, name1);
  788.     if (paginate_flag)
  789.       {
  790. --- 129,133 ----
  791.     strcat (name, " ");
  792.     strcat (name, name1);
  793. ! #if !defined(MSDOS)
  794.     if (paginate_flag)
  795.       {
  796. ***************
  797. *** 165,168 ****
  798. --- 165,169 ----
  799.       }
  800.     else
  801. + #endif /* MSDOS */      
  802.       {
  803.   
  804. ***************
  805. *** 189,193 ****
  806. --- 190,196 ----
  807.       {
  808.         fclose (outfile);
  809. + #if    !defined(MSDOS)
  810.         wait (0);
  811. + #endif /* MSDOS */
  812.       }
  813.   }
  814. ***************
  815. *** 205,209 ****
  816.     register char end_char = line_end_char;
  817.     int savechar;
  818.     /* Check first for exact identity.
  819.        If that is true, return 0 immediately.
  820. --- 208,211 ----
  821.