PERFORCE change 164928 for review
David Forsythe
dforsyth at FreeBSD.org
Tue Jun 23 05:42:16 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=164928
Change 164928 by dforsyth at squirrel on 2009/06/23 05:41:58
Conflict list is built.
Affected files ...
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_cfl.c#2 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_cfl.h#2 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.c#17 edit
.. //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.h#14 edit
Differences ...
==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_cfl.c#2 (text+ko) ====
@@ -10,13 +10,6 @@
/* Conflicts. */
-/* Yes, I'm that lazy. */
-struct pkg_cfl {
- char *name;
-
- TAILQ_ENTRY(pkg_cfl) next;
-};
-
struct pkg_cfl *
pkg_cfl_new()
{
==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_cfl.h#2 (text+ko) ====
@@ -1,7 +1,15 @@
#ifndef __PKG_CFL_H__
#define __PKG_CFL_H__
-struct pkg_cfl;
+/* Yes, I'm that lazy. */
+struct pkg_cfl {
+ char *name;
+ int version;
+
+ TAILQ_ENTRY(pkg_cfl) next;
+};
+
+struct pkg_cfl *pkg_cfl_new(void);
int pkg_cfl_set_name(struct pkg_cfl *pc, const char *name);
==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.c#17 (text+ko) ====
@@ -10,6 +10,7 @@
#include <limits.h>
#include "pkg_util.h"
+#include "pkg_cfl.h"
#include "pkg_dep.h"
#include "pkg_file.h"
#include "pkg_plist.h"
@@ -117,6 +118,8 @@
textp = strdup(text);
if (textp == NULL)
return (MEMORY_ERR);
+ /* Once parsed this is actually a leak because we lose track of the
+ * commands. */
pl->text = textp;
@@ -125,6 +128,7 @@
* worrying about ruining other instances of a package. */
pkg_plist_pkg_file_list_init(pl);
pkg_plist_pkg_dep_list_init(pl);
+ pkg_plist_pkg_cfl_list_init(pl);
set_parse_state_default(&st);
for (p = textp; *p != '\0'; p++) {
if (*p == '\n') {
@@ -169,6 +173,7 @@
char *sep;
struct pkg_file *pf;
struct pkg_dep *pd;
+ struct pkg_cfl *pc;
if (line == NULL)
return (-1);
@@ -268,19 +273,18 @@
}
st->last_elem = PLIST_COMMENT;
} else if (strcmp(command, PLIST_CMD_PKGDEP) == 0) {
+ /* I should really be checking the name setting return values
+ * for errors. */
pd = pkg_dep_new();
pkg_dep_set_name(pd, argument);
pkg_plist_pkg_dep_list_append(pl, pd);
st->last_elem = PLIST_PKGDEP;
- }
-#if 0
- else if (strcmp(comment, PLIST_CMD_CONFLICTS) == 0) {
+ } else if (strcmp(command, PLIST_CMD_CONFLICTS) == 0) {
pc = pkg_cfl_new();
- pc = pkg_cfl_set_name(pc, argument);
- pkg_plist_pkg_cfl_list_append(pl, pd);
+ pkg_cfl_set_name(pc, argument);
+ pkg_plist_pkg_cfl_list_append(pl, pc);
st->last_elem = PLIST_CONFLICTS;
}
-#endif
#if 0
else if (strcmp(command, PLIST_CMD_NOINST) == 0) {
if ((sep = strchr(argument, ' ')) != NULL)
@@ -530,3 +534,21 @@
return (TAILQ_FIRST(&pl->pkg_dep_head));
}
+
+void
+pkg_plist_pkg_cfl_list_init(struct pkg_plist *pl)
+{
+ if (pl == NULL)
+ return;
+
+ TAILQ_INIT(&pl->pkg_cfl_head);
+}
+
+void
+pkg_plist_pkg_cfl_list_append(struct pkg_plist *pl, struct pkg_cfl *pc)
+{
+ if (pl == NULL || pc == NULL)
+ return;
+
+ TAILQ_INSERT_TAIL(&pl->pkg_cfl_head, pc, next);
+}
==== //depot/projects/soc2009/dforsyth_libpkg/libpkg/pkg_plist.h#14 (text+ko) ====
@@ -21,7 +21,7 @@
PLIST_MTREE,
PLIST_DISPLAY,
PLIST_PKGDEP,
- PLIST_CONLICTS,
+ PLIST_CONFLICTS,
PLIST_FILE,
PLIST_UNKNOWN
};
@@ -142,4 +142,10 @@
struct pkg_dep *pkg_plist_pkg_dep_list_next(struct pkg_plist *pl);
struct pkg_dep *pkg_plist_pkg_dep_list_first(struct pkg_plist *pl);
+/* pkg_cfl */
+
+void pkg_plist_pkg_cfl_list_init(struct pkg_plist *pl);
+
+void pkg_plist_pkg_cfl_list_append(struct pkg_plist *pl,
+ struct pkg_cfl *pc);
#endif
More information about the p4-projects
mailing list