Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20070808202951

Diff

Diff from 1.51 to:

Annotations

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

Annotated File View

ragge
1.51
1 /*      $Id: cc.c,v 1.51 2007/08/08 20:29:51 ragge Exp $        */
ragge
1.3
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  */
ragge
1.2
35
ragge
1.1
36 /*
ragge
1.3
37  * Front-end to the C compiler.
ragge
1.18
38  *
39  * Brief description of its syntax:
40  * - Files that end with .c are passed via cpp->ccom->as->ld
41  * - Files that end with .s are passed as->ld
42  * - Files that end with .o are passed directly to ld
43  * - Multiple files may be given on the command line.
44  * - Unrecognized options are all sent directly to ld.
45  * -c or -S cannot be combined with -o if multiple files are given.
46  *
47  * This file should be rewritten readable.
ragge
1.1
48  */
ragge
1.9
49 #include <sys/types.h>
ragge
1.36
50 #include <sys/wait.h>
ragge
1.2
51
ragge
1.1
52 #include <stdio.h>
53 #include <ctype.h>
54 #include <signal.h>
ragge
1.4
55 #include <string.h>
56 #include <fcntl.h>
57 #include <unistd.h>
58 #include <stdlib.h>
ragge
1.36
59 #include <stdarg.h>
60 #include <libgen.h>
pj
1.38
61 #include <errno.h>
ragge
1.24
62
ragge
1.39
63 #include "../../config.h"
64
ragge
1.24
65 #include "ccconfig.h"
ragge
1.3
66 /* C command */
ragge
1.1
67
ragge
1.20
68 #define MKS(x) _MKS(x)
69 #define _MKS(x) #x
70
71 /*
72  * Many specific definitions, should be declared elsewhere.
73  */
74 #define STDINC    "/usr/include"
75
ragge
1.3
76 #define SBSIZE 10000
ragge
1.12
77 #define MAXINC 100
ragge
1.3
78 #define MAXFIL 100
ragge
1.12
79 #define MAXLIB 10000
ragge
1.14
80 #define MAXAV  10000
ragge
1.3
81 #define MAXOPT 100
82 char    *tmp3;
83 char    *tmp4;
ragge
1.1
84 char    *outfile;
pj
1.31
85 char *copy(char *as),*setsuf(char *aschar ch);
ragge
1.4
86 int getsuf(char []);
87 int main(intchar *[]);
ragge
1.36
88 void error(char *, ...);
89 void errorx(int evalchar *, ...);
ragge
1.4
90 int nodup(char **, char *);
91 int callsys(char [], char *[]);
92 int cunlink(char *);
ragge
1.36
93 void dexit(int eval);
ragge
1.4
94 void idexit(int);
pj
1.30
95 char *gettmp();
ragge
1.14
96 char    *av[MAXAV];
ragge
1.3
97 char    *clist[MAXFIL];
98 char    *llist[MAXLIB];
ragge
1.4
99 char    alist[20];
ragge
1.43
100 char    *xlist[100];
101 int     xnum;
102 int     dflag;
ragge
1.3
103 int     pflag;
104 int     sflag;
105 int     cflag;
106 int     eflag;
107 int     gflag;
ragge
1.5
108 int     vflag;
ragge
1.7
109 int     tflag;
ragge
1.8
110 int     Eflag;
ragge
1.4
111 int     Oflag;
ragge
1.49
112 int     kflag;  /* generate PIC code */
ragge
1.51
113 int     Mflag;  /* dependencies only */
ragge
1.3
114 int     proflag;
ragge
1.1
115 int     exfail;
ragge
1.10
116 int     Xflag;
ragge
1.14
117 int     nostartfilesBstatic;
ragge
1.20
118 int     nostdinc;
ragge
1.43
119 int     onlyas;
ragge
1.14
120
ragge
1.23
121 char    *pass0 = LIBEXECDIR "/ccom";
122 char    *passp = LIBEXECDIR "/cpp";
ragge
1.47
123 char    *Bflag;
ragge
1.20
124 char    *sysinc;
ragge
1.25
125 char *cppadd[] = CPPADD;
126 char *dynlinker[] = DYNLINKER;
127 char *crt0file = CRT0FILE;
128 char *startfiles[] = STARTFILES;
129 char *endfiles[] = ENDFILES;
130 char *cppmdadd[] = CPPMDADD;
ragge
1.50
131 #ifdef LIBCLIBS
132 char *libclibs[] = LIBCLIBS;
133 #else
134 char *libclibs[] = { "-lc"NULL };
135 #endif
ragge
1.48
136 #ifndef STARTLABEL
137 #define STARTLABEL "__start"
138 #endif
ragge
1.1
139
ragge
1.4
140 int
pj
1.26
141 main(int argcchar *argv[])
142 {
ragge
1.15
143         char *t, *u;
ragge
1.1
144         char *assource;
ragge
1.3
145         char **pv, *ptemp[MAXOPT], **pvt;
ragge
1.36
146         int ncnlijcnxona;
ragge
1.3
147
ragge
1.36
148         i = nc = nl = nxo = 0;
ragge
1.3
149         pv = ptemp;
150         while(++i < argc) {
ragge
1.18
151                 if (argv[i][0] == '-')
152                 switch (argv[i][1]) {
ragge
1.3
153                 default:
154                         goto passa;
ragge
1.22
155
ragge
1.47
156                 case 'B'/* other search paths for binaries */
157                         Bflag = &argv[i][2];
ragge
1.22
158                         break;
159
ragge
1.10
160                 case 'X':
161                         Xflag++;
162                         break;
ragge
1.15
163                 case 'W'/* Ignore (most of) W-flags */
164                         if (strncmp(argv[i], "-Wl,"4) == 0) {
165                                 /* options to the linker */
166                                 t = &argv[i][4];
167                                 while ((u = strchr(t','))) {
168                                         *u++ = 0;
169                                         llist[nl++] = t;
170                                         t = u;
171                                 }
172                                 llist[nl++] = t;
173                         }
174                         break;
175
ragge
1.49
176                 case 'f'/* GCC compatibility flags */
177                         if (strcmp(argv[i], "-fPIC") == 0)
178                                 kflag++;
179                         /* silently ignore the rest */
ragge
1.6
180                         break;
ragge
1.14
181
ragge
1.25
182                 case 'g'/* create debug output */
183                         gflag++;
184                         break;
185
ragge
1.20
186                 case 'i':
187                         if (strcmp(argv[i], "-isystem") == 0) {
188                                 sysinc = argv[++i];
189                         } else
190                                 goto passa;
191                         break;
192
ragge
1.49
193                 case 'k'/* generate PIC code */
194                         kflag++;
195                         break;
196
ragge
1.14
197                 case 'n'/* handle -n flags */
198                         if (strcmp(argv[i], "-nostdinc") == 0)
ragge
1.20
199                                 nostdinc++;
ragge
1.14
200                         else if (strcmp(argv[i], "-nostartfiles") == 0)
201                                 nostartfiles = 1;
202                         else
203                                 goto passa;
204                         break;
205
ragge
1.7
206                 case 'x':
ragge
1.43
207                         xlist[xnum++] = argv[i];
ragge
1.7
208                         break;
209                 case 't':
210                         tflag++;
211                         break;
ragge
1.1
212                 case 'S':
213                         sflag++;
214                         cflag++;
ragge
1.3
215                         break;
ragge
1.1
216                 case 'o':
ragge
1.18
217                         if (outfile)
ragge
1.36
218                                 errorx(8"too many -o");
ragge
1.18
219                         outfile = argv[++i];
ragge
1.3
220                         break;
ragge
1.1
221                 case 'O':
ragge
1.4
222                         Oflag++;
ragge
1.3
223                         break;
ragge
1.1
224                 case 'p':
225                         proflag++;
ragge
1.3
226                         break;
ragge
1.1
227                 case 'E':
ragge
1.8
228                         Eflag++;
229                         break;
ragge
1.1
230                 case 'P':
231                         pflag++;
ragge
1.3
232                         *pv++ = argv[i];
ragge
1.1
233                 case 'c':
234                         cflag++;
ragge
1.3
235                         break;
236
ragge
1.24
237 #if 0
ragge
1.3
238                 case '2':
239                         if(argv[i][2] == '\0')
240                                 pref = "/lib/crt2.o";
241                         else {
242                                 pref = "/lib/crt20.o";
243                         }
244                         break;
ragge
1.24
245 #endif
ragge
1.1
246                 case 'D':
247                 case 'I':
248                 case 'U':
249                 case 'C':
ragge
1.20
250                         *pv++ = argv[i];
ragge
1.3
251                         if (pv >= ptemp+MAXOPT)
252                                 {
ragge
1.36
253                                 error("Too many DIUC options");
ragge
1.3
254                                 --pv;
255                                 }
256                         break;
257
ragge
1.51
258                 case 'M':
259                         Mflag++;
260                         break;
261
ragge
1.1
262                 case 'd':
ragge
1.3
263                         dflag++;
ragge
1.4
264                         strncpy(alistargv[i], 19);
ragge
1.3
265                         break;
ragge
1.5
266                 case 'v':
ragge
1.39
267                         printf("%s\n"VERSSTR);
ragge
1.5
268                         vflag++;
269                         break;
ragge
1.14
270
271                 case 's':
272                         if (strcmp(argv[i], "-static") == 0)
273                                 Bstatic = 1;
274                         else
275                                 goto passa;
276                         break;
ragge
1.3
277                 } else {
278                 passa:
279                         t = argv[i];
ragge
1.11
280                         if (*argv[i] == '-' && argv[i][1] == 'L')
281                                 ;
ragge
1.51
282                         else if((c=getsuf(t))=='c' || c=='S' ||
283                             c=='s'|| Eflag) {
ragge
1.3
284                                 clist[nc++] = t;
285                                 if (nc>=MAXFIL)
286                                         {
ragge
1.36
287                                         error("Too many source files");
ragge
1.3
288                                         exit(1);
289                                         }
290                                 t = setsuf(t'o');
291                         }
292                         if (nodup(llistt)) {
293                                 llist[nl++] = t;
294                                 if (nl >= MAXLIB)
295                                         {
ragge
1.36
296                                         error("Too many object/library files");
ragge
1.3
297                                         exit(1);
298                                         }
299                                 if (getsuf(t)=='o')
300                                         nxo++;
ragge
1.1
301                         }
302                 }
303         }
ragge
1.18
304         /* Sanity checking */
305         if (nc == 0 && nl == 0)
ragge
1.36
306                 errorx(8"no input files");
ragge
1.18
307         if (outfile && (cflag || sflag) && nc > 1)
ragge
1.36
308                 errorx(8"-o given with -c || -S and more than one file");
ragge
1.19
309         if (outfile && clist[0] && strcmp(outfileclist[0]) == 0)
ragge
1.36
310                 errorx(8"output file will be clobbered");
ragge
1.18
311
ragge
1.4
312         if (gflagOflag = 0;
ragge
1.24
313 #if 0
314         if (proflag)
ragge
1.3
315                 pref = "/lib/mcrt0.o";
ragge
1.24
316 #endif
ragge
1.3
317         if(nc==0)
318                 goto nocom;
319         if (pflag==0) {
pj
1.30
320                 tmp3 = gettmp();
321                 tmp4 = gettmp();
ragge
1.1
322         }
ragge
1.3
323         if (signal(SIGINTSIG_IGN) != SIG_IGN/* interrupt */
ragge
1.1
324                 signal(SIGINTidexit);
ragge
1.3
325         if (signal(SIGTERMSIG_IGN) != SIG_IGN)        /* terminate */
ragge
1.1
326                 signal(SIGTERMidexit);
ragge
1.3
327         pvt = pv;
ragge
1.1
328         for (i=0i<nci++) {
ragge
1.18
329                 /*
330                  * C preprocessor
331                  */
ragge
1.37
332                 if (nc>1 && !Eflag)
ragge
1.1
333                         printf("%s:\n"clist[i]);
ragge
1.43
334                 onlyas = 0;
pj
1.32
335                 assource = tmp3;
ragge
1.3
336                 if (getsuf(clist[i])=='s') {
ragge
1.1
337                         assource = clist[i];
ragge
1.43
338                         onlyas = 1;
339                         goto assemble;
340                 } else if (getsuf(clist[i])=='S') {
341                         assource = clist[i];
342                         onlyas = 1;
pj
1.32
343                 }
ragge
1.1
344                 if (pflag)
345                         tmp4 = setsuf(clist[i], 'i');
ragge
1.5
346                 na = 0;
347                 av[na++] = "cpp";
ragge
1.20
348                 av[na++] = "-D__PCC__=" MKS(PCC_MAJOR);
ragge
1.40
349                 av[na++] = "-D__PCC_MINOR__=" MKS(PCC_MINOR);
350                 av[na++] = "-D__PCC_MINORMINOR__=" MKS(PCC_MINORMINOR);
ragge
1.51
351                 if (Mflag)
352                         av[na++] = "-M";
ragge
1.20
353                 if (!nostdinc)
ragge
1.21
354                         av[na++] = "-S"av[na++] = STDINC;
ragge
1.20
355                 if (sysinc)
356                         av[na++] = "-S"av[na++] = sysinc;
ragge
1.5
357                 for (j = 0cppadd[j]; j++)
358                         av[na++] = cppadd[j];
ragge
1.24
359                 for (j = 0cppmdadd[j]; j++)
360                         av[na++] = cppmdadd[j];
ragge
1.7
361                 if (tflag)
ragge
1.20
362                         av[na++] = "-t";
ragge
1.7
363                 for(pv=ptemppv <pvtpv++)
364                         av[na++] = *pv;
ragge
1.5
365                 av[na++] = clist[i];
ragge
1.51
366                 if (!Eflag && !Mflag)
ragge
1.20
367                         av[na++] = tmp4;
ragge
1.3
368                 av[na++]=0;
369                 if (callsys(passpav))
370                         {exfail++; eflag++;}
ragge
1.51
371                 if (Eflag || Mflag)
ragge
1.37
372                         continue;
ragge
1.43
373                 if (onlyas)
ragge
1.7
374                         goto assemble;
ragge
1.18
375
376                 /*
377                  * C compiler
378                  */
ragge
1.25
379                 na = 0;
380                 av[na++]= "ccom";
381                 if (gflag)
382                         av[na++] = "-g";
ragge
1.49
383                 if (kflag)
384                         av[na++] = "-k";
ragge
1.44
385                 if (Oflag) {
386                         av[na++] = "-xtemps";
387                 }
ragge
1.45
388                 for (j = 0j < xnumj++)
389                         av[na++] = xlist[j];
ragge
1.25
390                 av[na++] = tmp4;
ragge
1.3
391                 if (pflag || exfail)
392                         {
ragge
1.1
393                         cflag++;
394                         continue;
ragge
1.3
395                         }
ragge
1.16
396                 if(sflag) {
397                         if (outfile)
398                                 assource = tmp3 = outfile;
399                         else
400                                 assource = tmp3 = setsuf(clist[i], 's');
401                 }
ragge
1.25
402                 av[na++] = tmp3;
403 #if 0
ragge
1.3
404                 if (proflag) {
405                         av[3] = "-XP";
406                         av[4] = 0;
407                 } else
408                         av[3] = 0;
ragge
1.25
409 #endif
410                 av[na++] = NULL;
ragge
1.3
411                 if (callsys(pass0av)) {
ragge
1.1
412                         cflag++;
413                         eflag++;
414                         continue;
415                 }
416                 if (sflag)
417                         continue;
ragge
1.18
418
419                 /*
420                  * Assembler
421                  */
ragge
1.1
422         assemble:
ragge
1.49
423                 na = 0;
424                 av[na++] = "as";
425                 if (kflag)
426                         av[na++] = "-k";
427                 av[na++] = "-o";
ragge
1.18
428                 if (outfile && cflag)
ragge
1.49
429                         av[na++] = outfile;
ragge
1.18
430                 else
ragge
1.49
431                         av[na++] = setsuf(clist[i], 'o');
432                 av[na++] = onlyas ? tmp4 : assource;
433                 if (dflag)
434                         av[na++] = alist;
435                 av[na++] = 0;
ragge
1.21
436                 if (callsys("/bin/as"av)) {
ragge
1.1
437                         cflag++;
438                         eflag++;
ragge
1.7
439                         cunlink(tmp4);
ragge
1.1
440                         continue;
441                 }
ragge
1.7
442                 cunlink(tmp4);
ragge
1.1
443         }
ragge
1.18
444
ragge
1.51
445         if (Eflag || Mflag)
ragge
1.37
446                 dexit(eflag);
447
ragge
1.18
448         /*
449          * Linker
450          */
ragge
1.1
451 nocom:
452         if (cflag==0 && nl!=0) {
ragge
1.6
453                 j = 0;
454                 av[j++] = "ld";
455                 av[j++] = "-X";
456                 av[j++] = "-d";
457                 av[j++] = "-e";
ragge
1.48
458                 av[j++] = STARTLABEL;
ragge
1.14
459                 if (Bstatic == 0) { /* Dynamic linkage */
ragge
1.24
460                         for (i = 0dynlinker[i]; i++)
461                                 av[j++] = dynlinker[i];
ragge
1.14
462                 }
ragge
1.1
463                 if (outfile) {
ragge
1.3
464                         av[j++] = "-o";
465                         av[j++] = outfile;
466                 }
ragge
1.14
467                 if (!nostartfiles) {
ragge
1.24
468                         av[j++] = crt0file;
469                         for (i = 0startfiles[i]; i++)
470                                 av[j++] = startfiles[i];
ragge
1.14
471                 }
ragge
1.24
472                 i = 0;
ragge
1.14
473                 while(i<nl) {
ragge
1.3
474                         av[j++] = llist[i++];
ragge
1.14
475                         if (j >= MAXAV)
ragge
1.36
476                                 error("Too many ld options");
ragge
1.14
477                 }
ragge
1.11
478 #if 0
ragge
1.3
479                 if (gflag)
480                         av[j++] = "-lg";
ragge
1.11
481 #endif
ragge
1.50
482                 for (i = 0libclibs[i]; i++)
483                         av[j++] = libclibs[i];
ragge
1.14
484                 if (!nostartfiles) {
ragge
1.24
485                         for (i = 0endfiles[i]; i++)
486                                 av[j++] = endfiles[i];
ragge
1.14
487                 }
ragge
1.3
488                 av[j++] = 0;
489                 eflag |= callsys("/bin/ld"av);
ragge
1.1
490                 if (nc==1 && nxo==1 && eflag==0)
ragge
1.3
491                         cunlink(setsuf(clist[0], 'o'));
ragge
1.46
492                 else if (nc > 0 && eflag == 0) {
493                         /* remove .o files XXX ugly */
494                         for (i = 0i < nci++)
495                                 cunlink(setsuf(clist[i], 'o'));
496                 }
ragge
1.1
497         }
ragge
1.36
498         dexit(eflag);
ragge
1.4
499         return 0;
ragge
1.1
500 }
501
ragge
1.36
502 /*
503  * exit and cleanup after interrupt.
504  */
ragge
1.4
505 void
506 idexit(int arg)
ragge
1.1
507 {
ragge
1.36
508         dexit(100);
ragge
1.1
509 }
510
ragge
1.36
511 /*
512  * exit and cleanup.
513  */
ragge
1.4
514 void
ragge
1.36
515 dexit(int eval)
ragge
1.1
516 {
ragge
1.10
517         if (!pflag && !Xflag) {
ragge
1.1
518                 if (sflag==0)
519                         cunlink(tmp3);
520                 cunlink(tmp4);
521         }
ragge
1.36
522         exit(eval);
ragge
1.1
523 }
524
ragge
1.36
525 static void
526 ccerror(char *sva_list ap)
ragge
1.1
527 {
ragge
1.36
528         vfprintf(Eflag ? stderr : stdoutsap);
ragge
1.8
529         putc('\n'Eflagstderr : stdout);
ragge
1.1
530         exfail++;
531         cflag++;
532         eflag++;
533 }
534
ragge
1.36
535 /*
536  * complain a bit.
537  */
538 void
539 error(char *s, ...)
540 {
541         va_list ap;
542
543         va_start(aps);
544         ccerror(sap);
545         va_end(ap);
546 }
547
548 /*
549  * complain a bit and then exit.
550  */
ragge
1.18
551 void
ragge
1.36
552 errorx(int evalchar *s, ...)
ragge
1.18
553 {
ragge
1.36
554         va_list ap;
555
556         va_start(aps);
557         ccerror(sap);
558         va_end(ap);
559         dexit(eval);
ragge
1.18
560 }
ragge
1.3
561
ragge
1.4
562 int
ragge
1.3
563 getsuf(as)
564 char as[];
ragge
1.1
565 {
566         register char *s;
567
ragge
1.4
568         if ((s = strrchr(as'.')) && s[1] != '\0' && s[2] == '\0')
569                 return s[1];
ragge
1.3
570         return(0);
ragge
1.1
571 }
572
ragge
1.36
573 /*
574  * Get basename of string s and change its suffix to ch.
575  */
ragge
1.1
576 char *
ragge
1.36
577 setsuf(char *schar ch)
ragge
1.1
578 {
ragge
1.36
579         s = copy(basename(s));
pj
1.31
580         s[strlen(s) - 1] = ch;
ragge
1.36
581         return(s);
ragge
1.1
582 }
583
ragge
1.4
584 int
ragge
1.3
585 callsys(fv)
586 char f[], *v[]; {
ragge
1.1
587         int tstatus;
ragge
1.4
588         char *s;
ragge
1.5
589
590         if (vflag) {
ragge
1.41
591                 fprintf(stderr"%s "f);
592                 for (t = 1v[t]; t++)
ragge
1.6
593                         fprintf(stderr"%s "v[t]);
594                 fprintf(stderr"\n");
ragge
1.5
595         }
ragge
1.1
596
ragge
1.3
597         if ((t=fork())==0) {
ragge
1.47
598                 if (Bflag) {
599                         char *a = malloc(strlen(Bflag) + 8);
600                         if ((s = strrchr(f'/'))) {
601                                 strcpy(aBflag);
602                                 strcat(as);
603                                 execv(av);
604                         }
605                 }
ragge
1.1
606                 execv(fv);
ragge
1.4
607                 if ((s = strrchr(f'/')))
608                         execvp(s+1v);
ragge
1.1
609                 printf("Can't find %s\n"f);
ragge
1.3
610                 exit(100);
611         } else
612                 if (t == -1) {
613                         printf("Try again\n");
614                         return(100);
615                 }
616         while(t!=wait(&status));
ragge
1.1
617         if ((t=(status&0377)) != 0 && t!=14) {
ragge
1.3
618                 if (t!=2)               /* interrupt */
ragge
1.36
619                         errorx(8"Fatal error in %s"f);
620                 dexit(eflag);
ragge
1.1
621         }
ragge
1.3
622         return((status>>8) & 0377);
ragge
1.1
623 }
624
ragge
1.3
625 char *
pj
1.28
626 copy(char *as)
ragge
1.3
627 {
pj
1.28
628         char *p;
629
ragge
1.36
630         if ((p = strdup(as)) == NULL)
631                 errorx(8"no space for file names");
ragge
1.3
632
pj
1.28
633         return p;
ragge
1.3
634 }
635
ragge
1.4
636 int
ragge
1.3
637 nodup(los)
638 char **l, *os;
ragge
1.1
639 {
640         register char *t, *s;
641         register int c;
642
643         s = os;
644         if (getsuf(s) != 'o')
ragge
1.3
645                 return(1);
ragge
1.4
646         while((t = *l++)) {
647                 while((c = *s++))
ragge
1.1
648                         if (c != *t++)
649                                 break;
ragge
1.3
650                 if (*t=='\0' && c=='\0')
651                         return(0);
ragge
1.1
652                 s = os;
653         }
ragge
1.3
654         return(1);
ragge
1.1
655 }
656
ragge
1.4
657 int
ragge
1.3
658 cunlink(f)
659 char *f;
ragge
1.1
660 {
ragge
1.13
661         if (f==0 || Xflag)
ragge
1.3
662                 return(0);
663         return(unlink(f));
ragge
1.1
664 }
pj
1.30
665
666 char *
667 gettmp()
668 {
669         char *sfn = strdup("/tmp/ctm.XXXXXX");
670         int fd = -1;
671
672         if ((fd = mkstemp(sfn)) == -1) {
673                 fprintf(stderr"%s: %s\n"sfnstrerror(errno));
674                 exit(8);
675         }
676         close(fd);
677
678         return sfn;
679 }
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-02 02:27 +0200