You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pr.c 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* $XConsortium: pr.c,v 1.17 94/04/17 20:10:38 gildea Exp $ */
  2. /*
  3. Copyright (c) 1993, 1994 X Consortium
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  16. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. Except as contained in this notice, the name of the X Consortium shall not be
  19. used in advertising or otherwise to promote the sale, use or other dealings
  20. in this Software without prior written authorization from the X Consortium.
  21. */
  22. #include "def.h"
  23. extern struct inclist inclist[ MAXFILES ],
  24. *inclistp;
  25. extern char *objprefix;
  26. extern char *objsuffix;
  27. extern int width;
  28. extern boolean printed;
  29. extern boolean verbose;
  30. extern boolean show_where_not;
  31. add_include(filep, file, file_red, include, dot, failOK)
  32. struct filepointer *filep;
  33. struct inclist *file, *file_red;
  34. char *include;
  35. boolean dot;
  36. {
  37. register struct inclist *newfile;
  38. register struct filepointer *content;
  39. /*
  40. * First decide what the pathname of this include file really is.
  41. */
  42. newfile = inc_path(file->i_file, include, dot);
  43. if (newfile == NULL) {
  44. if (failOK)
  45. return;
  46. if (file != file_red)
  47. warning("%s (reading %s, line %d): ",
  48. file_red->i_file, file->i_file, filep->f_line);
  49. else
  50. warning("%s, line %d: ", file->i_file, filep->f_line);
  51. warning1("cannot find include file \"%s\"\n", include);
  52. show_where_not = TRUE;
  53. newfile = inc_path(file->i_file, include, dot);
  54. show_where_not = FALSE;
  55. }
  56. if (newfile) {
  57. included_by(file, newfile);
  58. if (!newfile->i_searched) {
  59. newfile->i_searched = TRUE;
  60. content = getfile(newfile->i_file);
  61. find_includes(content, newfile, file_red, 0, failOK);
  62. freefile(content);
  63. }
  64. }
  65. }
  66. recursive_pr_include(head, file, base)
  67. register struct inclist *head;
  68. register char *file, *base;
  69. {
  70. register int i;
  71. if (head->i_marked)
  72. return;
  73. head->i_marked = TRUE;
  74. if (head->i_file != file)
  75. pr(head, file, base);
  76. for (i=0; i<head->i_listlen; i++)
  77. recursive_pr_include(head->i_list[ i ], file, base);
  78. }
  79. pr(ip, file, base)
  80. register struct inclist *ip;
  81. char *file, *base;
  82. {
  83. static char *lastfile;
  84. register int len, i;
  85. char buf[ BUFSIZ ];
  86. #ifdef WIN32
  87. char *transfile = TranslateFileNameD2U(ip->i_file,0);
  88. #else
  89. char *transfile = ip->i_file;
  90. #endif
  91. printed = TRUE;
  92. if (file != lastfile) {
  93. lastfile = file;
  94. sprintf(buf, "%s%s%s %s.d: %s", objprefix, base, objsuffix,
  95. base, transfile);
  96. }
  97. else {
  98. sprintf(buf, " \\\n %s", transfile);
  99. }
  100. fwrite(buf, strlen(buf), 1, stdout);
  101. /*
  102. * If verbose is set, then print out what this file includes.
  103. */
  104. if (! verbose || ip->i_list == NULL || ip->i_notified)
  105. return;
  106. ip->i_notified = TRUE;
  107. lastfile = NULL;
  108. printf("\n# %s includes:", transfile);
  109. for (i=0; i<ip->i_listlen; i++)
  110. printf("\n#\t%s", ip->i_list[ i ]->i_incstring);
  111. #ifdef WIN32
  112. free(transfile);
  113. #endif
  114. }