From ce3fd38f538cdbeaa004117445d5a806777647e3 Mon Sep 17 00:00:00 2001
From: Martin Nilsson <mani@lysator.liu.se>
Date: Fri, 29 Nov 2002 02:35:28 +0100
Subject: [PATCH] Improved _sprintf

Rev: lib/modules/Protocols.pmod/HTTP.pmod/Query.pike:1.47
Rev: lib/modules/Protocols.pmod/HTTP.pmod/Server.pmod/Request.pike:1.13
Rev: lib/modules/Protocols.pmod/IRC.pmod/Client.pike:1.8
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/ProtocolTypes.pmod:1.9
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/Session.pike:1.32
Rev: lib/modules/Protocols.pmod/XMLRPC.pmod/module.pmod:1.20
Rev: lib/modules/SSL.pmod/sslfile.pike:1.50
Rev: lib/modules/Sql.pmod/Sql.pike:1.62
Rev: lib/modules/Sql.pmod/sql_result.pike:1.11
Rev: lib/modules/Standards.pmod/CIFF.pmod/File.pike:1.3
Rev: lib/modules/Standards.pmod/RDF.pike:1.8
Rev: lib/modules/Stdio.pmod/FakeFile.pike:1.4
Rev: lib/modules/Stdio.pmod/module.pmod:1.161
Rev: lib/modules/Thread.pmod:1.35
---
 .../Protocols.pmod/HTTP.pmod/Query.pike       |  8 +-
 .../HTTP.pmod/Server.pmod/Request.pike        |  8 +-
 .../Protocols.pmod/IRC.pmod/Client.pike       | 12 +--
 .../LysKOM.pmod/ProtocolTypes.pmod            | 79 ++++++-------------
 .../Protocols.pmod/LysKOM.pmod/Session.pike   | 48 +++++------
 .../Protocols.pmod/XMLRPC.pmod/module.pmod    | 19 +++--
 lib/modules/SSL.pmod/sslfile.pike             |  8 +-
 lib/modules/Sql.pmod/Sql.pike                 | 12 +--
 lib/modules/Sql.pmod/sql_result.pike          | 12 +--
 .../Standards.pmod/CIFF.pmod/File.pike        | 23 +++---
 lib/modules/Standards.pmod/RDF.pike           |  9 +--
 lib/modules/Stdio.pmod/FakeFile.pike          | 10 +--
 lib/modules/Stdio.pmod/module.pmod            | 68 ++--------------
 lib/modules/Thread.pmod                       | 33 ++------
 14 files changed, 107 insertions(+), 242 deletions(-)

diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike b/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
index b2846afcf2..9614c22db0 100644
--- a/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
+++ b/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike
@@ -1,6 +1,6 @@
 #pike __REAL_VERSION__
 
-// $Id: Query.pike,v 1.46 2002/11/26 16:46:40 mirar Exp $
+// $Id: Query.pike,v 1.47 2002/11/29 01:09:27 nilsson Exp $
 
 //!	Open and execute an HTTP query.
 
@@ -839,10 +839,10 @@ void async_fetch(function callback,mixed ... extra)
    con->set_nonblocking(async_fetch_read,0,async_fetch_close);
 }
 
-static string _sprintf()
+static string _sprintf(int t)
 {
-  return status ? sprintf("Query(%d %s)", status, status_desc)
-		: "Query()";
+  return t=='O' && status && sprintf("%O(%d %s)", this_program,
+				     status, status_desc);
 }
 
 /************************ example *****************************/
diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/Server.pmod/Request.pike b/lib/modules/Protocols.pmod/HTTP.pmod/Server.pmod/Request.pike
index 0783bb761d..828c38cb44 100644
--- a/lib/modules/Protocols.pmod/HTTP.pmod/Server.pmod/Request.pike
+++ b/lib/modules/Protocols.pmod/HTTP.pmod/Server.pmod/Request.pike
@@ -180,13 +180,7 @@ static void close_cb()
 
 string _sprintf(int t)
 {
-   switch (t)
-   {
-      case 'O':
-	 return sprintf("HTTP.Server.Request(%s %s)",request_type,full_query);
-      default:
-	 return 0;
-   }
+  return t=='O' sprintf("%O(%s %s)",this_program,request_type,full_query);
 }
 
 // ----------------------------------------------------------------
