svn commit: trunk/busybox: archival coreutils e2fsprogs editors fin etc...

vda at busybox.net vda at busybox.net
Wed Mar 26 20:04:28 UTC 2008


Author: vda
Date: 2008-03-26 13:04:27 -0700 (Wed, 26 Mar 2008)
New Revision: 21508

Log:
*: more uniform naming: s/xmalloc_getline/xmalloc_fgetline/



Modified:
   trunk/busybox/archival/dpkg.c
   trunk/busybox/archival/tar.c
   trunk/busybox/coreutils/cut.c
   trunk/busybox/coreutils/md5_sha1_sum.c
   trunk/busybox/coreutils/sort.c
   trunk/busybox/coreutils/uniq.c
   trunk/busybox/coreutils/uudecode.c
   trunk/busybox/e2fsprogs/fsck.c
   trunk/busybox/editors/patch.c
   trunk/busybox/editors/sed.c
   trunk/busybox/findutils/grep.c
   trunk/busybox/include/libbb.h
   trunk/busybox/include/usage.h
   trunk/busybox/libbb/get_line_from_file.c
   trunk/busybox/libbb/lineedit.c
   trunk/busybox/libbb/read.c
   trunk/busybox/loginutils/addgroup.c
   trunk/busybox/loginutils/chpasswd.c
   trunk/busybox/loginutils/cryptpw.c
   trunk/busybox/miscutils/dc.c
   trunk/busybox/miscutils/makedevs.c
   trunk/busybox/networking/ifupdown.c
   trunk/busybox/networking/sendmail.c
   trunk/busybox/util-linux/hexdump.c
   trunk/busybox/util-linux/mdev.c
   trunk/busybox/util-linux/mount.c


Changeset:
Modified: trunk/busybox/archival/dpkg.c
===================================================================
--- trunk/busybox/archival/dpkg.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/archival/dpkg.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -1162,7 +1162,7 @@
 		return NULL;
 	}
 
