Changeset 9239 for trunk/tools
- Timestamp:
- Sep 15, 2002, 1:24:42 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/fastdep/fastdep.c
r9209 r9239 1 /* $Id: fastdep.c,v 1.4 3 2002-09-05 02:21:23bird Exp $1 /* $Id: fastdep.c,v 1.44 2002-09-14 23:24:42 bird Exp $ 2 2 * 3 3 * Fast dependents. (Fast = Quick and Dirty!) … … 140 140 */ 141 141 typedef int ( _FNLANG) (const char *pszFilename, const char *pszNormFilename, 142 const char *pszTS, BOOL fHeader );142 const char *pszTS, BOOL fHeader, void **ppvRule); 143 143 typedef _FNLANG *PFNLANG; 144 144 … … 149 149 typedef struct _ConfigEntry 150 150 { 151 char szId[16]; /* Config ID. */ 151 152 const char **papszExts; /* Pointer to an array of pointer to extentions for this handler. */ 152 153 /* If NULL this is the last entry. */ … … 155 156 /* A non-header file may get a object rule. */ 156 157 PFNLANG pfn; /* Pointer to handler function. */ 158 char *pszzAddDeps; /* Pointer to an string of string of additional dependencies. */ 157 159 } CONFIGENTRY, *PCONFIGENTRY; 158 160 … … 185 187 static int makeDependent(const char *pszFilename, const char *pszTS); 186 188 187 static int langC_CPP(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader );188 static int langAsm( const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader );189 static int langRC( const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader );190 static int langCOBOL(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader );191 static int langIPF( const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader );189 static int langC_CPP(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule); 190 static int langAsm( const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule); 191 static int langRC( const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule); 192 static int langCOBOL(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule); 193 static int langIPF( const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader, void **ppvRule); 192 194 193 195 … … 251 253 static BOOL depValidate(PDEPRULE pdepRule); 252 254 INLINE char *depMakeTS(char *pszTS, PFILEFINDBUF3 pfindbuf3); 255 static void depAddSrcAddDeps(void *pvRule, const char *pszz); 253 256 254 257 … … 291 294 static const char *apszExtC_CPP[] = {"c", "sqc", "cpp", "h", "hpp", NULL}; 292 295 static const char *apszExtAsm[] = {"asm", "inc", NULL}; 293 static const char *apszExtRC[] = {"rc", "orc", "dlg", NULL}; 296 static const char *apszExtRC[] = {"rc", "dlg", NULL}; 297 static const char *apszExtORC[] = {"orc", "dlg", NULL}; 294 298 static const char *apszExtCOBOL[] = {"cbl", "cob", "sqb", "wbl", NULL}; 295 static const char *apszExtIPF[] = {"ipf", "man", NULL};299 static const char *apszExtIPF[] = {"ipf", "man", NULL}; 296 300 static CONFIGENTRY aConfig[] = 297 301 { 298 302 { 303 "CX", 299 304 apszExtC_CPP, 300 305 3, 301 306 langC_CPP, 307 NULL, 302 308 }, 303 309 304 310 { 311 "AS", 305 312 apszExtAsm, 306 313 1, 307 314 langAsm, 315 NULL, 308 316 }, 309 317 310 318 { 319 "RC", 311 320 apszExtRC, 312 2,321 1, 313 322 langRC, 323 NULL, 314 324 }, 315 325 316 326 { 327 "ORC", 328 apszExtORC, 329 1, 330 langRC, 331 NULL, 332 }, 333 334 { 335 "COB", 317 336 apszExtCOBOL, 318 337 -1, 319 338 langCOBOL, 339 NULL, 320 340 }, 321 341 322 342 { 343 "IPF", 323 344 apszExtIPF, 324 345 -1, 325 346 langIPF, 347 NULL, 326 348 }, 327 349 328 350 /* terminating entry */ 329 351 { 352 "", 330 353 NULL, 331 354 -1, 355 NULL, 332 356 NULL 333 357 } … … 659 683 break; 660 684 685 case 's': 686 case 'S': 687 if (!strnicmp(argv[argi]+1, "srcadd", 6)) 688 { 689 if (strlen(argv[argi]) > 7) 690 psz = argv[argi]+2; 691 else 692 { 693 if (++argi >= argc) 694 { 695 fprintf(stderr, "syntax error! Option -srcadd.\n"); 696 return 1; 697 } 698 psz = argv[argi]; 699 } 700 if (!(psz2 = strchr(psz, ':'))) 701 { 702 fprintf(stderr, "syntax error! Option -srcadd malformed!\n"); 703 return 1; 704 } 705 for (i = 0; aConfig[i].pfn; i++) 706 { 707 if ( !strnicmp(aConfig[i].szId, psz, psz2 - psz) 708 && !aConfig[i].szId[psz2 - psz]) 709 { 710 int cch, cch2; 711 if (!*++psz2) 712 { 713 fprintf(stderr, "error: Option -srcadd no additioanl dependancy!\n", 714 psz2 - psz, psz); 715 return 1; 716 } 717 cch = 0; 718 psz = aConfig[i].pszzAddDeps; 719 if (psz) 720 { 721 do 722 { 723 cch += (cch2 = strlen(psz)) + 1; 724 psz += cch2 + 1; 725 } while (*psz); 726 } 727 cch2 = strlen(psz2); 728 aConfig[i].pszzAddDeps = realloc(aConfig[i].pszzAddDeps, cch + cch2 + 2); 729 if (!aConfig[i].pszzAddDeps) 730 { 731 fprintf(stderr, "error: Out of memory!\n"); 732 return 1; 733 } 734 strcpy(aConfig[i].pszzAddDeps + cch, psz2); 735 aConfig[i].pszzAddDeps[cch + cch2 + 1] = '\0'; 736 psz = NULL; 737 break; 738 } 739 } 740 if (psz) 741 { 742 fprintf(stderr, "error: Option -srcadd, invalid language id '%.*s%'\n", 743 psz2 - psz, psz); 744 return 1; 745 } 746 } 747 else 748 { 749 fprintf(stderr, "syntax error! Invalid option %s\n", argv[argi]); 750 return 1; 751 } 752 break; 753 661 754 case 'x': 662 755 case 'X': /* Exclude files */ … … 861 954 { 862 955 printf( 863 "FastDep v0.4 6(build %d)\n"956 "FastDep v0.47 (build %d)\n" 864 957 "Dependency scanner. Creates a makefile readable depend file.\n" 865 958 " - was quick and dirty, now it's just quick -\n" … … 895 988 " -obr-: No object rule, rule for source filename is generated.\n" 896 989 " -obj[ ]<objext> Object extention. Default: obj\n" 990 " -srcadd[ ]<langid>:<dep>\n" 991 " Additional dependants for source file of the given language\n" 992 " type. langid: AS,CX,RC,ORC,COB,IPF\n" 993 " This is very usfull for compiler configuration files.\n" 897 994 " -r[ ]<rsrcext> Resource binary extention. Default: res\n" 898 995 " -x[ ]<f1[;f2]> Files to exclude. Only exact filenames.\n" … … 944 1041 if (pCfg->papszExts != NULL) 945 1042 { 946 char szNormFile[CCHMAXPATH]; 1043 void * pvRule = NULL; 1044 char szNormFile[CCHMAXPATH]; 947 1045 fileNormalize2(pszFilename, szNormFile); 948 rc = (*pCfg->pfn)(pszFilename, &szNormFile[0], pszTS, fHeader); 1046 rc = (*pCfg->pfn)(pszFilename, &szNormFile[0], pszTS, fHeader, &pvRule); 1047 if (!rc && pvRule) 1048 { 1049 if (!fHeader && pCfg->pszzAddDeps) 1050 depAddSrcAddDeps(pvRule, pCfg->pszzAddDeps); 1051 } 949 1052 } 950 1053 else … … 969 1072 * @param pszTS File time stamp. 970 1073 * @parma fHeader True if header file is being scanned. 1074 * @param ppvRule Variabel to return any new rule handle. 971 1075 * @status completely implemented. 972 1076 * @author knut st. osmundsen 973 1077 */ 974 1078 int langC_CPP(const char *pszFilename, const char *pszNormFilename, 975 const char *pszTS, BOOL fHeader )1079 const char *pszTS, BOOL fHeader, void **ppvRule) 976 1080 { 977 1081 void * pvFile; /* Text buffer pointer. */ … … 1023 1127 1024 1128 /* duplicate rule? */ 1129 *ppvRule = pvRule; 1025 1130 if (pvRule == NULL) 1026 1131 return 0; … … 1279 1384 * @param pszTS File time stamp. 1280 1385 * @parma fHeader True if header file is being scanned. 1386 * @param ppvRule Variabel to return any new rule handle. 1281 1387 * @status completely implemented. 1282 1388 * @author knut st. osmundsen 1283 1389 */ 1284 1390 int langAsm(const char *pszFilename, const char *pszNormFilename, 1285 const char *pszTS, BOOL fHeader )1391 const char *pszTS, BOOL fHeader, void **ppvRule) 1286 1392 { 1287 1393 void * pvFile; /* Text buffer pointer. */ … … 1317 1423 1318 1424 /* duplicate rule? */ 1425 *ppvRule = pvRule; 1319 1426 if (pvRule == NULL) 1320 1427 return 0; … … 1461 1568 1462 1569 /* duplicate rule? */ 1570 *ppvRule = pvRule; 1463 1571 if (pvRule == NULL) 1464 1572 return 0; … … 1585 1693 #else 1586 1694 int langRC(const char *pszFilename, const char *pszNormFilename, 1587 const char *pszTS, BOOL fHeader )1695 const char *pszTS, BOOL fHeader, void **ppvRule) 1588 1696 { 1589 1697 void * pvFile; /* Text buffer pointer. */ … … 1634 1742 1635 1743 /* duplicate rule? */ 1744 *ppvRule = pvRule; 1636 1745 if (pvRule == NULL) 1637 1746 return 0; … … 1957 2066 * @param pszTS File time stamp. 1958 2067 * @parma fHeader True if header file is being scanned. 2068 * @param ppvRule Variabel to return any new rule handle. 1959 2069 * @status completely implemented. 1960 2070 * @author knut st. osmundsen 1961 2071 */ 1962 2072 int langCOBOL(const char *pszFilename, const char *pszNormFilename, 1963 const char *pszTS, BOOL fHeader )2073 const char *pszTS, BOOL fHeader, void **ppvRule) 1964 2074 { 1965 2075 void * pvFile; /* Text buffer pointer. */ … … 1996 2106 1997 2107 /* duplicate rule? */ 2108 *ppvRule = pvRule; 1998 2109 if (pvRule == NULL) 1999 2110 return 0; … … 2132 2243 * @param pszNormFilename Pointer to normalized source filename. 2133 2244 * @param pszTS File time stamp. 2134 * @parma fHeader True if header file is being scanned. 2245 * @param fHeader True if header file is being scanned. 2246 * @param ppvRule Variabel to return any new rule handle. 2135 2247 * @status completely implemented. 2136 2248 * @author knut st. osmundsen 2137 2249 */ 2138 2250 int langIPF( const char *pszFilename, const char *pszNormFilename, 2139 const char *pszTS, BOOL fHeader )2251 const char *pszTS, BOOL fHeader, void **ppvRule) 2140 2252 { 2141 2253 void * pvFile; /* Text buffer pointer. */ … … 2172 2284 2173 2285 /* duplicate rule? */ 2286 *ppvRule = pvRule; 2174 2287 if (pvRule == NULL) 2175 2288 return 0; … … 2259 2372 2260 2373 textbufferDestroy(pvFile); 2261 2262 2374 fHeader = fHeader; 2375 2263 2376 return 0; 2264 2377 } … … 3916 4029 { 3917 4030 char *psz = pdepRule->papszDep[i]; 3918 if ( psz[1] == ':' 4031 if ( !strchr(psz, '$') 4032 && 4033 ( psz[1] == ':' 3919 4034 || strchr(psz, '\\') 3920 4035 || strchr(psz, '/') 4036 ) 3921 4037 ) 3922 4038 { … … 3989 4105 3990 4106 4107 /** 4108 * Adds the src additioanl dependenies to a rule. 4109 * @param pvRule Rule to add them to. 4110 * @param pszz Pointer to the string of strings of extra dependencies. 4111 */ 4112 void depAddSrcAddDeps(void *pvRule, const char *pszz) 4113 { 4114 while (*pszz) 4115 { 4116 depAddDepend(pvRule, pszz, FALSE, FALSE); 4117 pszz += strlen(pszz) + 1; 4118 } 4119 } 4120 4121 3991 4122 3992 4123
Note:
See TracChangeset
for help on using the changeset viewer.