pike.git / lib / modules / Stdio.pmod / Terminfo.pmod

version» Context lines:

pike.git/lib/modules/Stdio.pmod/Terminfo.pmod:271:    map |= mkmapping(indices(clears), allocate(sizeof(clears)));    }   }         //! Terminfo terminal description object   class Terminfo {       inherit TermMachine;    +  protected local constant MAGIC = 0432; // SysV +  protected local constant MAGIC2 = 01036; // Ncurses 6 +     //!    array(string) aliases;       protected private constant boolnames =    ({ "bw","am","xb","xs","xn","eo","gn","hc","km","hs","in","da","db","mi",    "ms","os","es","xt","hz","ul","xo","nx","5i","HC","NR","NP","ND","cc",    "ut","hl","YA","YB","YC","YD","YE","YF","YG" });    protected private constant numnames =    ({ "co","it","li","lm","sg","pb","vt","ws","Nl","lh","lw","ma","MW","Co",    "pa","NC","Ya","Yb","Yc","Yd","Ye","Yf","Yg","Yh","Yi","Yj","Yk","Yl",
pike.git/lib/modules/Stdio.pmod/Terminfo.pmod:335:    {    return predef::map(s/2, reverse)*"";    }       protected private int load_cap(.File f, int|void bug_compat)    {    int magic, sname, nbool, nnum, nstr, sstr;       if (6!=sscanf(swab(f->read(12)), "%2c%2c%2c%2c%2c%2c",    magic, sname, nbool, nnum, nstr, sstr) || -  magic != 0432) +  (magic != MAGIC && magic != MAGIC2))    return 0;    aliases = (f->read(sname)-"\0")/"|";    {    int blen = nbool;    if(((nbool+sname)&1) && !bug_compat)    blen++;    array(int) bools = values(f->read(blen)[..nbool-1]);    if (sizeof(bools)>sizeof(boolnames))    bools = bools[..sizeof(boolnames)-1];    map = mkmapping(boolnames[..sizeof(bools)-1], bools);    }    { -  array(int) nums = [array(int)] +  array(int) nums; +  if (magic == MAGIC2) { +  // 32-bit little-endian integers. +  nums = array_sscanf(f->read(nnum*4), "%-4c"*nnum); +  } else { +  nums = [array(int)]    array_sscanf(swab(f->read(nnum*2)), "%2c"*nnum); -  +  }    if (sizeof(nums)>sizeof(numnames))    nums = nums[..sizeof(numnames)-1];    mapping(string:int) tmp = mkmapping(numnames[..sizeof(nums)-1], nums); -  foreach (numnames[..sizeof(nums)-1], string name) -  if (tmp[name]>=0xfffe) +  foreach (numnames[..sizeof(nums)-1], string name) { +  if (tmp[name]>=0xfffe) { +  if ((magic == MAGIC) || (tmp[name] >= 0xfffffffe))    m_delete(tmp, name); -  +  } +  }    map += tmp;    }    {    string stroffs = swab(f->read(nstr*2));    string strbuf = f->read(sstr);    if(sizeof(strbuf)==sstr-1 && !bug_compat && (nbool&1)) {    // Ugh. Someone didn't pad their bool array properly (one suspects).    f->seek(0);    return load_cap(f, 1);    }