aboutsummaryrefslogtreecommitdiff
path: root/coreutils/diff.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
committerRob Landley <rob@landley.net>2006-08-03 15:41:12 +0000
commitd921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch)
treee4a2769349867c441cf2983d83097bb66701a733 /coreutils/diff.c
parent6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff)
downloadbusybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2
busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only had one user), clean up lots of #includes... General cleanup pass. What I've been doing for the last couple days. And it conflicts! I've removed httpd.c from this checkin due to somebody else touching that file. It builds for me. I have to catch a bus. (Now you know why I'm looking forward to Mercurial.)
Diffstat (limited to 'coreutils/diff.c')
-rw-r--r--coreutils/diff.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/coreutils/diff.c b/coreutils/diff.c
index 368efd383..22c157412 100644
--- a/coreutils/diff.c
+++ b/coreutils/diff.c
@@ -12,23 +12,6 @@
12 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 12 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
13 */ 13 */
14 14
15#include <time.h>
16#include <sys/types.h>
17#include <sys/param.h>
18#include <sys/stat.h>
19#include <ctype.h>
20#include <errno.h>
21#include <signal.h>
22#include <stdlib.h>
23#include <stdio.h>
24#include <stdarg.h>
25#include <string.h>
26#include <unistd.h>
27#include <sys/wait.h>
28#include <fcntl.h>
29#include <stddef.h>
30#include <paths.h>
31#include <dirent.h>
32#include "busybox.h" 15#include "busybox.h"
33 16
34#define FSIZE_MAX 32768 17#define FSIZE_MAX 32768
@@ -917,21 +900,21 @@ static int diffreg(char *ofile1, char *ofile2, int flags)
917 goto closem; 900 goto closem;
918 901
919 if (flags & D_EMPTY1) 902 if (flags & D_EMPTY1)
920 f1 = bb_xfopen(bb_dev_null, "r"); 903 f1 = xfopen(bb_dev_null, "r");
921 else { 904 else {
922 if (strcmp(file1, "-") == 0) 905 if (strcmp(file1, "-") == 0)
923 f1 = stdin; 906 f1 = stdin;
924 else 907 else
925 f1 = bb_xfopen(file1, "r"); 908 f1 = xfopen(file1, "r");
926 } 909 }
927 910
928 if (flags & D_EMPTY2) 911 if (flags & D_EMPTY2)
929 f2 = bb_xfopen(bb_dev_null, "r"); 912 f2 = xfopen(bb_dev_null, "r");
930 else { 913 else {
931 if (strcmp(file2, "-") == 0) 914 if (strcmp(file2, "-") == 0)
932 f2 = stdin; 915 f2 = stdin;
933 else 916 else
934 f2 = bb_xfopen(file2, "r"); 917 f2 = xfopen(file2, "r");
935 } 918 }
936 919
937 if ((i = files_differ(f1, f2, flags)) == 0) 920 if ((i = files_differ(f1, f2, flags)) == 0)
@@ -1004,19 +987,19 @@ static void do_diff(char *dir1, char *path1, char *dir2, char *path2)
1004 int flags = D_HEADER; 987 int flags = D_HEADER;
1005 int val; 988 int val;
1006 989
1007 char *fullpath1 = bb_xasprintf("%s/%s", dir1, path1); 990 char *fullpath1 = xasprintf("%s/%s", dir1, path1);
1008 char *fullpath2 = bb_xasprintf("%s/%s", dir2, path2); 991 char *fullpath2 = xasprintf("%s/%s", dir2, path2);
1009 992
1010 if (stat(fullpath1, &stb1) != 0) { 993 if (stat(fullpath1, &stb1) != 0) {
1011 flags |= D_EMPTY1; 994 flags |= D_EMPTY1;
1012 memset(&stb1, 0, sizeof(stb1)); 995 memset(&stb1, 0, sizeof(stb1));
1013 fullpath1 = bb_xasprintf("%s/%s", dir1, path2); 996 fullpath1 = xasprintf("%s/%s", dir1, path2);
1014 } 997 }
1015 if (stat(fullpath2, &stb2) != 0) { 998 if (stat(fullpath2, &stb2) != 0) {
1016 flags |= D_EMPTY2; 999 flags |= D_EMPTY2;
1017 memset(&stb2, 0, sizeof(stb2)); 1000 memset(&stb2, 0, sizeof(stb2));
1018 stb2.st_mode = stb1.st_mode; 1001 stb2.st_mode = stb1.st_mode;
1019 fullpath2 = bb_xasprintf("%s/%s", dir2, path1); 1002 fullpath2 = xasprintf("%s/%s", dir2, path1);
1020 } 1003 }
1021 1004
1022 if (stb1.st_mode == 0) 1005 if (stb1.st_mode == 0)
@@ -1051,7 +1034,7 @@ static int add_to_dirlist(const char *filename,
1051{ 1034{
1052 dl_count++; 1035 dl_count++;
1053 dl = xrealloc(dl, dl_count * sizeof(char *)); 1036 dl = xrealloc(dl, dl_count * sizeof(char *));
1054 dl[dl_count - 1] = bb_xstrdup(filename); 1037 dl[dl_count - 1] = xstrdup(filename);
1055 if (cmd_flags & FLAG_r) { 1038 if (cmd_flags & FLAG_r) {
1056 int *pp = (int *) userdata; 1039 int *pp = (int *) userdata;
1057 int path_len = *pp + 1; 1040 int path_len = *pp + 1;
@@ -1077,7 +1060,7 @@ static char **get_dir(char *path)
1077 int path_len = strlen(path); 1060 int path_len = strlen(path);
1078 void *userdata = &path_len; 1061 void *userdata = &path_len;
1079 1062
1080 /* Reset dl_count - there's no need to free dl as bb_xrealloc does 1063 /* Reset dl_count - there's no need to free dl as xrealloc does
1081 * the job nicely. */ 1064 * the job nicely. */
1082 dl_count = 0; 1065 dl_count = 0;
1083 1066
@@ -1089,7 +1072,7 @@ static char **get_dir(char *path)
1089 DIR *dp; 1072 DIR *dp;
1090 struct dirent *ep; 1073 struct dirent *ep;
1091 1074
1092 dp = bb_opendir(path); 1075 dp = warn_opendir(path);
1093 while ((ep = readdir(dp))) { 1076 while ((ep = readdir(dp))) {
1094 if ((!strcmp(ep->d_name, "..")) || (!strcmp(ep->d_name, "."))) 1077 if ((!strcmp(ep->d_name, "..")) || (!strcmp(ep->d_name, ".")))
1095 continue; 1078 continue;
@@ -1104,7 +1087,7 @@ static char **get_dir(char *path)
1104 /* Copy dl so that we can return it. */ 1087 /* Copy dl so that we can return it. */
1105 retval = xmalloc(dl_count * sizeof(char *)); 1088 retval = xmalloc(dl_count * sizeof(char *));
1106 for (i = 0; i < dl_count; i++) 1089 for (i = 0; i < dl_count; i++)
1107 retval[i] = bb_xstrdup(dl[i]); 1090 retval[i] = xstrdup(dl[i]);
1108 1091
1109 return retval; 1092 return retval;
1110} 1093}