diff --git a/lib/modules/Protocols.pmod/IRC.pmod/Client.pike b/lib/modules/Protocols.pmod/IRC.pmod/Client.pike
index c850e57d27..1ec7c6ff13 100644
--- a/lib/modules/Protocols.pmod/IRC.pmod/Client.pike
+++ b/lib/modules/Protocols.pmod/IRC.pmod/Client.pike
@@ -433,15 +433,9 @@ class Person
 
    string _sprintf(int t)
    {
-      switch (t)
-      {
-	 case 'O':
-	    return sprintf("Person(%s!%s@%s%s)",
-			   nick,user||"?",ip||"?",
-			   (realname!="?")?"("+realname+")":"");
-	 default:
-	    return 0;
-      }
+     return t=='O' && sprintf("%O(%s!%s@%s%s)", this_program,
+			      nick,user||"?",ip||"?",
+			      (realname!="?")?"("+realname+")":"");
    }
 }
 
diff --git a/lib/modules/Protocols.pmod/LysKOM.pmod/ProtocolTypes.pmod b/lib/modules/Protocols.pmod/LysKOM.pmod/ProtocolTypes.pmod
index 6ebb9646d8..fc8a2c820b 100644
--- a/lib/modules/Protocols.pmod/LysKOM.pmod/ProtocolTypes.pmod
+++ b/lib/modules/Protocols.pmod/LysKOM.pmod/ProtocolTypes.pmod
@@ -19,7 +19,9 @@ class LysKOMTime
    int              day_of_year;                   // INT32
    int(0..1)        is_dst;                        // BOOL
 
-  string _sprintf(){ return print(1); }
+  string _sprintf(int t){
+    return t=='O' && sprintf("%O(%s)", this_program, print(1));
+  }
 
    string print(void|int long)
    {
@@ -69,8 +71,6 @@ class TextStatOld
    int(0..65535)    no_of_marks;                   // INT16
    array(int)       misc_info;                     // ARRAY Misc-Info
 
-  string _sprintf(){ return "TextStatOld()"; }
-
    void create(string|int|array ... args)
    {
       creation_time=LysKOMTime(@args[0..8]);       // Time
@@ -116,10 +116,10 @@ class TextNumberPair
          });
    }
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("TextNumberPair(%d:%d)",
-		   local_number, global_number);
+    return t=='O' && sprintf("%O(%d:%d)", this_program,
+			     local_number, global_number);
   }
 }
 
@@ -138,8 +138,6 @@ class LocalToGlobalBlock
       sparse=Array.map(args[2..]/2,               // ARRAY Text-Number-Pair
 		       lambda(array z) { return TextNumberPair(@z); });
   }
-
-  string _sprintf(){ return "LocalToGlobalBlock()"; }
 }
 
 class TextMapping
@@ -167,8 +165,6 @@ class TextMapping
             @error("unimplemented"),               // Local-To-Global-Block
          });
    }
-
-  string _sprintf(){ return "TextMapping()"; }
 }
 
 constant sessionflagsnames = 
@@ -216,8 +212,6 @@ class DynamicSessionInfo
             H(what_am_i_doing),                    // HOLLERITH
          });
    }
-
-  string _sprintf(){ return "DynamicSessionInfo()"; }
 }
 
 class SessionInfo
@@ -254,8 +248,6 @@ class SessionInfo
             @connection_time->encode(),            // Time
          });
    }
-
-  string _sprintf(){ return "SessionInfo()"; }
 }
 
 class WhoInfo
@@ -286,8 +278,6 @@ class WhoInfo
             H(username),                           // HOLLERITH
          });
    }
-
-  string _sprintf(){ return "WhoInfo()"; }
 }
 
 constant personalflagsnames = 
@@ -351,7 +341,9 @@ class AuxItem
          });
    }
 
-  string _sprintf(){ return sprintf("AuxItem(%d)", tag); }
+  string _sprintf(int t){
+    return t=='O' && sprintf("%O(%d)", this_program, tag);
+  }
 }
 
 class TextStat
