[BusyBox] Silence... Ok. New patch

Vladimir N. Oleynik dzo at simtreas.ru
Sun Mar 25 17:04:45 UTC 2001


Hi.

I work with linear shell parser for sh/cmdedit/ftp and strcoll() for Uclibc and
very busy.
I see silence. Hmm.
Small patch to libbb/print_file_by_name.c:

- remove bug: not closing files (for example `cat' can open very many files)
- add standart features: for directory requires put warning "file: Is
directory".

Also. 
Why in libbb have very strange copiright in comments?
For example base ideas:
Xerror_msg* is Written by David MacKenzie <djm at gnu.ai.mit.edu>,
humman_readable is  Originally contributed by lm at sgi.com,
parse_suffix is  Written by Jim Meyering, original idea by Richard Stallman.
....
And Manuel, and I, and other? ;)


--w
vodz
-------------- next part --------------
diff -ru busybox.orig/print_file.c busybox/print_file.c
--- busybox.orig/print_file.c	Sun Mar 25 20:28:10 2001
+++ busybox/print_file.c	Sun Mar 25 20:25:26 2001
@@ -26,6 +26,7 @@
  */
 
 #include <stdio.h>
+#include <sys/stat.h>
 #include "libbb.h"
 
 
@@ -42,10 +43,20 @@
 extern int print_file_by_name(char *filename)
 {
 	FILE *file;
+	struct stat statBuf;
+	int status = TRUE;
+
 	if ((file = wfopen(filename, "r")) == NULL)
 		return FALSE;
-	print_file(file);
-	return TRUE;
+
+	if(is_directory(filename, TRUE, &statBuf)==TRUE) {
+		error_msg("%s: Is directory", filename);
+		status = FALSE;
+	} else {
+		print_file(file);
+	}
+	fclose(file);
+	return status;
 }
 
 


More information about the busybox mailing list