void string_append( CHAR_DATA *ch, char **pString )
{…
if ( *pString == NULL )
{
*pString = NULL;
}
…
}
if ( *pString == NULL )
{
*pString = str_dup("")
}
char *desc_pretty( char *string, int start, int lines, bool no_free )
{
char buf[MSL]={'\0'};
char wordbuf[MAX_INPUT_LENGTH]={'\0'};
char *p, *bp, *wp;
int i = 0,inword = 0;
/* find starting line to pretty-ify */
for( i = 1, p = string, bp = buf; *p != 0 && i < start; p++)
{
*bp++ = *p;
if( *p == '\r' )
i++;
}
*bp = 0;
/* now build pretty lines from raw ones */
pretty_proc( bp, NULL ); /* init pretty processor */
for( i = inword = 0, wp = wordbuf; i < lines && *p != 0; p++ )
{
if( *p == ' ' )
{
if( inword )
{
inword = 0;
*wp = 0;
pretty_proc( NULL, wordbuf );
wp = wordbuf;
}
*wp++ = ' ';
}
else if( *p == '\r' )
{
i++; /* inc line count */
if( inword )
{
inword = 0;
*wp = 0;
pretty_proc( NULL, wordbuf );
wp = wordbuf;
if( p[1] == '\n' || p[1] == ' ' || p[1] == 0)
pretty_proc( NULL, "\n\r" );
else
pretty_proc( NULL, " " );
}
else
{
pretty_proc( NULL, "\n\r" );
wp = wordbuf;
}
}
else if( *p == '\n' )
continue;
else {
inword = 1;
*wp++ = *p;
}
}
/* and append any leftover lines directly */
strncat( buf, p, sizeof(buf) );
/* and swap in the new editted description */
if(no_free)
{
snprintf(string, sizeof(string), "%s", buf);
return string;
}
PURGE_DATA( string );
return str_dup( buf );
}
I seg faulted during some OLC editing, but not during others and I cannot figure it out.
0x08128417 in string_append (ch=0x8388590, pString=0x834acb4) at string.c:72
72 if ( *(*pString + strlen( *pString ) - 1) != '\r' )
(gdb) bt
#0 0x08128417 in string_append (ch=0x8388590, pString=0x834acb4) at string.c:72
#1 0x080fd885 in redit_udesc (ch=0x8388590, argument=0x8385dce "") at olc_act.c:2085
#2 0x080ee559 in redit (ch=0x8388590, argument=0x8385dce "") at olc.c:1049
#3 0x080ecf79 in run_olc_editor (d=0x83859b0) at olc.c:55
#4 0x080982d7 in game_loop_unix (control=8) at comm.c:1036
#5 0x08097c8c in main (argc=2, argv=0xbfffd824) at comm.c:656
(gdb) list
67 {
68 *pString = NULL;
69 }
70 send_to_char( *pString, ch );
71
72 if ( *(*pString + strlen( *pString ) - 1) != '\r' )
73 send_to_char( "\n\r", ch );
74
75 ch->desc->pString = pString;
76
(gdb) info locals
No locals.
(gdb) frame 1
#1 0x080fd885 in redit_udesc (ch=0x8388590, argument=0x8385dce "") at olc_act.c:2085
2085 string_append( ch, &pRoom->udescription );
(gdb) list
2080
2081 EDIT_ROOM(ch, pRoom);
2082
2083 if ( IS_NULLSTR(argument) )
2084 {
2085 string_append( ch, &pRoom->udescription );
2086 return TRUE;
2087 }
2088
2089 send_to_char( "Syntax: udesc\n\r", ch );
(gdb) info locals
pRoom = 0x834ac50
This is the whole of string_append