@@ -394,8 +386,6 @@ class TextStat
                                { return z->encode(); }))),
          });
    }
-
-  string _sprintf(){ return "TextStat()"; }
 }
 
 class InfoOld
@@ -429,8 +419,6 @@ class InfoOld
             motd_of_lyskom,                        // Text-No
          });
    }
-
-  string _sprintf(){ return "InfoOld()"; }
 }
 
 constant membershiptypenames = 
@@ -487,8 +475,6 @@ class Membership
             B(@rows(type, membershiptypenames)),   // Membership-Type
          });
    }
-
-  string _sprintf(){ return "Membership()"; }
 }
 
 class Member
@@ -516,8 +502,6 @@ class Member
             B(@rows(type, membershiptypenames)),   // Membership-Type
          });
    }
-
-  string _sprintf(){ return "Member()"; }
 }
 
 class MembershipOld
@@ -549,8 +533,6 @@ class MembershipOld
             @A((array(string))read_texts),         // ARRAY Local-Text-No
          });
    }
-
-  string _sprintf(){ return "MembershipOld()"; }
 }
 
 class Info
@@ -592,8 +574,6 @@ class Info
                                { return z->encode(); }))),
          });
    }
-
-  string _sprintf(){ return "Info()"; }
 }
 
 class StaticSessionInfo
@@ -621,8 +601,6 @@ class StaticSessionInfo
             @connection_time->encode(),            // Time
          });
    }
-
-  string _sprintf(){ return "StaticSessionInfo()"; }
 }
 
 constant extendedconftypenames = 
@@ -659,8 +637,6 @@ class TextList
             @A((array(string))texts),              // ARRAY Text-No
          });
    }
-
-  string _sprintf(){ return "TextList()"; }
 }
 
 class AuxItemInput
@@ -688,8 +664,6 @@ class AuxItemInput
             H(data),                               // HOLLERITH
          });
    }
-
-  string _sprintf(){ return "AuxItemInput()"; }
 }
 
 class WhoInfoIdent
@@ -726,8 +700,6 @@ class WhoInfoIdent
             H(ident_user),                         // HOLLERITH
          });
    }
-
-  string _sprintf(){ return "WhoInfoIdent()"; }
 }
 
 constant conftypenames = 
@@ -764,8 +736,6 @@ class ConfZInfo
             conf_no,                               // Conf-No
          });
    }
-
-  string _sprintf(){ return "ConfZInfo()"; }
 }
 
 class WhoInfoOld
@@ -790,9 +760,6 @@ class WhoInfoOld
             H(what_am_i_doing),                    // HOLLERITH
          });
    }
-
-
-  string _sprintf(){ return "WhoInfoOld()"; }
 }
 
 class Mark
@@ -815,7 +782,9 @@ class Mark
          });
    }
 
-  string _sprintf(){ return sprintf("Mark(%d, text %d)", text_no, type); }
+  string _sprintf(int t){
+    return t=='O' && sprintf("%O(%d, text %d)", this_program, text_no, type);
+  }
 }
 
 class Conference
@@ -888,7 +857,9 @@ class Conference
          });
    }
 
-  string _sprintf(){ return sprintf("Conference(%s)", name); }
+  string _sprintf(int t){
+    return t=='O' && sprintf("%O(%s)", this_program, name);
+  }
 }
 
 class ConferenceOld
@@ -947,7 +918,9 @@ class ConferenceOld
          });
    }
 
-  string _sprintf(){ return sprintf("ConferenceOld(%s)", name); }
+  string _sprintf(int t){
+    return t=='O' && sprintf("%O(%s)", this_program, name);
+  }
 }
 
 class SessionInfoIdent
@@ -990,8 +963,6 @@ class SessionInfoIdent
             @connection_time->encode(),            // Time
          });
    }
-
-  string _sprintf(){ return "SessionInfoIdent()"; }
 }
 
 class VersionInfo
@@ -1018,10 +989,11 @@ class VersionInfo
    }
 
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("VersionInfo(%s version %s; protocol %d)",
-		   server_software, software_version, protocol_version);
+    return t=='O' && sprintf("%O(%s version %s; protocol %d)",
+			     this_program, server_software,
+			     software_version, protocol_version);
   }
 }
 
