Ignore:
Timestamp:
Aug 29, 2009, 3:22:10 AM (15 years ago)
Author:
Bruno Cornec
Message:
  • Some more fgets => mr_getline transformations
  • XWIN define is gone
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-fork.c

    r2339 r2357  
    3838    /*@ buffers ***************************************************** */
    3939    static char result[512];
    40     char *tmp;
     40    char *tmp = NULL;
    4141
    4242    /*@ pointers **************************************************** */
     
    4444
    4545    /*@ initialize data ********************************************* */
    46     malloc_string(tmp);
    4746    result[0] = '\0';
    48     tmp[0] = '\0';
    4947
    5048    /*@******************************************************************** */
     
    5250    assert_string_is_neither_NULL_nor_zerolength(call);
    5351    if ((fin = popen(call, "r"))) {
    54         for (fgets(tmp, MAX_STR_LEN, fin); !feof(fin);
    55              fgets(tmp, MAX_STR_LEN, fin)) {
     52        for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) {
    5653            if (strlen(tmp) > 1) {
    57                 strcpy(result, tmp);
    58             }
    59         }
     54                strncpy(result, 511, tmp);
     55            }
     56            mr_free(tmp);
     57        }
     58        mr_free(tmp);
    6059        paranoid_pclose(fin);
    6160    } else {
     
    6362    }
    6463    strip_spaces(result);
    65     paranoid_free(tmp);
    6664    return (result);
    6765}
     
    163161        mr_free(command);
    164162        command = tmp2;
    165 #ifndef _XWIN
    166163        if (!g_text_mode) {
    167164            newtSuspend();
    168165        }
    169 #endif
    170166        log_msg(1, "command = '%s'", command);
    171167        retval += system(command);
     
    294290    fin = fopen(tmp1, "r");
    295291    if (fin) {
    296         for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin);
    297              fgets(incoming, MAX_STR_LEN, fin)) {
     292        for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin); fgets(incoming, MAX_STR_LEN, fin)) {
    298293            p = incoming;
    299294            while (p && *p) {
     
    304299            }
    305300            strip_spaces(incoming);
    306             if ((res == 0 && log_if_success)
    307                 || (res != 0 && log_if_failure)) {
     301            if ((res == 0 && log_if_success) || (res != 0 && log_if_failure)) {
    308302                log_msg(0, incoming);
    309303            }
     
    375369        }
    376370    }
    377 #ifdef _XWIN
    378     /* This only can update when newline goes into the file,
    379        but it's *much* prettier/faster on Qt. */
    380     while (does_file_exist(lockfile)) {
    381         while (!feof(fin)) {
    382             if (!fgets(tmp1, 512, fin))
    383                 break;
    384             log_to_screen(tmp1);
    385         }
    386         usleep(500000);
    387     }
    388 #else
    389     /* This works on Newt, and it gives quicker updates. */
     371
    390372    for (; does_file_exist(lockfile); sleep(1)) {
    391373        log_file_end_to_screen(MONDO_LOGFILE, "");
    392374        update_evalcall_form(1);
    393375    }
    394 #endif
     376
    395377    /* Evaluate the status returned by pclose to get the exit code of the called program. */
    396378    errno = 0;
Note: See TracChangeset for help on using the changeset viewer.