Changeset 7340
- Timestamp:
- Nov 14, 2001, 4:26:13 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/tools/fastdep/fastdep.c ¶
r7332 r7340 1 /* $Id: fastdep.c,v 1.3 3 2001-11-14 11:13:26bird Exp $1 /* $Id: fastdep.c,v 1.34 2001-11-14 15:26:13 bird Exp $ 2 2 * 3 3 * Fast dependents. (Fast = Quick and Dirty!) … … 185 185 static int langRC( const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader); 186 186 static int langCOBOL(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader); 187 static int langIPF( const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader); 187 188 188 189 … … 205 206 INLINE BOOL filecacheFind(const char *pszFilename); 206 207 INLINE BOOL filecacheIsDirCached(const char *pszDir); 208 static char*filecacheFileExist(const char *pszFilename, char *pszBuffer); 207 209 208 210 /* pathlist operations */ … … 285 287 static const char *apszExtRC[] = {"rc", "orc", "dlg", NULL}; 286 288 static const char *apszExtCOBOL[] = {"cbl", "cob", "sqb", "wbl", NULL}; 289 static const char *apszExtIPF[] = {"ipf", "man", NULL}; 287 290 static CONFIGENTRY aConfig[] = 288 291 { … … 307 310 { 308 311 apszExtCOBOL, 309 4,312 -1, 310 313 langCOBOL, 314 }, 315 316 { 317 apszExtIPF, 318 -1, 319 langIPF, 311 320 }, 312 321 … … 943 952 if (*ppsz != NULL) 944 953 { 945 fHeader = &pCfg->papszExts[pCfg->iFirstHdr] <= ppsz;954 fHeader = pCfg->iFirstHdr > 0 && &pCfg->papszExts[pCfg->iFirstHdr] <= ppsz; 946 955 break; 947 956 } … … 2103 2112 } 2104 2113 2114 2115 /** 2116 * Generates depend info on this IPF file, these are stored internally 2117 * and written to file later. 2118 * @returns 0 on success. 2119 * !0 on error. 2120 * @param pszFilename Pointer to source filename. Correct case is assumed! 2121 * @param pszNormFilename Pointer to normalized source filename. 2122 * @param pszTS File time stamp. 2123 * @parma fHeader True if header file is being scanned. 2124 * @status completely implemented. 2125 * @author knut st. osmundsen 2126 */ 2127 int langIPF( const char *pszFilename, const char *pszNormFilename, 2128 const char *pszTS, BOOL fHeader) 2129 { 2130 void * pvFile; /* Text buffer pointer. */ 2131 void * pvRule; /* Handle to the current rule. */ 2132 char szBuffer[4096]; /* Temporary buffer (max line lenght size...) */ 2133 int iLine; /* current line number */ 2134 void * pv = NULL; /* An index used by textbufferGetNextLine. */ 2135 2136 2137 /**********************************/ 2138 /* Add the depend rule */ 2139 /**********************************/ 2140 /*if (options.fObjRule && !fHeader) 2141 { 2142 if (options.fNoObjectPath) 2143 pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszObjectExt, pszTS); 2144 else 2145 pvRule = depAddRule(options.fObjectDir ? 2146 options.pszObjectDir : 2147 filePathSlash(pszFilename, szBuffer), 2148 fileNameNoExt(pszFilename, szBuffer + CCHMAXPATH), 2149 options.pszObjectExt, 2150 pszTS); 2151 2152 if (options.fSrcWhenObj && pvRule) 2153 depAddDepend(pvRule, 2154 options.fExcludeAll || pathlistFindFile2(options.pszExclude, pszNormFilename) 2155 ? fileName(pszFilename, szBuffer) : fileNormalize2(pszFilename, szBuffer), 2156 options.fCheckCyclic); 2157 } 2158 else */ 2159 pvRule = depAddRule(options.fExcludeAll || pathlistFindFile2(options.pszExclude, pszNormFilename) ? 2160 fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, pszTS); 2161 2162 /* duplicate rule? */ 2163 if (pvRule == NULL) 2164 return 0; 2165 2166 2167 /********************/ 2168 /* Make file buffer */ 2169 /********************/ 2170 pvFile = textbufferCreate(pszFilename); 2171 if (!pvFile) 2172 { 2173 fprintf(stderr, "failed to open '%s'\n", pszFilename); 2174 return -1; 2175 } 2176 2177 2178 /*******************/ 2179 /* find dependants */ 2180 /*******************/ 2181 iLine = 0; 2182 while (textbufferGetNextLine(pvFile, &pv, szBuffer, sizeof(szBuffer)) != NULL) /* line loop */ 2183 { 2184 iLine++; 2185 2186 /* is this an imbed statement? */ 2187 if (!strncmp(&szBuffer[0], ".im", 3)) 2188 { 2189 char szFullname[CCHMAXPATH]; 2190 char * psz; 2191 int i; 2192 int j; 2193 char chQuote = 0; 2194 2195 /* skip statement and blanks */ 2196 i = 4; 2197 while (szBuffer[i] == ' ' || szBuffer[i] == '\t') 2198 i++; 2199 2200 /* check for quotes */ 2201 if (szBuffer[i] == '\'' || szBuffer[i] == '\"') 2202 chQuote = szBuffer[i++]; 2203 2204 /* find end */ 2205 j = 0; 2206 if (chQuote != 0) 2207 { 2208 while (szBuffer[i+j] != chQuote && szBuffer[i+j] != '\n' && szBuffer[i+j] != '\r' && szBuffer[i+j] != '\0') 2209 j++; 2210 } 2211 else 2212 { 2213 while (szBuffer[i+j] != '\n' && szBuffer[i+j] != '\r' && szBuffer[i+j] != '\0') 2214 j++; 2215 } 2216 2217 /* find end */ 2218 if (j >= CCHMAXPATH) 2219 { 2220 fprintf(stderr, "%s(%d) warning: Filename too long ignored", pszFilename, iLine); 2221 continue; 2222 } 2223 2224 /* copy filename */ 2225 strncpy(szFullname, &szBuffer[i], j); 2226 szFullname[j] = '\0'; /* ensure terminatition. */ 2227 strlwr(szFullname); 2228 2229 /* find include file! */ 2230 psz = filecacheFileExist(szFullname, szBuffer); 2231 2232 /* did we find the include? */ 2233 if (psz != NULL) 2234 { 2235 if (options.fExcludeAll || pathlistFindFile2(options.pszExclude, szBuffer)) 2236 depAddDepend(pvRule, fileName(szFullname, szBuffer), options.fCheckCyclic); 2237 else 2238 depAddDepend(pvRule, szBuffer, options.fCheckCyclic); 2239 } 2240 else 2241 { 2242 fprintf(stderr, "%s(%d): warning imbeded file '%s' was not found!\n", 2243 pszFilename, iLine, szFullname); 2244 depMarkNotFound(pvRule); 2245 } 2246 } 2247 } /*while*/ 2248 2249 textbufferDestroy(pvFile); 2250 2251 return 0; 2252 } 2253 2254 2255 2256 2105 2257 #define upcase(ch) \ 2106 2258 (ch >= 'a' && ch <= 'z' ? ch - ('a' - 'A') : ch) … … 2540 2692 } 2541 2693 2694 2695 /** 2696 * Checks if a file exist, uses file cache if possible. 2697 * @returns Pointer to a filename consiting of the path part + the given filename. 2698 * (pointer into pszBuffer) 2699 * NULL if file is not found. ("" in buffer) 2700 * @parma pszFilename Filename to find. 2701 * @parma pszBuffer Ouput Buffer. 2702 * @status completely implemented. 2703 * @author knut st. osmundsen 2704 */ 2705 char *filecacheFileExist(const char *pszFilename, char *pszBuffer) 2706 { 2707 APIRET rc; 2708 2709 *pszBuffer = '\0'; 2710 2711 fileNormalize2(pszFilename, pszBuffer); 2712 2713 /* 2714 * Search for the file in this directory. 2715 * Search cache first 2716 */ 2717 if (!filecacheFind(pszBuffer)) 2718 { 2719 char szDir[CCHMAXPATH]; 2720 2721 filePathSlash(pszBuffer, szDir); 2722 if (!filecacheIsDirCached(szDir)) 2723 { 2724 /* 2725 * If caching of entire dirs are enabled, we'll 2726 * add the directory to the cache and search it. 2727 */ 2728 if (options.fCacheSearchDirs && filecacheAddDir(szDir)) 2729 { 2730 if (filecacheFind(pszBuffer)) 2731 return pszBuffer; 2732 } 2733 else 2734 { 2735 FILESTATUS3 fsts3; 2736 2737 /* ask the OS */ 2738 rc = DosQueryPathInfo(pszBuffer, FIL_STANDARD, &fsts3, sizeof(fsts3)); 2739 if (rc == NO_ERROR) 2740 { /* add file to cache. */ 2741 filecacheAddFile(pszBuffer); 2742 return pszBuffer; 2743 } 2744 } 2745 } 2746 } 2747 else 2748 return pszBuffer; 2749 2750 return NULL; 2751 } 2542 2752 2543 2753
Note:
See TracChangeset
for help on using the changeset viewer.