@@ -1050,7 +1022,6 @@ class ConfListArchaic
                                { return B(@rows(z,conftypenames)); }))),
          });
    }
-  string _sprintf(){ return "ConfListArchaic()"; }
 }
 
 constant privbitsnames = 
@@ -1093,8 +1064,6 @@ class UConference
             nice,                                  // Garb-Nice
          });
    }
-
-  string _sprintf(){ return "UConference()"; }
 }
 
 class Person
@@ -1162,5 +1131,7 @@ class Person
          });
    }
 
-  string _sprintf(){ return sprintf("Person(%s)", username); }
+  string _sprintf(int t) {
+    return t=='O' && sprintf("%O(%s)", this_program, username);
+  }
 }
diff --git a/lib/modules/Protocols.pmod/LysKOM.pmod/Session.pike b/lib/modules/Protocols.pmod/LysKOM.pmod/Session.pike
index 0719aa41c8..d6a295a75c 100644
--- a/lib/modules/Protocols.pmod/LysKOM.pmod/Session.pike
+++ b/lib/modules/Protocols.pmod/LysKOM.pmod/Session.pike
@@ -1,6 +1,6 @@
 #pike __REAL_VERSION__
 
-//  $Id: Session.pike,v 1.31 2002/05/05 14:10:17 mast Exp $
+//  $Id: Session.pike,v 1.32 2002/11/29 01:12:44 nilsson Exp $
 
 import ".";
 
@@ -128,8 +128,9 @@ void async_new_text_old()
 
 class MiscInfo
 {
-  string _sprintf()
+  string _sprintf(int t)
   {
+    if(t!='O') return 0;
     array(string) to = ({});
     if(sizeof(recpt))
       to += ({ "To: " + String.implode_nicely(recpt->conf->no) });
@@ -138,8 +139,8 @@ class MiscInfo
     if(sizeof(bccrecpt))
       to += ({ "Bcc: " + String.implode_nicely(bccrecpt->conf->no) });
 
-    return sprintf("MiscInfo(%s)", sizeof(to) ? to * "; "
-					      : "No recipients");
+    return sprintf("%O(%s)", this_program,
+		   sizeof(to) ? to * "; " : "No recipients");
   }
 
   class Recpt
@@ -149,10 +150,10 @@ class MiscInfo
     object received_at;
     object sent_by;
     object sent_at;
-    string _sprintf()
+    string _sprintf(int t)
     {
-      return sprintf("Recpt(conf %d: text %d)",
-		     conf && conf->no, local_no);
+      return t=='O' && sprintf("%O(conf %d: text %d)", this_program,
+			       conf && conf->no, local_no);
     }
   }
 
@@ -471,9 +472,10 @@ class AuxItemInput
     data = _data;
   }
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("AuxItemInput(%s)", search(itemname_to_tag, tag));
+    return t=='O' && sprintf("%O(%s)", this_program,
+			     search(itemname_to_tag, tag));
   }
 }
 
@@ -481,13 +483,15 @@ class AuxItemInput
 //!   Undocumented
 class AuxItems
 {
-  string _sprintf()
+  string _sprintf(int t)
   {
+    if(t!='O') return 0;
     array desc = ({});
     foreach((array)tag_to_items, [int tag, mixed item])
       desc += ({ search(itemname_to_tag, tag) });
-    return sprintf("AuxItems(%s)", sizeof(desc) ? String.implode_nicely(desc)
-						: "none present");
+    return sprintf("%O(%s)", this_program,
+		   sizeof(desc) ? String.implode_nicely(desc)
+		   : "none present");
   }
 
   mapping(int:array(ProtocolTypes.AuxItem)) tag_to_items = ([]);
@@ -578,9 +582,9 @@ class Text
        error */
   }
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("Text(%d)", no);
+    return t=='O' && sprintf("%O(%d)", this_program, no);
   }
 
   //! @decl mixed prefetch_text
