]> gcc.gnu.org Git - gcc.git/blob - gcc/cp/xref.c
* lang-options.h (-fmessage-length=): Add missing option.
[gcc.git] / gcc / cp / xref.c
1 /* Code for handling XREF output from GNU C++.
2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 2000 Free Software Foundation, Inc.
4 Contributed by Michael Tiemann (tiemann@cygnus.com)
5
6 This file is part of GNU CC.
7
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
22
23
24 #include "config.h"
25 #include "system.h"
26 #include "tree.h"
27 #include "cp-tree.h"
28 #include "input.h"
29 #include "toplev.h"
30
31 /* The character(s) used to join a directory specification (obtained with
32 getwd or equivalent) with a non-absolute file name. */
33
34 #ifndef FILE_NAME_JOINER
35 #define FILE_NAME_JOINER "/"
36 #endif
37
38 /* Nonzero if NAME as a file name is absolute. */
39 #ifndef FILE_NAME_ABSOLUTE_P
40 #define FILE_NAME_ABSOLUTE_P(NAME) (NAME[0] == '/')
41 #endif
42
43 /* For cross referencing. */
44
45 int flag_gnu_xref;
46
47 /************************************************************************/
48 /* */
49 /* Common definitions */
50 /* */
51 /************************************************************************/
52
53 #ifndef TRUE
54 #define TRUE 1
55 #endif
56 #ifndef FALSE
57 #define FALSE 0
58 #endif
59
60 #define PALLOC(typ) ((typ *) xcalloc(1,sizeof(typ)))
61
62
63 /* Return a malloc'd copy of STR. */
64 #define SALLOC(str) ((char *) ((str) == NULL ? NULL : xstrdup (str)))
65 #define SFREE(str) (str != NULL && (free(str),0))
66
67 #define STREQL(s1,s2) (strcmp((s1),(s2)) == 0)
68 #define STRNEQ(s1,s2) (strcmp((s1),(s2)) != 0)
69 #define STRLSS(s1,s2) (strcmp((s1),(s2)) < 0)
70 #define STRLEQ(s1,s2) (strcmp((s1),(s2)) <= 0)
71 #define STRGTR(s1,s2) (strcmp((s1),(s2)) > 0)
72 #define STRGEQ(s1,s2) (strcmp((s1),(s2)) >= 0)
73
74 /************************************************************************/
75 /* */
76 /* Type definitions */
77 /* */
78 /************************************************************************/
79
80
81 typedef struct _XREF_FILE * XREF_FILE;
82 typedef struct _XREF_SCOPE * XREF_SCOPE;
83
84 typedef struct _XREF_FILE
85 {
86 const char *name;
87 const char *outname;
88 XREF_FILE next;
89 } XREF_FILE_INFO;
90
91 typedef struct _XREF_SCOPE
92 {
93 int gid;
94 int lid;
95 XREF_FILE file;
96 int start;
97 XREF_SCOPE outer;
98 } XREF_SCOPE_INFO;
99
100 /************************************************************************/
101 /* */
102 /* Local storage */
103 /* */
104 /************************************************************************/
105
106 static char doing_xref = 0;
107 static FILE * xref_file = NULL;
108 static char xref_name[1024];
109 static XREF_FILE all_files = NULL;
110 static char * wd_name = NULL;
111 static XREF_SCOPE cur_scope = NULL;
112 static int scope_ctr = 0;
113 static XREF_FILE last_file = NULL;
114 static tree last_fndecl = NULL;
115
116 /************************************************************************/
117 /* */
118 /* Forward definitions */
119 /* */
120 /************************************************************************/
121 static void gen_assign PARAMS ((XREF_FILE, tree));
122 static XREF_FILE find_file PARAMS ((const char *));
123 static const char * filename PARAMS ((XREF_FILE));
124 static const char * fctname PARAMS ((tree));
125 static const char * declname PARAMS ((tree));
126 static void simplify_type PARAMS ((char *));
127 static const char * fixname PARAMS ((const char *, char *));
128 static void open_xref_file PARAMS ((const char *));
129 static const char * classname PARAMS ((tree));
130
131 /* Start cross referencing. FILE is the name of the file we xref. */
132
133 void
134 GNU_xref_begin (file)
135 const char *file;
136 {
137 doing_xref = 1;
138
139 if (file != NULL && STRNEQ (file,"-"))
140 {
141 open_xref_file(file);
142 GNU_xref_file(file);
143 }
144 }
145
146 /* Finish cross-referencing. ERRCNT is the number of errors
147 we encountered. */
148
149 void
150 GNU_xref_end (ect)
151 int ect;
152 {
153 XREF_FILE xf;
154
155 if (!doing_xref) return;
156
157 xf = find_file (input_filename);
158 if (xf == NULL) return;
159
160 while (cur_scope != NULL)
161 GNU_xref_end_scope(cur_scope->gid,0,0,0);
162
163 doing_xref = 0;
164
165 if (xref_file == NULL) return;
166
167 fclose (xref_file);
168
169 xref_file = NULL;
170 all_files = NULL;
171
172 if (ect > 0) unlink (xref_name);
173 }
174
175 /* Write out xref for file named NAME. */
176
177 void
178 GNU_xref_file (name)
179 const char *name;
180 {
181 XREF_FILE xf;
182
183 if (!doing_xref || name == NULL) return;
184
185 if (xref_file == NULL)
186 {
187 open_xref_file (name);
188 if (!doing_xref) return;
189 }
190
191 if (all_files == NULL)
192 fprintf(xref_file,"SCP * 0 0 0 0 RESET\n");
193
194 xf = find_file (name);
195 if (xf != NULL) return;
196
197 xf = PALLOC (XREF_FILE_INFO);
198 xf->name = SALLOC (name);
199 xf->next = all_files;
200 all_files = xf;
201
202 if (wd_name == NULL)
203 wd_name = getpwd ();
204
205 if (FILE_NAME_ABSOLUTE_P (name) || ! wd_name)
206 xf->outname = xf->name;
207 else
208 {
209 char *nmbuf
210 = (char *) xmalloc (strlen (wd_name) + strlen (FILE_NAME_JOINER)
211 + strlen (name) + 1);
212 sprintf (nmbuf, "%s%s%s", wd_name, FILE_NAME_JOINER, name);
213 name = nmbuf;
214 xf->outname = nmbuf;
215 }
216
217 fprintf (xref_file, "FIL %s %s 0\n", name, wd_name);
218
219 filename (xf);
220 fctname (NULL);
221 }
222
223 /* Start a scope identified at level ID. */
224
225 void
226 GNU_xref_start_scope (id)
227 HOST_WIDE_INT id;
228 {
229 XREF_SCOPE xs;
230 XREF_FILE xf;
231
232 if (!doing_xref) return;
233 xf = find_file (input_filename);
234
235 xs = PALLOC (XREF_SCOPE_INFO);
236 xs->file = xf;
237 xs->start = lineno;
238 if (xs->start <= 0) xs->start = 1;
239 xs->gid = id;
240 xs->lid = ++scope_ctr;
241 xs->outer = cur_scope;
242 cur_scope = xs;
243 }
244
245 /* Finish a scope at level ID.
246 INID is ???
247 PRM is ???
248 KEEP is nonzero iff this scope is retained (nonzero if it's
249 a compiler-generated invisible scope).
250 TRNS is ??? */
251
252 void
253 GNU_xref_end_scope (id,inid,prm,keep)
254 HOST_WIDE_INT id;
255 HOST_WIDE_INT inid;
256 int prm,keep;
257 {
258 XREF_FILE xf;
259 XREF_SCOPE xs,lxs,oxs;
260 const char *stype;
261
262 if (!doing_xref) return;
263 xf = find_file (input_filename);
264 if (xf == NULL) return;
265
266 lxs = NULL;
267 for (xs = cur_scope; xs != NULL; xs = xs->outer)
268 {
269 if (xs->gid == id) break;
270 lxs = xs;
271 }
272 if (xs == NULL) return;
273
274 if (inid != 0) {
275 for (oxs = cur_scope; oxs != NULL; oxs = oxs->outer) {
276 if (oxs->gid == inid) break;
277 }
278 if (oxs == NULL) return;
279 inid = oxs->lid;
280 }
281
282 if (prm == 2) stype = "SUE";
283 else if (prm != 0) stype = "ARGS";
284 else if (keep == 2 || inid != 0) stype = "INTERN";
285 else stype = "EXTERN";
286
287 fprintf (xref_file, "SCP %s %d %d %d ",
288 filename (xf), xs->start, lineno,xs->lid);
289 fprintf (xref_file, HOST_WIDE_INT_PRINT_DEC, inid);
290 fprintf (xref_file, " %s\n", stype);
291
292 if (lxs == NULL) cur_scope = xs->outer;
293 else lxs->outer = xs->outer;
294
295 free (xs);
296 }
297
298 /* Output a reference to NAME in FNDECL. */
299
300 void
301 GNU_xref_ref (fndecl,name)
302 tree fndecl;
303 const char *name;
304 {
305 XREF_FILE xf;
306
307 if (!doing_xref) return;
308 xf = find_file (input_filename);
309 if (xf == NULL) return;
310
311 fprintf (xref_file, "REF %s %d %s %s\n",
312 filename (xf), lineno, fctname (fndecl), name);
313 }
314
315 /* Output a reference to DECL in FNDECL. */
316
317 void
318 GNU_xref_decl (fndecl,decl)
319 tree fndecl;
320 tree decl;
321 {
322 XREF_FILE xf,xf1;
323 const char *cls = 0;
324 const char *name;
325 char buf[10240];
326 int uselin;
327
328 if (!doing_xref) return;
329 xf = find_file (input_filename);
330 if (xf == NULL) return;
331
332 uselin = FALSE;
333
334 if (TREE_CODE (decl) == TYPE_DECL) cls = "TYPEDEF";
335 else if (TREE_CODE (decl) == FIELD_DECL) cls = "FIELD";
336 else if (TREE_CODE (decl) == VAR_DECL)
337 {
338 if (fndecl == NULL && TREE_STATIC(decl)
339 && TREE_READONLY(decl) && DECL_INITIAL(decl) != 0
340 && !TREE_PUBLIC(decl) && !DECL_EXTERNAL(decl)
341 && DECL_MODE(decl) != BLKmode) cls = "CONST";
342 else if (DECL_EXTERNAL(decl)) cls = "EXTERN";
343 else if (TREE_PUBLIC(decl)) cls = "EXTDEF";
344 else if (TREE_STATIC(decl)) cls = "STATIC";
345 else if (DECL_REGISTER(decl)) cls = "REGISTER";
346 else cls = "AUTO";
347 }
348 else if (TREE_CODE (decl) == PARM_DECL) cls = "PARAM";
349 else if (TREE_CODE (decl) == FIELD_DECL) cls = "FIELD";
350 else if (TREE_CODE (decl) == CONST_DECL) cls = "CONST";
351 else if (TREE_CODE (decl) == FUNCTION_DECL)
352 {
353 if (DECL_EXTERNAL (decl)) cls = "EXTERN";
354 else if (TREE_PUBLIC (decl)) cls = "EFUNCTION";
355 else cls = "SFUNCTION";
356 }
357 else if (TREE_CODE (decl) == LABEL_DECL) cls = "LABEL";
358 else if (TREE_CODE (decl) == UNION_TYPE)
359 {
360 cls = "UNIONID";
361 decl = TYPE_NAME (decl);
362 uselin = TRUE;
363 }
364 else if (TREE_CODE (decl) == RECORD_TYPE)
365 {
366 if (CLASSTYPE_DECLARED_CLASS (decl)) cls = "CLASSID";
367 else cls = "STRUCTID";
368 decl = TYPE_NAME (decl);
369 uselin = TRUE;
370 }
371 else if (TREE_CODE (decl) == ENUMERAL_TYPE)
372 {
373 cls = "ENUMID";
374 decl = TYPE_NAME (decl);
375 uselin = TRUE;
376 }
377 else if (TREE_CODE (decl) == TEMPLATE_DECL)
378 {
379 if (TREE_CODE (DECL_RESULT (decl)) == TYPE_DECL)
380 cls = "CLASSTEMP";
381 else if (TREE_CODE (DECL_RESULT (decl)) == FUNCTION_DECL)
382 cls = "FUNCTEMP";
383 else if (TREE_CODE (DECL_RESULT (decl)) == VAR_DECL)
384 cls = "VARTEMP";
385 else
386 my_friendly_abort (358);
387 uselin = TRUE;
388 }
389 else cls = "UNKNOWN";
390
391 if (decl == NULL || DECL_NAME (decl) == NULL) return;
392
393 if (uselin && decl->decl.linenum > 0 && decl->decl.filename != NULL)
394 {
395 xf1 = find_file (decl->decl.filename);
396 if (xf1 != NULL)
397 {
398 lineno = decl->decl.linenum;
399 xf = xf1;
400 }
401 }
402
403 if (DECL_ASSEMBLER_NAME (decl))
404 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
405 else
406 name = IDENTIFIER_POINTER (DECL_NAME (decl));
407
408 strcpy (buf, type_as_string (TREE_TYPE (decl), 0));
409 simplify_type (buf);
410
411 fprintf (xref_file, "DCL %s %d %s %d %s %s %s\n",
412 filename(xf), lineno, name,
413 (cur_scope != NULL ? cur_scope->lid : 0),
414 cls, fctname(fndecl), buf);
415
416 if (STREQL (cls, "STRUCTID") || STREQL (cls, "UNIONID"))
417 {
418 cls = "CLASSID";
419 fprintf (xref_file, "DCL %s %d %s %d %s %s %s\n",
420 filename(xf), lineno,name,
421 (cur_scope != NULL ? cur_scope->lid : 0),
422 cls, fctname(fndecl), buf);
423 }
424 }
425
426 /* Output a reference to a call to NAME in FNDECL. */
427
428 void
429 GNU_xref_call (fndecl, name)
430 tree fndecl;
431 const char *name;
432 {
433 XREF_FILE xf;
434 char buf[1024];
435 const char *s;
436
437 if (!doing_xref) return;
438 xf = find_file (input_filename);
439 if (xf == NULL) return;
440 name = fixname (name, buf);
441
442 for (s = name; *s != 0; ++s)
443 if (*s == '_' && s[1] == '_') break;
444 if (*s != 0) GNU_xref_ref (fndecl, name);
445
446 fprintf (xref_file, "CAL %s %d %s %s\n",
447 filename (xf), lineno, name, fctname (fndecl));
448 }
449
450 /* Output cross-reference info about FNDECL. If non-NULL,
451 ARGS are the arguments for the function (i.e., before the FUNCTION_DECL
452 has been fully built). */
453
454 void
455 GNU_xref_function (fndecl, args)
456 tree fndecl;
457 tree args;
458 {
459 XREF_FILE xf;
460 int ct;
461 char buf[1024];
462
463 if (!doing_xref) return;
464 xf = find_file (input_filename);
465 if (xf == NULL) return;
466
467 ct = 0;
468 buf[0] = 0;
469 if (args == NULL) args = DECL_ARGUMENTS (fndecl);
470
471 GNU_xref_decl (NULL, fndecl);
472
473 for ( ; args != NULL; args = TREE_CHAIN (args))
474 {
475 GNU_xref_decl (fndecl,args);
476 if (ct != 0) strcat (buf,",");
477 strcat (buf, declname (args));
478 ++ct;
479 }
480
481 fprintf (xref_file, "PRC %s %d %s %d %d %s\n",
482 filename(xf), lineno, declname(fndecl),
483 (cur_scope != NULL ? cur_scope->lid : 0),
484 ct, buf);
485 }
486
487 /* Output cross-reference info about an assignment to NAME. */
488
489 void
490 GNU_xref_assign(name)
491 tree name;
492 {
493 XREF_FILE xf;
494
495 if (!doing_xref) return;
496 xf = find_file(input_filename);
497 if (xf == NULL) return;
498
499 gen_assign(xf, name);
500 }
501
502 static void
503 gen_assign(xf, name)
504 XREF_FILE xf;
505 tree name;
506 {
507 const char *s;
508
509 s = NULL;
510
511 switch (TREE_CODE (name))
512 {
513 case IDENTIFIER_NODE :
514 s = IDENTIFIER_POINTER(name);
515 break;
516 case VAR_DECL :
517 s = declname(name);
518 break;
519 case COMPONENT_REF :
520 gen_assign(xf, TREE_OPERAND(name, 0));
521 gen_assign(xf, TREE_OPERAND(name, 1));
522 break;
523 case INDIRECT_REF :
524 case OFFSET_REF :
525 case ARRAY_REF :
526 case BUFFER_REF :
527 gen_assign(xf, TREE_OPERAND(name, 0));
528 break;
529 case COMPOUND_EXPR :
530 gen_assign(xf, TREE_OPERAND(name, 1));
531 break;
532 default :
533 break;
534 }
535
536 if (s != NULL)
537 fprintf(xref_file, "ASG %s %d %s\n", filename(xf), lineno, s);
538 }
539
540 static const char *
541 classname (cls)
542 tree cls;
543 {
544 if (cls && TREE_CODE_CLASS (TREE_CODE (cls)) == 't')
545 cls = TYPE_NAME (cls);
546 if (cls && TREE_CODE_CLASS (TREE_CODE (cls)) == 'd')
547 cls = DECL_NAME (cls);
548 if (cls && TREE_CODE (cls) == IDENTIFIER_NODE)
549 return IDENTIFIER_POINTER (cls);
550 return "?";
551 }
552
553 /* Output cross-reference info about a class hierarchy.
554 CLS is the class type of interest. BASE is a baseclass
555 for CLS. PUB and VIRT give the access info about
556 the class derivation. FRND is nonzero iff BASE is a friend
557 of CLS.
558
559 ??? Needs to handle nested classes. */
560
561 void
562 GNU_xref_hier(cls, base, pub, virt, frnd)
563 tree cls;
564 tree base;
565 int pub;
566 int virt;
567 int frnd;
568 {
569 XREF_FILE xf;
570
571 if (!doing_xref) return;
572 xf = find_file(input_filename);
573 if (xf == NULL) return;
574
575 fprintf(xref_file, "HIE %s %d %s %s %d %d %d\n",
576 filename(xf), lineno, classname (cls), classname (base),
577 pub, virt, frnd);
578 }
579
580 /* Output cross-reference info about class members. CLS
581 is the containing type; FLD is the class member. */
582
583 void
584 GNU_xref_member(cls, fld)
585 tree cls;
586 tree fld;
587 {
588 XREF_FILE xf;
589 const char *prot;
590 int confg, pure;
591 const char *d;
592 #ifdef XREF_SHORT_MEMBER_NAMES
593 int i;
594 #endif
595 char buf[1024], bufa[1024];
596
597 if (!doing_xref) return;
598 xf = find_file(fld->decl.filename);
599 if (xf == NULL) return;
600
601 if (TREE_PRIVATE (fld)) prot = "PRIVATE";
602 else if (TREE_PROTECTED(fld)) prot = "PROTECTED";
603 else prot = "PUBLIC";
604
605 confg = 0;
606 if (TREE_CODE (fld) == FUNCTION_DECL && DECL_CONST_MEMFUNC_P(fld))
607 confg = 1;
608 else if (TREE_CODE (fld) == CONST_DECL)
609 confg = 1;
610
611 pure = 0;
612 if (TREE_CODE (fld) == FUNCTION_DECL && DECL_PURE_VIRTUAL_P(fld))
613 pure = 1;
614
615 d = IDENTIFIER_POINTER(cls);
616 sprintf(buf, "%d%s", (int) strlen(d), d);
617 #ifdef XREF_SHORT_MEMBER_NAMES
618 i = strlen(buf);
619 #endif
620 strcpy(bufa, declname(fld));
621
622 #ifdef XREF_SHORT_MEMBER_NAMES
623 for (p = &bufa[1]; *p != 0; ++p)
624 {
625 if (p[0] == '_' && p[1] == '_' && p[2] >= '0' && p[2] <= '9') {
626 if (strncmp(&p[2], buf, i) == 0) *p = 0;
627 break;
628 }
629 else if (p[0] == '_' && p[1] == '_' && p[2] == 'C' && p[3] >= '0' && p[3] <= '9') {
630 if (strncmp(&p[3], buf, i) == 0) *p = 0;
631 break;
632 }
633 }
634 #endif
635
636 fprintf(xref_file, "MEM %s %d %s %s %s %d %d %d %d %d %d %d\n",
637 filename(xf), fld->decl.linenum, d, bufa, prot,
638 (TREE_CODE (fld) == FUNCTION_DECL ? 0 : 1),
639 (DECL_INLINE (fld) ? 1 : 0),
640 (DECL_LANG_SPECIFIC(fld) && DECL_FRIEND_P(fld) ? 1 : 0),
641 (DECL_VINDEX(fld) ? 1 : 0),
642 (TREE_STATIC(fld) ? 1 : 0),
643 pure, confg);
644 }
645
646 /* Find file entry given name. */
647
648 static XREF_FILE
649 find_file(name)
650 const char *name;
651 {
652 XREF_FILE xf;
653
654 for (xf = all_files; xf != NULL; xf = xf->next) {
655 if (STREQL(name, xf->name)) break;
656 }
657
658 return xf;
659 }
660
661 /* Return filename for output purposes. */
662
663 static const char *
664 filename(xf)
665 XREF_FILE xf;
666 {
667 if (xf == NULL) {
668 last_file = NULL;
669 return "*";
670 }
671
672 if (last_file == xf) return "*";
673
674 last_file = xf;
675
676 return xf->outname;
677 }
678
679 /* Return function name for output purposes. */
680
681 static const char *
682 fctname(fndecl)
683 tree fndecl;
684 {
685 static char fctbuf[1024];
686 const char *s;
687
688 if (fndecl == NULL && last_fndecl == NULL) return "*";
689
690 if (fndecl == NULL)
691 {
692 last_fndecl = NULL;
693 return "*TOP*";
694 }
695
696 if (fndecl == last_fndecl) return "*";
697
698 last_fndecl = fndecl;
699
700 s = declname(fndecl);
701 s = fixname(s, fctbuf);
702
703 return s;
704 }
705
706 /* Return decl name for output purposes. */
707
708 static const char *
709 declname(dcl)
710 tree dcl;
711 {
712 if (DECL_NAME (dcl) == NULL) return "?";
713
714 if (DECL_ASSEMBLER_NAME (dcl))
715 return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (dcl));
716 else
717 return IDENTIFIER_POINTER (DECL_NAME (dcl));
718 }
719
720 /* Simplify a type string by removing unneeded parenthesis. */
721
722 static void
723 simplify_type(typ)
724 char *typ;
725 {
726 char *s;
727 int lvl, i;
728
729 i = strlen(typ);
730 while (i > 0 && ISSPACE((unsigned char) typ[i-1])) typ[--i] = 0;
731
732 if (i > 7 && STREQL(&typ[i-5], "const"))
733 {
734 typ[i-5] = 0;
735 i -= 5;
736 }
737
738 if (typ[i-1] != ')') return;
739
740 s = &typ[i-2];
741 lvl = 1;
742 while (*s != 0) {
743 if (*s == ')') ++lvl;
744 else if (*s == '(')
745 {
746 --lvl;
747 if (lvl == 0)
748 {
749 s[1] = ')';
750 s[2] = 0;
751 break;
752 }
753 }
754 --s;
755 }
756
757 if (*s != 0 && s[-1] == ')')
758 {
759 --s;
760 --s;
761 if (*s == '(') s[2] = 0;
762 else if (*s == ':') {
763 while (*s != '(') --s;
764 s[1] = ')';
765 s[2] = 0;
766 }
767 }
768 }
769
770 /* Fixup a function name (take care of embedded spaces). */
771
772 static const char *
773 fixname(nam, buf)
774 const char *nam;
775 char *buf;
776 {
777 const char *s;
778 char *t;
779 int fg;
780
781 s = nam;
782 t = buf;
783 fg = 0;
784
785 while (*s != 0)
786 {
787 if (*s == ' ')
788 {
789 *t++ = '\36';
790 ++fg;
791 }
792 else *t++ = *s;
793 ++s;
794 }
795 *t = 0;
796
797 if (fg == 0) return nam;
798
799 return buf;
800 }
801
802 /* Open file for xreffing. */
803
804 static void
805 open_xref_file(file)
806 const char *file;
807 {
808 const char *s;
809 char *t;
810
811 #ifdef XREF_FILE_NAME
812 XREF_FILE_NAME (xref_name, file);
813 #else
814 s = rindex (file, '/');
815 if (s == NULL)
816 sprintf (xref_name, ".%s.gxref", file);
817 else
818 {
819 ++s;
820 strcpy (xref_name, file);
821 t = rindex (xref_name, '/');
822 ++t;
823 *t++ = '.';
824 strcpy (t, s);
825 strcat (t, ".gxref");
826 }
827 #endif /* no XREF_FILE_NAME */
828
829 xref_file = fopen(xref_name, "w");
830
831 if (xref_file == NULL)
832 {
833 error("Can't create cross-reference file `%s'", xref_name);
834 doing_xref = 0;
835 }
836 }
This page took 0.097706 seconds and 5 git commands to generate.