Changeset 6141 for trunk/tools
- Timestamp:
- Jul 2, 2001, 8:21:02 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/fastdep/fastdep.c
r5921 r6141 1 /* $Id: fastdep.c,v 1.2 7 2001-06-07 00:35:42 bird Exp $1 /* $Id: fastdep.c,v 1.28 2001-07-02 18:21:02 bird Exp $ 2 2 * 3 3 * Fast dependents. (Fast = Quick and Dirty!) … … 215 215 INLINE char *trim(char *psz); 216 216 INLINE char *trimR(char *psz); 217 INLINE char *trimQuotes(char *psz); 217 218 218 219 /* preprocessors */ … … 787 788 * Make full path. 788 789 */ 789 if ((psz = strrchr(argv[argi], '\\')) || (psz = strrchr(argv[argi], '/')) )790 if ((psz = strrchr(argv[argi], '\\')) || (psz = strrchr(argv[argi], '/')) || (*(psz = &argv[argi][1]) == ':')) 790 791 { 791 792 strncpy(szSource, argv[argi], psz - argv[argi] + 1); … … 2768 2769 2769 2770 /** 2771 * Trims any quotes of a possibly quoted string. 2772 * @returns Pointer to the string passed in. 2773 * @param psz Pointer to the string which is to be quote-trimmed. 2774 * @status completely implmented. 2775 * @author knut st. osmundsen (knut.stange.osmundsen@pmsc.no) 2776 */ 2777 INLINE char *trimQuotes(char *psz) 2778 { 2779 int i; 2780 if (psz == NULL) 2781 return NULL; 2782 2783 if (*psz == '\"' || *psz == '\'') 2784 psz++; 2785 i = strlen(psz) - 1; 2786 if (psz[i] == '\"' || psz[i] == '\'') 2787 psz[i] = '\0'; 2788 2789 return psz; 2790 } 2791 2792 2793 /** 2770 2794 * C/C++ preprocess a single line. Assumes that we're not starting 2771 2795 * with at comment. … … 2829 2853 */ 2830 2854 psz--; 2831 while (psz >= pszOut && *psz == ' ' && *psz == '\t')2855 while (psz >= pszOut && (*psz == ' ' || *psz == '\t')) 2832 2856 psz--; 2833 2857 psz[1] = '\0'; … … 2981 3005 2982 3006 /* get the filedate and subtract one month from it. */ 2983 if (!DosQueryPathInfo( pszFilename, FIL_STANDARD, &fst3, sizeof(fst3)))3007 if (!DosQueryPathInfo((PSZ)pszFilename, FIL_STANDARD, &fst3, sizeof(fst3))) 2984 3008 { 2985 3009 if (fst3.fdateLastWrite.month <= 1) … … 3027 3051 cch = strlen(psz); 3028 3052 if (cch == 0) 3053 { 3054 fMoreDeps = FALSE; 3055 continue; 3056 } 3057 3058 if (*psz == '#') 3029 3059 continue; 3030 3060 … … 3044 3074 { 3045 3075 static FDATE FileDate = {0,0,0}; 3076 char *pszCont = strchr(&psz[i], '\\'); 3077 fMoreDeps = pszCont != NULL && pszCont[1] == '\0'; 3078 3046 3079 psz[i] = '\0'; 3047 pvRule = depAddRule(trim R(psz), NULL, NULL, FileDate);3080 pvRule = depAddRule(trimQuotes(trimR(psz)), NULL, NULL, FileDate); 3048 3081 ((PDEPRULE)pvRule)->fUpdated = FALSE; 3049 3082 psz += i + 1; 3050 3083 cch -= i + 1; 3051 fMoreDeps = TRUE;3052 3084 break; 3053 3085 } … … 3070 3102 if (pvRule != NULL) 3071 3103 { 3072 psz = trim (psz);3104 psz = trimQuotes(trim(psz)); 3073 3105 if (*psz != '\0') 3074 3106 depAddDepend(pvRule, psz, options.fCheckCyclic); … … 3099 3131 int iBuffer = 0; 3100 3132 int cch; 3133 3134 /* 3135 * Write warning on top of file. 3136 */ 3137 fputs("#\n" 3138 "# This file was automatically generated by FastDep.\n" 3139 "# FastDep was written by knut st. osmundsen, and it's GPL software.\n" 3140 "#\n" 3141 "# THIS FILE SHOULD N O T BE EDITED MANUALLY!!!\n" 3142 "#\n" 3143 "# (As this may possibly make it unreadable for fastdep\n" 3144 "# and ruin the caching methods of FastDep.)\n" 3145 "#\n" 3146 "\n", 3147 phFile); 3148 3101 3149 3102 3150 /* @@@PH 2001-03-01 … … 3147 3195 while (pdep != NULL) 3148 3196 { 3197 int fQuoted = strpbrk(pdep->pszRule, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */ 3198 3149 3199 /* Write rule. Flush the buffer first if necessary. */ 3150 3200 cch = strlen(pdep->pszRule); 3151 if (iBuffer + cch + 2 >= sizeof(szBuffer))3201 if (iBuffer + cch + fQuoted * 2 + 2 >= sizeof(szBuffer)) 3152 3202 { 3153 3203 fwrite(szBuffer, iBuffer, 1, phFile); 3154 3204 iBuffer = 0; 3155 3205 } 3206 if (fQuoted) szBuffer[iBuffer++] = '"'; 3156 3207 strcpy(szBuffer + iBuffer, pdep->pszRule); 3157 3208 iBuffer += cch; 3209 if (fQuoted) szBuffer[iBuffer++] = '"'; 3158 3210 strcpy(szBuffer + iBuffer++, ":"); 3159 3211 … … 3165 3217 { 3166 3218 /* flush buffer? */ 3167 if (iBuffer + strlen(*ppsz) + 20 >= sizeof(szBuffer)) 3219 fQuoted = strpbrk(*ppsz, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */ 3220 cch = strlen(*ppsz); 3221 if (iBuffer + cch + fQuoted * 2 + 20 >= sizeof(szBuffer)) 3168 3222 { 3169 3223 fwrite(szBuffer, iBuffer, 1, phFile); 3170 3224 iBuffer = 0; 3171 3225 } 3172 iBuffer += sprintf(szBuffer + iBuffer, " \\\n %s", *ppsz); 3226 strcpy(szBuffer + iBuffer, " \\\n "); 3227 iBuffer += 7; 3228 if (fQuoted) szBuffer[iBuffer++] = '"'; 3229 strcpy(szBuffer + iBuffer, *ppsz); 3230 iBuffer += cch; 3231 if (fQuoted) szBuffer[iBuffer++] = '"'; 3173 3232 3174 3233 /* next dependant */ … … 3291 3350 * Reuse the node in the tree. 3292 3351 */ 3293 PDEPRULE pOld = (PDEPRULE) (void*)AVLGet((PPAVLNODECORE)(void*)&pdepTree, pNew->avlCore.Key);3352 PDEPRULE pOld = (PDEPRULE)AVLGet((PPAVLNODECORE)(void*)&pdepTree, pNew->avlCore.Key); 3294 3353 assert(pOld); 3295 3354 free(pNew); … … 3298 3357 3299 3358 pOld->fUpdated = TRUE; 3300 if (!options.fForceScan && *(PUSHORT) (void*)&FileDate < *(PUSHORT)(void*)&options.fDepDate)3359 if (!options.fForceScan && *(PUSHORT)&FileDate < *(PUSHORT)&options.fDepDate) 3301 3360 return NULL; 3302 3361 … … 3327 3386 { 3328 3387 PDEPRULE pdep = (PDEPRULE)pvRule; 3388 3389 if (pszDep[0] == '\0') 3390 { 3391 fprintf(stderr, "warning-internal: empty dependancy filename to '%s'. Ignored.\n", 3392 pdep->pszRule); 3393 /* __interrupt(3); */ 3394 return FALSE; 3395 } 3329 3396 3330 3397 if (fCheckCyclic && depCheckCyclic(pdep, pszDep))
Note:
See TracChangeset
for help on using the changeset viewer.