@@ -845,9 +849,9 @@ class Membership
 
   mixed `->(string what) { return `[](what); }
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("Membership(%d)", conf->no);
+    return t=='O' && sprintf("%O(%d)", this_program, conf->no);
   }
 
   array(string) _indices()
@@ -974,9 +978,9 @@ class Person
 
    mixed `->(string what) { return `[](what); }
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("Person(%d)", no);
+    return t=='O' && sprintf("%O(%d)", this_program, no);
   }
 
   array(string) _indices()
@@ -1084,9 +1088,9 @@ class Conference
 	      "permitted_submitters", });
   }
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("Conference(%d)", no);
+    return t=='O' && sprintf("%O(%d)", this_program, no);
   }
 }
 
@@ -1249,7 +1253,7 @@ void register_async_message_callback(function(int,int,string:void) cb)
   con->con->add_async_callback("async-send-message", cb);
 }
 
-string _sprintf()
+string _sprintf(int t)
 {
-  return sprintf("Session(%s)", server);
+  return t=='O' && sprintf("%O(%s)", this_program, server);
 }
diff --git a/lib/modules/Protocols.pmod/XMLRPC.pmod/module.pmod b/lib/modules/Protocols.pmod/XMLRPC.pmod/module.pmod
index d888df8daa..5001cc59fd 100644
--- a/lib/modules/Protocols.pmod/XMLRPC.pmod/module.pmod
+++ b/lib/modules/Protocols.pmod/XMLRPC.pmod/module.pmod
@@ -49,10 +49,11 @@ class Call(string method_name, array params)
   //! datatypes have been converted to equivalent or similar datatypes
   //! in Pike.
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("Protocols.XMLRPC.Call(%O, %d param%s)",
-		   method_name, sizeof(params), sizeof(params) == 1 ? "" : "s");
+    return t=='O' && sprintf("%O(%O, %d param%s)", this_program,
+			     method_name, sizeof(params),
+			     sizeof(params) == 1 ? "" : "s");
   }
 }
 
@@ -69,9 +70,10 @@ class Fault(int fault_code, string fault_string)
   //! @decl int fault_string
   //! Represents @tt{faultString@} in the XML-RPC standard.
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("Protocols.XMLRPC.Fault(%O, %O)", fault_code, fault_string);
+    return t=='O' && sprintf("%O(%O, %O)", this_program,
+			     fault_code, fault_string);
   }
 }
 
@@ -334,11 +336,8 @@ class Client(string|Standards.URI url)
 	   };
   }
 
-  string _sprintf()
+  string _sprintf(int t)
   {
-    return sprintf("Protocols.XMLRPC.Client(%O)",
-		   url);
+    return t=='O' && sprintf("%O(%O)", this_program, url);
   }
-
-  
 }
diff --git a/lib/modules/SSL.pmod/sslfile.pike b/lib/modules/SSL.pmod/sslfile.pike
index 9c3b1b4b0a..0e271fc025 100644
--- a/lib/modules/SSL.pmod/sslfile.pike
+++ b/lib/modules/SSL.pmod/sslfile.pike
@@ -1,6 +1,6 @@
 #pike __REAL_VERSION__
 
-/* $Id: sslfile.pike,v 1.49 2002/10/25 20:01:31 nilsson Exp $
+/* $Id: sslfile.pike,v 1.50 2002/11/29 01:22:14 nilsson Exp $
  *
  */
 
@@ -577,11 +577,7 @@ void create(object f, object c, int|void is_client, int|void is_blocking)
 }
 
 string _sprintf(int t) {
-  switch(t) {
-  case 't': return "SSL.sslfile";
-  case 'O': return sprintf("SSL.sslfile(%O,%O)", _fd, context);
-  }
-  error("Can not output SSL.sslfile as %c\n", t);
+  return t=='O' && sprintf("%O(%O,%O)", this_program, _fd, context);
 }
 
 void renegotiate()
