Ignore:
Timestamp:
Sep 25, 2007, 7:03:31 AM (18 years ago)
Author:
bird
Message:

kmk_builtin_cmp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/cmp_regular.c

    • Property svn:eol-style set to native
    r1115 r1117  
    3030 */
    3131
    32 #include <sys/cdefs.h>
     32/*#include <sys/cdefs.h>*/
    3333#ifndef lint
    34 #if 0
     34/*#if 0
    3535static char sccsid[] = "@(#)regular.c   8.3 (Berkeley) 4/2/94";
    3636#else
    3737__RCSID("$NetBSD: regular.c,v 1.20 2006/06/03 21:47:55 christos Exp $");
    38 #endif
     38#endif*/
    3939#endif /* not lint */
    4040
     
    4343#include <sys/stat.h>
    4444
    45 #include <err.h>
     45#include "err.h"
    4646#include <limits.h>
    4747#include <stdlib.h>
     
    4949#include <string.h>
    5050
    51 #include "extern.h"
     51#include "cmp_extern.h"
    5252
    53 void
     53static int
    5454c_regular(int fd1, char *file1, off_t skip1, off_t len1,
    5555    int fd2, char *file2, off_t skip2, off_t len2)
    5656{
    57         u_char ch, *p1, *p2;
     57        u_char ch, *p1, *p2, *b1, *b2;
    5858        off_t byte, length, line;
    5959        int dfound;
     
    6161
    6262        if (sflag && len1 != len2)
    63                 exit(1);
     63                return(1);
    6464
    6565        if (skip1 > len1)
    66                 eofmsg(file1, len1 + 1, 0);
     66                return eofmsg(file1, len1 + 1, 0);
    6767        len1 -= skip1;
    6868        if (skip2 > len2)
    69                 eofmsg(file2, len2 + 1, 0);
     69                return eofmsg(file2, len2 + 1, 0);
    7070        len2 -= skip2;
    7171
     
    7676                if (blk_sz > length)
    7777                        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,
    7979                    fd1, skip1);
    8080                if (p1 == MAP_FAILED)
    8181                        goto mmap_failed;
    8282
    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,
    8484                    fd2, skip2);
    8585                if (p2 == MAP_FAILED) {
     
    9292                        if ((ch = *p1) != *p2) {
    9393                                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);
    9697                                }
    9798                                dfound = 1;
     
    109110
    110111        if (len1 != len2)
    111                 eofmsg(len1 > len2 ? file2 : file1, byte, line);
     112                return eofmsg(len1 > len2 ? file2 : file1, byte, line);
    112113        if (dfound)
    113                 exit(DIFF_EXIT);
    114         return;
     114                return(DIFF_EXIT);
     115        return(0);
    115116
    116117mmap_failed:
    117         c_special(fd1, file1, skip1, fd2, file2, skip2);
     118        return c_special(fd1, file1, skip1, fd2, file2, skip2);
    118119}
     120
Note: See TracChangeset for help on using the changeset viewer.