コード例 #1
0
ファイル: Text.c プロジェクト: zaporozhets/ti_ezsdk_tools
/*
 *  ======== putLab ========
 *  len == -1 => infinite output 
 */
Int Text_putLab(Types_Label *lab, Char **bufp, Int len)
{
    Int res;

    res = Text_putMod(lab->modId, bufp, len);
    if (len < 0 || (len - res) > 8) {  /* need at most 9 characters for "%p" */
        res += Text_xprintf(bufp, "%p", lab->handle);
    }
    
    if (lab->named
        && (len < 0 || (len - res) >= (4 + (Int)strlen(lab->iname))) ) {

        res += Text_xprintf(bufp, "('%s')", lab->iname);
    }

    return (res);
}
コード例 #2
0
ファイル: Text.c プロジェクト: andreimironenko/slog
/*
 *  ======== putSite ========
 *  len == -1 => infinite output
 *  
 *  If site->mod == 0, the module is unspecified and will be omitted from the output.
 */
Int Text_putSite(Types_Site *site, Char **bufp, Int len)
{
    Int res;
    Int max = len < 0 ? 0x7fff : len;   /* 0x7fff == infinite, well almost */

    res = 0;
    
    if (!site) {
        return (0);
    }

    /* The 'mod' field is optional; 0 if it's unspecified. */
    if (site->mod != 0) {
        res = Text_putMod(site->mod, bufp, max);
        max -= (res + 2);     /* +2 for the ": " string below */
    }
        
    if (max > 0) {
        /* Don't output this if there's no mod */
        if (site->mod != 0) {
            res += Text_xprintf(bufp, ": ");
        }

        if (site->line == 0) {
            return (res);
        }
    
        if (site->file && (max >= ((Int)strlen(site->file) + 4))) {
            Int oc = Text_xprintf(bufp, "\"%s\", ", site->file);
            res += oc;
            max -= oc;
        }
        
        /* 7 = length of "line : ", 10 = max decimal digits in 32-bit number */
        if (max >= (7 + 10)) {
            res += Text_xprintf(bufp, "line %d: ", site->line);
        }
    }

    return (res);
}