=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/units/units.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/units/units.c 1996/06/26 05:42:15 1.3 --- src/usr.bin/units/units.c 1996/08/11 00:17:31 1.4 *************** *** 1,4 **** ! /* $OpenBSD: units.c,v 1.3 1996/06/26 05:42:15 deraadt Exp $ */ /* $NetBSD: units.c,v 1.6 1996/04/06 06:01:03 thorpej Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: units.c,v 1.4 1996/08/11 00:17:31 deraadt Exp $ */ /* $NetBSD: units.c,v 1.6 1996/04/06 06:01:03 thorpej Exp $ */ /* *************** *** 59,64 **** --- 59,70 ---- char *NULLUNIT = ""; + #ifdef DOS + #define SEPERATOR ";" + #else + #define SEPERATOR ":" + #endif + int unitcount; int prefixcount; *************** *** 103,122 **** userfile); exit(1); } ! } ! else { unitfile = fopen(UNITSFILE, "rt"); if (!unitfile) { char *direc, *env; char filename[1000]; ! char separator[2]; env = getenv("PATH"); if (env) { - if (strchr(env, ';')) - strcpy(separator, ";"); - else - strcpy(separator, ":"); direc = strtok(env, separator); while (direc) { strcpy(filename, ""); --- 109,123 ---- userfile); exit(1); } ! } else { unitfile = fopen(UNITSFILE, "rt"); if (!unitfile) { char *direc, *env; char filename[1000]; ! char separator[2] = SEPERATOR; env = getenv("PATH"); if (env) { direc = strtok(env, separator); while (direc) { strcpy(filename, ""); *************** *** 152,158 **** continue; if (lineptr[strlen(lineptr) - 1] == '-') { /* it's a prefix */ if (prefixcount == MAXPREFIXES) { ! fprintf(stderr, "Memory for prefixes exceeded in line %d\n", linenum); continue; } --- 153,160 ---- continue; if (lineptr[strlen(lineptr) - 1] == '-') { /* it's a prefix */ if (prefixcount == MAXPREFIXES) { ! fprintf(stderr, ! "Memory for prefixes exceeded in line %d\n", linenum); continue; } *************** *** 160,166 **** prefixtable[prefixcount].prefixname = dupstr(lineptr); for (i = 0; i < prefixcount; i++) if (!strcmp(prefixtable[i].prefixname, lineptr)) { ! fprintf(stderr, "Redefinition of prefix '%s' on line %d ignored\n", lineptr, linenum); continue; } --- 162,169 ---- prefixtable[prefixcount].prefixname = dupstr(lineptr); for (i = 0; i < prefixcount; i++) if (!strcmp(prefixtable[i].prefixname, lineptr)) { ! fprintf(stderr, ! "Redefinition of prefix '%s' on line %d ignored\n", lineptr, linenum); continue; } *************** *** 176,189 **** } else { /* it's not a prefix */ if (unitcount == MAXUNITS) { ! fprintf(stderr, "Memory for units exceeded in line %d\n", linenum); continue; } unittable[unitcount].uname = dupstr(lineptr); for (i = 0; i < unitcount; i++) if (!strcmp(unittable[i].uname, lineptr)) { ! fprintf(stderr, "Redefinition of unit '%s' on line %d ignored\n", lineptr, linenum); continue; } --- 179,194 ---- } else { /* it's not a prefix */ if (unitcount == MAXUNITS) { ! fprintf(stderr, ! "Memory for units exceeded in line %d\n", linenum); continue; } unittable[unitcount].uname = dupstr(lineptr); for (i = 0; i < unitcount; i++) if (!strcmp(unittable[i].uname, lineptr)) { ! fprintf(stderr, ! "Redefinition of unit '%s' on line %d ignored\n", lineptr, linenum); continue; } *************** *** 618,625 **** void usage() { ! fprintf(stderr, "\nunits [-f unitsfile] [-q] [-v] [from-unit to-unit]\n"); ! fprintf(stderr, "\n -f specify units file\n"); fprintf(stderr, " -q supress prompting (quiet)\n"); fprintf(stderr, " -v print version number\n"); exit(3); --- 623,630 ---- void usage() { ! fprintf(stderr, "units [-f unitsfile] [-q] [-v] [from-unit to-unit]\n"); ! fprintf(stderr, " -f specify units file\n"); fprintf(stderr, " -q supress prompting (quiet)\n"); fprintf(stderr, " -v print version number\n"); exit(3); *************** *** 648,656 **** quiet = 1; break; case 'v': ! fprintf(stderr, "\n units version %s Copyright (c) 1993 by Adrian Mariano\n", VERSION); ! fprintf(stderr, " This program may be freely distributed\n"); usage(); default: usage(); --- 653,663 ---- quiet = 1; break; case 'v': ! fprintf(stderr, ! "units version %s Copyright (c) 1993 by Adrian Mariano\n", VERSION); ! fprintf(stderr, ! "This program may be freely distributed\n"); usage(); default: usage(); *************** *** 676,682 **** } else { if (!quiet) ! printf("%d units, %d prefixes\n\n", unitcount, prefixcount); for (;;) { do { --- 683,689 ---- } else { if (!quiet) ! printf("%d units, %d prefixes\n", unitcount, prefixcount); for (;;) { do { *************** *** 684,691 **** if (!quiet) printf("You have: "); if (!fgets(havestr, 80, stdin)) { ! if (!quiet); ! putchar('\n'); exit(0); } } while (addunit(&have, havestr, 0) || --- 691,698 ---- if (!quiet) printf("You have: "); if (!fgets(havestr, 80, stdin)) { ! if (!quiet) ! putchar('\n'); exit(0); } } while (addunit(&have, havestr, 0) || *************** *** 704,707 **** --- 711,715 ---- showanswer(&have, &want); } } + return (0); }