Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:mickey:20110804083232

Diff

Diff from 1.22 to:

Annotations

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

Annotated File View

mickey
1.22
1 /*      $Id: f77.c,v 1.22 2011/08/04 08:32:32 mickey 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 #define YES 1
54 #define NO 0
ragge
1.1
55
ragge
1.7
56 FILEP diagfile;
57
ragge
1.1
58 static int pid;
59 static int sigivalue    = 0;
60 static int sigqvalue    = 0;
61
ragge
1.5
62 #ifndef FCOM
63 #define FCOM            "fcom"
64 #endif
65
ragge
1.6
66 #ifndef ASSEMBLER
67 #define ASSEMBLER       "as"
68 #endif
69
70 #ifndef LINKER
71 #define LINKER          "ld"
72 #endif
73
ragge
1.5
74 static char *fcom       = LIBEXECDIR "/" FCOM ;
ragge
1.6
75 static char *asmname    = ASSEMBLER ;
76 static char *ldname     = LINKER ;
77 static char *startfiles[] = STARTFILES;
78 static char *endfiles[] = ENDFILES;
79 static char *dynlinker[] = DYNLINKER;
80 static char *crt0file = CRT0FILE;
ragge
1.1
81 static char *macroname  = "m4";
82 static char *shellname  = "/bin/sh";
83 static char *aoutname   = "a.out" ;
ragge
1.12
84 static char *libdir     = LIBDIR ;
ragge
1.6
85 static char *liblist[] = F77LIBLIST;
ragge
1.1
86
87 static char *infname;
88 static char asmfname[15];
89 static char prepfname[15];
90
ragge
1.6
91 #define MAXARGS 100
92 int ffmax;
93 static char *ffary[MAXARGS];
ragge
1.1
94 static char eflags[30]  = "";
95 static char rflags[30]  = "";
96 static char lflag[3]    = "-x";
97 static char *eflagp     = eflags;
98 static char *rflagp     = rflags;
99 static char **loadargs;
100 static char **loadp;
ragge
1.9
101 static int oflag;
ragge
1.1
102
103 static flag loadflag    = YES;
104 static flag saveasmflag = NO;
105 static flag profileflag = NO;
106 static flag optimflag   = NO;
107 static flag debugflag   = NO;
108 static flag verbose     = NO;
109 static flag fortonly    = NO;
110 static flag macroflag   = NO;
111
sgk
1.20
112 static char *setdoto(char *), *lastchar(char *), *lastfield(char *);
113 static void intrupt(int);
114 static void enbint(void (*)(int));
115 static void crfnames(void);
ragge
1.4
116 static void fatal1(char *, ...);
sgk
1.20
117 static void done(int), texec(char *, char **);
sgk
1.18
118 static char *copyn(intchar *);
sgk
1.20
119 static int dotchar(char *), unreadable(char *), sys(char *), dofort(char *);
120 static int nodup(char *);
121 static int await(int);
122 static void rmf(char *), doload(char *[], char *[]), doasm(char *);
123 static int callsys(char *, char **);
124 static void errorx(char *, ...);
ragge
1.6
125
126 static void
127 addarg(char **aryint *numchar *arg)
128 {
129         ary[(*num)++] = arg;
130         if ((*num) == MAXARGS) {
131                 fprintf(stderr"argument array too small\n");
132                 exit(1);
133         }
134 }
ragge
1.2
135
136 int
137 main(int argcchar **argv)
ragge
1.1
138 {
ragge
1.6
139         int icstatus;
sgk
1.20
140         char *s;
ragge
1.6
141         char fortfile[20], *t;
142         char buff[100];
143
ragge
1.7
144         diagfile = stderr;
145
ragge
1.6
146         sigivalue = (intsignal(SIGINTSIG_IGN) & 01;
147         sigqvalue = (intsignal(SIGQUITSIG_IGN) & 01;
148         enbint(intrupt);
ragge
1.1
149
ragge
1.6
150         pid = getpid();
151         crfnames();
ragge
1.1
152
sgk
1.20
153         loadargs = (char **)calloc(1, (argc + 20) * sizeof(*loadargs));
154         if (!loadargs)
155                 fatal1("out of memory");
ragge
1.6
156         loadp = loadargs;
ragge
1.1
157
ragge
1.6
158         --argc;
159         ++argv;
ragge
1.1
160
ragge
1.6
161         while(argc>0 && argv[0][0]=='-' && argv[0][1]!='\0') {
162                 for(s = argv[0]+1 ; *s ; ++s)
163                         switch(*s) {
164                         case 'T':  /* use special passes */
165                                 switch(*++s) {
ragge
1.1
166                                 case '1':
ragge
1.5
167                                         fcom = s+1goto endfor;
ragge
1.1
168                                 case 'a':
169                                         asmname = s+1goto endfor;
170                                 case 'l':
171                                         ldname = s+1goto endfor;
172                                 case 'm':
173                                         macroname = s+1goto endfor;
174                                 default:
175                                         fatal1("bad option -T%c", *s);
176                                 }
ragge
1.6
177                                 break;
178
179                         case 'w'/* F66 warn or no warn */
180                                 addarg(ffary, &ffmaxs-1);
181                                 break;
ragge
1.1
182
sgk
1.16
183                         case 'q':
184                                 /*
185                                  * Suppress printing of procedure names during
186                                  * compilation.
187                                  */
188                                 addarg(ffary, &ffmaxs-1);
189                                 break;
190
ragge
1.6
191                         copyfflag:
192                         case 'u':
193                         case 'U':
194                         case 'M':
195                         case '1':
196                         case 'C':
197                                 addarg(ffary, &ffmaxs-1);
198                                 break;
ragge
1.1
199
ragge
1.6
200                         case 'O':
201                                 optimflag = YES;
202                                 addarg(ffary, &ffmaxs-1);
203                                 break;
ragge
1.1
204
ragge
1.6
205                         case 'm':
206                                 if(s[1] == '4')
207                                         ++s;
208                                 macroflag = YES;
209                                 break;
ragge
1.1
210
ragge
1.6
211                         case 'S':
212                                 saveasmflag = YES;
ragge
1.1
213
ragge
1.6
214                         case 'c':
215                                 loadflag = NO;
216                                 break;
ragge
1.1
217
ragge
1.6
218                         case 'v':
219                                 verbose = YES;
220                                 break;
ragge
1.1
221
ragge
1.6
222                         case 'd':
223                                 debugflag = YES;
224                                 goto copyfflag;
ragge
1.1
225
ragge
1.6
226                         case 'p':
227                                 profileflag = YES;
228                                 goto copyfflag;
ragge
1.1
229
ragge
1.6
230                         case 'o':
231                                 if(!strcmp(s"onetrip")) {
232                                         addarg(ffary, &ffmaxs-1);
233                                         goto endfor;
ragge
1.1
234                                 }
ragge
1.9
235                                 oflag = 1;
ragge
1.6
236                                 aoutname = *++argv;
237                                 --argc;
238                                 break;
ragge
1.1
239
ragge
1.6
240                         case 'F':
241                                 fortonly = YES;
242                                 loadflag = NO;
243                                 break;
ragge
1.1
244
ragge
1.6
245                         case 'I':
246                                 if(s[1]=='2' || s[1]=='4' || s[1]=='s')
247                                         goto copyfflag;
248                                 fprintf(diagfile"invalid flag -I%c\n"s[1]);
249                                 done(1);
250
251                         case 'l':       /* letter ell--library */
252                                 s[-1] = '-';
253                                 *loadp++ = s-1;
254                                 goto endfor;
ragge
1.1
255
ragge
1.6
256                         case 'E':       /* EFL flag argument */
257                                 while(( *eflagp++ = *++s))
258                                         ;
259                                 *eflagp++ = ' ';
260                                 goto endfor;
261                         case 'R':
262                                 while(( *rflagp++ = *++s ))
263                                         ;
264                                 *rflagp++ = ' ';
265                                 goto endfor;
266                         default:
267                                 lflag[1] = *s;
sgk
1.18
268                                 *loadp++ = copyn(strlen(lflag), lflag);
ragge
1.6
269                                 break;
270                         }
ragge
1.1
271 endfor:
272         --argc;
273         ++argv;
274         }
275
ragge
1.6
276         if (verbose)
277                 fprintf(stderrxxxvers);
278
279         if (argc == 0)
280                 errorx("No input files");
281
ragge
1.4
282 #ifdef mach_pdp11
ragge
1.1
283         if(nofloating)
284                 *loadp++ = (profileflag ? NOFLPROF : NOFLFOOT);
285         else
286 #endif
287
ragge
1.6
288         for(i = 0 ; i<argc ; ++i)
289                 switch(c =  dotchar(infname = argv[i]) ) {
ragge
1.1
290                 case 'r':       /* Ratfor file */
291                 case 'e':       /* EFL file */
292                         ifunreadable(argv[i]) )
293                                 break;
294                         s = fortfile;
295                         t = lastfield(argv[i]);
ragge
1.2
296                         while(( *s++ = *t++))
ragge
1.1
297                                 ;
298                         s[-2] = 'f';
299
ragge
1.6
300                         if(macroflag) {
mickey
1.22
301                                 snprintf(buffsizeof(buff), "%s %s >%s",
302                                     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')
mickey
1.22
311                                 snprintf(buffsizeof(buff), "efl %s %s >%s",
312                                     eflagsinfnamefortfile);
ragge
1.1
313                         else
mickey
1.22
314                                 snprintf(buffsizeof(buff), "ratfor %s %s >%s",
315                                     rflagsinfnamefortfile);
ragge
1.1
316                         status = sys(buff);
317                         if(macroflag)
318                                 rmf(infname);
ragge
1.6
319                         if(status) {
ragge
1.1
320                                 loadflag = NO;
321                                 rmf(fortfile);
322                                 break;
ragge
1.6
323                         }
ragge
1.1
324
ragge
1.6
325                         if( ! fortonly ) {
ragge
1.1
326                                 infname = argv[i] = lastfield(argv[i]);
327                                 *lastchar(infname) = 'f';
328         
329                                 ifdofort(argv[i]) )
330                                         loadflag = NO;
331                                 else    {
332                                         ifnodup(t = setdoto(argv[i])) )
333                                                 *loadp++ = t;
334                                         rmf(fortfile);
335                                 }
ragge
1.6
336                         }
ragge
1.1
337                         break;
338
339                 case 'f':       /* Fortran file */
340                 case 'F':
341                         ifunreadable(argv[i]) )
342                                 break;
343                         ifdofort(argv[i]) )
344                                 loadflag = NO;
345                         else ifnodup(t=setdoto(argv[i])) )
346                                 *loadp++ = t;
347                         break;
348
349                 case 'c':       /* C file */
350                 case 's':       /* Assembler file */
351                         ifunreadable(argv[i]) )
352                                 break;
353                         fprintf(diagfile"%s:\n"argv[i]);
mickey
1.22
354                         snprintf(buffsizeof(buff), "cc -c %s"argv[i]);
ragge
1.1
355                         ifsys(buff) )
356                                 loadflag = NO;
357                         else
358                                 ifnodup(t = setdoto(argv[i])) )
359                                         *loadp++ = t;
360                         break;
361
362                 case 'o':
363                         ifnodup(argv[i]) )
364                                 *loadp++ = argv[i];
365                         break;
366
367                 default:
368                         if( ! strcmp(argv[i], "-o") )
369                                 aoutname = argv[++i];
370                         else
371                                 *loadp++ = argv[i];
372                         break;
373                 }
374
ragge
1.6
375         if(loadflag)
376                 doload(loadargsloadp);
377         done(0);
378         return 0;
ragge
1.1
379 }
ragge
1.6
380
sgk
1.15
381 #define ADD(x)  addarg(params, &nparms, (x))
382
sgk
1.20
383 static int
ragge
1.6
384 dofort(char *s)
385 {
386         int nparmsi;
387         char *params[MAXARGS];
388
389         nparms = 0;
sgk
1.15
390         ADD(FCOM);
ragge
1.6
391         for (i = 0i < ffmaxi++)
sgk
1.15
392                 ADD(ffary[i]);
393         ADD(s);
394         ADD(asmfname);
395         ADD(NULL);
ragge
1.6
396
397         infname = s;
398         if (callsys(fcomparams))
399                 errorx("Error.  No assembly.");
400         doasm(s);
ragge
1.1
401
ragge
1.8
402         if (saveasmflag == NO)
403                 rmf(asmfname);
ragge
1.6
404         return(0);
ragge
1.1
405 }
406
407
sgk
1.20
408 static void
ragge
1.6
409 doasm(char *s)
ragge
1.1
410 {
ragge
1.6
411         char *obj;
412         char *params[MAXARGS];
413         int nparms;
ragge
1.1
414
ragge
1.10
415         if (oflag && loadflag == NO)
ragge
1.9
416                 obj = aoutname;
417         else
418                 obj = setdoto(s);
ragge
1.1
419
ragge
1.6
420         nparms = 0;
sgk
1.15
421         ADD(asmname);
422         ADD("-o");
423         ADD(obj);
424         ADD(asmfname);
425         ADD(NULL);
ragge
1.1
426
ragge
1.6
427         if (callsys(asmnameparams))
sgk
1.13
428                 fatal1("assembler error");
ragge
1.1
429         if(verbose)
430                 fprintf(diagfile"\n");
431 }
432
433
sgk
1.20
434 static void
ragge
1.6
435 doload(char *v0[], char *v[])
ragge
1.1
436 {
ragge
1.6
437         int nparmsi;
438         char *params[MAXARGS];
439         char **p;
440
441         nparms = 0;
442         ADD(ldname);
443         ADD("-X");
444         ADD("-d");
445         for (i = 0dynlinker[i]; i++)
446                 ADD(dynlinker[i]);
447         ADD("-o");
448         ADD(aoutname);
449         ADD(crt0file);
450         for (i = 0startfiles[i]; i++)
451                 ADD(startfiles[i]);
452         *v = NULL;
453         for(p = v0; *p ; p++)
454                 ADD(*p);
ragge
1.12
455         if (libdir)
456                 ADD(libdir);
ragge
1.6
457         for(p = liblist ; *p ; p++)
458                 ADD(*p);
459         for (i = 0endfiles[i]; i++)
460                 ADD(endfiles[i]);
sgk
1.15
461         ADD(NULL);
ragge
1.1
462
ragge
1.6
463         if (callsys(ldnameparams))
ragge
1.1
464                 fatal1("couldn't load %s"ldname);
465
ragge
1.6
466         if(verbose)
467                 fprintf(diagfile"\n");
ragge
1.1
468 }
ragge
1.6
469
ragge
1.1
470 /* Process control and Shell-simulating routines */
471
ragge
1.6
472 /*
473  * Execute f[] with parameter array v[].
474  * Copied from cc.
475  */
sgk
1.20
476 static int
ragge
1.6
477 callsys(char f[], char *v[])
ragge
1.1
478 {
ragge
1.6
479         int tstatus = 0;
480         pid_t p;
481         char *s;
482
ragge
1.12
483         if (debugflag || verbose) {
ragge
1.6
484                 fprintf(stderr"%s "f);
485                 for (t = 1v[t]; t++)
486                         fprintf(stderr"%s "v[t]);
487                 fprintf(stderr"\n");
488         }
489
490         if ((p = fork()) == 0) {
491 #ifdef notyet
492                 if (Bflag) {
493                         size_t len = strlen(Bflag) + 8;
494                         char *a = malloc(len);
495                         if (a == NULL) {
496                                 error("callsys: malloc failed");
497                                 exit(1);
ragge
1.1
498                         }
ragge
1.6
499                         if ((s = strrchr(f'/'))) {
500                                 strlcpy(aBflaglen);
501                                 strlcat(aslen);
502                                 execv(av);
ragge
1.1
503                         }
504                 }
ragge
1.6
505 #endif
506                 execvp(fv);
507                 if ((s = strrchr(f'/')))
508                         execvp(s+1v);
509                 fprintf(stderr"Can't find %s\n"f);
510                 _exit(100);
511         } else {
512                 if (p == -1) {
513                         printf("Try again\n");
514                         return(100);
515                 }
516         }
517         while (waitpid(p, &status0) == -1 && errno == EINTR)
518                 ;
519         if (WIFEXITED(status))
520                 return (WEXITSTATUS(status));
521         if (WIFSIGNALED(status))
522                 done(1);
523         fatal1("Fatal error in %s"f);
524         return 0/* XXX */
525 }
526
527
sgk
1.20
528 static int
ragge
1.6
529 sys(char *str)
530 {
sgk
1.20
531         char *s, *t;
ragge
1.6
532         char *argv[100], path[100];
533         char *inname, *outname;
534         int append = 0;
ragge
1.12
535         int wait_pid;
ragge
1.6
536         int argc;
537
538
539         if(debugflag)
540                 fprintf(diagfile"%s\n"str);
541         inname  = NULL;
542         outname = NULL;
543         argv[0] = shellname;
544         argc = 1;
545
546         t = str;
547         whileisspace((int)*t) )
ragge
1.1
548                 ++t;
ragge
1.6
549         while(*t) {
550                 if(*t == '<')
551                         inname = t+1;
552                 else if(*t == '>') {
553                         if(t[1] == '>') {
554                                 append = YES;
555                                 outname = t+2;
556                         } else  {
557                                 append = NO;
558                                 outname = t+1;
559                         }
560                 } else
561                         argv[argc++] = t;
562                 while( !isspace((int)*t) && *t!='\0' )
ragge
1.1
563                         ++t;
ragge
1.6
564                 if(*t) {
565                         *t++ = '\0';
566                         whileisspace((int)*t) )
567                                 ++t;
ragge
1.1
568                 }
569         }
570
ragge
1.6
571         if(argc == 1)   /* no command */
572                 return(-1);
573         argv[argc] = 0;
574
575         s = path;
576         t = "/usr/bin/";
577         while(*t)
578                 *s++ = *t++;
579         for(t = argv[1] ; (*s++ = *t++) ; )
580                 ;
ragge
1.12
581         if((wait_pid = fork()) == 0) {
ragge
1.6
582                 if(inname)
583                         freopen(inname"r"stdin);
584                 if(outname)
585                         freopen(outname, (append ? "a" : "w"), stdout);
586                 enbint(SIG_DFL);
587
588                 texec(path+9argv);  /* command */
589                 texec(path+4argv);  /*  /bin/command */
590                 texec(path  , argv);  /* /usr/bin/command */
ragge
1.1
591
ragge
1.6
592                 fatal1("Cannot load %s",path+9);
ragge
1.1
593         }
594
ragge
1.12
595         returnawait(wait_pid) );
ragge
1.1
596 }
597
598 /* modified version from the Shell */
sgk
1.20
599 static void
ragge
1.6
600 texec(char *fchar **av)
ragge
1.1
601 {
602
ragge
1.6
603         execv(fav+1);
ragge
1.1
604
ragge
1.6
605         if (errno==ENOEXEC) {
606                 av[1] = f;
607                 execv(shellnameav);
sgk
1.13
608                 fatal1("No shell!");
ragge
1.1
609         }
ragge
1.6
610         if (errno==ENOMEM)
611                 fatal1("%s: too large"f);
ragge
1.1
612 }
613
ragge
1.6
614 /*
615  * Cleanup and exit with value k.
616  */
sgk
1.20
617 static void
ragge
1.6
618 done(int k)
ragge
1.1
619 {
ragge
1.6
620         static int recurs       = NO;
ragge
1.1
621
ragge
1.6
622         if(recurs == NO) {
623                 recurs = YES;
sgk
1.13
624                 if (saveasmflag == NO)
625                         rmf(asmfname);
ragge
1.1
626         }
ragge
1.6
627         exit(k);
ragge
1.1
628 }
629
630
sgk
1.20
631 static void
632 enbint(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
sgk
1.20
642 static void
ragge
1.2
643 intrupt(int a)
ragge
1.1
644 {
645 done(2);
646 }
647
648
sgk
1.20
649 static int
650 await(int wait_pid)
ragge
1.1
651 {
652 int wstatus;
653
654 enbint(SIG_IGN);
ragge
1.12
655 while ( (w = wait(&status)) != wait_pid)
ragge
1.1
656         if(w == -1)
sgk
1.13
657                 fatal1("bad wait code");
ragge
1.1
658 enbint(intrupt);
659 if(status & 0377)
660         {
661         if(status != SIGINT)
662                 fprintf(diagfile"Termination code %d"status);
663         done(3);
664         }
665 return(status>>8);
666 }
667
668 /* File Name and File Manipulation Routines */
669
sgk
1.20
670 static int
ragge
1.6
671 unreadable(char *s)
ragge
1.1
672 {
ragge
1.6
673         FILE *fp;
ragge
1.1
674
ragge
1.6
675         if((fp = fopen(s"r"))) {
676                 fclose(fp);
677                 return(NO);
678         } else {
679                 fprintf(diagfile"Error: Cannot read file %s\n"s);
680                 loadflag = NO;
681                 return(YES);
ragge
1.1
682         }
683 }
684
685
sgk
1.20
686 static void
sgk
1.13
687 crfnames(void)
ragge
1.1
688 {
mickey
1.22
689         snprintf(asmfname,  sizeof(asmfname),  "fort%d.%s"pid"s");
690         snprintf(prepfnamesizeof(prepfname), "fort%d.%s"pid"p");
ragge
1.1
691 }
692
693
694
sgk
1.20
695 static void
696 rmf(char *fn)
ragge
1.1
697 {
698 if(!debugflag && fn!=NULL && *fn!='\0')
699         unlink(fn);
700 }
701
702
sgk
1.20
703 static int
704 dotchar(char *s)
ragge
1.1
705 {
706 for( ; *s ; ++s)
707         if(s[0]=='.' && s[1]!='\0' && s[2]=='\0')
708                 returns[1] );
709 return(NO);
710 }
711
712
sgk
1.20
713 static char *
714 lastfield(char *s)
ragge
1.1
715 {
sgk
1.20
716 char *t;
ragge
1.1
717 for(t = s; *s ; ++s)
718         if(*s == '/')
719                 t = s+1;
720 return(t);
721 }
722
723
sgk
1.20
724 static char *
725 lastchar(char *s)
ragge
1.1
726 {
727 while(*s)
728         ++s;
729 return(s-1);
730 }
731
sgk
1.20
732
733 static char *
734 setdoto(char *s)
ragge
1.1
735 {
736 *lastchar(s) = 'o';
737 returnlastfield(s) );
738 }
739
740
sgk
1.18
741 static char *
742 copyn(int nchar *s)
ragge
1.1
743 {
sgk
1.18
744         char *p, *q;
ragge
1.1
745
sgk
1.20
746         p = q = (char *)calloc(1, (unsignedn + 1);
747         if (!p)
748                 fatal1("out of memory");
749
sgk
1.18
750         while(n-- > 0)
751                 *q++ = *s++;
752         return (p);
ragge
1.1
753 }
754
755
sgk
1.20
756 static int
757 nodup(char *s)
ragge
1.1
758 {
sgk
1.20
759 char **p;
ragge
1.1
760
761 for(p = loadargs ; p < loadp ; ++p)
762         if( !strcmp(*ps) )
763                 return(NO);
764
765 return(YES);
766 }
767
768
sgk
1.17
769 static void
ragge
1.6
770 errorx(char *fmt, ...)
771 {
772         va_list ap;
773
774         va_start(apfmt);
775         vfprintf(diagfilefmtap);
776         fprintf(diagfile"\n");
777         va_end(ap);
ragge
1.1
778
ragge
1.6
779         if (debugflag)
780                 abort();
781         done(1);
782 }
ragge
1.1
783
784
ragge
1.4
785 static void
786 fatal1(char *fmt, ...)
ragge
1.1
787 {
ragge
1.4
788         va_list ap;
789
790         va_start(apfmt);
791         fprintf(diagfile"Compiler error in file %s: "infname);
792         vfprintf(diagfilefmtap);
793         fprintf(diagfile"\n");
794         va_end(ap);
795
796         if (debugflag)
797                 abort();
798         done(1);
ragge
1.1
799 }
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-18 21:45 +0200