Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/editors/diff.c

    r2725 r3232  
    7777 */
    7878
     79//usage:#define diff_trivial_usage
     80//usage:       "[-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2"
     81//usage:#define diff_full_usage "\n\n"
     82//usage:       "Compare files line by line and output the differences between them.\n"
     83//usage:       "This implementation supports unified diffs only.\n"
     84//usage:     "\n    -a  Treat all files as text"
     85//usage:     "\n    -b  Ignore changes in the amount of whitespace"
     86//usage:     "\n    -B  Ignore changes whose lines are all blank"
     87//usage:     "\n    -d  Try hard to find a smaller set of changes"
     88//usage:     "\n    -i  Ignore case differences"
     89//usage:     "\n    -L  Use LABEL instead of the filename in the unified header"
     90//usage:     "\n    -N  Treat absent files as empty"
     91//usage:     "\n    -q  Output only whether files differ"
     92//usage:     "\n    -r  Recurse"
     93//usage:     "\n    -S  Start with FILE when comparing directories"
     94//usage:     "\n    -T  Make tabs line up by prefixing a tab when necessary"
     95//usage:     "\n    -s  Report when two files are the same"
     96//usage:     "\n    -t  Expand tabs to spaces in output"
     97//usage:     "\n    -U  Output LINES lines of context"
     98//usage:     "\n    -w  Ignore all whitespace"
     99
    79100#include "libbb.h"
    80101
    81102#if 0
    82 //#define dbg_error_msg(...) bb_error_msg(__VA_ARGS__)
     103# define dbg_error_msg(...) bb_error_msg(__VA_ARGS__)
    83104#else
    84 #define dbg_error_msg(...) ((void)0)
     105# define dbg_error_msg(...) ((void)0)
    85106#endif
    86107
     
    673694static int diffreg(char *file[2])
    674695{
    675     FILE *fp[2] = { stdin, stdin };
     696    FILE *fp[2];
    676697    bool binary = false, differ = false;
    677698    int status = STATUS_SAME, i;
    678699
     700    fp[0] = stdin;
     701    fp[1] = stdin;
    679702    for (i = 0; i < 2; i++) {
    680703        int fd = open_or_warn_stdin(file[i]);
     
    795818            if (r != 0 || !S_ISDIR(osb.st_mode)) {
    796819                /* other dir doesn't have similarly named
    797                  * directory, don't recurse */
     820                 * directory, don't recurse; return 1 upon
     821                 * exit, just like diffutils' diff */
     822                exit_status |= 1;
    798823                return SKIP;
    799824            }
     
    819844        list[i].len = strlen(p[i]);
    820845        recursive_action(p[i], ACTION_RECURSE | ACTION_FOLLOWLINKS,
    821                          add_to_dirlist, skip_dir, &list[i], 0);
     846                add_to_dirlist, skip_dir, &list[i], 0);
    822847        /* Sort dl alphabetically.
    823848         * GNU diff does this ignoring any number of trailing dots.
     
    847872        pos = !dp[0] ? 1 : (!dp[1] ? -1 : strcmp(dp[0], dp[1]));
    848873        k = pos > 0;
    849         if (pos && !(option_mask32 & FLAG(N)))
     874        if (pos && !(option_mask32 & FLAG(N))) {
    850875            printf("Only in %s: %s\n", p[k], dp[k]);
    851         else {
     876            exit_status |= 1;
     877        } else {
    852878            char *fullpath[2], *path[2]; /* if -N */
    853879
     
    950976        bb_error_msg_and_die("can't compare stdin to a directory");
    951977
     978    /* Compare metadata to check if the files are the same physical file.
     979     *
     980     * Comment from diffutils source says:
     981     * POSIX says that two files are identical if st_ino and st_dev are
     982     * the same, but many file systems incorrectly assign the same (device,
     983     * inode) pair to two distinct files, including:
     984     * GNU/Linux NFS servers that export all local file systems as a
     985     * single NFS file system, if a local device number (st_dev) exceeds
     986     * 255, or if a local inode number (st_ino) exceeds 16777215.
     987     */
     988    if (ENABLE_DESKTOP
     989     && stb[0].st_ino == stb[1].st_ino
     990     && stb[0].st_dev == stb[1].st_dev
     991     && stb[0].st_size == stb[1].st_size
     992     && stb[0].st_mtime == stb[1].st_mtime
     993     && stb[0].st_ctime == stb[1].st_ctime
     994     && stb[0].st_mode == stb[1].st_mode
     995     && stb[0].st_nlink == stb[1].st_nlink
     996     && stb[0].st_uid == stb[1].st_uid
     997     && stb[0].st_gid == stb[1].st_gid
     998    ) {
     999        /* files are physically the same; no need to compare them */
     1000        return STATUS_SAME;
     1001    }
     1002
    9521003    if (S_ISDIR(stb[0].st_mode) && S_ISDIR(stb[1].st_mode)) {
    9531004#if ENABLE_FEATURE_DIFF_DIR
Note: See TracChangeset for help on using the changeset viewer.