Commits

Robert Lowry committed ef9f197

random cleanup.

  • Participants
  • Parent commits 2b310dd

Comments (0)

Files changed (1)

 
 Line *add_line(Line *line, char *buf)
 {
-	Line *l;
-	if(!line) {
-		line = new_line();
-		line->text = strdup(buf);
-		return line;
-	}
-	l = new_line();
+	Line *l = new_line();
 	l->text = strdup(buf);
-	line->next = l;
 	l->prev = line;
+	if(line) line->next = l;
 	return l;
 }
 
 		if(stat(file,&sb) == 0) {
 			if((fd = open(file,O_RDONLY)) < 0)
 				warn("error opening %s for reading",file);
-			else {
+			else 
 				w->infd = fd;
-				//read_watch_input(w);
-			}
 		}
 	}
 	if (w->outfd == -1) {
 		curwatch = next_active(curwatch);
 		updatescreen = 1;
 	}
-	if(w->prev) 
-		w->prev->next = w->next;
-	if(w->next)
-		w->next->prev = w->prev;
-	else
-		lastwatch = w->prev;
 	for(l = w->lines; l; l = l->next) {
 		if(l->prev)
 			free(l->prev);
 			break;
 		}
 	}
-	close(w->infd);
 	close(w->outfd);
-	free(w->path);
-	free(w);
+	w->outfd = -1;
+	w->active = 0;
 }
 
 #ifdef HAVE_INOTIFY
 				if(w->wd == event->wd)
 					break;
 				if(w->next == NULL)
-					return;
+					ftw(dir, add_dir_inotify, MAX_OPENFD);
 			}
 			if (event->mask & (IN_CREATE | IN_MODIFY | IN_DELETE)) {
 				if(!strcmp(event->name,"out") && w->infd != -1)
 
 void draw_screen()
 {
-	if(updatescreen) clear();
-	if(updatescreen) draw_lines();
-	if(updatescreen) draw_bar();
-	if(updatescreen || updateinput) draw_input();
-	if(updatescreen || updateinput) refresh();
+	if(updatescreen) {
+		clear();
+		draw_lines();
+		draw_bar();
+	}
+	if(updatescreen || updateinput) {
+		draw_input();
+		refresh();
+	}
 	updatescreen = 0;
 }