Branch: Tag:

2013-11-30

2013-11-30 18:33:15 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Master: Fix the case where main() doesn't take any args at all.

Also adds main() compat for Pike 7.8.

3568:   //! This function is called when all the driver is done with all setup   //! of modules, efuns, tables etc. etc. and is ready to start executing   //! _real_ programs. It receives the arguments not meant for the driver. - void _main(array(string) orig_argv) + void _main(array(string(0..255)) orig_argv)   {    array(string) argv=copy_value(orig_argv);    int debug,trace,run_tool;
4033:    error("Error: %s has no main().\n", argv[0]);    if (cur_compat_ver <= Version (7, 6))    ret=script->main(sizeof(argv),argv,getenv()); +  else if (cur_compat_ver <= Version (8, 0)) +  ret = script->main(sizeof(argv),argv);    else    { -  array a; -  if( __get_first_arg_type(_typeof(script->main))<=typeof(a) ) +  mixed first_arg = __get_first_arg_type(_typeof(script->main)); +  // NB: first_arg may be zero eg in case main() ignores all args. +  if( first_arg && (typeof(argv) <= first_arg) ) { +  // argv accepted as first argument.    ret=script->main(argv); -  else +  } else    ret=script->main(sizeof(argv),argv);    }    };