Ignore:
Timestamp:
Mar 26, 2018, 10:25:56 PM (7 years ago)
Author:
bird
Message:

kmkbuiltin: funnel output thru output.c (usually via err.c).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/kbuild_protection.c

    r2413 r3192  
    116116 *          On failure an error is printed, eval is set and -1 is returned.
    117117 */
    118 static int countPathComponents(const char *pszPath)
     118static int countPathComponents(PCKBUILDPROTECTION pThis, const char *pszPath)
    119119{
    120120    int cComponents = 0;
     
    158158            if (!pszTmp)
    159159            {
    160                 err(1, "_getdcwd");
     160                err(pThis->pCtx, 1, "_getdcwd");
    161161                return -1;
    162162            }
     
    196196        if (!getcwd(szCwd, sizeof(szCwd)))
    197197        {
    198             err(1, "getcwd");
     198            err(pThis->pCtx, 1, "getcwd");
    199199            return -1;
    200200        }
     
    217217 * @param   pThis   Pointer to the instance data.
    218218 */
    219 void kBuildProtectionInit(PKBUILDPROTECTION pThis)
     219void kBuildProtectionInit(PKBUILDPROTECTION pThis, PKMKBUILTINCTX pCtx)
    220220{
    221221    pThis->uMagic = KBUILD_PROTECTION_MAGIC;
     222    pThis->pCtx = pCtx;
    222223    pThis->afTypes[KBUILDPROTECTIONTYPE_FULL] = 0;
    223224    pThis->afTypes[KBUILDPROTECTIONTYPE_RECURSIVE] = 1;
     
    268269    /* number or path? */
    269270    if (!isdigit(*pszValue) || strpbrk(pszValue, ":/\\"))
    270         pThis->cProtectionDepth = countPathComponents(pszValue);
     271        pThis->cProtectionDepth = countPathComponents(pThis, pszValue);
    271272    else
    272273    {
     
    280281        }
    281282        if (!pThis->cProtectionDepth || pszValue == pszMore || *pszMore)
    282             return errx(1, "bogus protection depth: %s", pszValue);
     283            return errx(pThis->pCtx, 1, "bogus protection depth: %s", pszValue);
    283284    }
    284285
    285286    if (pThis->cProtectionDepth < 1)
    286         return  errx(1, "bogus protection depth: %s", pszValue);
     287        return  errx(pThis->pCtx, 1, "bogus protection depth: %s", pszValue);
    287288    return 0;
    288289}
     
    351352         * Count the path and compare it with the required depth.
    352353         */
    353         int cComponents = countPathComponents(pszPath);
     354        int cComponents = countPathComponents(pThis, pszPath);
    354355        if (cComponents < 0)
    355356            return -1;
    356357        if ((unsigned int)cComponents <= pThis->cProtectionDepth)
    357358        {
    358             errx(1, "%s: protected", pszPath);
     359            errx(pThis->pCtx, 1, "%s: protected", pszPath);
    359360            return -1;
    360361        }
Note: See TracChangeset for help on using the changeset viewer.