ack/lang/m2/m2mm/options.c

104 lines
1.5 KiB
C
Raw Normal View History

1987-09-24 13:01:27 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*
* Author: Ceriel J.H. Jacobs
*/
/* U S E R O P T I O N - H A N D L I N G */
/* stripped down version from the one in the Modula-2 compiler */
/* $Header$ */
#include <alloc.h>
#include "main.h"
static int ndirs = 1;
DoOption(text)
register char *text;
{
extern char *mflags;
extern char *suff;
extern char *compiler;
1988-09-06 11:28:16 +00:00
extern char *llibs;
1987-09-24 13:01:27 +00:00
switch(*text++) {
1988-09-06 11:28:16 +00:00
case 'L' :
AddLibDir(text);
break;
1987-09-24 13:01:27 +00:00
case 'I' :
AddInclDir(text);
break;
case 'M':
mflags = text;
break;
case 'C':
compiler = text;
break;
case 'S':
suff = text;
break;
1988-09-06 11:28:16 +00:00
case 'l':
{ static unsigned int liblen = 0;
unsigned int len = strlen(text) + 4;
if (liblen) {
llibs = Realloc(llibs, liblen += len);
}
else {
llibs = Malloc(liblen = len);
*llibs = '\0';
}
strcat(llibs,"\\\n\t");
strcat(llibs, text);
}
break;
1987-09-24 13:01:27 +00:00
default:
Gerror("Unrecognized option: -%s", text-1);
break;
}
}
AddInclDir(text)
char *text;
{
register int i;
register char *new = text;
if (! *text) {
DEFPATH[ndirs] = 0;
return;
}
if (++nDEF > mDEF) {
mDEF += 10;
1988-02-17 17:21:51 +00:00
DEFPATH = (char **) Realloc((char *)DEFPATH,
(unsigned)(mDEF * sizeof(char *)));
1987-09-24 13:01:27 +00:00
}
1990-06-29 10:00:41 +00:00
for (i = ndirs++; i <= nDEF; i++) {
char *tmp = DEFPATH[i];
1987-09-24 13:01:27 +00:00
DEFPATH[i++] = new;
new = tmp;
}
}
1988-09-06 11:28:16 +00:00
AddLibDir(text)
char *text;
{
if (*text) {
set_libdir(ndirs);
AddInclDir(text);
}
}