version 1.12, 2007/02/20 01:56:12 |
version 1.13, 2007/02/24 03:28:16 |
|
|
char * |
char * |
lookupunit(char *unit) |
lookupunit(char *unit) |
{ |
{ |
|
size_t len; |
int i; |
int i; |
char *copy; |
char *copy; |
|
|
|
|
return unittable[i].uval; |
return unittable[i].uval; |
} |
} |
|
|
if (unit[strlen(unit) - 1] == '^') { |
len = strlen(unit); |
|
if (len == 0) |
|
return NULL; |
|
if (unit[len - 1] == '^') { |
copy = dupstr(unit); |
copy = dupstr(unit); |
copy[strlen(copy) - 1] = '\0'; |
copy[len - 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)) { |
strlcpy(buffer, copy, sizeof(buffer)); |
strlcpy(buffer, copy, sizeof(buffer)); |
|
|
} |
} |
free(copy); |
free(copy); |
} |
} |
if (unit[strlen(unit) - 1] == 's') { |
if (unit[len - 1] == 's') { |
copy = dupstr(unit); |
copy = dupstr(unit); |
copy[strlen(copy) - 1] = 0; |
copy[len - 1] = '\0'; |
|
--len; |
for (i = 0; i < unitcount; i++) { |
for (i = 0; i < unitcount; i++) { |
if (!strcmp(unittable[i].uname, copy)) { |
if (!strcmp(unittable[i].uname, copy)) { |
strlcpy(buffer, copy, sizeof(buffer)); |
strlcpy(buffer, copy, sizeof(buffer)); |
|
|
return buffer; |
return buffer; |
} |
} |
} |
} |
if (copy[strlen(copy) - 1] == 'e') { |
if (len != 0 && copy[len - 1] == 'e') { |
copy[strlen(copy) - 1] = 0; |
copy[len - 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)) { |
strlcpy(buffer, copy, sizeof(buffer)); |
strlcpy(buffer, copy, sizeof(buffer)); |
|
|
free(copy); |
free(copy); |
} |
} |
for (i = 0; i < prefixcount; i++) { |
for (i = 0; i < prefixcount; i++) { |
if (!strncmp(prefixtable[i].prefixname, unit, |
len = strlen(prefixtable[i].prefixname); |
strlen(prefixtable[i].prefixname))) { |
if (!strncmp(prefixtable[i].prefixname, unit, len)) { |
unit += strlen(prefixtable[i].prefixname); |
unit += len; |
if (!strlen(unit) || lookupunit(unit)) { |
if (!strlen(unit) || lookupunit(unit)) { |
snprintf(buffer, sizeof(buffer), |
snprintf(buffer, sizeof(buffer), |
"%s %s", prefixtable[i].prefixval, unit); |
"%s %s", prefixtable[i].prefixval, unit); |
|
|
} |
} |
} |
} |
} |
} |
return 0; |
return NULL; |
} |
} |
|
|
|
|