Changeset 1117 for trunk/src/kmk/kmkbuiltin/cmp_regular.c
- Timestamp:
- Sep 25, 2007, 7:03:31 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/cmp_regular.c
-
Property svn:eol-style
set to
native
r1115 r1117 30 30 */ 31 31 32 #include <sys/cdefs.h> 32 /*#include <sys/cdefs.h>*/ 33 33 #ifndef lint 34 #if 034 /*#if 0 35 35 static char sccsid[] = "@(#)regular.c 8.3 (Berkeley) 4/2/94"; 36 36 #else 37 37 __RCSID("$NetBSD: regular.c,v 1.20 2006/06/03 21:47:55 christos Exp $"); 38 #endif 38 #endif*/ 39 39 #endif /* not lint */ 40 40 … … 43 43 #include <sys/stat.h> 44 44 45 #include <err.h>45 #include "err.h" 46 46 #include <limits.h> 47 47 #include <stdlib.h> … … 49 49 #include <string.h> 50 50 51 #include " extern.h"51 #include "cmp_extern.h" 52 52 53 void 53 static int 54 54 c_regular(int fd1, char *file1, off_t skip1, off_t len1, 55 55 int fd2, char *file2, off_t skip2, off_t len2) 56 56 { 57 u_char ch, *p1, *p2 ;57 u_char ch, *p1, *p2, *b1, *b2; 58 58 off_t byte, length, line; 59 59 int dfound; … … 61 61 62 62 if (sflag && len1 != len2) 63 exit(1);63 return(1); 64 64 65 65 if (skip1 > len1) 66 eofmsg(file1, len1 + 1, 0);66 return eofmsg(file1, len1 + 1, 0); 67 67 len1 -= skip1; 68 68 if (skip2 > len2) 69 eofmsg(file2, len2 + 1, 0);69 return eofmsg(file2, len2 + 1, 0); 70 70 len2 -= skip2; 71 71 … … 76 76 if (blk_sz > length) 77 77 blk_sz = length; 78 p1 = mmap(NULL, blk_sz, PROT_READ, MAP_FILE|MAP_SHARED,78 b1 = p1 = mmap(NULL, blk_sz, PROT_READ, MAP_FILE|MAP_SHARED, 79 79 fd1, skip1); 80 80 if (p1 == MAP_FAILED) 81 81 goto mmap_failed; 82 82 83 p2 = mmap(NULL, blk_sz, PROT_READ, MAP_FILE|MAP_SHARED,83 b2 = p2 = mmap(NULL, blk_sz, PROT_READ, MAP_FILE|MAP_SHARED, 84 84 fd2, skip2); 85 85 if (p2 == MAP_FAILED) { … … 92 92 if ((ch = *p1) != *p2) { 93 93 if (!lflag) { 94 diffmsg(file1, file2, byte, line); 95 /* NOTREACHED */ 94 munmap(b1, blk_sz); 95 munmap(b2, blk_sz); 96 return diffmsg(file1, file2, byte, line); 96 97 } 97 98 dfound = 1; … … 109 110 110 111 if (len1 != len2) 111 eofmsg(len1 > len2 ? file2 : file1, byte, line);112 return eofmsg(len1 > len2 ? file2 : file1, byte, line); 112 113 if (dfound) 113 exit(DIFF_EXIT);114 return ;114 return(DIFF_EXIT); 115 return(0); 115 116 116 117 mmap_failed: 117 c_special(fd1, file1, skip1, fd2, file2, skip2);118 return c_special(fd1, file1, skip1, fd2, file2, skip2); 118 119 } 120 -
Property svn:eol-style
set to
Note:
See TracChangeset
for help on using the changeset viewer.