1 #include <../../nmodlconf.h> 11 #if MAC && TARGET_API_MAC_CARBON 20 int isend(
char*,
char*);
29 #if __TURBOC__ || SYSV || VMS || defined(MINGW) 40 if ((cp =
index(
buf,
'!')) != (
char *) 0) {
43 while (cp >=
buf && isspace(*cp)) {
47 for (cp =
buf; *cp !=
'\0' && isspace(*cp); cp++){
65 if (cp == (
char *) 0) {
67 diag(s,
"block goes to end of file");
80 char *cp, word[256], *wp, test[256];
85 while (*cp ==
' ' || *cp ==
'\t')
88 for (wp = word; isalpha(*cp);) {
92 if (strcmp(test, word) == 0) {
111 for(i=0; i < size; ++
i) {
113 if (c == EOF || c == 26 || c == 4) {
129 if (c < 0 || c > 127) {
133 diag(
"Non-Ascii character in file:", buf);
147 diag(
"Line too long:", buf);
155 if (
ctp == (
char *) 0 || *
ctp ==
'\0') {
162 if (
ctp == (
char *) 0) {
184 diag(
"internal error in unGetc",
"");
195 while ((c =
Getc()) != EOF && c !=
'\n') {
202 }
else if (c == EOF) {
205 diag(
"internal error in Gets()",
"");
218 diag(
"internal error in unGets()",
"");
228 for (p = buf; *
p; ++
p) {
262 #if MAC && TARGET_API_MAC_CARBON 263 SIOUXSettings.autocloseonquit =
true;
264 RunApplicationEventLoop();
270 static Symbol *symq[20], **symhead = symq, **symtail = symq;
289 if (symhead >= symtail)
293 f =
fopen(fname,
"r");
294 if (f == (FILE *) 0) {
295 diag(
"Can't open", fname);
318 for (cp = prefix + strlen(prefix); cp+1 !=
prefix; --cp) {
324 return (prefix[0] !=
'\0');
336 if(fname[0] ==
'/') {
337 return fopen(fname,
"r");
350 if (err)
fprintf(stderr,
"Couldn't open: %s\n", buf);
352 f =
fopen(fname,
"r");
364 if (err)
fprintf(stderr,
"Couldn't open: %s\n", fname);
367 dirs =
getenv(
"MODL_INCLUDE");
372 for (dirs = colon; *dirs; dirs = colon){
374 for(; *colon; ++colon) {
381 buf2 =
static_cast<char *
>(
emalloc(strlen(dirs) + 2 + strlen(fname)));
385 f =
fopen(buf2,
"r");
392 if (err)
fprintf(stderr,
"Couldn't open: %s\n", buf2);
409 strcpy(fname,
STR(q) + 1);
410 fname[strlen(fname)-1] =
'\0';
423 diag(
"Couldn't open ", fname);
425 fprintf(stderr,
"INCLUDEing %s\n", fname);
433 pf = realpath(fname,
NULL);
447 remove(filestack->
prev);
460 return (filestack->
next == filestack);
466 const size_t len = strlen(path);
473 if (len >
sizeof(mypath)-1) {
474 fprintf(stderr,
"Output directory path too long\n");
478 strcpy(mypath, path);
481 for (p = mypath + 1; *
p; p++) {
487 if (_mkdir(mypath) != 0) {
489 if (mkdir(mypath, S_IRWXU) != 0) {
499 if (_mkdir(mypath) != 0) {
501 if (mkdir(mypath, S_IRWXU) != 0) {
char * stralloc(char *buf, char *rel)
char finname[NRN_BUFSIZE]
int mkdir_p(const char *path)
char * Fgets(char *buf, int size, FILE *f)
char finname[NRN_BUFSIZE]
Item * lappendsym(List *list, Symbol *sym)
static int file_stack_empty()
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
static int getprefix(char *prefix, char *s)
static struct prefix prefix[]
Item * lappendstr(List *list, char *str)
static const char * fname(const char *name)
void enquextern(Symbol *)
char * getenv(const char *s)
fprintf(stderr, "Don't know the location of params at %p\, pp)
char * emalloc(unsigned n)
static char inlinebuf[2][NRN_BUFSIZE]
NMODL parser global flags / functions.
int isend(char *, char *)
struct FileStackItem FileStackItem
void diag(char *s1, char *s2)
Item * putintoken(char *s, short type, short toktype)
void replacstr(Item *q, char *s)
static FILE * include_open(char *fname, int err)
void include_file(Item *q)