goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement ! */
}
- field_num = compare_string_array(field_names, field_name);
+ field_num = index_in_str_array(field_names, field_name);
switch (field_num) {
case 0: /* Package */
new_node->name = search_name_hashtable(field_value);
/* skip past the separating spaces */
status_string += strspn(status_string, " ");
}
- len = strcspn(status_string, " \n\0");
+ len = strcspn(status_string, " \n");
state_sub_string = xstrndup(status_string, len);
state_sub_num = search_name_hashtable(state_sub_string);
free(state_sub_string);
unsigned int status_num;
status_file = xfopen(filename, "r");
- while ((control_buffer = fgets_str(status_file, "\n\n")) != NULL) {
+ while ((control_buffer = xmalloc_fgets_str(status_file, "\n\n")) != NULL) {
const unsigned int package_num = fill_package_struct(control_buffer);
if (package_num != -1) {
status_node = xmalloc(sizeof(status_node_t));
if (status_line != NULL) {
status_line += 7;
status_line += strspn(status_line, " \n\t");
- status_line = xstrndup(status_line, strcspn(status_line, "\n\0"));
+ status_line = xstrndup(status_line, strcspn(status_line, "\n"));
status_node->status = search_name_hashtable(status_line);
free(status_line);
}
int i = 0;
/* Update previously known packages */
- while ((control_buffer = fgets_str(old_status_file, "\n\n")) != NULL) {
+ while ((control_buffer = xmalloc_fgets_str(old_status_file, "\n\n")) != NULL) {
if ((tmp_string = strstr(control_buffer, "Package:")) == NULL) {
continue;
}
tmp_string += 8;
tmp_string += strspn(tmp_string, " \n\t");
- package_name = xstrndup(tmp_string, strcspn(tmp_string, "\n\0"));
+ package_name = xstrndup(tmp_string, strcspn(tmp_string, "\n"));
write_flag = FALSE;
tmp_string = strstr(control_buffer, "Status:");
if (tmp_string != NULL) {
return NULL;
}
- while ((line = bb_get_chomped_line_from_file(list_stream)) != NULL) {
+ while ((line = xmalloc_getline(list_stream)) != NULL) {
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
file_list[count] = line;
count++;
sprintf(conffile_name, "/var/lib/dpkg/info/%s.conffiles", package_name);
exclude_files = create_list(conffile_name);
- /* Some directories cant be removed straight away, so do multiple passes */
- while (remove_file_array(remove_files, exclude_files));
+ /* Some directories can't be removed straight away, so do multiple passes */
+ while (remove_file_array(remove_files, exclude_files)) /*repeat */;
free_array(exclude_files);
free_array(remove_files);
exclude_files = xzalloc(sizeof(char*));
/* Some directories cant be removed straight away, so do multiple passes */
- while (remove_file_array(remove_files, exclude_files));
+ while (remove_file_array(remove_files, exclude_files)) /* repeat */;
free_array(remove_files);
/* Create a list of all /var/lib/dpkg/info/<package> files */