pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:7221:    struct program *prog,    INT_TYPE *linep)   {    linep[0] = 0;       if (prog->program && prog->linenumbers) {    ptrdiff_t offset = pc - prog->program;    if ((offset < (ptrdiff_t)prog->num_program) && (offset >= 0)) {    static char *file = NULL;    static char *base, *cnt; -  static INT32 off,pid; +  static ptrdiff_t off; +  static INT32 pid;    static INT_TYPE line;    static size_t len;    static INT32 shift;    -  if(prog->linenumbers != base || prog->id != pid || offset < off) -  { +  if(prog->linenumbers == base && prog->id == pid && offset > off && +  cnt < prog->linenumbers + prog->num_linenumbers) +  goto fromold; +     base = cnt = prog->linenumbers;    off=line=0;    pid=prog->id;    file = 0; -  }else{ -  if (cnt < prog->linenumbers + prog->num_linenumbers) -  goto fromold; -  } +        while(cnt < prog->linenumbers + prog->num_linenumbers)    {    if(*cnt == 127)    {    cnt++;    len = get_small_number(&cnt);    shift = *cnt;    file = ++cnt;    CHECK_FILE_ENTRY (prog, cnt, len, shift);    cnt += len<<shift; -  +  continue;    }    off+=get_small_number(&cnt);    fromold:    if(off > offset) break;    line+=get_small_number(&cnt);    } -  +  if (cnt >= prog->linenumbers + prog->num_linenumbers) { +  /* We reached the end of the table. Make sure +  * we get in sync again next time we're called. +  */ +  base = NULL; +  }    linep[0]=line;    if (file) {    struct pike_string *res = begin_wide_shared_string(len, shift);    memcpy(res->str, file, len<<shift);    return end_shared_string(res);    }    } else {    fprintf(stderr, "Bad offset: pc:%p program:%p (%p)\n",    pc, prog->program, (void *)prog->num_program);    }