Robert Lowry avatar Robert Lowry committed 0709490

did a little cleaning

Comments (0)

Files changed (3)

 #define TERM "urxvt"
 
 /*
- * The default nick to highlight when using colors, "" reverts to your login name ($USER)
+ * The default nick to highlight when using colors, NULL reverts to your system username ($USER)
+ * NOTE: remember to use quotes around your nick, or pcw will not compile properly.
  */
-#define DEFAULT_NICK ""
+#define DEFAULT_NICK NULL
+//#define DEFAULT_NICK "johndoe"
 
 /*
  * The default color setting (0 for off, 1 for on.)
 
 	for (;;) {
 		i = kevent(kq, NULL, 0, &event, 1, NULL);
-		if (i == -1) {
-			/* don't quit on interrupts (ie. SIGWINCH */
-			if (errno == EINTR)
-				continue;
-			else
-				err(1, "kevent read"); 
+		if (i == -1 && errno != EINTR) {
+			err(1, "kevent read"); 
 		}
 
 		if (event.filter == EVFILT_READ) {
 void usage()
 {
 	fprintf(stderr, "pcw-"VERSION" (c) Evan Gates\n");
-	fprintf(stderr, "Usage: pcw [-v] [-c nick] dir\n");
+	fprintf(stderr, "Usage: pcw [-c nick] dir\n");
 	exit(1);
 }
 
 #ifdef HAVE_INOTIFY
 int add_dir_inotify(const char *fpath, const struct stat *sb, int typeflag)
 {
-	watch_t *w;
 	int wd;
 
 	if(!(typeflag & FTW_D))
 	if(!(typeflag & FTW_D))
 		return 0;
 
-	printf("adding %s\n",fpath);
-
 	for (w = watch; w; w = w->next) {
 		if (w->path && !strcmp(w->path, fpath)) {
 			if(w->outwd)
 	if (!w) {
 		if((fd = open(fpath, O_RDONLY)) == -1)
 			err(1,"directory open");
+
 		w = add_watch(fd,fpath);
 
 		EV_SET(&kadd, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE, 0, w);
 		if(kevent(kq, &kadd, 1, NULL, 0, NULL) == -1)
 			err(1,"kevent set EVFILT_VNODE");
-		}
+	}
 
 	if(!w->outwd) {
 		snprintf(out,sizeof(out),"%s/out",fpath);
 		if(stat(out, &st) == 0) {
-			printf("adding %s/out\n",fpath);
 			fd = open(out, O_RDONLY);
 			EV_SET(&kadd, fd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_WRITE, 0, w);
 			if(kevent(kq, &kadd, 1, NULL, 0, NULL) == -1)
 		if (i == -1 && errno != EINTR)
 			err(1, "kevent read");
 		if (i > 0) {
-			printf("event recieved\n");
 			w = (watch_t *)event.udata;
 			if(event.ident == w->wd) {
 				ftw(w->path, add_dir_kqueue, MAX_OPENFD);
 	int i;
 
 	if (argc<2) usage();
-
 	for (i = 1; i < argc; i++) {
 		if (argv[i][0] != '-') {
-			if(!dir) {
-				dir = argv[i];
-				continue;
-			} else usage();
+			if(!dir) { dir = argv[i]; continue; }
+			else usage();
 		}
 		if (argv[i][2] != '\0')
 			usage();
 		switch (argv[i][1]) {
 			case 'c': color = 1; nick = argv[++i]; break;
-			case 'v': break;
 			default: usage();
 		}
 	}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.