Quote:
So is that supposed to be "sizeof buf1" and not "sizeof( buf1 )"?
My initial suggestion omitted the brackets, however because of the confusion I put them into the script. Whichever you prefer. I don't think they do any harm.
Quote:
So all I'd need to do is have this script run inside of mushclient and it will patch up the smaug source to change all of the buffer usage in the code?
Yes, although since MUSHclient is a Windows program, unless you are using Cygwin, you would need to copy the source to a suitable directory, put its path into the script, and run it. Make a blank directory for the src_fixed (output files) so you can run a diff on the before and after.
Quote:
And how will I be able to spot the remaining special cases?
As I mentioned, this command in Linux or Cygwin will do it:
grep -n snprintf *.c | grep -v sizeof
That will give you the files and line numbers, namely:
act_wiz.c:7675: snprintf( race_table[rcindex]->race_name, 16, "%-.16s", argument );
act_wiz.c:7807: snprintf( race->race_name, 16, "%s", capitalize( argument ) );
color.c:1542: vsnprintf( buf, MAX_STRING_LENGTH * 2, fmt, args );
color.c:1554: vsnprintf( buf, MAX_STRING_LENGTH * 2, fmt, args );
color.c:1570: vsnprintf( buf, MAX_STRING_LENGTH * 2, fmt, args );
color.c:1582: vsnprintf( buf, MAX_STRING_LENGTH * 2, fmt, args );
color.c:1594: vsnprintf( buf, MAX_STRING_LENGTH * 2, fmt, args );
db.c:4182: vsnprintf( buf, MAX_STRING_LENGTH * 2, fmt, args );
db.c:4194: vsnprintf( buf, MAX_STRING_LENGTH * 2, fmt, args );
imc.c:427: snprintf( buf, LGST * 2, "%s\033[0m", color_itom( txt, ch ) );
imc.c:462: snprintf( buf, LGST * 2, "%s\033[0m", color_itom( txt, ch ) );
imc.c:1541: snprintf( data->field, IMC_BUFF_SIZE, " %s", escape_string( pkt ) );
imc.c:1569: snprintf( p->from, SMST, "%s@%s", from, this_imcmud->localname );
imc.c:6379: snprintf( buf + strlen( buf ), MAX_STRING_LENGTH,
interp.c:383: snprintf( lastplayercmd, ( MAX_INPUT_LENGTH * 2 ), "%s used %s", ch->name, logline );
misc.c:2002: snprintf( p, ( XBI * 12 ) - ( p - buf ), "%d", bits->bits[x] );
skills.c:759: snprintf( buf + 3, MAX_STRING_LENGTH - 3, ") lvl: %3d max: %2d%%", skill->skill_level[iClass],
tables.c:383: snprintf( race_table[i]->race_name, 16, "%s", "unused" );
tables.c:626: snprintf( race->race_name, 16, "%-.16s", race_name );
(This was with the amended regexps in the later post).
The double grep is a powerfull tool. The first one finds the snprintf lines, the second one omits (-v) the ones which already have sizeof in them.
Quote:
Also going to need to know what the "Immediate window" is in Mushclient since I can't find a menu option called anything like that.
Game Menu -> Immediate (Ctrl+I). |