vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I made some modifications in usr.bin/join/join.c. The following list explains these from top to bottom: * The code for parsing option -j in obsolete() does the same for '1' and '2' except setting of ap[1], which can be taken out of ap[2] directly. * If -j has an invalid option argument, join does not show usage because errx() instead of warnx() was used: therefore usage() won't be called. * When -o is parsed in obsolete(), it is possible that an element behind *argv[] gets accessed (which would be *env[0]). This is harmless because environment options cannot begin with '1' or '2', in which case join stops parsing anyway. * Output of usage() is in sync with manual page again. Main reason for this mail are points 2 and 4, just noticed the other things while at it. It would be nice to get some feedback about this patch, i.e. if it's OK, crap, unneeded, etc. Tobias Stoeckmann --- usr.bin/join/join.c~ Mon Apr 23 15:59:30 2007 +++ usr.bin/join/join.c Mon Apr 23 16:01:47 2007 @@ -601,21 +601,16 @@ */ switch(ap[2]) { case '1': - if (ap[3] != '\0') - goto jbad; - ap[1] = '1'; - ap[2] = '\0'; - break; case '2': if (ap[3] != '\0') goto jbad; - ap[1] = '2'; + ap[1] = ap[2]; ap[2] = '\0'; break; case '\0': break; default: -jbad: errx(1, "illegal option -- %s", ap); +jbad: warnx("illegal option -- %s", ap + 1); usage(); } break; @@ -624,7 +619,7 @@ * The original join allowed "-o arg arg". * Convert to "-o arg -o arg". */ - if (ap[2] != '\0') + if (ap[2] != '\0' || argv[1] == NULL) break; for (p = argv + 2; *p != NULL; ++p) { if (p[0][0] == '0' || ((p[0][0] != '1' && @@ -649,8 +644,8 @@ void usage(void) { - (void)fprintf(stderr, "%s%s\n", - "usage: join [-a fileno | -v fileno ] [-e string] [-1 field] ", - "[-2 field]\n [-o list] [-t char] file1 file2"); + (void)fprintf(stderr, "usage: join [-1 field] [-2 field] " + "[-a file_number | -v file_number] [-e string]\n " + "[-j file_number field] [-o list] [-t char] file1 file2\n"); exit(1); } |