Ticket #1671: i18n-checktimelength.patch

File i18n-checktimelength.patch, 1.3 KB (added by sfionov, 10 years ago)

Cycle around all months to determine maximum time string length.

  • src/util.c

    diff --git a/src/util.c b/src/util.c
    index 12b7ef7..fbe5359 100644
    a b load_mc_home_file (const char *filename, char **allocated_filename) 
    635635} 
    636636 
    637637/* Check strftime() results. Some systems (i.e. Solaris) have different 
    638    short-month-name sizes for different locales */ 
     638   short-month-name sizes for different locales and months */ 
    639639size_t 
    640640i18n_checktimelength (void) 
    641641{ 
    642     size_t length; 
     642    size_t length = 0; 
    643643    time_t testtime = time (NULL); 
    644644    struct tm* lt = localtime(&testtime); 
    645645 
    i18n_checktimelength (void) 
    648648        length = str_term_width1 (_(INVALID_TIME_TEXT)); 
    649649    } else { 
    650650        char buf [MB_LEN_MAX * MAX_I18NTIMELENGTH + 1]; 
    651         size_t a, b; 
    652651 
    653         strftime (buf, sizeof(buf) - 1, FMTTIME, lt); 
    654         a = str_term_width1 (buf); 
    655         strftime (buf, sizeof(buf) - 1, FMTYEAR, lt); 
    656         b = str_term_width1 (buf); 
     652        for (lt->tm_mon = 0, lt->tm_mday = 1; lt->tm_mon < 12; lt->tm_mon++) { 
     653            strftime (buf, sizeof(buf) - 1, FMTTIME, lt); 
     654            length = max ((size_t)str_term_width1 (buf), length); 
     655            strftime (buf, sizeof(buf) - 1, FMTYEAR, lt); 
     656            length = max ((size_t)str_term_width1 (buf), length); 
     657        } 
    657658 
    658         length = max (a, b); 
    659659        length = max ((size_t)str_term_width1 (_(INVALID_TIME_TEXT)), length); 
    660660    } 
    661661