svn commit: trunk/busybox: findutils shell

vda at busybox.net vda at busybox.net
Sun Feb 25 02:37:50 UTC 2007


Author: vda
Date: 2007-02-24 18:37:49 -0800 (Sat, 24 Feb 2007)
New Revision: 17974

Log:
ash: replace xstrdup (shell shall not die)
grep: fix mis-indented block


Modified:
   trunk/busybox/findutils/grep.c
   trunk/busybox/shell/ash.c


Changeset:
Modified: trunk/busybox/findutils/grep.c
===================================================================
--- trunk/busybox/findutils/grep.c	2007-02-25 00:40:37 UTC (rev 17973)
+++ trunk/busybox/findutils/grep.c	2007-02-25 02:37:49 UTC (rev 17974)
@@ -84,7 +84,7 @@
 static llist_t *pattern_head;   /* growable list of patterns to match */
 static const char *cur_file;    /* the current file we are reading */
 
-typedef struct GREP_LIST_DATA {
+typedef struct grep_list_data_t {
 	char *pattern;
 	regex_t preg;
 #define PATTERN_MEM_A 1
@@ -162,68 +162,68 @@
 			if (BE_QUIET || PRINT_FILES_WITHOUT_MATCHES)
 				return -1;
 
-				/* keep track of matches */
-				nmatches++;
+			/* keep track of matches */
+			nmatches++;
 
-				/* if we're just printing filenames, we stop after the first match */
-				if (PRINT_FILES_WITH_MATCHES)
-					break;
+			/* if we're just printing filenames, we stop after the first match */
+			if (PRINT_FILES_WITH_MATCHES)
+				break;
 
-				/* print the matched line */
-				if (PRINT_MATCH_COUNTS == 0) {
+			/* print the matched line */
+			if (PRINT_MATCH_COUNTS == 0) {
 #if ENABLE_FEATURE_GREP_CONTEXT
-					int prevpos = (curpos == 0) ? lines_before - 1 : curpos - 1;
+				int prevpos = (curpos == 0) ? lines_before - 1 : curpos - 1;
 
-					/* if we were told to print 'before' lines and there is at least
-					 * one line in the circular buffer, print them */
-					if (lines_before && before_buf[prevpos] != NULL) {
-						int first_buf_entry_line_num = linenum - lines_before;
+				/* if we were told to print 'before' lines and there is at least
+				 * one line in the circular buffer, print them */
+				if (lines_before && before_buf[prevpos] != NULL) {
+					int first_buf_entry_line_num = linenum - lines_before;
 
-						/* advance to the first entry in the circular buffer, and
-						 * figure out the line number is of the first line in the
-						 * buffer */
-						idx = curpos;
-						while (before_buf[idx] == NULL) {
-							idx = (idx + 1) % lines_before;
-							first_buf_entry_line_num++;
-						}
+					/* advance to the first entry in the circular buffer, and
+					 * figure out the line number is of the first line in the
+					 * buffer */
+					idx = curpos;
+					while (before_buf[idx] == NULL) {
+						idx = (idx + 1) % lines_before;
+						first_buf_entry_line_num++;
+					}
 
-						/* now print each line in the buffer, clearing them as we go */
-						while (before_buf[idx] != NULL) {
-							print_line(before_buf[idx], first_buf_entry_line_num, '-');
-							free(before_buf[idx]);
-							before_buf[idx] = NULL;
-							idx = (idx + 1) % lines_before;
-							first_buf_entry_line_num++;
-						}
+					/* now print each line in the buffer, clearing them as we go */
+					while (before_buf[idx] != NULL) {
+						print_line(before_buf[idx], first_buf_entry_line_num, '-');
+						free(before_buf[idx]);
+						before_buf[idx] = NULL;
+						idx = (idx + 1) % lines_before;
+						first_buf_entry_line_num++;
 					}
+				}
 
-					/* make a note that we need to print 'after' lines */
-					print_n_lines_after = lines_after;
+				/* make a note that we need to print 'after' lines */
+				print_n_lines_after = lines_after;
 #endif
-					if (option_mask32 & GREP_OPT_o) {
-						line[regmatch.rm_eo] = '\0';
-						print_line(line + regmatch.rm_so, linenum, ':');
-					} else {
-						print_line(line, linenum, ':');
-					}
+				if (option_mask32 & GREP_OPT_o) {
+					line[regmatch.rm_eo] = '\0';
+					print_line(line + regmatch.rm_so, linenum, ':');
+				} else {
+					print_line(line, linenum, ':');
 				}
 			}
+		}
 #if ENABLE_FEATURE_GREP_CONTEXT
-			else { /* no match */
-				/* Add the line to the circular 'before' buffer */
-				if (lines_before) {
-					free(before_buf[curpos]);
-					before_buf[curpos] = xstrdup(line);
-					curpos = (curpos + 1) % lines_before;
-				}
+		else { /* no match */
+			/* Add the line to the circular 'before' buffer */
+			if (lines_before) {
+				free(before_buf[curpos]);
+				before_buf[curpos] = xstrdup(line);
+				curpos = (curpos + 1) % lines_before;
 			}
+		}
 
-			/* if we need to print some context lines after the last match, do so */
-			if (print_n_lines_after && (last_line_printed != linenum)) {
-				print_line(line, linenum, '-');
-				print_n_lines_after--;
-			}
+		/* if we need to print some context lines after the last match, do so */
+		if (print_n_lines_after && (last_line_printed != linenum)) {
+			print_line(line, linenum, '-');
+			print_n_lines_after--;
+		}
 #endif /* ENABLE_FEATURE_GREP_CONTEXT */
 		free(line);
 	}

Modified: trunk/busybox/shell/ash.c
===================================================================
--- trunk/busybox/shell/ash.c	2007-02-25 00:40:37 UTC (rev 17973)
+++ trunk/busybox/shell/ash.c	2007-02-25 02:37:49 UTC (rev 17974)
@@ -2156,7 +2156,7 @@
 {
 	if (ENABLE_ASH_EXPAND_PRMT) {
 		free((char*)cmdedit_prompt);
-		cmdedit_prompt = xstrdup(s);
+		cmdedit_prompt = ckstrdup(s);
 		return;
 	}
 	cmdedit_prompt = s;
@@ -11033,7 +11033,7 @@
 	int status = 0;
 
 	for (sp = cmdenviron; sp; sp = sp->next)
-		setvareq(xstrdup(sp->text), VSTRFIXED | VTEXTFIXED);
+		setvareq(ckstrdup(sp->text), VSTRFIXED | VTEXTFIXED);
 
 	if (argc >= 2) {        /* That's what SVR2 does */
 		char *fullname;




More information about the busybox-cvs mailing list