|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 1389 (0x56d)
Types: TextFile
Names: »getopt.c«
└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
└─⟦af5ba6c8e⟧ »unix3.0/DVIWARE.tar.Z«
└─⟦ca79c7339⟧
└─⟦this⟧ »DVIware/laser-setters/mctex/lib/getopt.c«
/*
* Copyright (c) 1987, 1989 University of Maryland
* Department of Computer Science. All rights reserved.
* Permission to copy for any purpose is hereby granted
* so long as this copyright notice remains intact.
*/
/*
* getopt - get option letter from argv
* (From Henry Spencer @ U of Toronto Zoology, slightly edited)
*/
#include <stdio.h>
char *optarg; /* Global argument pointer. */
int optind; /* Global argv index. */
static char *scan; /* Private scan pointer. */
extern char *index();
int
getopt(argc, argv, optstring)
register int argc;
register char **argv;
char *optstring;
{
register int c;
register char *place;
optarg = NULL;
if (scan == NULL || *scan == 0) {
if (optind == 0)
optind++;
if (optind >= argc || argv[optind][0] != '-' ||
argv[optind][1] == 0)
return (EOF);
if (strcmp(argv[optind], "--") == 0) {
optind++;
return (EOF);
}
scan = argv[optind] + 1;
optind++;
}
c = *scan++;
place = index(optstring, c);
if (place == NULL || c == ':') {
fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
return ('?');
}
place++;
if (*place == ':') {
if (*scan != '\0') {
optarg = scan;
scan = NULL;
} else {
if (optind >= argc) {
fprintf(stderr,
"%s: missing argument after -%c\n",
argv[0], c);
return ('?');
}
optarg = argv[optind];
optind++;
}
}
return (c);
}