PERFORCE change 163333 for review

David Forsythe dforsyth at FreeBSD.org
Tue Jun 2 05:38:59 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=163333

Change 163333 by dforsyth at squirrel on 2009/06/02 05:38:46

	Blotted out the newline from read comments.  pkg_info prints names and comments, though with poor formatting.

Affected files ...

.. //depot/projects/soc2009/dforsyth_libpkg/info/main.c#3 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#4 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb.c#5 edit

Differences ...

==== //depot/projects/soc2009/dforsyth_libpkg/info/main.c#3 (text+ko) ====

@@ -56,7 +56,7 @@
 void
 usage(int exit_val)
 {
-	printf("If you don't know how to use me, then you shouldn't be...\n");
+	fprintf(stderr, "%s", "If you don't know how to use me, then you shouldn't be...\n");
 	exit(exit_val);
 }
 

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#4 (text+ko) ====

@@ -36,7 +36,8 @@
 struct pkg *
 pkg_set_comment(struct pkg *p, const char *comment)
 {
-	int l;
+	int c;
+	char *f;
 
 	if (p == NULL)
 		return (p);
@@ -52,6 +53,13 @@
 		/* Something bad happened...  I should probably let people know
 		 * about it... */
 	}
+	
+	/* Blot out a trailing '\n'. */
+	c = (int) '\n';
+	f = strrchr(p->comment, c);
+	if (f != NULL)
+		*f = '\0';
+
 	return (p);
 }
 

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb.c#5 (text+ko) ====

@@ -231,6 +231,7 @@
 	}
 	/* reuse s */
 	s = read(fd, text, sb.st_size);
+	close(fd);
 	if (s < 0) {
 		free(text);
 		return (NULL);
@@ -247,6 +248,7 @@
 pkgdb_pkg_list_init(struct pkgdb *db) {
 	if (db == NULL)
 		return;
+
 	TAILQ_INIT(&db->p_head);
 }
 


More information about the p4-projects mailing list