Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:sgk:20081224194016

Diff

Diff from 1.19 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/pcc/pcc/f77/f77/f77.c

Annotated File View

sgk
1.19
1 /*      $Id: f77.c,v 1.19 2008/12/24 19:40:16 sgk Exp $ */
ragge
1.1
2 /*
3  * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * Redistributions of source code and documentation must retain the above
10  * copyright notice, this list of conditions and the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditionsand the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * All advertising materials mentioning features or use of this software
15  * must display the following acknowledgement:
16  *      This product includes software developed or owned by Caldera
17  *      International, Inc.
18  * Neither the name of Caldera International, Inc. nor the names of other
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23  * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED.  IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27  * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35
sgk
1.15
36 char xxxvers[] = "FORTRAN 77 DRIVER, VERSION 1.11,   28 JULY 1978\n";
ragge
1.2
37
38 #include <sys/wait.h>
39
ragge
1.1
40 #include <stdio.h>
41 #include <ctype.h>
42 #include <signal.h>
ragge
1.2
43 #include <unistd.h>
44 #include <string.h>
45 #include <stdlib.h>
ragge
1.4
46 #include <stdarg.h>
ragge
1.6
47 #include <errno.h>
ragge
1.2
48
ragge
1.6
49 #include "ccconfig.h"
ragge
1.2
50
ragge
1.11
51 typedef FILE *FILEP;
52 typedef int flag;
53 typedef void *ptr;
54 #define YES 1
55 #define NO 0
ragge
1.1
56
ragge
1.7
57 FILEP diagfile;
58
ragge
1.1
59 static int pid;
60 static int sigivalue    = 0;
61 static int sigqvalue    = 0;
62
ragge
1.5
63 #ifndef FCOM
64 #define FCOM            "fcom"
65 #endif
66
ragge
1.6
67 #ifndef ASSEMBLER
68 #define ASSEMBLER       "as"
69 #endif
70
71 #ifndef LINKER
72 #define LINKER          "ld"
73 #endif
74
ragge
1.5
75 static char *fcom       = LIBEXECDIR "/" FCOM ;
ragge
1.6
76 static char *asmname    = ASSEMBLER ;
77 static char *ldname     = LINKER ;
78 static char *startfiles[] = STARTFILES;
79 static char *endfiles[] = ENDFILES;
80 static char *dynlinker[] = DYNLINKER;
81 static char *crt0file = CRT0FILE;
ragge
1.1
82 static char *macroname  = "m4";
83 static char *shellname  = "/bin/sh";
84 static char *aoutname   = "a.out" ;
ragge
1.12
85 static char *libdir     = LIBDIR ;
ragge
1.6
86 static char *liblist[] = F77LIBLIST;
ragge
1.1
87
88 static char *infname;
89 static char asmfname[15];
90 static char prepfname[15];
91
ragge
1.6
92 #define MAXARGS 100
93 int ffmax;
94 static char *ffary[MAXARGS];
ragge
1.1
95 static char eflags[30]  = "";
96 static char rflags[30]  = "";
97 static char lflag[3]    = "-x";
98 static char *eflagp     = eflags;
99 static char *rflagp     = rflags;
100 static char **loadargs;
101 static char **loadp;
ragge
1.9
102 static int oflag;
ragge
1.1
103
104 static flag loadflag    = YES;
105 static flag saveasmflag = NO;
106 static flag profileflag = NO;
107 static flag optimflag   = NO;
108 static flag debugflag   = NO;
109 static flag verbose     = NO;
110 static flag fortonly    = NO;
111 static flag macroflag   = NO;
112
ragge
1.2
113 char *setdoto(char *), *lastchar(char *), *lastfield(char *);
114 ptr ckalloc(int);
115 void intrupt(int);
116 void enbint(void (*k)(int));
117 void crfnames(void);
ragge
1.4
118 static void fatal1(char *, ...);
sgk
1.13
119 void done(int), texec(char *, char **);
sgk
1.18
120 static char *copyn(intchar *);
ragge
1.2
121 int dotchar(char *), unreadable(char *), sys(char *), dofort(char *);
ragge
1.6
122 int nodup(char *), dopass2(void);
ragge
1.2
123 int await(int);
124 void rmf(char *), doload(char *[], char *[]), doasm(char *);
ragge
1.6
125 static int callsys(char f[], char *v[]);
sgk
1.17
126 static void errorx(char *fmt, ...);
ragge
1.6
127
128
129 static void
130 addarg(char **aryint *numchar *arg)
131 {
132         ary[(*num)++] = arg;
133         if ((*num) == MAXARGS) {
134                 fprintf(stderr"argument array too small\n");
135                 exit(1);
136         }
137 }
ragge
1.2
138
139 int
140 main(int argcchar **argv)
ragge
1.1
141 {
ragge
1.6
142         int icstatus;
143         register char *s;
144         char fortfile[20], *t;
145         char buff[100];
146
ragge
1.7
147         diagfile = stderr;
148
ragge
1.6
149         sigivalue = (intsignal(SIGINTSIG_IGN) & 01;
150         sigqvalue = (intsignal(SIGQUITSIG_IGN) & 01;
151         enbint(intrupt);
ragge
1.1
152
ragge
1.6
153         pid = getpid();
154         crfnames();
ragge
1.1
155
ragge
1.6
156         loadargs = (char **) ckalloc( (argc+20) * sizeof(*loadargs) );
157         loadp = loadargs;
ragge
1.1
158
ragge
1.6
159         --argc;
160         ++argv;
ragge
1.1
161
ragge
1.6
162         while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0') {
163                 for(s = argv[0]+1 ; *s ; ++s)
164                         switch(*s) {
165                         case 'T':  /* use special passes */
166                                 switch(*++s) {
ragge
1.1
167                                 case '1':
ragge
1.5
168                                         fcom = s+1goto endfor;
ragge
1.1
169                                 case 'a':
170                                         asmname = s+1goto endfor;
171                                 case 'l':
172                                         ldname = s+1goto endfor;
173                                 case 'm':
174                                         macroname = s+1goto endfor;
175                                 default:
176                                         fatal1("bad option -T%c", *s);
177                                 }
ragge
1.6
178                                 break;
179
180                         case 'w'/* F66 warn or no warn */
181                                 addarg(ffary, &ffmaxs-1);
182                                 break;
ragge
1.1
183
sgk
1.16
184                         case 'q':
185                                 /*
186                                  * Suppress printing of procedure names during
187                                  * compilation.
188                                  */
189                                 addarg(ffary, &ffmaxs-1);
190                                 break;
191
ragge
1.6
192                         copyfflag:
193                         case 'u':
194                         case 'U':
195                         case 'M':
196                         case '1':
197                         case 'C':
198                                 addarg(ffary, &ffmaxs-1);
199                                 break;
ragge
1.1
200
ragge
1.6
201                         case 'O':
202                                 optimflag = YES;
203                                 addarg(ffary, &ffmaxs-1);
204                                 break;
ragge
1.1
205
ragge
1.6
206                         case 'm':
207                                 if(s[1] == '4')
208                                         ++s;
209                                 macroflag = YES;
210                                 break;
ragge
1.1
211
ragge
1.6
212                         case 'S':
213                                 saveasmflag = YES;
ragge
1.1
214
ragge
1.6
215                         case 'c':
216                                 loadflag = NO;
217                                 break;
ragge
1.1
218
ragge
1.6
219                         case 'v':
220                                 verbose = YES;
221                                 break;
ragge
1.1
222
ragge
1.6
223                         case 'd':
224                                 debugflag = YES;
225                                 goto copyfflag;
ragge
1.1
226
ragge
1.6
227                         case 'p':
228                                 profileflag = YES;
229                                 goto copyfflag;
ragge
1.1
230
ragge
1.6
231                         case 'o':
232                                 if(!strcmp(s"onetrip")) {
233                                         addarg(ffary, &ffmaxs-1);
234                                         goto endfor;
ragge
1.1
235                                 }
ragge
1.9
236                                 oflag = 1;
ragge
1.6
237                                 aoutname = *++argv;
238                                 --argc;
239                                 break;
ragge
1.1
240
ragge
1.6
241                         case 'F':
242                                 fortonly = YES;
243                                 loadflag = NO;
244                                 break;
ragge
1.1
245
ragge
1.6
246                         case 'I':
247                                 if(s[1]=='2' || s[1]=='4' || s[1]=='s')
248                                         goto copyfflag;
249                                 fprintf(diagfile"invalid flag -I%c\n"s[1]);
250                                 done(1);
251
252                         case 'l':       /* letter ell--library */
253                                 s[-1] = '-';
254                                 *loadp++ = s-1;
255                                 goto endfor;
ragge
1.1
256
ragge
1.6
257                         case 'E':       /* EFL flag argument */
258                                 while(( *eflagp++ = *++s))
259                                         ;
260                                 *eflagp++ = ' ';
261                                 goto endfor;
262                         case 'R':
263                                 while(( *rflagp++ = *++s ))
264                                         ;
265                                 *rflagp++ = ' ';
266                                 goto endfor;
267                         default:
268                                 lflag[1] = *s;
sgk
1.18
269                                 *loadp++ = copyn(strlen(lflag), lflag);
ragge
1.6
270                                 break;
271                         }
ragge
1.1
272 endfor:
273         --argc;
274         ++argv;
275         }
276
ragge
1.6
277         if (verbose)
278                 fprintf(stderrxxxvers);
279
280         if (argc == 0)
281                 errorx("No input files");
282
ragge
1.4
283 #ifdef mach_pdp11
ragge
1.1
284         if(nofloating)
285                 *loadp++ = (profileflag ? NOFLPROF : NOFLFOOT);
286         else
287 #endif
288
ragge
1.6
289         for(i = 0 ; i<argc ; ++i)
290                 switch(c =  dotchar(infname = argv[i]) ) {
ragge
1.1
291                 case 'r':       /* Ratfor file */
292                 case 'e':       /* EFL file */
293                         ifunreadable(argv[i]) )
294                                 break;
295                         s = fortfile;
296                         t = lastfield(argv[i]);
ragge
1.2
297                         while(( *s++ = *t++))
ragge
1.1
298                                 ;
299                         s[-2] = 'f';
300
ragge
1.6
301                         if(macroflag) {
ragge
1.2
302                                 sprintf(buff"%s %s >%s"macronameinfnameprepfname);
ragge
1.6
303                                 if(sys(buff)) {
ragge
1.1
304                                         rmf(prepfname);
305                                         break;
ragge
1.6
306                                 }
ragge
1.1
307                                 infname = prepfname;
ragge
1.6
308                         }
ragge
1.1
309
310                         if(c == 'e')
311                                 sprintf(buff"efl %s %s >%s"eflagsinfnamefortfile);
312                         else
313                                 sprintf(buff"ratfor %s %s >%s"rflagsinfnamefortfile);
314                         status = sys(buff);
315                         if(macroflag)
316                                 rmf(infname);
ragge
1.6
317                         if(status) {
ragge
1.1
318                                 loadflag = NO;
319                                 rmf(fortfile);
320                                 break;
ragge
1.6
321                         }
ragge
1.1
322
ragge
1.6
323                         if( ! fortonly ) {
ragge
1.1
324                                 infname = argv[i] = lastfield(argv[i]);
325                                 *lastchar(infname) = 'f';
326         
327                                 ifdofort(argv[i]) )
328                                         loadflag = NO;
329                                 else    {
330                                         ifnodup(t = setdoto(argv[i])) )
331                                                 *loadp++ = t;
332                                         rmf(fortfile);
333                                 }
ragge
1.6
334                         }
ragge
1.1
335                         break;
336
337                 case 'f':       /* Fortran file */
338                 case 'F':
339                         ifunreadable(argv[i]) )
340                                 break;
341                         ifdofort(argv[i]) )
342                                 loadflag = NO;
343                         else ifnodup(t=setdoto(argv[i])) )
344                                 *loadp++ = t;
345                         break;
346
347                 case 'c':       /* C file */
348                 case 's':       /* Assembler file */
349                         ifunreadable(argv[i]) )
350                                 break;
351                         fprintf(diagfile"%s:\n"argv[i]);
352                         sprintf(buff"cc -c %s"argv[i] );
353                         ifsys(buff) )
354                                 loadflag = NO;
355                         else
356                                 ifnodup(t = setdoto(argv[i])) )
357                                         *loadp++ = t;
358                         break;
359
360                 case 'o':
361                         ifnodup(argv[i]) )
362                                 *loadp++ = argv[i];
363                         break;
364
365                 default:
366                         if( ! strcmp(argv[i], "-o") )
367                                 aoutname = argv[++i];
368                         else
369                                 *loadp++ = argv[i];
370                         break;
371                 }
372
ragge
1.6
373         if(loadflag)
374                 doload(loadargsloadp);
375         done(0);
376         return 0;
ragge
1.1
377 }
ragge
1.6
378
sgk
1.15
379 #define ADD(x)  addarg(params, &nparms, (x))
380
ragge
1.2
381 int
ragge
1.6
382 dofort(char *s)
383 {
384         int nparmsi;
385         char *params[MAXARGS];
386
387         nparms = 0;
sgk
1.15
388         ADD(FCOM);
ragge
1.6
389         for (i = 0i < ffmaxi++)
sgk
1.15
390                 ADD(ffary[i]);
391         ADD(s);
392         ADD(asmfname);
393         ADD(NULL);
ragge
1.6
394
395         infname = s;
396         if (callsys(fcomparams))
397                 errorx("Error.  No assembly.");
398         doasm(s);
ragge
1.1
399
ragge
1.8
400         if (saveasmflag == NO)
401                 rmf(asmfname);
ragge
1.6
402         return(0);
ragge
1.1
403 }
404
405
ragge
1.2
406 void
ragge
1.6
407 doasm(char *s)
ragge
1.1
408 {
ragge
1.6
409         char *obj;
410         char *params[MAXARGS];
411         int nparms;
ragge
1.1
412
ragge
1.10
413         if (oflag && loadflag == NO)
ragge
1.9
414                 obj = aoutname;
415         else
416                 obj = setdoto(s);
ragge
1.1
417
ragge
1.6
418         nparms = 0;
sgk
1.15
419         ADD(asmname);
420         ADD("-o");
421         ADD(obj);
422         ADD(asmfname);
423         ADD(NULL);
ragge
1.1
424
ragge
1.6
425         if (callsys(asmnameparams))
sgk
1.13
426                 fatal1("assembler error");
ragge
1.1
427         if(verbose)
428                 fprintf(diagfile"\n");
429 }
430
431
432
ragge
1.2
433 void
ragge
1.6
434 doload(char *v0[], char *v[])
ragge
1.1
435 {
ragge
1.6
436         int nparmsi;
437         char *params[MAXARGS];
438         char **p;
439
440         nparms = 0;
441         ADD(ldname);
442         ADD("-X");
443         ADD("-d");
444         for (i = 0dynlinker[i]; i++)
445                 ADD(dynlinker[i]);
446         ADD("-o");
447         ADD(aoutname);
448         ADD(crt0file);
449         for (i = 0startfiles[i]; i++)
450                 ADD(startfiles[i]);
451         *v = NULL;
452         for(p = v0; *p ; p++)
453                 ADD(*p);
ragge
1.12
454         if (libdir)
455                 ADD(libdir);
ragge
1.6
456         for(p = liblist ; *p ; p++)
457                 ADD(*p);
458         for (i = 0endfiles[i]; i++)
459                 ADD(endfiles[i]);
sgk
1.15
460         ADD(NULL);
ragge
1.1
461
ragge
1.6
462         if (callsys(ldnameparams))
ragge
1.1
463                 fatal1("couldn't load %s"ldname);
464
ragge
1.6
465         if(verbose)
466                 fprintf(diagfile"\n");
ragge
1.1
467 }
ragge
1.6
468
ragge
1.1
469 /* Process control and Shell-simulating routines */
470
ragge
1.6
471 /*
472  * Execute f[] with parameter array v[].
473  * Copied from cc.
474  */
ragge
1.2
475 int
ragge
1.6
476 callsys(char f[], char *v[])
ragge
1.1
477 {
ragge
1.6
478         int tstatus = 0;
479         pid_t p;
480         char *s;
481
ragge
1.12
482         if (debugflag || verbose) {
ragge
1.6
483                 fprintf(stderr"%s "f);
484                 for (t = 1v[t]; t++)
485                         fprintf(stderr"%s "v[t]);
486                 fprintf(stderr"\n");
487         }
488
489         if ((p = fork()) == 0) {
490 #ifdef notyet
491                 if (Bflag) {
492                         size_t len = strlen(Bflag) + 8;
493                         char *a = malloc(len);
494                         if (a == NULL) {
495                                 error("callsys: malloc failed");
496                                 exit(1);
ragge
1.1
497                         }
ragge
1.6
498                         if ((s = strrchr(f'/'))) {
499                                 strlcpy(aBflaglen);
500                                 strlcat(aslen);
501                                 execv(av);
ragge
1.1
502                         }
503                 }
ragge
1.6
504 #endif
505                 execvp(fv);
506                 if ((s = strrchr(f'/')))
507                         execvp(s+1v);
508                 fprintf(stderr"Can't find %s\n"f);
509                 _exit(100);
510         } else {
511                 if (p == -1) {
512                         printf("Try again\n");
513                         return(100);
514                 }
515         }
516         while (waitpid(p, &status0) == -1 && errno == EINTR)
517                 ;
518         if (WIFEXITED(status))
519                 return (WEXITSTATUS(status));
520         if (WIFSIGNALED(status))
521                 done(1);
522         fatal1("Fatal error in %s"f);
523         return 0/* XXX */
524 }
525
526
527 int
528 sys(char *str)
529 {
530         register char *s, *t;
531         char *argv[100], path[100];
532         char *inname, *outname;
533         int append = 0;
ragge
1.12
534         int wait_pid;
ragge
1.6
535         int argc;
536
537
538         if(debugflag)
539                 fprintf(diagfile"%s\n"str);
540         inname  = NULL;
541         outname = NULL;
542         argv[0] = shellname;
543         argc = 1;
544
545         t = str;
546         whileisspace((int)*t) )
ragge
1.1
547                 ++t;
ragge
1.6
548         while(*t) {
549                 if(*t == '<')
550                         inname = t+1;
551                 else if(*t == '>') {
552                         if(t[1] == '>') {
553                                 append = YES;
554                                 outname = t+2;
555                         } else  {
556                                 append = NO;
557                                 outname = t+1;
558                         }
559                 } else
560                         argv[argc++] = t;
561                 while( !isspace((int)*t) && *t!='\0' )
ragge
1.1
562                         ++t;
ragge
1.6
563                 if(*t) {
564                         *t++ = '\0';
565                         whileisspace((int)*t) )
566                                 ++t;
ragge
1.1
567                 }
568         }
569
ragge
1.6
570         if(argc == 1)   /* no command */
571                 return(-1);
572         argv[argc] = 0;
573
574         s = path;
575         t = "/usr/bin/";
576         while(*t)
577                 *s++ = *t++;
578         for(t = argv[1] ; (*s++ = *t++) ; )
579                 ;
ragge
1.12
580         if((wait_pid = fork()) == 0) {
ragge
1.6
581                 if(inname)
582                         freopen(inname"r"stdin);
583                 if(outname)
584                         freopen(outname, (append ? "a" : "w"), stdout);
585                 enbint(SIG_DFL);
586
587                 texec(path+9argv);  /* command */
588                 texec(path+4argv);  /*  /bin/command */
589                 texec(path  , argv);  /* /usr/bin/command */
ragge
1.1
590
ragge
1.6
591                 fatal1("Cannot load %s",path+9);
ragge
1.1
592         }
593
ragge
1.12
594         returnawait(wait_pid) );
ragge
1.1
595 }
596
597 /* modified version from the Shell */
ragge
1.2
598 void
ragge
1.6
599 texec(char *fchar **av)
ragge
1.1
600 {
601
ragge
1.6
602         execv(fav+1);
ragge
1.1
603
ragge
1.6
604         if (errno==ENOEXEC) {
605                 av[1] = f;
606                 execv(shellnameav);
sgk
1.13
607                 fatal1("No shell!");
ragge
1.1
608         }
ragge
1.6
609         if (errno==ENOMEM)
610                 fatal1("%s: too large"f);
ragge
1.1
611 }
612
ragge
1.6
613 /*
614  * Cleanup and exit with value k.
615  */
ragge
1.2
616 void
ragge
1.6
617 done(int k)
ragge
1.1
618 {
ragge
1.6
619         static int recurs       = NO;
ragge
1.1
620
ragge
1.6
621         if(recurs == NO) {
622                 recurs = YES;
sgk
1.13
623                 if (saveasmflag == NO)
624                         rmf(asmfname);
ragge
1.1
625         }
ragge
1.6
626         exit(k);
ragge
1.1
627 }
628
629
ragge
1.2
630 void
ragge
1.1
631 enbint(k)
ragge
1.2
632 void (*k)(int);
ragge
1.1
633 {
634 if(sigivalue == 0)
635         signal(SIGINT,k);
636 if(sigqvalue == 0)
637         signal(SIGQUIT,k);
638 }
639
640
641
ragge
1.2
642 void
643 intrupt(int a)
ragge
1.1
644 {
645 done(2);
646 }
647
648
ragge
1.2
649 int
ragge
1.12
650 await(wait_pid)
651 int wait_pid;
ragge
1.1
652 {
653 int wstatus;
654
655 enbint(SIG_IGN);
ragge
1.12
656 while ( (w = wait(&status)) != wait_pid)
ragge
1.1
657         if(w == -1)
sgk
1.13
658                 fatal1("bad wait code");
ragge
1.1
659 enbint(intrupt);
660 if(status & 0377)
661         {
662         if(status != SIGINT)
663                 fprintf(diagfile"Termination code %d"status);
664         done(3);
665         }
666 return(status>>8);
667 }
668
669 /* File Name and File Manipulation Routines */
670
ragge
1.2
671 int
ragge
1.6
672 unreadable(char *s)
ragge
1.1
673 {
ragge
1.6
674         FILE *fp;
ragge
1.1
675
ragge
1.6
676         if((fp = fopen(s"r"))) {
677                 fclose(fp);
678                 return(NO);
679         } else {
680                 fprintf(diagfile"Error: Cannot read file %s\n"s);
681                 loadflag = NO;
682                 return(YES);
ragge
1.1
683         }
684 }
685
686
ragge
1.2
687 void
sgk
1.13
688 crfnames(void)
ragge
1.1
689 {
sgk
1.13
690         sprintf(asmfname,  "fort%d.%s"pid"s");
691         sprintf(prepfname"fort%d.%s"pid"p");
ragge
1.1
692 }
693
694
695
ragge
1.2
696 void
ragge
1.1
697 rmf(fn)
698 register char *fn;
699 {
700 if(!debugflag && fn!=NULL && *fn!='\0')
701         unlink(fn);
702 }
703
704
ragge
1.2
705 int
ragge
1.1
706 dotchar(s)
707 register char *s;
708 {
709 for( ; *s ; ++s)
710         if(s[0]=='.' && s[1]!='\0' && s[2]=='\0')
711                 returns[1] );
712 return(NO);
713 }
714
715
716
717 char *lastfield(s)
718 register char *s;
719 {
720 register char *t;
721 for(t = s; *s ; ++s)
722         if(*s == '/')
723                 t = s+1;
724 return(t);
725 }
726
727
728
729 char *lastchar(s)
730 register char *s;
731 {
732 while(*s)
733         ++s;
734 return(s-1);
735 }
736
737 char *setdoto(s)
738 register char *s;
739 {
740 *lastchar(s) = 'o';
741 returnlastfield(s) );
742 }
743
744
745 ptr ckalloc(n)
746 int n;
747 {
ragge
1.2
748 ptr p;
ragge
1.1
749
ragge
1.2
750 if( (p = calloc(1, (unsignedn) ))
ragge
1.1
751         return(p);
752
sgk
1.13
753 fatal1("out of memory");
ragge
1.1
754 /* NOTREACHED */
ragge
1.2
755 return NULL;
ragge
1.1
756 }
757
758
sgk
1.18
759 static char *
760 copyn(int nchar *s)
ragge
1.1
761 {
sgk
1.18
762         char *p, *q;
ragge
1.1
763
sgk
1.18
764         p = q = (char *)ckalloc(n + 1);
765         while(n-- > 0)
766                 *q++ = *s++;
767         return (p);
ragge
1.1
768 }
769
770
ragge
1.2
771 int
ragge
1.1
772 nodup(s)
773 char *s;
774 {
775 register char **p;
776
777 for(p = loadargs ; p < loadp ; ++p)
778         if( !strcmp(*ps) )
779                 return(NO);
780
781 return(YES);
782 }
783
784
sgk
1.17
785 static void
ragge
1.6
786 errorx(char *fmt, ...)
787 {
788         va_list ap;
789
790         va_start(apfmt);
791         vfprintf(diagfilefmtap);
792         fprintf(diagfile"\n");
793         va_end(ap);
ragge
1.1
794
ragge
1.6
795         if (debugflag)
796                 abort();
797         done(1);
798 }
ragge
1.1
799
800
ragge
1.4
801 static void
802 fatal1(char *fmt, ...)
ragge
1.1
803 {
ragge
1.4
804         va_list ap;
805
806         va_start(apfmt);
807         fprintf(diagfile"Compiler error in file %s: "infname);
808         vfprintf(diagfilefmtap);
809         fprintf(diagfile"\n");
810         va_end(ap);
811
812         if (debugflag)
813                 abort();
814         done(1);
ragge
1.1
815 }
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-09-21 18:09 +0200