Changeset 3180
- Timestamp:
- Mar 21, 2000, 2:16:18 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/tools/fastdep/fastdep.c ¶
r3169 r3180 1 /* $Id: fastdep.c,v 1.1 6 2000-03-19 16:23:55bird Exp $1 /* $Id: fastdep.c,v 1.17 2000-03-21 13:16:18 bird Exp $ 2 2 * 3 3 * Fast dependents. (Fast = Quick and Dirty!) … … 172 172 /* pathlist operations */ 173 173 static char *pathlistFindFile(const char *pszPathList, const char *pszFilename, char *pszBuffer, POPTIONS pOptions); 174 static BOOL pathlistFindFile2(const char *pszPathList, const char *pszFilename, POPTIONS pOptions); 174 175 175 176 /* word operations */ … … 670 671 { 671 672 printf( 672 "FastDep v0.2\n" 673 "Quick and dirty dependency scanner. Creates a makefile readable depend file.\n" 673 "FastDep v0.3\n" 674 "Dependency scanner. Creates a makefile readable depend file.\n" 675 " - was quick and dirty, now it's just quick -\n" 674 676 "\n" 675 677 "Syntax: FastDep [-a<[+]|->] [-ca] [-cy<[+]|->] [-d <outputfn>]\n" 676 678 " [-e <excludepath>] [-eall<[+]|->] [-i <include>] [-n<[+]|->]\n" 677 679 " [-o <objdir>] [-obr<[+]|->] <files>\n" 680 " or\n" 681 " FastDep [options] @<parameterfile>\n" 678 682 "\n" 679 683 " -a<[+]|-> Append to the output file. Default: Overwrite.\n" … … 685 689 " -e excludepath Exclude paths. If a filename is found in any\n" 686 690 " of these paths only the filename is used, not\n" 687 " the path+filename (which is default) (don't work?).\n"691 " the path+filename (which is default).\n" 688 692 " -eall<[+]|-> Include and source filenames, paths or no paths.\n" 689 693 " -eall+: No path are added to the filename.\n" … … 814 818 if (pOptions->fSrcWhenObj && pvRule) 815 819 depAddDepend(pvRule, 816 pOptions->fExcludeAll ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 820 pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, pszFilename, pOptions) ? 821 fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 817 822 pOptions->fCheckCyclic); 818 823 } 819 824 else 820 pvRule = depAddRule(pOptions->fExcludeAll ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), NULL, NULL); 825 pvRule = depAddRule(pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, pszFilename, pOptions) ? 826 fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), NULL, NULL); 821 827 822 828 /* duplicate rule? */ … … 920 926 if (psz != NULL) 921 927 { 922 char szBuffer2[CCHMAXPATH]; 923 if (pOptions->fExcludeAll || 924 pathlistFindFile(pOptions->pszExclude, szFullname, szBuffer2, pOptions) != NULL 925 ) 928 if (pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, szBuffer, pOptions)) 926 929 depAddDepend(pvRule, szFullname, pOptions->fCheckCyclic); 927 930 else … … 1080 1083 if (pOptions->fSrcWhenObj && pvRule) 1081 1084 depAddDepend(pvRule, 1082 pOptions->fExcludeAll ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 1085 pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, pszFilename, pOptions) ? 1086 fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 1083 1087 pOptions->fCheckCyclic); 1084 1088 } 1085 1089 else 1086 pvRule = depAddRule(pOptions->fExcludeAll ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), NULL, NULL); 1090 pvRule = depAddRule(pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, pszFilename, pOptions) ? 1091 fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), NULL, NULL); 1087 1092 1088 1093 /* duplicate rule? */ … … 1146 1151 if (psz != NULL) 1147 1152 { 1148 char szBuffer2[CCHMAXPATH]; 1149 if (pOptions->fExcludeAll || 1150 pathlistFindFile(pOptions->pszExclude, szFullname, szBuffer2, pOptions) != NULL 1151 ) 1153 if (pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, szBuffer, pOptions)) 1152 1154 depAddDepend(pvRule, szFullname, pOptions->fCheckCyclic); 1153 1155 else … … 1199 1201 if (pOptions->fSrcWhenObj && pvRule) 1200 1202 depAddDepend(pvRule, 1201 pOptions->fExcludeAll ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 1203 pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, pszFilename, pOptions) ? 1204 fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 1202 1205 pOptions->fCheckCyclic); 1203 1206 } 1204 1207 else 1205 pvRule = depAddRule(pOptions->fExcludeAll ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), NULL, NULL); 1208 pvRule = depAddRule(pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, pszFilename, pOptions) ? 1209 fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), NULL, NULL); 1206 1210 1207 1211 /* duplicate rule? */ … … 1219 1223 int cbLen; 1220 1224 int i = 0; 1225 int i1; 1221 1226 iLine++; 1222 1227 … … 1227 1232 1228 1233 /* is this an include? */ 1229 if ( strncmp(&szBuffer[i], "#include", 8) == 01230 || strncmp(&szBuffer[i], "RCINCLUDE", 9) == 01231 || strncmp(&szBuffer[i], "DLGINCLUDE", 10) == 01234 if ( (i1 = strncmp(&szBuffer[i], "#include", 8)) == 0 1235 || strncmp(&szBuffer[i], "RCINCLUDE", 9) == 0 1236 || (i1 = strncmp(&szBuffer[i], "DLGINCLUDE", 10)) == 0 1232 1237 ) 1233 1238 { … … 1237 1242 int j; 1238 1243 1239 /* extract info between "" or <> */ 1240 while (i < cbLen && !(f = (szBuffer[i] == '"' || szBuffer[i] == '<'))) 1241 i++; 1242 i++; /* skip '"' or '<' */ 1243 1244 /* if invalid statement then continue with the next line! */ 1245 if (!f) continue; 1246 1247 /* find end */ 1248 j = f = 0; 1249 while (i + j < cbLen && j < CCHMAXPATH && 1250 !(f = (szBuffer[i+j] == '"' || szBuffer[i+j] == '>'))) 1251 j++; 1252 1253 /* if invalid statement then continue with the next line! */ 1254 if (!f) continue; 1244 if (i1 == 0) 1245 { /* 1246 * #include <file.h>, #include "file.h" or DLGINCLUDE 1 "file.h" 1247 * 1248 * extract info between "" or <> 1249 */ 1250 while (i < cbLen && !(f = (szBuffer[i] == '"' || szBuffer[i] == '<'))) 1251 i++; 1252 i++; /* skip '"' or '<' */ 1253 1254 /* if invalid statement then continue with the next line! */ 1255 if (!f) continue; 1256 1257 /* find end */ 1258 j = f = 0; 1259 while (i + j < cbLen && j < CCHMAXPATH && 1260 !(f = (szBuffer[i+j] == '"' || szBuffer[i+j] == '>'))) 1261 j++; 1262 1263 /* if invalid statement then continue with the next line! */ 1264 if (!f) continue; 1265 } 1266 else 1267 { /* RCINCLUDE filename.dlg 1268 * Extract filename. 1269 */ 1270 1271 /* skip to filename.dlg start - if eol will continue to loop. */ 1272 i += 9; 1273 while (szBuffer[i] == ' ' || szBuffer[i] == '\t') 1274 i++; 1275 if (szBuffer[i] == '\0') 1276 continue; 1277 1278 /* search to end of filename. */ 1279 j = i+1; 1280 while (szBuffer[i+j] != ' ' && szBuffer[i+j] != '\t' && szBuffer[i+j] != '\0') 1281 j++; 1282 } 1255 1283 1256 1284 /* copy filename */ … … 1267 1295 if (psz != NULL) 1268 1296 { 1269 char szBuffer2[CCHMAXPATH]; 1270 if (pOptions->fExcludeAll || 1271 pathlistFindFile(pOptions->pszExclude, szFullname, szBuffer2, pOptions) != NULL 1272 ) 1297 if (pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, szBuffer, pOptions)) 1273 1298 depAddDepend(pvRule, szFullname, pOptions->fCheckCyclic); 1274 1299 else … … 1320 1345 if (pOptions->fSrcWhenObj && pvRule) 1321 1346 depAddDepend(pvRule, 1322 pOptions->fExcludeAll ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 1347 pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, pszFilename, pOptions) ? 1348 fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 1323 1349 pOptions->fCheckCyclic); 1324 1350 } 1325 1351 else 1326 pvRule = depAddRule(pOptions->fExcludeAll ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), NULL, NULL); 1352 pvRule = depAddRule(pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, pszFilename, pOptions) ? 1353 fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), NULL, NULL); 1327 1354 1328 1355 /* duplicate rule? */ … … 1418 1445 if (psz != NULL) 1419 1446 { 1420 char szBuffer2[CCHMAXPATH]; 1421 if (pOptions->fExcludeAll || 1422 pathlistFindFile(pOptions->pszExclude, szFullname, szBuffer2, pOptions) != NULL 1423 ) 1447 if (pOptions->fExcludeAll || pathlistFindFile2(pOptions->pszExclude, szBuffer, pOptions)) 1424 1448 depAddDepend(pvRule, szFullname, pOptions->fCheckCyclic); 1425 1449 else … … 1598 1622 else 1599 1623 { 1600 strncpy(pszBuffer, pszFilename, psz - pszFilename - 1);1601 pszBuffer[psz - pszFilename - 1] = '\0';1624 strncpy(pszBuffer, pszFilename, psz - pszFilename); 1625 pszBuffer[psz - pszFilename] = '\0'; 1602 1626 } 1603 1627 … … 1885 1909 * @status completely implemented. 1886 1910 * @author knut st. osmundsen 1887 * @remark need substantial optimizations. 95% of execution is spend here.1888 1911 */ 1889 1912 static char *pathlistFindFile(const char *pszPathList, const char *pszFilename, char *pszBuffer, POPTIONS pOptions) … … 1914 1937 strcpy(&pszBuffer[pszNext - psz], "\\"); 1915 1938 strcat(pszBuffer, pszFilename); 1916 //strlwr(pszBuffer); /* to speed up AVL tree search we'll lowercase all names. */1917 1939 fileNormalize(pszBuffer); 1918 1940 … … 1965 1987 1966 1988 1989 1990 /** 1991 * Checks if the given filename may exist within any of the given paths. 1992 * This check only matches the filename path agianst the paths in the pathlist. 1993 * @returns TRUE: if exists. 1994 * FALSE: don't exist. 1995 * @param pszPathList Path list to search for filename. 1996 * @parma pszFilename Filename to find. 1997 * @param pOptions Pointer to options struct. 1998 * @status completely implemented. 1999 * @author knut st. osmundsen 2000 */ 2001 static BOOL pathlistFindFile2(const char *pszPathList, const char *pszFilename, POPTIONS pOptions) 2002 { 2003 const char *psz = pszPathList; 2004 const char *pszNext = NULL; 2005 char szBuffer[CCHMAXPATH]; 2006 char szBuffer2[CCHMAXPATH]; 2007 char *pszPathToFind = &szBuffer2[0]; 2008 2009 /* 2010 * Input checking 2011 */ 2012 if (pszPathList == NULL) 2013 return FALSE; 2014 2015 /* 2016 * Normalize the filename and get it's path. 2017 */ 2018 fileNormalize2(pszFilename, szBuffer); 2019 filePath(pszFilename, pszPathToFind); 2020 2021 2022 /* 2023 * Loop thru the path list. 2024 */ 2025 while (*psz != '\0') 2026 { 2027 /* find end of this path */ 2028 pszNext = strchr(psz, ';'); 2029 if (pszNext == NULL) 2030 pszNext = psz + strlen(psz); 2031 2032 if (pszNext - psz > 0) 2033 { 2034 char * pszPath = &szBuffer[0]; 2035 2036 /* 2037 * Extract and normalize the path 2038 */ 2039 strncpy(pszPath, psz, pszNext - psz); 2040 pszPath[pszNext - psz] = '\0'; 2041 if (pszPath[pszNext - psz - 1] == '\\' && pszPath[pszNext - psz - 1] == '/') 2042 pszPath[pszNext - psz - 1] = '\0'; 2043 fileNormalize(pszPath); 2044 2045 /* 2046 * Check if it matches the path of the filename 2047 */ 2048 if (strcmp(pszPath, pszPathToFind) == 0) 2049 return TRUE; 2050 } 2051 2052 /* 2053 * Next part of the path list. 2054 */ 2055 if (*pszNext != ';') 2056 break; 2057 psz = pszNext + 1; 2058 } 2059 2060 pOptions = pOptions; 2061 return FALSE; 2062 } 2063 2064 1967 2065 /** 1968 2066 * Finds the first char after word. … … 2081 2179 * @returns Pointer to file memoryblock. NULL on error. 2082 2180 * @param pszFilename Pointer to filename string. 2181 * @remark This function is the one using most of the execution 2182 * time (DosRead + DosOpen) - about 70% of the execution time! 2083 2183 */ 2084 2184 static void *textbufferCreate(const char *pszFilename)
Note:
See TracChangeset
for help on using the changeset viewer.