pike.git / src / main.c

version» Context lines:

pike.git/src/main.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: main.c,v 1.216 2004/12/11 13:29:59 grubba Exp $ + || $Id: main.c,v 1.217 2004/12/29 09:11:44 agehall Exp $   */      #include "global.h"   #include "fdlib.h"   #include "backend.h"   #include "module.h"   #include "object.h"   #include "lex.h"   #include "pike_types.h"   #include "builtin_functions.h"
pike.git/src/main.c:77:   /* #define TRACE_MAIN */      #ifdef TRACE_MAIN   #define TRACE(X) fprintf X   #else /* !TRACE_MAIN */   #define TRACE(X)   #endif /* TRACE_MAIN */      char *master_file;   char **ARGV; + JMP_BUF back;      PMOD_EXPORT int debug_options=0;   PMOD_EXPORT int runtime_options=0;   PMOD_EXPORT int d_flag=0;   PMOD_EXPORT int c_flag=0;   PMOD_EXPORT int default_t_flag=0;   PMOD_EXPORT int a_flag=0;   PMOD_EXPORT int l_flag=0;   PMOD_EXPORT int p_flag=0;   #if defined(YYDEBUG) || defined(PIKE_DEBUG)
pike.git/src/main.c:219:    return 0;   }      static struct Hook scan_amigaos_environment_hook = {    { NULL, NULL },    (ULONG (*)())scan_amigaos_environment_func,    NULL, NULL   };   #endif /* __amigsos4__ */    - int dbm_main(int argc, char **argv) - { -  JMP_BUF back; -  int e, num; +  + void pike_main_setup(int argc, char **argv) { +  int e;    char *p; -  struct array *a; +    #ifdef DECLARE_ENVIRON    extern char **environ;   #endif    -  TRACE((stderr, "dbm_main()\n")); -  +     init_rusage();       /* Attempt to make sure stderr is unbuffered. */   #ifdef HAVE_SETVBUF    setvbuf(stderr, NULL, _IONBF, 0);   #else /* !HAVE_SETVBUF */   #ifdef HAVE_SETBUF    setbuf(stderr, NULL);   #endif /* HAVE_SETBUF */   #endif /* HAVE_SETVBUF */
pike.git/src/main.c:754:       init_opcodes();       TRACE((stderr, "Init programs...\n"));       init_program();       TRACE((stderr, "Init objects...\n"));       init_object(); + }    -  if(SETJMP(back)) -  { +  + int pike_handle_error_in_main() { +  int num;    if(throw_severity == THROW_EXIT)    {    num=throw_value.u.integer;    }else{    if (throw_value.type == T_OBJECT &&    throw_value.u.object->prog == master_load_error_program &&    !get_master()) {    /* Report this specific error in a nice way. Since there's no    * master it'd be reported with a raw error dump otherwise. */    struct generic_error_struct *err;
pike.git/src/main.c:792:    describe_svalue(&t,0,0);    s=complex_free_buf(&buf);       fputs(s.str, stderr);    free(s.str);    }    else    call_handle_error();    num=10;    } -  }else{ -  back.severity=THROW_EXIT; +  return num; + }    -  TRACE((stderr, "Init master cookie...\n")); -  -  /* Avoid duplicate entries... */ -  push_constant_text(MASTER_COOKIE1); -  push_constant_text(MASTER_COOKIE2); -  f_add(2); -  low_add_constant("__master_cookie", Pike_sp-1); -  pop_stack(); -  -  TRACE((stderr, "Init modules...\n")); -  -  init_modules(); -  - #ifdef TEST_MULTISET -  /* A C-level testsuite for the low level stuff in multisets. */ -  test_multiset(); - #endif -  -  TRACE((stderr, "Init master...\n")); -  -  master(); -  call_callback(& post_master_callbacks, 0); -  free_callback_list(& post_master_callbacks); -  + int pike_run_master(int argc, char **argv) { +  int num; +  struct array *a;    TRACE((stderr, "Call master->_main()...\n"));       a=allocate_array_no_init(argc,0);    for(num=0;num<argc;num++)    {    ITEM(a)[num].u.string=make_shared_string(argv[num]);    ITEM(a)[num].type=T_STRING;    }    a->type_field = BIT_STRING;    push_array(a);
pike.git/src/main.c:856:    ITEM(a)[num].u.string=make_shared_string(environ[num]);    ITEM(a)[num].type=T_STRING;    }    a->type_field = BIT_STRING;    push_array(a);   #endif       apply(master(),"_main",2);    pop_stack();    num=0; +  return num;   } -  +  + void pike_init_master() { +  TRACE((stderr, "Init master cookie...\n")); +  +  /* Avoid duplicate entries... */ +  push_constant_text(MASTER_COOKIE1); +  push_constant_text(MASTER_COOKIE2); +  f_add(2); +  low_add_constant("__master_cookie", Pike_sp-1); +  pop_stack(); +  +  TRACE((stderr, "Init modules...\n")); +  +  init_modules(); +  + #ifdef TEST_MULTISET +  /* A C-level testsuite for the low level stuff in multisets. */ +  test_multiset(); + #endif +  +  TRACE((stderr, "Init master...\n")); +  +  master(); +  call_callback(& post_master_callbacks, 0); +  free_callback_list(& post_master_callbacks); + } +  + int dbm_main(int argc, char **argv) + { +  int num; +  struct array *a; +  +  TRACE((stderr, "dbm_main()\n")); +  +  pike_main_setup(argc, argv); +  +  if(SETJMP(back)) +  { +  num=pike_handle_error_in_main(); +  }else{ +  back.severity=THROW_EXIT; +  pike_init_master(); +  num=pike_run_master(argc, argv); +  }    UNSETJMP(back);       TRACE((stderr, "Exit %d...\n", num));       pike_do_exit(num);    return num; /* avoid warning */   }      #undef ATTRIBUTE   #define ATTRIBUTE(X)