Source code of Windows XP (NT5)
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.

241 lines
6.4 KiB

  1. // PRINT.C -- routines to display info for -p option
  2. //
  3. // Copyright (c) 1988-1990, Microsoft Corporation. All rights reserved.
  4. //
  5. // Purpose:
  6. // Contains routines that print stuff for -p (and also -z, ifdef'ed)
  7. //
  8. // Revision History:
  9. // 04-Feb-2000 BTF Ported to Win64
  10. // 15-Oct-1993 HV Use tchar.h instead of mbstring.h directly, change STR*() to _ftcs*()
  11. // 10-May-1993 HV Add include file mbstring.h
  12. // Change the str* functions to STR*
  13. // 08-Jun-1992 SS Port to DOSX32
  14. // 16-May-1991 SB Move printDate() here from build.c
  15. // 02-Feb-1990 SB change fopen() to FILEOPEN()
  16. // 22-Nov-1989 SB Changed free() to FREE()
  17. // 07-Nov-1989 SB When TMP ended in '\\' then don't add '\\' at end of path
  18. // specification for PWB.SHL
  19. // 19-Oct-1989 SB added searchHandle parameter
  20. // 18-Aug-1989 SB added fclose() error check
  21. // 05-Jul-1989 SB Cleaned up -p output to look neater
  22. // 19-Jun-1989 SB Localized messages with -p option
  23. // 24-Apr-1989 SB added 1.2 filename support, FILEINFO replaced by void *
  24. // 05-Apr-1989 SB made all funcs NEAR; Reqd to make all function calls NEAR
  25. // 10-Mar-1989 SB printReverse() now prints to TMP:PWB.SHL instead of stdout
  26. // 1-Dec-1988 SB Added printReverseFile() to handle 'z' option
  27. // 17-Aug-1988 RB Clean up.
  28. #include "precomp.h"
  29. #pragma hdrstop
  30. #include <time.h>
  31. #include "nmtime.h"
  32. // for formatting -p info
  33. #define PAD1 40
  34. size_t checkLineLength(size_t i, char *s);
  35. void showDependents(STRINGLIST*, STRINGLIST*);
  36. size_t
  37. checkLineLength(
  38. size_t i, // current length
  39. char *s // string whose length is to be checked
  40. )
  41. {
  42. if ((i += _tcslen(s)) > 40) {
  43. printf("\n\t\t\t");
  44. i = 0;
  45. }
  46. return(i);
  47. }
  48. void
  49. printDate(
  50. unsigned spaces, // spaces to print
  51. char *name, // name of file whose date is to be printed
  52. time_t dateTime // dateTime of file
  53. )
  54. {
  55. if (dateTime == 0) {
  56. makeMessage(TARGET_DOESNT_EXIST, spaces, "", name);
  57. } else {
  58. char *s;
  59. s = ctime(&dateTime);
  60. s[24] = '\0';
  61. makeMessage(TIME_FORMAT, spaces, "", name, PAD1-spaces, s);
  62. }
  63. }
  64. void
  65. showDependents(
  66. STRINGLIST *q, // list of dependents
  67. STRINGLIST *macros // macros in the dependents
  68. )
  69. {
  70. char *u, *v;
  71. char *w;
  72. size_t i;
  73. struct _finddata_t finddata;
  74. NMHANDLE searchHandle;
  75. makeMessage(DEPENDENTS_MESSAGE);
  76. for (i = 0; q; q = q->next) {
  77. char *szFilename;
  78. if (_tcschr(q->text, '$')) {
  79. u = expandMacros(q->text, &macros);
  80. for (v = _tcstok(u, " \t"); v; v = _tcstok(NULL, " \t")) {
  81. if (_tcspbrk(v, "*?")) {
  82. if (szFilename = findFirst(v, &finddata, &searchHandle)) {
  83. do {
  84. w = prependPath(v, szFilename);
  85. printf("%s ", w);
  86. i = checkLineLength(i, w);
  87. FREE(w);
  88. }
  89. while (szFilename = findNext(&finddata, searchHandle));
  90. }
  91. } else {
  92. printf("%s ", v);
  93. i = checkLineLength(i, v);
  94. }
  95. }
  96. FREE(u);
  97. } else if (_tcspbrk(q->text, "*?")) {
  98. if (szFilename = findFirst(q->text, &finddata, &searchHandle)) {
  99. do {
  100. v = prependPath(q->text, szFilename);
  101. printf("%s ", v);
  102. i = checkLineLength(i, v);
  103. FREE(v);
  104. }
  105. while (szFilename = findNext(&finddata, searchHandle));
  106. }
  107. } else {
  108. printf("%s ", q->text);
  109. i = checkLineLength(i, q->text);
  110. }
  111. }
  112. }
  113. void
  114. showMacros(
  115. void
  116. )
  117. {
  118. MACRODEF *p;
  119. STRINGLIST *q;
  120. int n = 0;
  121. makeMessage(MACROS_MESSAGE);
  122. for (n = 0; n < MAXMACRO; ++n) {
  123. for (p = macroTable[n]; p; p = p->next) {
  124. if (p->values && p->values->text) {
  125. makeMessage(MACRO_DEFINITION, p->name, p->values->text);
  126. for (q = p->values->next; q; q = q->next) {
  127. if (q->text) {
  128. printf("\t\t%s\n", q->text);
  129. }
  130. }
  131. }
  132. }
  133. }
  134. putchar('\n');
  135. fflush(stdout);
  136. }
  137. void
  138. showRules(
  139. void
  140. )
  141. {
  142. RULELIST *p;
  143. STRINGLIST *q;
  144. unsigned n;
  145. makeMessage(INFERENCE_MESSAGE);
  146. for (p = rules, n = 1; p; p = p->next, ++n) {
  147. printf(p->fBatch? "%s::" : "%s:", p->name);
  148. makeMessage(COMMANDS_MESSAGE);
  149. if (q = p->buildCommands) {
  150. printf("%s\n", q->text);
  151. while (q = q->next) {
  152. printf("\t\t\t%s\n", q->text);
  153. }
  154. }
  155. putchar('\n');
  156. }
  157. printf("%s: ", suffixes);
  158. for (q = dotSuffixList; q; q = q->next) {
  159. printf("%s ", q->text);
  160. }
  161. putchar('\n');
  162. fflush(stdout);
  163. }
  164. void
  165. showTargets(
  166. void
  167. )
  168. {
  169. unsigned bit, i;
  170. STRINGLIST *q;
  171. BUILDLIST *s;
  172. BUILDBLOCK *r;
  173. MAKEOBJECT *t;
  174. unsigned n;
  175. LOCAL char *flagLetters = "dinsb";
  176. makeMessage(TARGETS_MESSAGE);
  177. for (n = 0; n < MAXTARGET; ++n) {
  178. for (t = targetTable[n]; t; t = t->next, putchar('\n')) {
  179. printf("%s:%c", t->name,
  180. ON(t->buildList->buildBlock->flags, F2_DOUBLECOLON)
  181. ? ':' : ' ');
  182. dollarStar = dollarAt = dollarDollarAt = t->name;
  183. for (s = t->buildList; s; s = s->next) {
  184. r = s->buildBlock;
  185. makeMessage(FLAGS_MESSAGE);
  186. for (i = 0, bit = F2_DISPLAY_FILE_DATES;
  187. bit < F2_FORCE_BUILD;
  188. ++i, bit <<= 1)
  189. if (ON(r->flags, bit))
  190. printf("-%c ", flagLetters[i]);
  191. showDependents(r->dependents, r->dependentMacros);
  192. makeMessage(COMMANDS_MESSAGE);
  193. if (q = r->buildCommands) {
  194. if (q->text) printf("%s\n", q->text);
  195. while (q = q->next)
  196. if (q->text) printf("\t\t\t%s\n", q->text);
  197. }
  198. else putchar('\n');
  199. }
  200. }
  201. }
  202. dollarStar = dollarAt = dollarDollarAt = NULL;
  203. putchar('\n');
  204. fflush(stdout);
  205. }