[BusyBox-cvs] busybox.stable cmdedit.c,1.70,1.71

Erik Andersen andersen at busybox.net
Tue Dec 23 21:36:58 UTC 2003


Update of /var/cvs/busybox.stable
In directory nail:/tmp/cvs-serv7455

Modified Files:
	cmdedit.c 
Log Message:
remove duplication


Index: cmdedit.c
===================================================================
RCS file: /var/cvs/busybox.stable/cmdedit.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- cmdedit.c	23 Dec 2003 21:26:49 -0000	1.70
+++ cmdedit.c	23 Dec 2003 21:36:56 -0000	1.71
@@ -1232,48 +1232,6 @@
 }
 
 #ifdef BB_FEATURE_COMMAND_SAVEHISTORY
-/* get_line_from_file() - This function reads an entire line from a text file,
- * up to a newline. It returns a malloc'ed char * which must be stored and
- * free'ed  by the caller.  If 'c' is nonzero, the trailing '\n' (if any)
- * is removed.  In event of a read error or EOF, NULL is returned. */
-
-static char *private_get_line_from_file(FILE *file, int c)
-{
-#define GROWBY (80)		/* how large we will grow strings by */
-
-	int ch;
-	int idx = 0;
-	char *linebuf = NULL;
-	int linebufsz = 0;
-
-	while ((ch = getc(file)) != EOF) {
-		/* grow the line buffer as necessary */
-		if (idx > linebufsz - 2) {
-			linebuf = xrealloc(linebuf, linebufsz += GROWBY);
-		}
-		linebuf[idx++] = (char)ch;
-		if (ch == '\n' || ch == '\0') {
-			if (c) {
-				--idx;
-			}
-			break;
-		}
-	}
-	if (linebuf) {
-		if (ferror(file)) {
-			free(linebuf);
-			return NULL;
-		}
-		linebuf[idx] = 0;
-	}
-	return linebuf;
-}
-
-extern char *bb_get_chomped_line_from_file(FILE *file)
-{
-	return private_get_line_from_file(file, 1);
-}
-
 extern void load_history ( const char *fromfile )
 {
 	FILE *fp;
@@ -1289,7 +1247,7 @@
 	if (( fp = fopen ( fromfile, "r" ))) {
 
 		for ( hi = 0; hi < MAX_HISTORY; ) {
-			char * hl = bb_get_chomped_line_from_file(fp);
+			char * hl = get_chomped_line_from_file(fp);
 			int l;
 
 			if(!hl)




More information about the busybox-cvs mailing list