diff --git a/lib/modules/Sql.pmod/Sql.pike b/lib/modules/Sql.pmod/Sql.pike
index e6a1cd850f..d773a7daf3 100644
--- a/lib/modules/Sql.pmod/Sql.pike
+++ b/lib/modules/Sql.pmod/Sql.pike
@@ -1,5 +1,5 @@
 /*
- * $Id: Sql.pike,v 1.61 2002/06/17 15:03:32 grubba Exp $
+ * $Id: Sql.pike,v 1.62 2002/11/29 01:28:57 nilsson Exp $
  *
  * Implements the generic parts of the SQL-interface
  *
@@ -247,14 +247,8 @@ void create(void|string|object host, void|string|mapping(string:int|string) db,
 
 string _sprintf(int type, mapping|void flags)
 {
-  switch(type)
-  {
-    case 't': return "Sql";
-    case 'O':
-      if(master_sql && master_sql->_sprintf)
-	return sprintf("Sql.%O", master_sql);
-      return "Sql()";
-  }
+  if(type=='O' && master_sql && master_sql->_sprintf)
+    return sprintf("Sql.%O", master_sql);
 }
 
 static private array(mapping(string:mixed)) res_obj_to_array(object res_obj)
diff --git a/lib/modules/Sql.pmod/sql_result.pike b/lib/modules/Sql.pmod/sql_result.pike
index cd40ea4747..c76c676c62 100644
--- a/lib/modules/Sql.pmod/sql_result.pike
+++ b/lib/modules/Sql.pmod/sql_result.pike
@@ -1,5 +1,5 @@
 /*
- * $Id: sql_result.pike,v 1.10 2002/04/11 10:59:02 jhs Exp $
+ * $Id: sql_result.pike,v 1.11 2002/11/29 01:29:14 nilsson Exp $
  *
  * Implements the generic result module of the SQL-interface
  *
@@ -33,13 +33,9 @@ void create(object|array res)
 
 string _sprintf(int type, mapping|void flags)
 {
-  switch(type)
-  {
-    case 't': return "sql_result";
-    case 'O':
-      return sprintf("sql_result(/* row %d/%d, %d fields */)",
-		     index, num_rows(), num_fields());
-  }
+  return type=='O' && sprintf("%O(/* row %d/%d, %d fields */)",
+			      this_program, index, num_rows(),
+			      num_fields());
 }
 
 //! Returns the number of rows in the result.
diff --git a/lib/modules/Standards.pmod/CIFF.pmod/File.pike b/lib/modules/Standards.pmod/CIFF.pmod/File.pike
index 0ed8a3b455..5bb0bd01f5 100644
--- a/lib/modules/Standards.pmod/CIFF.pmod/File.pike
+++ b/lib/modules/Standards.pmod/CIFF.pmod/File.pike
@@ -101,20 +101,15 @@ class Record
 
    string _sprintf(int t,mapping z)
    {
-      switch (t)
-      {
-	 case 'O': 
-	    return sprintf(
-	       "Record(%s:%s%s)",
-	       _stgtoid[storage]||sprintf("%xh",storage),
-//  	       _ctoid[datatype]||sprintf("%xh",datatype),
-	       _dttoid[typeid]||sprintf("%xh",typeid),
-	       (storage==kStg_InRecordEntry)?"":
-	       sprintf(" %d+%d",offset,length)
-			   );
-	 default:
-	    return 0;
-      }
+     if(t=='O')
+       return sprintf(
+         "%O(%s:%s%s)", this_program,
+         _stgtoid[storage]||sprintf("%xh",storage),
+//       _ctoid[datatype]||sprintf("%xh",datatype),
+         _dttoid[typeid]||sprintf("%xh",typeid),
+         (storage==kStg_InRecordEntry)?"":
+           sprintf(" %d+%d",offset,length)
+         );
    }
 
    void seek(void|int n)
diff --git a/lib/modules/Standards.pmod/RDF.pike b/lib/modules/Standards.pmod/RDF.pike
index 73e6846be9..8f445dd901 100644
--- a/lib/modules/Standards.pmod/RDF.pike
+++ b/lib/modules/Standards.pmod/RDF.pike
@@ -1,4 +1,4 @@
-// $Id: RDF.pike,v 1.7 2002/10/30 01:07:03 nilsson Exp $
+// $Id: RDF.pike,v 1.8 2002/11/29 01:29:44 nilsson Exp $
 
 //! Represents an RDF domain which can contain any number of complete
 //! statements.
