Branch: Tag:

2001-07-13

2001-07-13 11:26:40 by Henrik Grubbström (Grubba) <grubba@grubba.org>

get_{program_,}line() now returns a pike_string.
store_linenumber() is now wide string safe.
Added some more debug to store_linenumber().
Fixes [bug 1866].

Rev: src/builtin.cmod:1.59
Rev: src/builtin_functions.c:1.394
Rev: src/gc.c:1.169
Rev: src/interpret.c:1.219
Rev: src/interpreter.h:1.68
Rev: src/object.c:1.179
Rev: src/opcodes.c:1.113
Rev: src/program.c:1.353
Rev: src/program.h:1.138

5:   \*/   /**/   #include "global.h" - RCSID("$Id: interpret.c,v 1.218 2001/07/09 14:19:15 grubba Exp $"); + RCSID("$Id: interpret.c,v 1.219 2001/07/13 11:26:38 grubba Exp $");   #include "interpret.h"   #include "object.h"   #include "program.h"
676:       if(backlog[e].program)    { -  char *file; +  struct pike_string *file;    INT32 line;      #ifdef _REENTRANT
687:    }   #endif    -  file=get_line(backlog[e].pc-1,backlog[e].program, &line); +  file = get_line(backlog[e].pc-1,backlog[e].program, &line);   #ifdef HAVE_COMPUTED_GOTO    fprintf(stderr,"%s:%ld: %s", -  file, +  file->str,    (long)line,    get_opcode_name(backlog[e].instruction));   #else /* !HAVE_COMPUTED_GOTO */    if(backlog[e].instruction < 0 || backlog[e].instruction+F_OFFSET > F_MAX_OPCODE)    {    fprintf(stderr,"%s:%ld: ILLEGAL INSTRUCTION %d\n", -  file, +  file->str,    (long)line,    backlog[e].instruction + F_OFFSET); -  +  free_string(file);    continue;    }       fprintf(stderr,"%s:%ld: %s", -  file, +  file->str,    (long)line,    low_get_f_name(backlog[e].instruction + F_OFFSET, backlog[e].program));    if(instrs[backlog[e].instruction].flags & I_HASARG2)
725:    DO_NOT_WARN((long)backlog[e].stack),    DO_NOT_WARN((long)backlog[e].mark_stack));   #endif /* HAVE_COMPUTED_GOTO */ +  free_string(file);    }    }while(e!=backlogp);   }
800:      static void do_trace_call(INT32 args)   { -  char *file,*s; +  struct pike_string *filep = NULL; +  char *file, *s;    INT32 linep,e;    my_strcat("(");    for(e=0;e<args;e++)
820:    if(Pike_fp && Pike_fp->pc)    {    char *f; -  file=get_line(Pike_fp->pc,Pike_fp->context.prog,&linep); -  while((f=STRCHR(file,'/'))) file=f+1; +  filep = get_line(Pike_fp->pc,Pike_fp->context.prog,&linep); +  file = filep->str; +  while((f=STRCHR(file,'/'))) +  file=f+1;    }else{    linep=0;    file="-";    }    fprintf(stderr,"- %s:%4ld: %s\n",file,(long)linep,s); -  +  if (filep) { +  free_string(filep); +  }    free(s);   }   
1805:    for (of = 0; f; f = (of = f)->next)    if (f->refs) {    int args, i; -  char *file = 0; +  struct pike_string *file = NULL;    INT32 line;       if (f->context.prog) {
1814:    else    file = get_program_line (f->context.prog, &line);    } -  if (file) -  fprintf (stderr, "%s:%d: ", file, line); -  else +  if (file) { +  fprintf (stderr, "%s:%d: ", file->str, line); +  free_string(file); +  } else    fputs ("unknown program: ", stderr);       if (f->current_object && f->current_object->prog) {
1934:    struct program *p = arg->u.object->prog;    if (p && p->num_linenumbers) {    file = get_program_line (p, &line); -  fprintf (stderr, "object(%s:%d)", file, line); +  fprintf (stderr, "object(%s:%d)", file->str, line); +  free_string(file);    }    else    fputs ("object", stderr);
1945:    struct program *p = arg->u.program;    if (p->num_linenumbers) {    file = get_program_line (p, &line); -  fprintf (stderr, "program(%s:%d)", file, line); +  fprintf (stderr, "program(%s:%d)", file->str, line); +  free_string(file);    }    else    fputs ("program", stderr);