PERFORCE change 164482 for review

David Forsythe dforsyth at FreeBSD.org
Tue Jun 16 06:05:23 UTC 2009


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

Change 164482 by dforsyth at squirrel on 2009/06/16 06:04:24

	Plist parse is working again (atleast the parts of it that are done).

Affected files ...

.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg.c#19 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.c#11 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb_pkgdb_sub.c#7 edit

Differences ...

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

@@ -70,13 +70,21 @@
 int
 pkg_set_comment(struct pkg *p, const char *comment)
 {
+	int c;
+	char *f;
+
 	if (p == NULL)
 		arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT);
 	
-	if (comment != NULL)
+	p->comment = NULL;
+	if (comment != NULL) {
 		p->comment = strdup(comment);
-	else
-		p->comment = NULL;
+		/* Blot out trailing \n */
+		c = (int)'\n';
+		f = strrchr(p->comment, c);
+		if (f != NULL)
+			*f = '\0';
+	}
 
 	return (OK);
 }
@@ -89,10 +97,13 @@
 	if (p == NULL)
 		arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT);
 	
+	/*
 	if (contents != NULL)
 		p->contents = strdup(contents);
 	else
 		p->contents = NULL;
+	*/
+	p->contents = contents;
 
 	return (OK);
 }
@@ -235,9 +246,6 @@
 
 	if (p == NULL)
 		arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT);
-	
-	if (pf == NULL)
-		arg_rage_quit(__func__, "Not a valid package file.", RAGE_AT_CLIENT);
 
 	pf = pkg_plist_pkg_file_list_next(&p->plist);
 	
@@ -264,7 +272,7 @@
  * called on pkgs that are not explicitly created by the client. */
 
 void
-pkg_free(struct pkg *p)
+pkg_delete(struct pkg *p)
 {
 	if (p == NULL)
 		arg_rage_quit(__func__, "Not a valid package.", RAGE_AT_CLIENT);

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.c#11 (text+ko) ====

@@ -86,11 +86,12 @@
 	/* This function will parse text and create a pkg_plist */
 	if (text == NULL)
 		return (NOT_OK);
-	
+
+	/*
 	pl = pkg_plist_new();
 	if (pl == NULL)
 		return (MEMORY_ERR);
-	
+	*/
 	/* Not sure if this is how I still want to do this, but for now, hold
 	 * a copy of the text. */
 	textp = strdup(text);
@@ -115,11 +116,13 @@
 			 * easier to deal with different types of data. */
 
 			/* Consider a dirty flag for these lists? */
+#if 0
 			if (s != 0) {
 				/* bad parse. */
 				/* free a bunch of stuff. */
 				return (NOT_OK);
 			}
+#endif
 			textp = p + 1;
 		}
 	}
@@ -280,7 +283,7 @@
 {
 	if (pl == NULL)
 		return (NULL);
-
+	
 	return (pl->name);
 }
 

==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkgdb_hierdb_pkgdb_sub.c#7 (text+ko) ====

@@ -106,7 +106,7 @@
 		free(text);
 		return (SUB_NO_FILE); /* Could be a lie, maybe check errno? */
 	}
-	text[sb.st_size] = '\0';	
+	text[sb.st_size] = '\0';
 
 	/* This is dumb.  But I forgot how computers work and wrote this
 	 * function like a moron.  So I'm stuck with it until I feel like


More information about the p4-projects mailing list