* archival/dpkg.c (create_list): Use chomp.
authorMatt Kraai <kraai@debian.org>
Wed, 2 Jan 2002 19:01:41 +0000 (19:01 -0000)
committerMatt Kraai <kraai@debian.org>
Wed, 2 Jan 2002 19:01:41 +0000 (19:01 -0000)
* archival/tar.c (append_file_list_to_list): Likewise.

archival/dpkg.c
archival/tar.c

index f41363d0ffb0c3d6c56003518052e5b5fcb908f8..6dee43f5004237bb7d2c44a31a62e0af9d825476 100644 (file)
@@ -1034,7 +1034,6 @@ char **create_list(const char *filename)
        FILE *list_stream;
        char **file_list = xmalloc(sizeof(char *));
        char *line = NULL;
-       char *last_char;
        int length = 0;
        int count = 0;
 
@@ -1047,10 +1046,7 @@ char **create_list(const char *filename)
        while (getline(&line, &length, list_stream) != -1) {
                /* +2 as we need to include space for the terminating NULL pointer */
                file_list = xrealloc(file_list, sizeof(char *) * (length + 2));
-               last_char = last_char_is(line, '\n');
-               if (last_char) {
-                       *last_char = '\0';
-               }
+               chomp(line);
                file_list[count] = xstrdup(line);
                count++;
        }
index 22cbf3ab2803dc21cb945135076d56803d56cb21..19c84a77020f969b8eaa851ac0ac52150cb5c52e 100644 (file)
@@ -516,14 +516,10 @@ void append_file_list_to_list(char *filename, char ***name_list, int *num_of_ent
 {
        FILE *src_stream;
        char *line;
-       char *line_ptr;
        
        src_stream = xfopen(filename, "r");
        while ((line = get_line_from_file(src_stream)) != NULL) {
-               line_ptr = last_char_is(line, '\n');
-               if (line_ptr) {
-                       *line_ptr = '\0';
-               }
+               chomp (line);
                append_file_to_list(line, name_list, num_of_entries);
                free(line);
        }