@@ -37,7 +37,6 @@ class Resource {
   static string __sprintf(string c, int t) {
     if(t=='t') return "RDF."+c;
     if(t=='O') return "RDF."+c+"(" + get_n_triple_name() + ")";
-    error("Can not represent RDF.%s as %c.\n", c, t);
   }
 
   string _sprintf(int t) { return __sprintf("Resource", t); }
@@ -185,7 +184,7 @@ int parse_n_triples(string in) {
 
   class Temp(string id) {
     constant type = "";
-    string _sprintf() { return sprintf("%s(%O)", type, id); }
+    string _sprintf(int t) { return t=='O' && sprintf("%s(%O)", type, id); }
   };
   class TempURI {
     inherit Temp;
@@ -373,7 +372,5 @@ int _sizeof() {
 }
 
 string _sprintf(int t) {
-  if(t=='t') return "RDF";
-  if(t=='O') return "RDF(" + _sizeof() + ")";
-  error("Can not represent RDF as %c.\n", t);
+  return t=='O' && sprintf("%O(%d)", _sizeof());
 }
diff --git a/lib/modules/Stdio.pmod/FakeFile.pike b/lib/modules/Stdio.pmod/FakeFile.pike
index a1055b6f31..1d05eec794 100644
--- a/lib/modules/Stdio.pmod/FakeFile.pike
+++ b/lib/modules/Stdio.pmod/FakeFile.pike
@@ -1,4 +1,4 @@
-// $Id: FakeFile.pike,v 1.3 2002/07/22 13:47:55 nilsson Exp $
+// $Id: FakeFile.pike,v 1.4 2002/11/29 01:30:43 nilsson Exp $
 #pike __REAL_VERSION__
 
 //! A string wrapper that pretends to be a @[Stdio.File] object.
@@ -146,12 +146,8 @@ int(0..1) truncate(int length) {
 }
 
 string _sprintf(int t) {
-  switch(t) {
-  case 't': return "Stdio.FakeFile";
-  case 'O': return "Stdio.FakeFile(" + sizeof(data) + ", \"" +
-	      make_type_str() + "\")";
-  }
-  error("Could not format Stdio.FakeFile as '%c'.\n", t);
+  return t=='O' && sprintf("%O(%d,%O)", this_program, sizeof(data),
+			   make_type_str());
 }
 
 //! @ignore
diff --git a/lib/modules/Stdio.pmod/module.pmod b/lib/modules/Stdio.pmod/module.pmod
index 7a363d046e..684f06ce1d 100644
--- a/lib/modules/Stdio.pmod/module.pmod
+++ b/lib/modules/Stdio.pmod/module.pmod
@@ -1,4 +1,4 @@
-// $Id: module.pmod,v 1.160 2002/11/28 00:36:13 marcus Exp $
+// $Id: module.pmod,v 1.161 2002/11/29 01:30:30 nilsson Exp $
 #pike __REAL_VERSION__
 
 inherit files;
@@ -38,17 +38,6 @@ class Stream
   optional string read_oob(int nbytes);
   optional int write_oob(string data);
 #endif
-
-  static string _sprintf( int type )
-  {
-    switch( type )
-    {
-     case 'O':
-       return sprintf("%t()", this_object());
-     case 't':
-       return "Stdio.Stream";
-    }
-  }
 }
 
 //! The Stdio.NonblockingStream API.
@@ -83,15 +72,6 @@ class NonblockingStream
   void set_nonblocking( function a, function b, function c,
                         function|void d, function|void e);
   void set_blocking();
-
-  static string _sprintf( int type )
-  {
-    switch( type )
-    {
-     case 't': return "Stdio.NonblockingStream";
-    }
-    return ::_sprintf( type );
-  }
 }
 
 //! The Stdio.BlockFile API.
@@ -109,14 +89,6 @@ class BlockFile
   inherit Stream;
   int seek(int to);
   int tell();
-  static string _sprintf( int type )
-  {
-    switch( type )
-    {
-     case 't': return "Stdio.BlockFile";
-    }
-    return ::_sprintf( type );
-  }
 }
 
 //! This is the basic I/O object, it provides socket communication as well
