Changeset 2356 in MondoRescue


Ignore:
Timestamp:
Aug 29, 2009, 1:00:03 AM (15 years ago)
Author:
Bruno Cornec
Message:

Remove function spread_flaws_across_three_lines and expand it at the single place where it was useful, and fix memory allocation issues in it.
(backport from 2.2.9)

Location:
branches/2.2.10/mondo/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-string-EXT.h

    r2352 r2356  
    1919                         char *s);
    2020extern int special_dot_char(int i);
    21 extern void spread_flaws_across_three_lines(char *flaws_str,
    22                                             char *flaws_str_A,
    23                                             char *flaws_str_B,
    24                                             char *flaws_str_C);
    2521extern int strcmp_inc_numbers(char *stringA, char *stringB);
    2622extern char *strip_afio_output_line(char *input);
  • branches/2.2.10/mondo/src/common/libmondo-string.c

    r2352 r2356  
    589589    return ('.');
    590590}
    591 
    592 
    593 
    594 
    595 /**
    596  * Wrap @p flaws_str across three lines. The first two are no more than 74 characters wide.
    597  * @param flaws_str The original string to split.
    598  * @param flaws_str_A Where to put the first 74-or-less characters.
    599  * @param flaws_str_B Where to put the second 74-or-less characters.
    600  * @param flaws_str_C Where to put the rest.
    601  */
    602 void
    603 spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
    604                                 char *flaws_str_B, char *flaws_str_C)
    605 {
    606 
    607     /*@ int ************************************************************* */
    608     int i = 0;
    609 
    610     /*@ initialize ****************************************************** */
    611     assert(flaws_str != NULL);
    612 
    613     if (strlen(flaws_str) > 0) {
    614         mr_asprintf(flaws_str_A, "%s", flaws_str + 1);
    615     }
    616     if (strlen(flaws_str_A) >= 74) {
    617         for (i = 74; flaws_str_A[i] != ' '; i--);
    618         mr_asprintf(flaws_str_B, "%s", flaws_str_A + i + 1);
    619         flaws_str_A[i] = '\0';
    620     }
    621     if (strlen(flaws_str_B) >= 74) {
    622         for (i = 74; flaws_str_B[i] != ' '; i--);
    623         mr_asprintf(flaws_str_C, "%s", flaws_str_B + i + 1);
    624         flaws_str_B[i] = '\0';
    625     }
    626 }
    627 
    628591
    629592
  • branches/2.2.10/mondo/src/common/libmondo-string.h

    r2352 r2356  
    1717char *slice_fname(long bigfileno, long sliceno, char *path, char *s);
    1818int special_dot_char(int i);
    19 void spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
    20                                      char *flaws_str_B, char *flaws_str_C);
    2119int strcmp_inc_numbers(char *stringA, char *stringB);
    2220char *strip_afio_output_line(char *input);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c

    r2352 r2356  
    19661966    while (!finished) {
    19671967        flaws_str = evaluate_mountlist(mountlist, &res);
    1968         spread_flaws_across_three_lines(flaws_str, flaws_str_A, flaws_str_B, flaws_str_C);
    1969 
     1968        if (strlen(flaws_str) > 0) {
     1969            mr_asprintf(flaws_str_A, "%s", flaws_str + 1);
     1970        } else {
     1971            mr_asprintf(flaws_str_A, "");
     1972        }
     1973        if (strlen(flaws_str_A) >= 74) {
     1974            for (i = 74; flaws_str_A[i] != ' '; i--);
     1975            mr_asprintf(flaws_str_B, "%s", flaws_str_A + i + 1);
     1976            flaws_str_A[i] = '\0';
     1977        } else {
     1978            mr_asprintf(flaws_str_B, "");
     1979        }
     1980        if (strlen(flaws_str_B) >= 74) {
     1981            for (i = 74; flaws_str_B[i] != ' '; i--);
     1982            mr_asprintf(flaws_str_C, "%s", flaws_str_B + i + 1);
     1983            flaws_str_B[i] = '\0';
     1984        } else {
     1985            mr_asprintf(flaws_str_C, "");
     1986        }
    19701987        mr_free(flaws_str);
    19711988
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.h

    r2352 r2356  
    180180void setup_newt_stuff(void);
    181181long size_of_specific_device(struct mountlist_itself *, char *);
    182 void spread_flaws_across_three_lines(char *, char *, char *, char *);
    183182char *turn_raid_level_number_to_string(int);
    184183void update_evalcall_form(int);
Note: See TracChangeset for help on using the changeset viewer.