*** -	Fri Sep  2 14:12:38 1994
--- unsupported/programs/dish/main.cxx	Fri Sep  2 14:12:20 1994
***************
*** 1,3 ****
--- 1,4 ----
+ /* $XConsortium: main.cxx,v 1.10 94/09/02 18:12:30 matt Exp $ */
  /* Copyright (c) 1992-1993 Silicon Graphics, Inc.
   * Copyright (c) 1993 Fujitsu, Ltd.
   *
***************
*** 35,41 ****
  #include <string.h>
  #include <tcl.h>
  
! #if defined(AIXV3)
  extern "C" int strcasecmp(const char*, const char*);
  #endif
  
--- 36,42 ----
  #include <string.h>
  #include <tcl.h>
  
! #if defined(AIXV3) || defined(__GNUC__)
  extern "C" int strcasecmp(const char*, const char*);
  #endif
  
***************
*** 251,264 ****
--- 252,273 ----
      if (strcmp(s, "0") == 0) {
  	obj = nil;
      } else {
+ #if defined(__GNUC__)
+ 	b = sscanf(s, "_dish_%lx", &obj) == 1;
+ #else
  	b = sscanf(s, "_dish_%p", &obj) == 1;
+ #endif
      }
      return b;
  }
  
  char* Dish::object_to_string(BaseObjectRef obj, char* result) {
      if (is_not_nil(obj)) {
+ #if defined(__GNUC__)
+ 	sprintf(result, "_dish_%lx", obj);
+ #else
  	sprintf(result, "_dish_%p", obj);
+ #endif
      } else {
  	sprintf(result, "0");
      }
***************
*** 556,562 ****
      TypeObjRef array, char* arg, RequestObjRef req, Tcl_Interp* interp
  ) {
      Boolean b = false;
!     long element_count;
      TypeObj_var element_type;
      array->array_info(element_type._out(), element_count);
      if (arg != nil) {
--- 565,571 ----
      TypeObjRef array, char* arg, RequestObjRef req, Tcl_Interp* interp
  ) {
      Boolean b = false;
!     Long element_count;
      TypeObj_var element_type;
      array->array_info(element_type._out(), element_count);
      if (arg != nil) {
***************
*** 660,666 ****
     TypeObjRef sequence, char* arg, RequestObjRef req, Tcl_Interp* interp
  ) {
      Boolean b = false;
!     long length;
      TypeObj_var element_type;
      sequence->sequence_info(element_type._out(), length);
      if (arg != nil) {
--- 669,675 ----
     TypeObjRef sequence, char* arg, RequestObjRef req, Tcl_Interp* interp
  ) {
      Boolean b = false;
!     Long length;
      TypeObj_var element_type;
      sequence->sequence_info(element_type._out(), length);
      if (arg != nil) {
***************
*** 832,838 ****
  ) {
      Tcl_DString result;
      Tcl_DStringInit(&result);
!     long element_count;
      TypeObj_var element_type;
      array->array_info(element_type._out(), element_count);
      for (int i = 0; i < element_count; i++) {
--- 841,847 ----
  ) {
      Tcl_DString result;
      Tcl_DStringInit(&result);
!     Long element_count;
      TypeObj_var element_type;
      array->array_info(element_type._out(), element_count);
      for (int i = 0; i < element_count; i++) {
***************
*** 879,885 ****
  ) {
      Tcl_DString result;
      Tcl_DStringInit(&result);
!     long size;
      TypeObj_var element_type;
      sequence->sequence_info(element_type._out(), size);
      size = req->get_long();
--- 888,894 ----
  ) {
      Tcl_DString result;
      Tcl_DStringInit(&result);
!     Long size;
      TypeObj_var element_type;
      sequence->sequence_info(element_type._out(), size);
      size = req->get_long();
***************
*** 951,957 ****
--- 960,970 ----
  		ThreadObjRef t = threads->thread(a);
  		if (is_not_nil(t)) {
  		    t->run();
+ #if defined(__GNUC__)
+ 		    sprintf(interp->result, "%lx", ThreadObjRef(t));
+ #else
  		    sprintf(interp->result, "%p", ThreadObjRef(t));
+ #endif
  		    status = TCL_OK;
  		} else {
  		    Tcl_AppendResult(interp, "No threads available", 0);
***************
*** 1087,1112 ****
      }
  }
  
  /*
!  *  Called by main() defined in tcl lib.
   */
  
  #if defined(sun) && !defined(SVR4)
! extern "C" {
!   void _main();
!   void on_exit(void (*)(), caddr_t);
  }
  #endif
  
! int Tcl_AppInit(Tcl_Interp* interp) {
! #if defined(sun) && !defined(SVR4)
      _main();
!     on_exit(&Dish::cleanup, NULL);
  #else
!     atexit(&Dish::cleanup);
  #endif
      Dish* dish = new Dish(interp);
      dish->add_commands(interp);
      dish->add_variables(interp);
      return TCL_OK;
  }
--- 1100,1147 ----
      }
  }
  
+ 
  /*
!  * This is for platforms that don't have atexit()
   */
  
  #if defined(sun) && !defined(SVR4)
! extern "C" int on_exit(void (*)(), caddr_t);
! int atexit(void (*func)(void)) {
!     return on_exit(func, NULL);
  }
  #endif
  
! 
! /*
!  * This is for cfront-based compilers that need to call _main to 
!  * get static initializers run.
!  */
! 
! #if defined(sun) && !defined(SVR4) && !defined(__GNUC__)
! extern "C" void _main();
! void init_static_initializers() {
      _main();
! }
  #else
! void init_static_initializers()	{
!     /* nothing */
! }
  #endif
+ 
+ 
+ /*
+  *  Called by main() defined in tcl lib.
+  */
+ 
+ 
+ int Tcl_AppInit(Tcl_Interp* interp) {
+     init_static_initializers();
+     atexit(&Dish::cleanup);
      Dish* dish = new Dish(interp);
      dish->add_commands(interp);
      dish->add_variables(interp);
      return TCL_OK;
  }
+ 
+ 
