Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:sgk:20081227003639

Diff

Diff from 1.21 to:

Annotations

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

Annotated File View

sgk
1.21
1 /*      $Id: f77.c,v 1.21 2008/12/27 00:36:39 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 #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) {
ragge
1.2
301                                 sprintf(buff"%s %s >%s"macronameinfnameprepfname);
ragge
1.6
302                                 if(sys(buff)) {
ragge
1.1
303                                         rmf(prepfname);
304                                         break;
ragge
1.6
305                                 }
ragge
1.1
306                                 infname = prepfname;
ragge
1.6
307                         }
ragge
1.1
308
309                         if(c == 'e')
310                                 sprintf(buff"efl %s %s >%s"eflagsinfnamefortfile);
311                         else
312                                 sprintf(buff"ratfor %s %s >%s"rflagsinfnamefortfile);
313                         status = sys(buff);
314                         if(macroflag)
315                                 rmf(infname);
ragge
1.6
316                         if(status) {
ragge
1.1
317                                 loadflag = NO;
318                                 rmf(fortfile);
319                                 break;
ragge
1.6
320                         }
ragge
1.1
321
ragge
1.6
322                         if( ! fortonly ) {
ragge
1.1
323                                 infname = argv[i] = lastfield(argv[i]);
324                                 *lastchar(infname) = 'f';
325         
326                                 ifdofort(argv[i]) )
327                                         loadflag = NO;
328                                 else    {
329                                         ifnodup(t = setdoto(argv[i])) )
330                                                 *loadp++ = t;
331                                         rmf(fortfile);
332                                 }
ragge
1.6
333                         }
ragge
1.1
334                         break;
335
336                 case 'f':       /* Fortran file */
337                 case 'F':
338                         ifunreadable(argv[i]) )
339                                 break;
340                         ifdofort(argv[i]) )
341                                 loadflag = NO;
342                         else ifnodup(t=setdoto(argv[i])) )
343                                 *loadp++ = t;
344                         break;
345
346                 case 'c':       /* C file */
347                 case 's':       /* Assembler file */
348                         ifunreadable(argv[i]) )
349                                 break;
350                         fprintf(diagfile"%s:\n"argv[i]);
351                         sprintf(buff"cc -c %s"argv[i] );
352                         ifsys(buff) )
353                                 loadflag = NO;
354                         else
355                                 ifnodup(t = setdoto(argv[i])) )
356                                         *loadp++ = t;
357                         break;
358
359                 case 'o':
360                         ifnodup(argv[i]) )
361                                 *loadp++ = argv[i];
362                         break;
363
364                 default:
365                         if( ! strcmp(argv[i], "-o") )
366                                 aoutname = argv[++i];
367                         else
368                                 *loadp++ = argv[i];
369                         break;
370                 }
371
ragge
1.6
372         if(loadflag)
373                 doload(loadargsloadp);
374         done(0);
375         return 0;
ragge
1.1
376 }
ragge
1.6
377
sgk
1.15
378 #define ADD(x)  addarg(params, &nparms, (x))
379
sgk
1.20
380 static int
ragge
1.6
381 dofort(char *s)
382 {
383         int nparmsi;
384         char *params[MAXARGS];
385
386         nparms = 0;
sgk
1.15
387         ADD(FCOM);
ragge
1.6
388         for (i = 0i < ffmaxi++)
sgk
1.15
389                 ADD(ffary[i]);
390         ADD(s);
391         ADD(asmfname);
392         ADD(NULL);
ragge
1.6
393
394         infname = s;
395         if (callsys(fcomparams))
396                 errorx("Error.  No assembly.");
397         doasm(s);
ragge
1.1
398
ragge
1.8
399         if (saveasmflag == NO)
400                 rmf(asmfname);
ragge
1.6
401         return(0);
ragge
1.1
402 }
403
404
sgk
1.20
405 static void
ragge
1.6
406 doasm(char *s)
ragge
1.1
407 {
ragge
1.6
408         char *obj;
409         char *params[MAXARGS];
410         int nparms;
ragge
1.1
411
ragge
1.10
412         if (oflag && loadflag == NO)
ragge
1.9
413                 obj = aoutname;
414         else
415                 obj = setdoto(s);
ragge
1.1
416
ragge
1.6
417         nparms = 0;
sgk
1.15
418         ADD(asmname);
419         ADD("-o");
420         ADD(obj);
421         ADD(asmfname);
422         ADD(NULL);
ragge
1.1
423
ragge
1.6
424         if (callsys(asmnameparams))
sgk
1.13
425                 fatal1("assembler error");
ragge
1.1
426         if(verbose)
427                 fprintf(diagfile"\n");
428 }
429
430
sgk
1.20
431 static void
ragge
1.6
432 doload(char *v0[], char *v[])
ragge
1.1
433 {
ragge
1.6
434         int nparmsi;
435         char *params[MAXARGS];
436         char **p;
437
438         nparms = 0;
439         ADD(ldname);
440         ADD("-X");
441         ADD("-d");
442         for (i = 0dynlinker[i]; i++)
443                 ADD(dynlinker[i]);
444         ADD("-o");
445         ADD(aoutname);
446         ADD(crt0file);
447         for (i = 0startfiles[i]; i++)
448                 ADD(startfiles[i]);
449         *v = NULL;
450         for(p = v0; *p ; p++)
451                 ADD(*p);
ragge
1.12
452         if (libdir)
453                 ADD(libdir);
ragge
1.6
454         for(p = liblist ; *p ; p++)
455                 ADD(*p);
456         for (i = 0endfiles[i]; i++)
457                 ADD(endfiles[i]);
sgk
1.15
458         ADD(NULL);
ragge
1.1
459
ragge
1.6
460         if (callsys(ldnameparams))
ragge
1.1
461                 fatal1("couldn't load %s"ldname);
462
ragge
1.6
463         if(verbose)
464                 fprintf(diagfile"\n");
ragge
1.1
465 }
ragge
1.6
466
ragge
1.1
467 /* Process control and Shell-simulating routines */
468
ragge
1.6
469 /*
470  * Execute f[] with parameter array v[].
471  * Copied from cc.
472  */
sgk
1.20
473 static int
ragge
1.6
474 callsys(char f[], char *v[])
ragge
1.1
475 {
ragge
1.6
476         int tstatus = 0;
477         pid_t p;
478         char *s;
479
ragge
1.12
480         if (debugflag || verbose) {
ragge
1.6
481                 fprintf(stderr"%s "f);
482                 for (t = 1v[t]; t++)
483                         fprintf(stderr"%s "v[t]);
484                 fprintf(stderr"\n");
485         }
486
487         if ((p = fork()) == 0) {
488 #ifdef notyet
489                 if (Bflag) {
490                         size_t len = strlen(Bflag) + 8;
491                         char *a = malloc(len);
492                         if (a == NULL) {
493                                 error("callsys: malloc failed");
494                                 exit(1);
ragge
1.1
495                         }
ragge
1.6
496                         if ((s = strrchr(f'/'))) {
497                                 strlcpy(aBflaglen);
498                                 strlcat(aslen);
499                                 execv(av);
ragge
1.1
500                         }
501                 }
ragge
1.6
502 #endif
503                 execvp(fv);
504                 if ((s = strrchr(f'/')))
505                         execvp(s+1v);
506                 fprintf(stderr"Can't find %s\n"f);
507                 _exit(100);
508         } else {
509                 if (p == -1) {
510                         printf("Try again\n");
511                         return(100);
512                 }
513         }
514         while (waitpid(p, &status0) == -1 && errno == EINTR)
515                 ;
516         if (WIFEXITED(status))
517                 return (WEXITSTATUS(status));
518         if (WIFSIGNALED(status))
519                 done(1);
520         fatal1("Fatal error in %s"f);
521         return 0/* XXX */
522 }
523
524
sgk
1.20
525 static int
ragge
1.6
526 sys(char *str)
527 {
sgk
1.20
528         char *s, *t;
ragge
1.6
529         char *argv[100], path[100];
530         char *inname, *outname;
531         int append = 0;
ragge
1.12
532         int wait_pid;
ragge
1.6
533         int argc;
534
535
536         if(debugflag)
537                 fprintf(diagfile"%s\n"str);
538         inname  = NULL;
539         outname = NULL;
540         argv[0] = shellname;
541         argc = 1;
542
543         t = str;
544         whileisspace((int)*t) )
ragge
1.1
545                 ++t;
ragge
1.6
546         while(*t) {
547                 if(*t == '<')
548                         inname = t+1;
549                 else if(*t == '>') {
550                         if(t[1] == '>') {
551                                 append = YES;
552                                 outname = t+2;
553                         } else  {
554                                 append = NO;
555                                 outname = t+1;
556                         }
557                 } else
558                         argv[argc++] = t;
559                 while( !isspace((int)*t) && *t!='\0' )
ragge
1.1
560                         ++t;
ragge
1.6
561                 if(*t) {
562                         *t++ = '\0';
563                         whileisspace((int)*t) )
564                                 ++t;
ragge
1.1
565                 }
566         }
567
ragge
1.6
568         if(argc == 1)   /* no command */
569                 return(-1);
570         argv[argc] = 0;
571
572         s = path;
573         t = "/usr/bin/";
574         while(*t)
575                 *s++ = *t++;
576         for(t = argv[1] ; (*s++ = *t++) ; )
577                 ;
ragge
1.12
578         if((wait_pid = fork()) == 0) {
ragge
1.6
579                 if(inname)
580                         freopen(inname"r"stdin);
581                 if(outname)
582                         freopen(outname, (append ? "a" : "w"), stdout);
583                 enbint(SIG_DFL);
584
585                 texec(path+9argv);  /* command */
586                 texec(path+4argv);  /*  /bin/command */
587                 texec(path  , argv);  /* /usr/bin/command */
ragge
1.1
588
ragge
1.6
589                 fatal1("Cannot load %s",path+9);
ragge
1.1
590         }
591
ragge
1.12
592         returnawait(wait_pid) );
ragge
1.1
593 }
594
595 /* modified version from the Shell */
sgk
1.20
596 static void
ragge
1.6
597 texec(char *fchar **av)
ragge
1.1
598 {
599
ragge
1.6
600         execv(fav+1);
ragge
1.1
601
ragge
1.6
602         if (errno==ENOEXEC) {
603                 av[1] = f;
604                 execv(shellnameav);
sgk
1.13
605                 fatal1("No shell!");
ragge
1.1
606         }
ragge
1.6
607         if (errno==ENOMEM)
608                 fatal1("%s: too large"f);
ragge
1.1
609 }
610
ragge
1.6
611 /*
612  * Cleanup and exit with value k.
613  */
sgk
1.20
614 static void
ragge
1.6
615 done(int k)
ragge
1.1
616 {
ragge
1.6
617         static int recurs       = NO;
ragge
1.1
618
ragge
1.6
619         if(recurs == NO) {
620                 recurs = YES;
sgk
1.13
621                 if (saveasmflag == NO)
622                         rmf(asmfname);
ragge
1.1
623         }
ragge
1.6
624         exit(k);
ragge
1.1
625 }
626
627
sgk
1.20
628 static void
629 enbint(void (*k)(int))
ragge
1.1
630 {
631 if(sigivalue == 0)
632         signal(SIGINT,k);
633 if(sigqvalue == 0)
634         signal(SIGQUIT,k);
635 }
636
637
638
sgk
1.20
639 static void
ragge
1.2
640 intrupt(int a)
ragge
1.1
641 {
642 done(2);
643 }
644
645
sgk
1.20
646 static int
647 await(int wait_pid)
ragge
1.1
648 {
649 int wstatus;
650
651 enbint(SIG_IGN);
ragge
1.12
652 while ( (w = wait(&status)) != wait_pid)
ragge
1.1
653         if(w == -1)
sgk
1.13
654                 fatal1("bad wait code");
ragge
1.1
655 enbint(intrupt);
656 if(status & 0377)
657         {
658         if(status != SIGINT)
659                 fprintf(diagfile"Termination code %d"status);
660         done(3);
661         }
662 return(status>>8);
663 }
664
665 /* File Name and File Manipulation Routines */
666
sgk
1.20
667 static int
ragge
1.6
668 unreadable(char *s)
ragge
1.1
669 {
ragge
1.6
670         FILE *fp;
ragge
1.1
671
ragge
1.6
672         if((fp = fopen(s"r"))) {
673                 fclose(fp);
674                 return(NO);
675         } else {
676                 fprintf(diagfile"Error: Cannot read file %s\n"s);
677                 loadflag = NO;
678                 return(YES);
ragge
1.1
679         }
680 }
681
682
sgk
1.20
683 static void
sgk
1.13
684 crfnames(void)
ragge
1.1
685 {
sgk
1.13
686         sprintf(asmfname,  "fort%d.%s"pid"s");
687         sprintf(prepfname"fort%d.%s"pid"p");
ragge
1.1
688 }
689
690
691
sgk
1.20
692 static void
693 rmf(char *fn)
ragge
1.1
694 {
695 if(!debugflag && fn!=NULL && *fn!='\0')
696         unlink(fn);
697 }
698
699
sgk
1.20
700 static int
701 dotchar(char *s)
ragge
1.1
702 {
703 for( ; *s ; ++s)
704         if(s[0]=='.' && s[1]!='\0' && s[2]=='\0')
705                 returns[1] );
706 return(NO);
707 }
708
709
sgk
1.20
710 static char *
711 lastfield(char *s)
ragge
1.1
712 {
sgk
1.20
713 char *t;
ragge
1.1
714 for(t = s; *s ; ++s)
715         if(*s == '/')
716                 t = s+1;
717 return(t);
718 }
719
720
sgk
1.20
721 static char *
722 lastchar(char *s)
ragge
1.1
723 {
724 while(*s)
725         ++s;
726 return(s-1);
727 }
728
sgk
1.20
729
730 static char *
731 setdoto(char *s)
ragge
1.1
732 {
733 *lastchar(s) = 'o';
734 returnlastfield(s) );
735 }
736
737
sgk
1.18
738 static char *
739 copyn(int nchar *s)
ragge
1.1
740 {
sgk
1.18
741         char *p, *q;
ragge
1.1
742
sgk
1.20
743         p = q = (char *)calloc(1, (unsignedn + 1);
744         if (!p)
745                 fatal1("out of memory");
746
sgk
1.18
747         while(n-- > 0)
748                 *q++ = *s++;
749         return (p);
ragge
1.1
750 }
751
752
sgk
1.20
753 static int
754 nodup(char *s)
ragge
1.1
755 {
sgk
1.20
756 char **p;
ragge
1.1
757
758 for(p = loadargs ; p < loadp ; ++p)
759         if( !strcmp(*ps) )
760                 return(NO);
761
762 return(YES);
763 }
764
765
sgk
1.17
766 static void
ragge
1.6
767 errorx(char *fmt, ...)
768 {
769         va_list ap;
770
771         va_start(apfmt);
772         vfprintf(diagfilefmtap);
773         fprintf(diagfile"\n");
774         va_end(ap);
ragge
1.1
775
ragge
1.6
776         if (debugflag)
777                 abort();
778         done(1);
779 }
ragge
1.1
780
781
ragge
1.4
782 static void
783 fatal1(char *fmt, ...)
ragge
1.1
784 {
ragge
1.4
785         va_list ap;
786
787         va_start(apfmt);
788         fprintf(diagfile"Compiler error in file %s: "infname);
789         vfprintf(diagfilefmtap);
790         fprintf(diagfile"\n");
791         va_end(ap);
792
793         if (debugflag)
794                 abort();
795         done(1);
ragge
1.1
796 }
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-08-29 12:00 +0200