Changeset 2252

Show
Ignore:
Timestamp:
01/31/04 11:17:15 (9 years ago)
Author:
khali
Message:

Move degrees string construction into a single, common place.

Location:
lm-sensors/trunk/prog/sensors
Files:
2 modified

Legend:

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

    r2251 r2252  
    3535 
    3636extern int fahrenheit; 
     37extern char degstr[5]; 
    3738 
    3839char *spacestr(int n) 
     
    6364                     int minmax, int curprec, int limitprec) 
    6465{ 
    65    char degv[5]; 
    66  
    6766   if (fahrenheit) { 
    68       sprintf(degv, "%cF", 176); 
    6967      n_cur  = deg_ctof(n_cur); 
    7068      n_over = deg_ctof(n_over); 
    7169      n_hyst = deg_ctof(n_hyst); 
    72    } else { 
    73       sprintf(degv, "%cC", 176); 
    7470   } 
    7571 
     
    7773   if(minmax == MINMAX) 
    7874        printf("%+6.*f%s  (low  = %+5.*f%s, high = %+5.*f%s)  ", 
    79             curprec, n_cur, degv, 
    80             limitprec, n_hyst, degv, 
    81             limitprec, n_over, degv); 
     75            curprec, n_cur, degstr, 
     76            limitprec, n_hyst, degstr, 
     77            limitprec, n_over, degstr); 
    8278   else if(minmax == MAXONLY) 
    8379        printf("%+6.*f%s  (high = %+5.*f%s)                    ", 
    84             curprec, n_cur, degv, 
    85             limitprec, n_over, degv); 
     80            curprec, n_cur, degstr, 
     81            limitprec, n_over, degstr); 
    8682   else if(minmax == CRIT) 
    8783        printf("%+6.*f%s  (high = %+5.*f%s, crit = %+5.*f%s)  ", 
    88             curprec, n_cur, degv, 
    89             limitprec, n_over, degv, 
    90             limitprec, n_hyst, degv); 
     84            curprec, n_cur, degstr, 
     85            limitprec, n_over, degstr, 
     86            limitprec, n_hyst, degstr); 
    9187   else if(minmax == HYST) 
    9288        printf("%+6.*f%s  (high = %+5.*f%s, hyst = %+5.*f%s)  ", 
    93             curprec, n_cur, degv, 
    94             limitprec, n_over, degv, 
    95             limitprec, n_hyst, degv); 
     89            curprec, n_cur, degstr, 
     90            limitprec, n_over, degstr, 
     91            limitprec, n_hyst, degstr); 
    9692   else if(minmax == SINGLE) 
    9793        printf("%+6.*f%s", 
    98             curprec, n_cur, degv); 
     94            curprec, n_cur, degstr); 
    9995   else if(minmax == HYSTONLY) 
    10096        printf( "%+6.*f%s  (hyst = %+5.*f%s)                   ", 
    101             curprec, n_cur, degv, 
    102             limitprec, n_over, degv); 
     97            curprec, n_cur, degstr, 
     98            limitprec, n_over, degstr); 
    10399   else 
    104100        printf("Unknown temperature mode!"); 
     
    14091405      !sensors_get_feature(*name,SENSORS_LM80_TEMP_OS_MAX,&max2)) { 
    14101406    if (valid) { 
    1411       print_label(label,10); 
    1412  
    1413       if ( fahrenheit ) 
    1414       { 
    1415       printf("%+3.2f°C (hot:limit = %+3.0f°F,  hysteresis = %+3.0f°F) %s\n", 
    1416            deg_ctof(cur),deg_ctof(max),deg_ctof(min), alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
    1417     printf("         (os: limit = %+3.0f°F,  hysteresis = %+3.0f°F) %s\n", 
    1418            deg_ctof(max2),deg_ctof(min2), alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
    1419       } 
    1420       else 
    1421       { 
    1422       printf("%+3.2f °C (hot:limit = %+3.0f°C,  hysteresis = %+3.0f°C) %s\n", 
    1423            cur,max,min, alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
    1424     printf("         (os: limit = %+3.0f°C,  hysteresis = %+3.0f°C) %s\n", 
    1425            max2,min2, alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
    1426       } 
     1407      if (fahrenheit) { 
     1408        cur = deg_ctof(cur); 
     1409        max = deg_ctof(max); 
     1410        min = deg_ctof(min); 
     1411        max2 = deg_ctof(max2); 
     1412        min2 = deg_ctof(min2); 
     1413      } 
     1414 
     1415      print_label(label,10); 
     1416      printf("%+6.2f%s (hot: limit = %+3.0f%s, hyst = %+3.0f%s) %s\n", 
     1417             cur, degstr, max, degstr, min, degstr, 
     1418             alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
     1419      print_label("",10); 
     1420      printf("         (os:  limit = %+3.0f%s, hyst = %+3.0f%s) %s\n", 
     1421             max2, degstr, min2, degstr, 
     1422             alarms&LM80_ALARM_TEMP_HOT?"ALARM":""); 
    14271423    } 
    14281424  } else 
     
    40204016static void lm92_print_temp (float n_cur,float n_high,float n_low,float n_crit,float n_hyst) 
    40214017{ 
    4022         char suffix[5]; 
    4023  
    40244018        if (fahrenheit) { 
    4025                 sprintf (suffix,"%cF",176); 
    40264019                n_cur = deg_ctof (n_cur); 
    40274020                n_high = deg_ctof (n_high); 
     
    40294022                n_crit = deg_ctof (n_crit); 
    40304023                n_hyst = deg_ctof (n_hyst); 
    4031         } else sprintf (suffix,"%cC",176); 
     4024        } 
    40324025 
    40334026        printf ("%+6.4f%s (high = %+6.4f%s, low = %+6.4f%s, crit = %+6.4f%s, hyst = %+6.4f%s)", 
    4034                         n_cur,suffix, 
    4035                         n_high,suffix, 
    4036                         n_low,suffix, 
    4037                         n_crit,suffix, 
    4038                         n_hyst,suffix); 
     4027                        n_cur, degstr, 
     4028                        n_high, degstr, 
     4029                        n_low, degstr, 
     4030                        n_crit, degstr, 
     4031                        n_hyst, degstr); 
    40394032} 
    40404033 
  • lm-sensors/trunk/prog/sensors/main.c

    r2243 r2252  
    5454int chips_count=0; 
    5555int do_sets, do_unknown, fahrenheit, show_algorithm, hide_adapter, hide_unknown; 
     56 
     57char degstr[5]; /* store the correct string to print degrees */ 
    5658 
    5759void print_short_help(void) 
     
    245247 
    246248  close_config_file(); 
     249 
     250  /* build the degrees string */ 
     251  sprintf(degstr, "%c", 176); 
     252  if (fahrenheit) { 
     253    strcat(degstr, "F"); 
     254  } else { 
     255    strcat(degstr, "C"); 
     256  } 
    247257 
    248258  if(do_the_real_work(&error)) {