Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20061222062309

Diff

Diff from 1.49 to:

Annotations

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

Annotated File View

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