Fix bug where it wasnt returning the last line of a multiline field
This commit is contained in:
parent
daf0b78e1a
commit
481d19b38e
@ -7,24 +7,21 @@
|
|||||||
*/
|
*/
|
||||||
extern char *read_package_field(const char *package_buffer)
|
extern char *read_package_field(const char *package_buffer)
|
||||||
{
|
{
|
||||||
char *field = NULL;
|
|
||||||
int field_length = 0;
|
int field_length = 0;
|
||||||
int buffer_length = 0;
|
int buffer_length = 0;
|
||||||
|
|
||||||
buffer_length = strlen(package_buffer);
|
if (package_buffer == NULL) {
|
||||||
|
|
||||||
while ((field = strchr(&package_buffer[field_length], '\n')) != NULL) {
|
|
||||||
field_length = buffer_length - strlen(field);
|
|
||||||
if (package_buffer[field_length + 1] != ' ') {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
field_length++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (field_length == 0) {
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
} else {
|
}
|
||||||
|
buffer_length = strlen(package_buffer);
|
||||||
|
field_length = strcspn(package_buffer, "\n");
|
||||||
|
while (field_length < buffer_length) {
|
||||||
|
if (package_buffer[field_length + 1] != ' ') {
|
||||||
return(xstrndup(package_buffer, field_length));
|
return(xstrndup(package_buffer, field_length));
|
||||||
}
|
}
|
||||||
|
field_length++;
|
||||||
|
field_length += strcspn(&package_buffer[field_length], "\n");
|
||||||
|
}
|
||||||
|
return(xstrdup(package_buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user