BSD systems may have this problem with intermud: (fwd)

From: Michael Scott (scottm@dns.workcomm.net)
Date: 05/08/96


	Okay, I have found out why on my system once you do a 'discon'
then a 'connect' again.. it always aborts the intermud server.. as
well as why every now and then it would just abort out after it started
talking about a BAD bitmap.. (this AFTER I thought I'd fixed the first
bugs regarding some cleanup in the code!)

	On my NetBSD system .. the strtok function works sort of strange..
if you were to send it a string containing "1050|Thryne|4010|blah|||blah"
then through subsequent parsing you would THINK would result in:
	first parse (delim == "|")   == "1050"
	second parse (delim == "|")  == "Thryne"
	third parse (delim == "|")   == "4010"
        fourth parse (delim == "|")  == "blah"
        fifth parse (delim == "|")   == ""
        sixth parse (delim == "|")   == ""
        seventh parse (delim == "|") == "blah"

	But on my system and probably several other BSD systems out 
there the fifth and sixth parses were SKIPPED and the fifth parse ends up
being another "blah"....
	So to solve this problem, I had to re-write a personal version
of strtok command which would return what it was supposed to, (named 
str_tok) and then rename all the function calls through out intermud.c
and act.intermud.c from strtok to str_tok.  (I added the new str_tok into
utils.c and put a prototype in utils.h for it.

new personalized function call I added:
__________________________________________
char *str_tok(char *string, char *delim)  {
   static char *flow = NULL, *flow_end = NULL;
   
   if (!string && !flow) return NULL;
   if (!string && !flow_end) flow = NULL;
   else if (string) flow = string;
   else if (flow) {
      flow = flow_end + 1;
      if (*flow == NULL) flow = NULL;
   }
   if (flow)  {
      if (*flow != NULL)  {
	 flow_end = flow + (strcspn(flow, delim));
	 if (*flow_end != NULL) flow_end[0] = NULL;
	 else flow_end = NULL;   /* at the end of the string, so return NULL
				  * nextime */
      }
      else flow = NULL;
   }
   return flow;
}
__________________________________________

	Sorry my example was so long winded .. just wanted to get my 
point across as clearly as possible, so you would know if you had this 
problem or not.

	NOTE: I wrote the above procedure in about 10 minutes so I'm not
gauranteeing that its bug free (or well written) .. but it seemed to work
ok fer me (solved all my abort for bad bitmap problems due to certain muds
not putting all the information into their part of the mudlist and my 
intermud server parsing several "|" delimiter characters in a row as one.)

                             All flames/questions to Michael Scott
			     Aka. the Wayfarer:    (scottm@workcomm.net)



This archive was generated by hypermail 2b30 : 12/18/00 PST