From dc23bec5af327cff093dc471441124944c39cc9c Mon Sep 17 00:00:00 2001 From: graham.gower Date: Tue, 10 Nov 2009 00:00:59 -0500 Subject: Remove opkg_internal_use_only and fix associated assumptions RE pkg->provides. It appears that the opkg_internal_use_only provides string was introduced to bandaid over problems with assuming that the pkg->provides, pkg->provides_str and pkg->provides_count are all the same length. As each pkg provides itself, the pkg->provides array was one longer than the str and count fields. Most of the uses of pkg->provides did not take this into account. This behaviour has been changed. pkg->provides is now pkg->provides_count long and it is pkg->provides_str which is shorter by one. Associated dead code has also been removed. git-svn-id: http://opkg.googlecode.com/svn/trunk@277 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- (limited to 'libopkg/pkg_parse.c') diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c index 98d7a9b..12aabbe 100644 --- a/libopkg/pkg_parse.c +++ b/libopkg/pkg_parse.c @@ -156,38 +156,6 @@ int parseVersion(pkg_t *pkg, char *raw) return 0; } - -/* This code is needed to insert in first position the keyword for the aligning bug */ - -int alterProvidesLine(char *raw, char *temp) -{ - - - if (!*raw) { - fprintf(stderr, "%s: ERROR: Provides string is empty", __FUNCTION__); - return -EINVAL; - } - - if ( temp == NULL ) { - fprintf(stderr, "%s: out of memory \n", __FUNCTION__); - return -ENOMEM; - } - - if (strncmp(raw, "Provides:", 9) == 0) { - raw += 9; - } - while (*raw && isspace(*raw)) { - raw++; - } - - snprintf ( temp, 35, "Provides: opkg_internal_use_only, "); /* First part of the line */ - while (*raw) { - strncat( temp, raw++, 1); - } - return 0; - -} - /* Some random thoughts from Carl: This function could be considerably simplified if we just kept @@ -208,9 +176,7 @@ int alterProvidesLine(char *raw, char *temp) int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest) { int reading_conffiles, reading_description; - int pkg_false_provides=1; char ** lines; - char * provide=NULL; pkg->src = src; pkg->dest = dest; @@ -226,17 +192,7 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest) else if(isGenericFieldType("Priority:", *lines)) pkg->priority = parseGenericFieldType("Priority", *lines); else if(isGenericFieldType("Provides", *lines)){ -/* Here we add the internal_use to align the off by one problem between provides_str and provides */ - provide = xcalloc(1, strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */ - if ( alterProvidesLine(*lines,provide) ){ - return EINVAL; - } - pkg->provides_str = parseDependsString( provide, &pkg->provides_count); -/* Let's try to hack a bit here. - The idea is that if a package has no Provides, we would add one generic, to permit the check of dependencies - in alot of other places. We will remove it before writing down the status database */ - pkg_false_provides=0; - free(provide); + pkg->provides_str = parseDependsString(*lines, &pkg->provides_count); } else if(isGenericFieldType("Pre-Depends", *lines)) pkg->pre_depends_str = parseDependsString(*lines, &pkg->pre_depends_count); @@ -370,13 +326,6 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest) out:; *raw = lines; -/* If the opk has not a Provides line, we insert our false line */ - if ( pkg_false_provides==1) - { - pkg->provides_count = 1; - pkg->provides_str = xcalloc(1, sizeof (char*)); - pkg->provides_str[0] = xstrdup("opkg_internal_use_only"); - } if (pkg->name) { return 0; -- cgit v0.9.1