@@ -177,23 +149,18 @@ class File
 
   static string _sprintf( int type, mapping flags )
   {
+    if(type!='O') return 0;
     int do_query_fd( )
     {
       int fd = -1;
       catch{ fd = query_fd(); };
       return fd;
     };
-    switch( type )
-    {
-     case 'O':
-       return sprintf("%t(%O, %O, %o /* fd=%d */)", 
-                      this_object(), 
-                      debug_file, debug_mode,
-                      debug_bits||0777,
-                      do_query_fd() );
-     case 't':
-       return "Stdio.File";
-    }
+    return sprintf("%O(%O, %O, %o /* fd=%d */)",
+		   this_program,
+		   debug_file, debug_mode,
+		   debug_bits||0777,
+		   do_query_fd() );
   }
 
   //  @decl int open(int fd, string mode)
@@ -1108,13 +1075,7 @@ class Port
 
   static string _sprintf( int f )
   {
-    switch( f )
-    {
-     case 't':
-       return "Stdio.Port";
-     case 'O':
-       return sprintf( "%t(%s:%O)", this_object(), debug_ip, debug_port );
-    }
+    return f=='O' && sprintf( "%O(%s:%O)", this_program, debug_ip, debug_port );
   }
 
   //! @decl void create()
@@ -1213,8 +1174,6 @@ class FILE
   
   static string _sprintf( int type, mapping flags )
   {
-    if( type == 't' )
-      return "Stdio.FILE";
     return ::_sprintf( type, flags );
   }
 
@@ -2520,17 +2479,6 @@ class UDP
   private static array extra=0;
   private static function callback=0;
 
-  static string _sprintf( int f )
-  {
-    switch( f )
-    {
-    case 't':
-      return "Stdio.UDP";
-    case 'O':
-      return sprintf("%t()", this_object() );
-    }
-  }
-
   //! @decl UDP set_nonblocking()
   //! @decl UDP set_nonblocking(function(mapping(string:int|string), @
   //!                                    mixed ...:void) read_cb, @
diff --git a/lib/modules/Thread.pmod b/lib/modules/Thread.pmod
index f75d5075b1..cc15644d1f 100644
--- a/lib/modules/Thread.pmod
+++ b/lib/modules/Thread.pmod
@@ -154,15 +154,10 @@ optional class Fifo {
 
   static string _sprintf( int f )
   {
-    switch( f )
-    {
-      case 't':
-	return "Thread.Fifo";
-      case 'O':
-	return sprintf( "%t(%d / %d)", this_object(), size(), read_tres );
-    }
+    return f=='O' && sprintf( "%O(%d / %d)", this_program,
+			      size(), read_tres );
   }
-};
+}
 
 //! @[Queue] implements a queue, or a pipeline. The main difference
 //! between @[Queue] and @[Fifo] is that @[Queue]
@@ -233,13 +228,7 @@ optional class Queue {
 
   static string _sprintf( int f )
   {
-    switch( f )
-    {
-      case 't':
-	return "Thread.Queue";
-      case 'O':
-	return sprintf( "%t(%d)", this_object(), size() );
-    }
+    return f=='O' && sprintf( "%O(%d)", this_program, size() );
   }
 }
 
@@ -400,7 +389,8 @@ optional class Farm
 	case 't':
 	  return "Thread.Farm().Handler";
 	case 'O':
-	  return sprintf( "%t(%f / %d,  %d)", total_time, max_time,handled );
+	  return sprintf( "%t(%f / %d,  %d)", this_object(),
+			  total_time, max_time, handled );
       }
     }
   }
@@ -517,20 +507,11 @@ optional class Farm
     return res;
   }
 
-
   static string _sprintf( int f )
   {
-    switch( f )
-    {
-      case 't':
-	return "Thread.Farm";
-      case 'O':
-	return sprintf( "%t(/* %s */)", this_object, debug_status() );
-    }
+    return f=='O' && sprintf( "%O(/* %s */)", this_program, debug_status() );
   }
 
-
-
   static void create()
   {
     thread_create( dispatcher );
-- 
GitLab