>Hi there, I'm trying to complete a custom prompt system where people may >choose their own prompt style, and what they would like to see in it. > >However, there seems to be a critical bug somewhere in my procedure, but >I cannot locate it. > >here's what the code looks like at the moment.. > >void make_prompt(struct descriptor_data * d) >{ > > register char *i, *buff; > static char lbuff[MAX_STRING_LENGTH]; > char *prompt; > > if (d->str) > write_to_descriptor(d->descriptor, "] "); > else if (d->showstr_point) > write_to_descriptor(d->descriptor, > "\r\nPress Enter to continue:"); > else if (!d->connected) { > > sprintf(prompt, "< &N > "); /* this is where the procedure would normally > read the character's custom title from > char_data, but I'll just put this simple > string in for debugging purposes. */ > buff = lbuff; > > for (;;) { > if (*prompt == '&') { > switch (*(++prompt)) { > case 'N': > i = GET_NAME(d->character); > break; > case '&': > i = "&"; > break; > default: > break; > } > while ((*buff = *(i++))) > buff++; > prompt++; > } else if (!(*(buff++) = *(prompt++))) > break; > } > write_to_descriptor(d->descriptor, CAP(lbuff)); > } >} > >As you can see, it's very simular to the act() procedure, however >dubugging it is beyond me :(. > >What happens is it will proceed to work for about 15 seconds to a minute, >then all of a sudden it will core dump and spit the following out in >core.circle.. > >#0 0x7f67d in __sfvwrite (0x00000000, 0x001e0800, 0x00000000, 0x00000000) > >If you have any ideas what is causing this, I would be happy to hear >them. > >Ryan I don't see anything in here to stop the pointers tromping off the end of lbuff do something like if ((strlen(buff) + strlen(i)) > MAX_LBUFF) break; You also prob want to bzero(lbuff, MAX_LBUFF) just to make sure yer string is properly terminated. -- Ich habe Dinge gesehen, die ihr Menschen niemals glauben wuerdet. Gigantische Schiffe, die brannten draussen vor der Schulter des Orion. Und ich habe C-Beams gesehen - glitzernd im Dunkeln nahe dem Tannhaeuser Tor. All diese Momente werden verloren sein in der Zeit...so wie Traenen im Regen. Zeit zu sterben...
This archive was generated by hypermail 2b30 : 12/07/00 PST