Changeset 5944

Show
Ignore:
Timestamp:
03/16/11 22:31:25 (14 months ago)
Author:
khali
Message:

Ensure that hysteresis and the limit it relates to are always
printed on the same line.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/sensors/chips.c

    r5943 r5944  
    6868} 
    6969 
     70static const char hyst_str[] = "hyst"; 
     71 
    7072static inline double deg_ctof(double cel) 
    7173{ 
     
    155157                         const char *fmt) 
    156158{ 
    157         int i; 
     159        int i, slot, skip; 
    158160        int alarms_printed = 0; 
    159161 
    160         for (i = 0; i < limit_count; i++) { 
    161                 if (!(i & 1)) { 
    162                         if (i) 
     162        /* 
     163         * We print limits on two columns, filling lines first, except for 
     164         * hysteresis which must always go on the right column, with the 
     165         * limit it relates to being in the left column on the same line. 
     166         */ 
     167        for (i = slot = 0; i < limit_count; i++, slot++) { 
     168                if (!(slot & 1)) { 
     169                        if (slot) 
    163170                                printf("\n%*s", label_size + 10, ""); 
    164171                        printf("("); 
     
    168175                printf(fmt, limits[i].name, limits[i].value, 
    169176                             limits[i].unit); 
    170                 if ((i & 1) || i == limit_count - 1) { 
     177 
     178                /* If needed, skip one slot to avoid hyst on first column */ 
     179                skip = i + 2 < limit_count && limits[i + 2].name == hyst_str && 
     180                       !(slot & 1); 
     181 
     182                if (((slot + skip) & 1) || i == limit_count - 1) { 
    171183                        printf(")"); 
    172184                        if (alarm_count && !alarms_printed) { 
    173185                                print_alarms(alarms, alarm_count, 
    174                                              (i & 1) ? 0 : 16); 
     186                                             (slot & 1) ? 0 : 16); 
    175187                                alarms_printed = 1; 
    176188                        } 
    177189                } 
     190                slot += skip; 
    178191        } 
    179192        if (alarm_count && !alarms_printed) 
     
    240253 
    241254static const struct sensor_subfeature_list temp_max_sensors[] = { 
    242         { SENSORS_SUBFEATURE_TEMP_MAX_HYST, NULL, 0, "hyst" }, 
     255        { SENSORS_SUBFEATURE_TEMP_MAX_HYST, NULL, 0, hyst_str }, 
    243256        { -1, NULL, 0, NULL } 
    244257}; 
    245258 
    246259static const struct sensor_subfeature_list temp_crit_sensors[] = { 
    247         { SENSORS_SUBFEATURE_TEMP_CRIT_HYST, NULL, 0, "crit hyst" }, 
     260        { SENSORS_SUBFEATURE_TEMP_CRIT_HYST, NULL, 0, hyst_str }, 
    248261        { -1, NULL, 0, NULL } 
    249262}; 
     
    251264static const struct sensor_subfeature_list temp_emergency_sensors[] = { 
    252265        { SENSORS_SUBFEATURE_TEMP_EMERGENCY_HYST, NULL, 0, 
    253             "emerg hyst" }, 
     266            hyst_str }, 
    254267        { -1, NULL, 0, NULL } 
    255268};