Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:sgk:20081225000659

Diff

Diff from 1.20 to:

Annotations

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

Annotated File View

sgk
1.20
1 /*      $Id: f77.c,v 1.20 2008/12/25 00:06:59 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
sgk
1.20
113 static char *setdoto(char *), *lastchar(char *), *lastfield(char *);
114 static void intrupt(int);
115 static void enbint(void (*)(int));
116 static void crfnames(void);
ragge
1.4
117 static void fatal1(char *, ...);
sgk
1.20
118 static void done(int), texec(char *, char **);
sgk
1.18
119 static char *copyn(intchar *);
sgk
1.20
120 static int dotchar(char *), unreadable(char *), sys(char *), dofort(char *);
121 static int nodup(char *);
122 static int await(int);
123 static void rmf(char *), doload(char *[], char *[]), doasm(char *);
124 static int callsys(char *, char **);
125 static void errorx(char *, ...);
ragge
1.6
126
127 static void
128 addarg(char **aryint *numchar *arg)
129 {
130         ary[(*num)++] = arg;
131         if ((*num) == MAXARGS) {
132                 fprintf(stderr"argument array too small\n");
133                 exit(1);
134         }
135 }
ragge
1.2
136
137 int
138 main(int argcchar **argv)
ragge
1.1
139 {
ragge
1.6
140         int icstatus;
sgk
1.20
141         char *s;
ragge
1.6
142         char fortfile[20], *t;
143         char buff[100];
144
ragge
1.7
145         diagfile = stderr;
146
ragge
1.6
147         sigivalue = (intsignal(SIGINTSIG_IGN) & 01;
148         sigqvalue = (intsignal(SIGQUITSIG_IGN) & 01;
149         enbint(intrupt);
ragge
1.1
150
ragge
1.6
151         pid = getpid();
152         crfnames();
ragge
1.1
153
sgk
1.20
154         loadargs = (char **)calloc(1, (argc + 20) * sizeof(*loadargs));
155         if (!loadargs)
156                 fatal1("out of memory");
ragge
1.6
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
sgk
1.20
381 static 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
sgk
1.20
406 static 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
sgk
1.20
432 static void
ragge
1.6
433 doload(char *v0[], char *v[])
ragge
1.1
434 {
ragge
1.6
435         int nparmsi;
436         char *params[MAXARGS];
437         char **p;
438
439         nparms = 0;
440         ADD(ldname);
441         ADD("-X");
442         ADD("-d");
443         for (i = 0dynlinker[i]; i++)
444                 ADD(dynlinker[i]);
445         ADD("-o");
446         ADD(aoutname);
447         ADD(crt0file);
448         for (i = 0startfiles[i]; i++)
449                 ADD(startfiles[i]);
450         *v = NULL;
451         for(p = v0; *p ; p++)
452                 ADD(*p);
ragge
1.12
453         if (libdir)
454                 ADD(libdir);
ragge
1.6
455         for(p = liblist ; *p ; p++)
456                 ADD(*p);
457         for (i = 0endfiles[i]; i++)
458                 ADD(endfiles[i]);
sgk
1.15
459         ADD(NULL);
ragge
1.1
460
ragge
1.6
461         if (callsys(ldnameparams))
ragge
1.1
462                 fatal1("couldn't load %s"ldname);
463
ragge
1.6
464         if(verbose)
465                 fprintf(diagfile"\n");
ragge
1.1
466 }
ragge
1.6
467
ragge
1.1
468 /* Process control and Shell-simulating routines */
469
ragge
1.6
470 /*
471  * Execute f[] with parameter array v[].
472  * Copied from cc.
473  */
sgk
1.20
474 static int
ragge
1.6
475 callsys(char f[], char *v[])
ragge
1.1
476 {
ragge
1.6
477         int tstatus = 0;
478         pid_t p;
479         char *s;
480
ragge
1.12
481         if (debugflag || verbose) {
ragge
1.6
482                 fprintf(stderr"%s "f);
483                 for (t = 1v[t]; t++)
484                         fprintf(stderr"%s "v[t]);
485                 fprintf(stderr"\n");
486         }
487
488         if ((p = fork()) == 0) {
489 #ifdef notyet
490                 if (Bflag) {
491                         size_t len = strlen(Bflag) + 8;
492                         char *a = malloc(len);
493                         if (a == NULL) {
494                                 error("callsys: malloc failed");
495                                 exit(1);
ragge
1.1
496                         }
ragge
1.6
497                         if ((s = strrchr(f'/'))) {
498                                 strlcpy(aBflaglen);
499                                 strlcat(aslen);
500                                 execv(av);
ragge
1.1
501                         }
502                 }
ragge
1.6
503 #endif
504                 execvp(fv);
505                 if ((s = strrchr(f'/')))
506                         execvp(s+1v);
507                 fprintf(stderr"Can't find %s\n"f);
508                 _exit(100);
509         } else {
510                 if (p == -1) {
511                         printf("Try again\n");
512                         return(100);
513                 }
514         }
515         while (waitpid(p, &status0) == -1 && errno == EINTR)
516                 ;
517         if (WIFEXITED(status))
518                 return (WEXITSTATUS(status));
519         if (WIFSIGNALED(status))
520                 done(1);
521         fatal1("Fatal error in %s"f);
522         return 0/* XXX */
523 }
524
525
sgk
1.20
526 static int
ragge
1.6
527 sys(char *str)
528 {
sgk
1.20
529         char *s, *t;
ragge
1.6
530         char *argv[100], path[100];
531         char *inname, *outname;
532         int append = 0;
ragge
1.12
533         int wait_pid;
ragge
1.6
534         int argc;
535
536
537         if(debugflag)
538                 fprintf(diagfile"%s\n"str);
539         inname  = NULL;
540         outname = NULL;
541         argv[0] = shellname;
542         argc = 1;
543
544         t = str;
545         whileisspace((int)*t) )
ragge
1.1
546                 ++t;
ragge
1.6
547         while(*t) {
548                 if(*t == '<')
549                         inname = t+1;
550                 else if(*t == '>') {
551                         if(t[1] == '>') {
552                                 append = YES;
553                                 outname = t+2;
554                         } else  {
555                                 append = NO;
556                                 outname = t+1;
557                         }
558                 } else
559                         argv[argc++] = t;
560                 while( !isspace((int)*t) && *t!='\0' )
ragge
1.1
561                         ++t;
ragge
1.6
562                 if(*t) {
563                         *t++ = '\0';
564                         whileisspace((int)*t) )
565                                 ++t;
ragge
1.1
566                 }
567         }
568
ragge
1.6
569         if(argc == 1)   /* no command */
570                 return(-1);
571         argv[argc] = 0;
572
573         s = path;
574         t = "/usr/bin/";
575         while(*t)
576                 *s++ = *t++;
577         for(t = argv[1] ; (*s++ = *t++) ; )
578                 ;
ragge
1.12
579         if((wait_pid = fork()) == 0) {
ragge
1.6
580                 if(inname)
581                         freopen(inname"r"stdin);
582                 if(outname)
583                         freopen(outname, (append ? "a" : "w"), stdout);
584                 enbint(SIG_DFL);
585
586                 texec(path+9argv);  /* command */
587                 texec(path+4argv);  /*  /bin/command */
588                 texec(path  , argv);  /* /usr/bin/command */
ragge
1.1
589
ragge
1.6
590                 fatal1("Cannot load %s",path+9);
ragge
1.1
591         }
592
ragge
1.12
593         returnawait(wait_pid) );
ragge
1.1
594 }
595
596 /* modified version from the Shell */
sgk
1.20
597 static void
ragge
1.6
598 texec(char *fchar **av)
ragge
1.1
599 {
600
ragge
1.6
601         execv(fav+1);
ragge
1.1
602
ragge
1.6
603         if (errno==ENOEXEC) {
604                 av[1] = f;
605                 execv(shellnameav);
sgk
1.13
606                 fatal1("No shell!");
ragge
1.1
607         }
ragge
1.6
608         if (errno==ENOMEM)
609                 fatal1("%s: too large"f);
ragge
1.1
610 }
611
ragge
1.6
612 /*
613  * Cleanup and exit with value k.
614  */
sgk
1.20
615 static void
ragge
1.6
616 done(int k)
ragge
1.1
617 {
ragge
1.6
618         static int recurs       = NO;
ragge
1.1
619
ragge
1.6
620         if(recurs == NO) {
621                 recurs = YES;
sgk
1.13
622                 if (saveasmflag == NO)
623                         rmf(asmfname);
ragge
1.1
624         }
ragge
1.6
625         exit(k);
ragge
1.1
626 }
627
628
sgk
1.20
629 static void
630 enbint(void (*k)(int))
ragge
1.1
631 {
632 if(sigivalue == 0)
633         signal(SIGINT,k);
634 if(sigqvalue == 0)
635         signal(SIGQUIT,k);
636 }
637
638
639
sgk
1.20
640 static void
ragge
1.2
641 intrupt(int a)
ragge
1.1
642 {
643 done(2);
644 }
645
646
sgk
1.20
647 static int
648 await(int wait_pid)
ragge
1.1
649 {
650 int wstatus;
651
652 enbint(SIG_IGN);
ragge
1.12
653 while ( (w = wait(&status)) != wait_pid)
ragge
1.1
654         if(w == -1)
sgk
1.13
655                 fatal1("bad wait code");
ragge
1.1
656 enbint(intrupt);
657 if(status & 0377)
658         {
659         if(status != SIGINT)
660                 fprintf(diagfile"Termination code %d"status);
661         done(3);
662         }
663 return(status>>8);
664 }
665
666 /* File Name and File Manipulation Routines */
667
sgk
1.20
668 static int
ragge
1.6
669 unreadable(char *s)
ragge
1.1
670 {
ragge
1.6
671         FILE *fp;
ragge
1.1
672
ragge
1.6
673         if((fp = fopen(s"r"))) {
674                 fclose(fp);
675                 return(NO);
676         } else {
677                 fprintf(diagfile"Error: Cannot read file %s\n"s);
678                 loadflag = NO;
679                 return(YES);
ragge
1.1
680         }
681 }
682
683
sgk
1.20
684 static void
sgk
1.13
685 crfnames(void)
ragge
1.1
686 {
sgk
1.13
687         sprintf(asmfname,  "fort%d.%s"pid"s");
688         sprintf(prepfname"fort%d.%s"pid"p");
ragge
1.1
689 }
690
691
692
sgk
1.20
693 static void
694 rmf(char *fn)
ragge
1.1
695 {
696 if(!debugflag && fn!=NULL && *fn!='\0')
697         unlink(fn);
698 }
699
700
sgk
1.20
701 static int
702 dotchar(char *s)
ragge
1.1
703 {
704 for( ; *s ; ++s)
705         if(s[0]=='.' && s[1]!='\0' && s[2]=='\0')
706                 returns[1] );
707 return(NO);
708 }
709
710
sgk
1.20
711 static char *
712 lastfield(char *s)
ragge
1.1
713 {
sgk
1.20
714 char *t;
ragge
1.1
715 for(t = s; *s ; ++s)
716         if(*s == '/')
717                 t = s+1;
718 return(t);
719 }
720
721
sgk
1.20
722 static char *
723 lastchar(char *s)
ragge
1.1
724 {
725 while(*s)
726         ++s;
727 return(s-1);
728 }
729
sgk
1.20
730
731 static char *
732 setdoto(char *s)
ragge
1.1
733 {
734 *lastchar(s) = 'o';
735 returnlastfield(s) );
736 }
737
738
sgk
1.18
739 static char *
740 copyn(int nchar *s)
ragge
1.1
741 {
sgk
1.18
742         char *p, *q;
ragge
1.1
743
sgk
1.20
744         p = q = (char *)calloc(1, (unsignedn + 1);
745         if (!p)
746                 fatal1("out of memory");
747
sgk
1.18
748         while(n-- > 0)
749                 *q++ = *s++;
750         return (p);
ragge
1.1
751 }
752
753
sgk
1.20
754 static int
755 nodup(char *s)
ragge
1.1
756 {
sgk
1.20
757 char **p;
ragge
1.1
758
759 for(p = loadargs ; p < loadp ; ++p)
760         if( !strcmp(*ps) )
761                 return(NO);
762
763 return(YES);
764 }
765
766
sgk
1.17
767 static void
ragge
1.6
768 errorx(char *fmt, ...)
769 {
770         va_list ap;
771
772         va_start(apfmt);
773         vfprintf(diagfilefmtap);
774         fprintf(diagfile"\n");
775         va_end(ap);
ragge
1.1
776
ragge
1.6
777         if (debugflag)
778                 abort();
779         done(1);
780 }
ragge
1.1
781
782
ragge
1.4
783 static void
784 fatal1(char *fmt, ...)
ragge
1.1
785 {
ragge
1.4
786         va_list ap;
787
788         va_start(apfmt);
789         fprintf(diagfile"Compiler error in file %s: "infname);
790         vfprintf(diagfilefmtap);
791         fprintf(diagfile"\n");
792         va_end(ap);
793
794         if (debugflag)
795                 abort();
796         done(1);
ragge
1.1
797 }
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-10-01 14:17 +0200