-	while ((line = xmalloc_getline(list_stream)) != NULL) {
+	while ((line = xmalloc_fgetline(list_stream)) != NULL) {
 		file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
 		file_list[count] = line;
 		count++;

Modified: trunk/busybox/archival/tar.c
===================================================================
--- trunk/busybox/archival/tar.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/archival/tar.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -660,7 +660,7 @@
 		tmp = cur;
 		cur = cur->link;
 		free(tmp);
-		while ((line = xmalloc_getline(src_stream)) != NULL) {
+		while ((line = xmalloc_fgetline(src_stream)) != NULL) {
 			/* kill trailing '/' unless the string is just "/" */
 			char *cp = last_char_is(line, '/');
 			if (cp > line)

Modified: trunk/busybox/coreutils/cut.c
===================================================================
--- trunk/busybox/coreutils/cut.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/coreutils/cut.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -51,7 +51,7 @@
 	unsigned int linenum = 0;	/* keep these zero-based to be consistent */
 
 	/* go through every line in the file */
-	while ((line = xmalloc_getline(file)) != NULL) {
+	while ((line = xmalloc_fgetline(file)) != NULL) {
 
 		/* set up a list so we can keep track of what's been printed */
 		char * printed = xzalloc(strlen(line) * sizeof(char));

Modified: trunk/busybox/coreutils/md5_sha1_sum.c
===================================================================
--- trunk/busybox/coreutils/md5_sha1_sum.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/coreutils/md5_sha1_sum.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -115,7 +115,7 @@
 
 		pre_computed_stream = xfopen_stdin(argv[0]);
 
-		while ((line = xmalloc_getline(pre_computed_stream)) != NULL) {
+		while ((line = xmalloc_fgetline(pre_computed_stream)) != NULL) {
 			char *filename_ptr;
 
 			count_total++;

Modified: trunk/busybox/coreutils/sort.c
===================================================================
--- trunk/busybox/coreutils/sort.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/coreutils/sort.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -150,9 +150,9 @@
 #define GET_LINE(fp) \
 	((option_mask32 & FLAG_z) \
 	? bb_get_chunk_from_file(fp, NULL) \
-	: xmalloc_getline(fp))
+	: xmalloc_fgetline(fp))
 #else
-#define GET_LINE(fp) xmalloc_getline(fp)
+#define GET_LINE(fp) xmalloc_fgetline(fp)
 #endif
 
 /* Iterate through keys list and perform comparisons */

Modified: trunk/busybox/coreutils/uniq.c
===================================================================
--- trunk/busybox/coreutils/uniq.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/coreutils/uniq.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -71,7 +71,7 @@
 		dups = 0;
 
 		/* gnu uniq ignores newlines */
-		while ((s1 = xmalloc_getline(in)) != NULL) {
+		while ((s1 = xmalloc_fgetline(in)) != NULL) {
 			e1 = s1;
 			for (i = skip_fields; i; i--) {
 				e1 = skip_whitespace(e1);

Modified: trunk/busybox/coreutils/uudecode.c
===================================================================
--- trunk/busybox/coreutils/uudecode.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/coreutils/uudecode.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -18,7 +18,7 @@
 {
 	char *line;
 
-	while ((line = xmalloc_getline(src_stream)) != NULL) {
+	while ((line = xmalloc_fgetline(src_stream)) != NULL) {
 		int encoded_len, str_len;
 		char *line_ptr, *dst;
 
@@ -151,7 +151,7 @@
 	src_stream = xfopen_stdin(*argv);
 
 	/* Search for the start of the encoding */
-	while ((line = xmalloc_getline(src_stream)) != NULL) {
+	while ((line = xmalloc_fgetline(src_stream)) != NULL) {
 		void (*decode_fn_ptr)(FILE * src, FILE * dst);
 		char *line_ptr;
 		FILE *dst_stream;

Modified: trunk/busybox/e2fsprogs/fsck.c
===================================================================
--- trunk/busybox/e2fsprogs/fsck.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/e2fsprogs/fsck.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -391,7 +391,7 @@
 	}
 	while (1) {
 		int r;
-		char *buf = xmalloc_getline(f);
+		char *buf = xmalloc_fgetline(f);
 		if (!buf) break;
 		r = parse_fstab_line(buf, &fs);
 		free(buf);

Modified: trunk/busybox/editors/patch.c
===================================================================
--- trunk/busybox/editors/patch.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/editors/patch.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -85,7 +85,7 @@
 		patch_file = xfopen_stdin(i);
 	}
 
-	patch_line = xmalloc_getline(patch_file);
+	patch_line = xmalloc_fgetline(patch_file);
 	while (patch_line) {
 		FILE *src_stream;
 		FILE *dst_stream;
@@ -106,7 +106,7 @@
 			/* Extract the filename used before the patch was generated */
 			new_filename = extract_filename(patch_line, patch_level, "--- ");
 			// was old_filename above
-			patch_line = xmalloc_getline(patch_file);
+			patch_line = xmalloc_fgetline(patch_file);
 			if (!patch_line) goto quit;
 		} while (!new_filename);
 		free(new_filename); // "source" filename is irrelevant

Modified: trunk/busybox/editors/sed.c
===================================================================
--- trunk/busybox/editors/sed.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/editors/sed.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -1028,7 +1028,7 @@
 				if (rfile) {
 					char *line;
 
-					while ((line = xmalloc_getline(rfile))
+					while ((line = xmalloc_fgetline(rfile))
 							!= NULL)
 						append(line);
 					xprint_and_close_file(rfile);
@@ -1273,7 +1273,7 @@
 		char *line;
 		FILE *cmdfile;
 		cmdfile = xfopen(opt_f->data, "r");
-		while ((line = xmalloc_getline(cmdfile)) != NULL) {
+		while ((line = xmalloc_fgetline(cmdfile)) != NULL) {
 			add_cmd(line);
 			free(line);
 		}

Modified: trunk/busybox/findutils/grep.c
===================================================================
--- trunk/busybox/findutils/grep.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/findutils/grep.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -172,7 +172,7 @@
 	enum { print_n_lines_after = 0 };
 #endif /* ENABLE_FEATURE_GREP_CONTEXT */
 
-	while ((line = xmalloc_getline(file)) != NULL) {
+	while ((line = xmalloc_fgetline(file)) != NULL) {
 		llist_t *pattern_ptr = pattern_head;
 		grep_list_data_t *gl = gl; /* for gcc */
 
@@ -364,7 +364,7 @@
 		fopt = cur->link;
 		free(cur);
 		f = xfopen(ffile, "r");
-		while ((line = xmalloc_getline(f)) != NULL) {
+		while ((line = xmalloc_fgetline(f)) != NULL) {
 			llist_add_to(&pattern_head,
 				new_grep_list_data(line, PATTERN_MEM_A));
 		}

Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/include/libbb.h	2008-03-26 20:04:27 UTC (rev 21508)
@@ -524,15 +524,16 @@
 extern ssize_t full_read(int fd, void *buf, size_t count);
 extern void xread(int fd, void *buf, size_t count);
 extern unsigned char xread_char(int fd);
-// Read one line a-la fgets. Uses one read(), works only on seekable streams
+// Reads one line a-la fgets (but doesn't save terminating '\n').
+// Uses single full_read() call, works only on seekable streams.
 extern char *reads(int fd, char *buf, size_t count);
-// Read one line a-la fgets. Reads byte-by-byte.
-// Useful when it is important to not read ahead.
+// Reads one line a-la fgets (but doesn't save terminating '\n').
+// Reads byte-by-byte. Useful when it is important to not read ahead.
 // Bytes are appended to pfx (which must be malloced, or NULL).
 extern char *xmalloc_reads(int fd, char *pfx, size_t *maxsz_p);
-extern ssize_t read_close(int fd, void *buf, size_t count);
-extern ssize_t open_read_close(const char *filename, void *buf, size_t count);
-extern void *xmalloc_open_read_close(const char *filename, size_t *sizep);
+extern ssize_t read_close(int fd, void *buf, size_t maxsz);
+extern ssize_t open_read_close(const char *filename, void *buf, size_t maxsz);
+extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p);
 
 extern ssize_t safe_write(int fd, const void *buf, size_t count);
 // NB: will return short write on error, not -1,
@@ -549,7 +550,7 @@
 /* Reads up to (and including) "\n" or NUL byte */
 extern char *xmalloc_fgets(FILE *file);
 /* Chops off '\n' from the end, unlike fgets: */
-extern char *xmalloc_getline(FILE *file);
+extern char *xmalloc_fgetline(FILE *file);
 extern char *bb_get_chunk_from_file(FILE *file, int *end);
 extern void die_if_ferror(FILE *file, const char *msg);
 extern void die_if_ferror_stdout(void);

Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/include/usage.h	2008-03-26 20:04:27 UTC (rev 21508)
@@ -133,6 +133,8 @@
      "\n	-f	Control pipe (else exit after drawing image)" \
      "\n			commands: 'NN' (% for progress bar) or 'exit'" \
 
+
+
 #define brctl_trivial_usage \
        "COMMAND [BRIDGE [INTERFACE]]"
 #define brctl_full_usage \

Modified: trunk/busybox/libbb/get_line_from_file.c
===================================================================
--- trunk/busybox/libbb/get_line_from_file.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/libbb/get_line_from_file.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -57,7 +57,7 @@
 }
 
 /* Get line.  Remove trailing \n */
-char *xmalloc_getline(FILE *file)
+char *xmalloc_fgetline(FILE *file)
 {
 	int i;
 	char *c = bb_get_chunk_from_file(file, &i);

Modified: trunk/busybox/libbb/lineedit.c
===================================================================
--- trunk/busybox/libbb/lineedit.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/libbb/lineedit.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -969,7 +969,7 @@
 		}
 
 		for (hi = 0; hi < MAX_HISTORY;) {
-			char *hl = xmalloc_getline(fp);
+			char *hl = xmalloc_fgetline(fp);
 			int l;
 
 			if (!hl)

Modified: trunk/busybox/libbb/read.c
===================================================================
--- trunk/busybox/libbb/read.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/libbb/read.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -141,7 +141,7 @@
 		off_t offset;
 		*p++ = '\0';
 		// avoid incorrect (unsigned) widening
-		offset = (off_t)(p-buffer) - (off_t)size;
+		offset = (off_t)(p - buffer) - (off_t)size;
 		// set fd position right after '\n'
 		if (offset && lseek(fd, offset, SEEK_CUR) == (off_t)-1)
 			return NULL;
@@ -149,8 +149,8 @@
 	return buffer;
 }
 
-// Read one line a-la fgets. Reads byte-by-byte.
-// Useful when it is important to not read ahead.
+// Reads one line a-la fgets (but doesn't save terminating '\n').
+// Reads byte-by-byte. Useful when it is important to not read ahead.
 // Bytes are appended to pfx (which must be malloced, or NULL).
 char *xmalloc_reads(int fd, char *buf, size_t *maxsz_p)
 {
@@ -178,9 +178,10 @@
 			break;
 		p++;
 	}
-	*p++ = '\0';
+	*p = '\0';
 	if (maxsz_p)
-		*maxsz_p  = p - buf - 1;
+		*maxsz_p  = p - buf;
+	p++;
 	return xrealloc(buf, p - buf);
 }
 

Modified: trunk/busybox/loginutils/addgroup.c
===================================================================
--- trunk/busybox/loginutils/addgroup.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/loginutils/addgroup.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -83,7 +83,7 @@
 
 	if (!group_file) return;
 
-	while ((line = xmalloc_getline(group_file))) {
+	while ((line = xmalloc_fgetline(group_file)) != NULL) {
 		/* Find the group */
 		if (!strncmp(line, args[1], len)
 		 && line[len] == ':'

Modified: trunk/busybox/loginutils/chpasswd.c
===================================================================
--- trunk/busybox/loginutils/chpasswd.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/loginutils/chpasswd.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -33,7 +33,7 @@
 	USE_GETOPT_LONG(applet_long_options = chpasswd_longopts;)
 	opt = getopt32(argv, "em");
 
-	while ((name = xmalloc_getline(stdin)) != NULL) {
+	while ((name = xmalloc_fgetline(stdin)) != NULL) {
 		pass = strchr(name, ':');
 		if (!pass)
 			bb_error_msg_and_die("missing new password");

Modified: trunk/busybox/loginutils/cryptpw.c
===================================================================
--- trunk/busybox/loginutils/cryptpw.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/loginutils/cryptpw.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -22,7 +22,7 @@
 		crypt_make_salt(salt, 1, 0);     /* des */
 	}
 
-	puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_getline(stdin), salt));
+	puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_fgetline(stdin), salt));
 
 	return 0;
 }

Modified: trunk/busybox/miscutils/dc.c
===================================================================
--- trunk/busybox/miscutils/dc.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/miscutils/dc.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -204,7 +204,7 @@
 		char *line;
 		char *cursor;
 		char *token;
-		while ((line = xmalloc_getline(stdin)) != NULL) {
+		while ((line = xmalloc_fgetline(stdin)) != NULL) {
 			cursor = line;
 			while (1) {
 				token = get_token(&cursor);

Modified: trunk/busybox/miscutils/makedevs.c
===================================================================
--- trunk/busybox/miscutils/makedevs.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/miscutils/makedevs.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -97,7 +97,7 @@
 		printf("table=<stdin>\n");
 	}
 
-	while ((line = xmalloc_getline(table))) {
+	while ((line = xmalloc_fgetline(table)) != NULL) {
 		char type;
 		unsigned int mode = 0755;
 		unsigned int major = 0;

Modified: trunk/busybox/networking/ifupdown.c
===================================================================
--- trunk/busybox/networking/ifupdown.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/networking/ifupdown.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -693,13 +693,13 @@
 	defn = xzalloc(sizeof(*defn));
 	f = xfopen(filename, "r");
 
-	while ((buf = xmalloc_getline(f)) != NULL) {
+	while ((buf = xmalloc_fgetline(f)) != NULL) {
 #if ENABLE_DESKTOP
 		/* Trailing "\" concatenates lines */
 		char *p;
 		while ((p = last_char_is(buf, '\\')) != NULL) {
 			*p = '\0';
-			rest_of_line = xmalloc_getline(f);
+			rest_of_line = xmalloc_fgetline(f);
 			if (!rest_of_line)
 				break;
 			p = xasprintf("%s%s", buf, rest_of_line);
@@ -1051,7 +1051,7 @@
 		/* If the mapping script exited successfully, try to
 		 * grab a line of output and use that as the name of the
 		 * logical interface. */
-		char *new_logical = xmalloc_getline(out);
+		char *new_logical = xmalloc_fgetline(out);
 
 		if (new_logical) {
 			/* If we are able to read a line of output from the script,

Modified: trunk/busybox/networking/sendmail.c
===================================================================
--- trunk/busybox/networking/sendmail.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/networking/sendmail.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -170,7 +170,7 @@
 	// if code = -1 then just return this number
 	// if code != -1 then checks whether the number equals the code
 	// if not equal -> die saying msg
-	while ((answer = xmalloc_getline(stdin)) != NULL)
+	while ((answer = xmalloc_fgetline(stdin)) != NULL)
 		if (strlen(answer) <= 3 || '-' != answer[3])
 			break;
 	if (answer) {
@@ -211,7 +211,7 @@
 static void pop3_checkr(const char *fmt, const char *param, char **ret)
 {
 	const char *msg = command(fmt, param);
-	char *answer = xmalloc_getline(stdin);
+	char *answer = xmalloc_fgetline(stdin);
 	if (answer && '+' == *answer) {
 		alarm(0);
 		if (ret)

Modified: trunk/busybox/util-linux/hexdump.c
===================================================================
--- trunk/busybox/util-linux/hexdump.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/util-linux/hexdump.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -23,7 +23,7 @@
 
 	fp = xfopen(name, "r");
 
-	while ((buf = xmalloc_getline(fp)) != NULL) {
+	while ((buf = xmalloc_fgetline(fp)) != NULL) {
 		p = skip_whitespace(buf);
 
 		if (*p && (*p != '#')) {
@@ -135,7 +135,7 @@
 		char *buf;
 		fp = xfopen(*argv, "r");
  jump_in:
-		while ((buf = xmalloc_getline(fp)) != NULL) {
+		while ((buf = xmalloc_fgetline(fp)) != NULL) {
 			p = buf;
 			while (1) {
 				/* skip address or previous byte */

Modified: trunk/busybox/util-linux/mdev.c
===================================================================
--- trunk/busybox/util-linux/mdev.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/util-linux/mdev.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -68,7 +68,7 @@
 		if (!fp)
 			goto end_parse;
 
-		while ((vline = line = xmalloc_getline(fp)) != NULL) {
+		while ((vline = line = xmalloc_fgetline(fp)) != NULL) {
 			int field;
 
 			/* A pristine copy for command execution. */

Modified: trunk/busybox/util-linux/mount.c
===================================================================
--- trunk/busybox/util-linux/mount.c	2008-03-26 19:42:15 UTC (rev 21507)
+++ trunk/busybox/util-linux/mount.c	2008-03-26 20:04:27 UTC (rev 21508)
@@ -362,7 +362,7 @@
 		f = fopen(filesystems[i], "r");
 		if (!f) continue;
 
-		while ((buf = xmalloc_getline(f)) != 0) {
+		while ((buf = xmalloc_fgetline(f)) != NULL) {
 			if (!strncmp(buf, "nodev", 5) && isspace(buf[5]))
 				continue;
 			fs = skip_whitespace(buf);




More information about the busybox-cvs mailing list