Changeset 6866 for trunk/tools
- Timestamp:
- Sep 30, 2001, 2:22:05 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/fastdep/fastdep.c
r6632 r6866 1 /* $Id: fastdep.c,v 1.3 0 2001-09-04 13:48:29bird Exp $1 /* $Id: fastdep.c,v 1.31 2001-09-30 00:22:05 bird Exp $ 2 2 * 3 3 * Fast dependents. (Fast = Quick and Dirty!) … … 163 163 int cDeps; /* Entries in the dependant array. */ 164 164 char ** papszDep; /* Pointer to an array of pointers to dependants. */ 165 BOOL fUpdated; /* If we have updated this entry during currentrun. */165 BOOL fUpdated; /* If we have updated this entry during the run. */ 166 166 char szTS[TS_SIZE]; /* Time stamp. */ 167 167 } DEPRULE, *PDEPRULE; … … 234 234 235 235 /* depend workers */ 236 static BOOL depReadFile(const char *pszFilename );237 static BOOL depWriteFile(const char *pszFilename );236 static BOOL depReadFile(const char *pszFilename, BOOL fAppend); 237 static BOOL depWriteFile(const char *pszFilename, BOOL fWriteUpdatedOnly); 238 238 static void depRemoveAll(void); 239 239 static void *depAddRule(const char *pszRulePath, const char *pszName, const char *pszExt, const char *pszTS); … … 462 462 if (pdepTree != NULL && pszOld != pszDepFile) 463 463 { 464 if (!depWriteFile(pszOld ))464 if (!depWriteFile(pszOld, !options.fAppend)) 465 465 fprintf(stderr, "error: failed to write (flush) dependencies.\n"); 466 466 depRemoveAll(); … … 779 779 */ 780 780 if (pdepTree == NULL && (options.fAppend || !options.fForceScan)) 781 depReadFile(pszDepFile );781 depReadFile(pszDepFile, options.fAppend); 782 782 783 783 /* … … 849 849 850 850 /* Write the depend file! */ 851 if (!depWriteFile(pszDepFile ))851 if (!depWriteFile(pszDepFile, !options.fAppend)) 852 852 fprintf(stderr, "error: failed to write dependencies file!\n"); 853 853 #if 0 … … 1002 1002 */ 1003 1003 } achIfStack[256]; 1004 1004 char szSrcDir[CCHMAXPATH]; 1005 filePath(pszNormFilename, szSrcDir);/* determin source code directory. */ 1005 1006 1006 1007 /**********************************/ … … 1105 1106 if (achIfStack[iIfStack].fIncluded) 1106 1107 { 1107 char szFullname[CCHMAXPATH]; 1108 char *psz; 1109 BOOL f = FALSE; 1110 int j; 1108 char szFullname[CCHMAXPATH]; 1109 char * psz; 1110 BOOL f = FALSE; 1111 int j; 1112 BOOL fQuote; 1111 1113 1112 1114 /* extract info between "" or <> */ 1113 1115 while (i < cbLen && !(f = (szBuffer[i] == '"' || szBuffer[i] == '<'))) 1114 1116 i++; 1117 fQuote = szBuffer[i] == '"'; 1115 1118 i++; /* skip '"' or '<' */ 1116 1119 … … 1133 1136 1134 1137 /* find include file! */ 1135 psz = pathlistFindFile(options.pszInclude, szFullname, szBuffer); 1138 psz = fQuote ? pathlistFindFile(szSrcDir, szFullname, szBuffer) : NULL; 1139 if (psz == NULL) 1140 psz = pathlistFindFile(options.pszInclude, szFullname, szBuffer); 1136 1141 if (psz == NULL) 1137 1142 psz = pathlistFindFile(pszIncludeEnv, szFullname, szBuffer); … … 2446 2451 char szDir[CCHMAXPATH]; 2447 2452 int cchDir; 2448 char achBuffer[ 16384];2453 char achBuffer[32768]; 2449 2454 PFILEFINDBUF3 pfindbuf3 = (PFILEFINDBUF3)(void*)&achBuffer[0]; 2450 2455 HDIR hDir = HDIR_CREATE; … … 3032 3037 * This will update the date in the option struct. 3033 3038 */ 3034 BOOL depReadFile(const char *pszFilename )3039 BOOL depReadFile(const char *pszFilename, BOOL fAppend) 3035 3040 { 3036 3041 void * pvFile; … … 3116 3121 psz[i] = '\0'; 3117 3122 pvRule = depAddRule(trimQuotes(trimR(psz)), NULL, NULL, szTS); 3118 ((PDEPRULE)pvRule)->fUpdated = FALSE;3123 ((PDEPRULE)pvRule)->fUpdated = fAppend; 3119 3124 psz += i + 1; 3120 3125 cch -= i + 1; … … 3158 3163 * 3159 3164 * @returns Success indicator. 3160 * @params pszFilename Pointer to name of the output file. 3161 */ 3162 BOOL depWriteFile(const char *pszFilename) 3165 * @param pszFilename Pointer to name of the output file. 3166 * @param fWriteUpdatedOnly If set we'll only write updated rules. 3167 */ 3168 BOOL depWriteFile(const char *pszFilename, BOOL fWriteUpdatedOnly) 3163 3169 { 3164 3170 FILE *phFile; … … 3168 3174 AVLENUMDATA EnumData; 3169 3175 PDEPRULE pdep; 3170 char szBuffer[ 4096];3176 char szBuffer[32678]; 3171 3177 int iBuffer = 0; 3172 3178 int cch; … … 3201 3207 while (pdep != NULL) 3202 3208 { 3203 char *psz = pdep->pszRule; 3204 3205 /* flush buffer? */ 3206 if (iBuffer + strlen(psz) + 20 >= sizeof(szBuffer)) 3209 if (!fWriteUpdatedOnly || pdep->fUpdated) 3210 { 3211 char *psz = pdep->pszRule; 3212 3213 /* flush buffer? */ 3214 if (iBuffer + strlen(psz) + 20 >= sizeof(szBuffer)) 3215 { 3216 fwrite(szBuffer, iBuffer, 1, phFile); 3217 iBuffer = 0; 3218 } 3219 3220 /* write rule title as dependant */ 3221 iBuffer += sprintf(szBuffer + iBuffer, 3222 " \\\n %s",psz); 3223 } 3224 3225 /* next rule */ 3226 pdep = (PDEPRULE)(void*)AVLGetNextNode(&EnumData); 3227 } 3228 3229 /* Add two new lines. Flush buffer first if necessary. */ 3230 if (iBuffer + CBNEWLINE*2 >= sizeof(szBuffer)) 3231 { 3232 fwrite(szBuffer, iBuffer, 1, phFile); 3233 iBuffer = 0; 3234 } 3235 3236 /* add 2 linefeeds */ 3237 strcpy(szBuffer + iBuffer, "\n\n"); 3238 iBuffer += CBNEWLINE*2; 3239 } 3240 3241 3242 /* normal dependency output */ 3243 pdep = (PDEPRULE)(void*)AVLBeginEnumTree((PPAVLNODECORE)(void*)&pdepTree, &EnumData, TRUE); 3244 while (pdep != NULL) 3245 { 3246 if (!fWriteUpdatedOnly || pdep->fUpdated) 3247 { 3248 int cchTS = strlen(pdep->szTS); 3249 int fQuoted = strpbrk(pdep->pszRule, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */ 3250 3251 /* Write rule. Flush the buffer first if necessary. */ 3252 cch = strlen(pdep->pszRule); 3253 if (iBuffer + cch + fQuoted * 2 + cchTS + 9 >= sizeof(szBuffer)) 3207 3254 { 3208 3255 fwrite(szBuffer, iBuffer, 1, phFile); … … 3210 3257 } 3211 3258 3212 /* write rule title as dependant */ 3213 iBuffer += sprintf(szBuffer + iBuffer, 3214 " \\\n %s",psz); 3215 3216 /* next rule */ 3217 pdep = (PDEPRULE)(void*)AVLGetNextNode(&EnumData); 3218 } 3219 3220 /* Add two new lines. Flush buffer first if necessary. */ 3221 if (iBuffer + CBNEWLINE*2 >= sizeof(szBuffer)) 3222 { 3223 fwrite(szBuffer, iBuffer, 1, phFile); 3224 iBuffer = 0; 3225 } 3226 3227 /* add 2 linefeeds */ 3228 strcpy(szBuffer + iBuffer, "\n\n"); 3229 iBuffer += CBNEWLINE*2; 3230 } 3231 3232 3233 /* normal dependency output */ 3234 pdep = (PDEPRULE)(void*)AVLBeginEnumTree((PPAVLNODECORE)(void*)&pdepTree, &EnumData, TRUE); 3235 while (pdep != NULL) 3236 { 3237 int cchTS = strlen(pdep->szTS); 3238 int fQuoted = strpbrk(pdep->pszRule, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */ 3239 3240 /* Write rule. Flush the buffer first if necessary. */ 3241 cch = strlen(pdep->pszRule); 3242 if (iBuffer + cch + fQuoted * 2 + cchTS + 9 >= sizeof(szBuffer)) 3243 { 3244 fwrite(szBuffer, iBuffer, 1, phFile); 3245 iBuffer = 0; 3246 } 3247 3248 memcpy(szBuffer + iBuffer, "# ", 2); 3249 memcpy(szBuffer + iBuffer + 2, pdep->szTS, cchTS); 3250 iBuffer += cchTS + 2; 3251 szBuffer[iBuffer++] = '\n'; 3252 3253 if (fQuoted) szBuffer[iBuffer++] = '"'; 3254 strcpy(szBuffer + iBuffer, pdep->pszRule); 3255 iBuffer += cch; 3256 if (fQuoted) szBuffer[iBuffer++] = '"'; 3257 strcpy(szBuffer + iBuffer++, ":"); 3258 3259 /* write rule dependants. */ 3260 if (pdep->papszDep != NULL) 3261 { 3262 char **ppsz = pdep->papszDep; 3263 while (*ppsz != NULL) 3259 memcpy(szBuffer + iBuffer, "# ", 2); 3260 memcpy(szBuffer + iBuffer + 2, pdep->szTS, cchTS); 3261 iBuffer += cchTS + 2; 3262 szBuffer[iBuffer++] = '\n'; 3263 3264 if (fQuoted) szBuffer[iBuffer++] = '"'; 3265 strcpy(szBuffer + iBuffer, pdep->pszRule); 3266 iBuffer += cch; 3267 if (fQuoted) szBuffer[iBuffer++] = '"'; 3268 strcpy(szBuffer + iBuffer++, ":"); 3269 3270 /* write rule dependants. */ 3271 if (pdep->papszDep != NULL) 3264 3272 { 3265 /* flush buffer? */ 3266 fQuoted = strpbrk(*ppsz, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */ 3267 cch = strlen(*ppsz); 3268 if (iBuffer + cch + fQuoted * 2 + 20 >= sizeof(szBuffer)) 3273 char **ppsz = pdep->papszDep; 3274 while (*ppsz != NULL) 3269 3275 { 3270 fwrite(szBuffer, iBuffer, 1, phFile); 3271 iBuffer = 0; 3276 /* flush buffer? */ 3277 fQuoted = strpbrk(*ppsz, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */ 3278 cch = strlen(*ppsz); 3279 if (iBuffer + cch + fQuoted * 2 + 20 >= sizeof(szBuffer)) 3280 { 3281 fwrite(szBuffer, iBuffer, 1, phFile); 3282 iBuffer = 0; 3283 } 3284 strcpy(szBuffer + iBuffer, " \\\n "); 3285 iBuffer += 7; 3286 if (fQuoted) szBuffer[iBuffer++] = '"'; 3287 strcpy(szBuffer + iBuffer, *ppsz); 3288 iBuffer += cch; 3289 if (fQuoted) szBuffer[iBuffer++] = '"'; 3290 3291 /* next dependant */ 3292 ppsz++; 3272 3293 } 3273 strcpy(szBuffer + iBuffer, " \\\n ");3274 iBuffer += 7;3275 if (fQuoted) szBuffer[iBuffer++] = '"';3276 strcpy(szBuffer + iBuffer, *ppsz);3277 iBuffer += cch;3278 if (fQuoted) szBuffer[iBuffer++] = '"';3279 3280 /* next dependant */3281 ppsz++;3282 3294 } 3283 } 3284 3285 /* Add two new lines. Flush buffer first if necessary. */3286 if (iBuffer + CBNEWLINE*2 >= sizeof(szBuffer))3287 {3288 fwrite(szBuffer, iBuffer, 1, phFile);3289 iBuffer = 0;3290 } 3291 3292 /* add 2 linefeeds */3293 strcpy(szBuffer + iBuffer, "\n\n");3294 iBuffer += CBNEWLINE*2;3295 3296 /* Add two new lines. Flush buffer first if necessary. */ 3297 if (iBuffer + CBNEWLINE*2 >= sizeof(szBuffer)) 3298 { 3299 fwrite(szBuffer, iBuffer, 1, phFile); 3300 iBuffer = 0; 3301 } 3302 3303 /* add 2 linefeeds */ 3304 strcpy(szBuffer + iBuffer, "\n\n"); 3305 iBuffer += CBNEWLINE*2; 3306 } 3295 3307 3296 3308 /* next rule */
Note:
See TracChangeset
for help on using the changeset viewer.