[BACK]Return to units.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / units

Diff for /src/usr.bin/units/units.c between version 1.4 and 1.5

version 1.4, 1996/08/11 00:17:31 version 1.5, 1997/07/08 18:32:27
Line 120 
Line 120 
                         if (env) {                          if (env) {
                                 direc = strtok(env, separator);                                  direc = strtok(env, separator);
                                 while (direc) {                                  while (direc) {
                                         strcpy(filename, "");                                          snprintf(filename, sizeof(filename),
                                         strncat(filename, direc, 999);                                              "%s/%s", direc, UNITSFILE);
                                         strncat(filename, "/",  
                                             999 - strlen(filename));  
                                         strncat(filename, UNITSFILE,  
                                             999 - strlen(filename));  
                                         unitfile = fopen(filename, "rt");                                          unitfile = fopen(filename, "rt");
                                         if (unitfile)                                          if (unitfile)
                                                 break;                                                  break;
Line 444 
Line 440 
   
         if (unit[strlen(unit) - 1] == '^') {          if (unit[strlen(unit) - 1] == '^') {
                 copy = dupstr(unit);                  copy = dupstr(unit);
                 copy[strlen(copy) - 1] = 0;                  copy[strlen(copy) - 1] = '\0';
                 for (i = 0; i < unitcount; i++) {                  for (i = 0; i < unitcount; i++) {
                         if (!strcmp(unittable[i].uname, copy)) {                          if (!strcmp(unittable[i].uname, copy)) {
                                 strcpy(buffer, copy);                                  strncpy(buffer, copy, sizeof(buffer) - 1);
                                   buffer[sizeof(buffer) - 1] = '\0';
                                 free(copy);                                  free(copy);
                                 return buffer;                                  return buffer;
                         }                          }
Line 459 
Line 456 
                 copy[strlen(copy) - 1] = 0;                  copy[strlen(copy) - 1] = 0;
                 for (i = 0; i < unitcount; i++) {                  for (i = 0; i < unitcount; i++) {
                         if (!strcmp(unittable[i].uname, copy)) {                          if (!strcmp(unittable[i].uname, copy)) {
                                 strcpy(buffer, copy);                                  strncpy(buffer, copy, sizeof(buffer) - 1);
                                   buffer[sizeof(buffer) - 1] = '\0';
                                 free(copy);                                  free(copy);
                                 return buffer;                                  return buffer;
                         }                          }
Line 468 
Line 466 
                         copy[strlen(copy) - 1] = 0;                          copy[strlen(copy) - 1] = 0;
                         for (i = 0; i < unitcount; i++) {                          for (i = 0; i < unitcount; i++) {
                                 if (!strcmp(unittable[i].uname, copy)) {                                  if (!strcmp(unittable[i].uname, copy)) {
                                         strcpy(buffer, copy);                                          strncpy(buffer, copy, sizeof(buffer) - 1);
                                           buffer[sizeof(buffer) - 1] = '\0';
                                         free(copy);                                          free(copy);
                                         return buffer;                                          return buffer;
                                 }                                  }
Line 481 
Line 480 
                         strlen(prefixtable[i].prefixname))) {                          strlen(prefixtable[i].prefixname))) {
                         unit += strlen(prefixtable[i].prefixname);                          unit += strlen(prefixtable[i].prefixname);
                         if (!strlen(unit) || lookupunit(unit)) {                          if (!strlen(unit) || lookupunit(unit)) {
                                 strcpy(buffer, prefixtable[i].prefixval);                                  snprintf(buffer, sizeof(buffer),
                                 strcat(buffer, " ");                                      "%s %s", prefixtable[i].prefixval, unit);
                                 strcat(buffer, unit);  
                                 return buffer;                                  return buffer;
                         }                          }
                 }                  }
Line 671 
Line 669 
         readunits(userfile);          readunits(userfile);
   
         if (optind == argc - 2) {          if (optind == argc - 2) {
                 strcpy(havestr, argv[optind]);                  strncpy(havestr, argv[optind], sizeof(havestr) - 1);
                 strcpy(wantstr, argv[optind + 1]);                  havestr[sizeof(havestr) - 1] = '\0';
                   strncpy(wantstr, argv[optind + 1], sizeof(wantstr) - 1);
                   wantstr[sizeof(wantstr) - 1] = '\0';
                 initializeunit(&have);                  initializeunit(&have);
                 addunit(&have, havestr, 0);                  addunit(&have, havestr, 0);
                 completereduce(&have);                  completereduce(&have);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5