View Issue Details

IDProjectCategoryView StatusLast Update
0000881LDMud 3.6Efunspublic2020-09-01 22:40
Reporterhumni Assigned ToGnomi  
Status resolvedResolutionfixed 
Fixed in Version3.6.3 
Summary0000881: sprintf problems concerning ANSI-Codecs
DescriptionIn Morgengrauen, we have ANSI-Codecs which change the colour of the code.
They have a "size" (meaning: sizeof(ANSI_BOLD) has a value>0).
But of course, there is no character if you see the text displayed, just a change in the color.

If you now use sprintf on some "coloured" strings, the behaviour is not consistent:

will return a blue Text with 18 following Spaces, followed by Text. This is how I would expect sprintf to work.


will return

with the first Text blue and the second Text not.

Probably this happens because sprintf thinks the first Text is longer than 12 characters and doesn't change it. This may be, because


is 18.

Steps To ReproduceUsing a Morgengrauen Mudlib, you may use this code:

#include <ansi.h>

#define TI this_interactive()

protected void create()

and then just load the object.

The 18 is the length mentioned above. The first line (after the numbers to see how long the string is) seems to be as expected, the last line is not.

As a Morgengrauen mage, you may just load the object from /players/humni/temp/test1.c



2020-08-06 01:53

administrator   ~0002538

Additional info - the defines are as follows:
#define ANSI_BOLD "ESC[1m"
#define ANSI_BLUE "ESC[34m"
#define ANSI_NORMAL "ESC[0m"


2020-08-06 12:12

manager   ~0002539

I fixed this in my 363preparations branch that will eventually go into LDMud 3.6.3:

Issue History

Date Modified Username Field Change
2020-08-06 01:24 humni New Issue
2020-08-06 01:24 humni Tag Attached: sprintf
2020-08-06 01:29 zesstra Project LDMud => LDMud 3.6
2020-08-06 01:53 zesstra Note Added: 0002538
2020-08-06 12:12 Gnomi Note Added: 0002539
2020-09-01 22:40 Gnomi Assigned To => Gnomi
2020-09-01 22:40 Gnomi Status new => assigned
2020-09-01 22:40 Gnomi Status assigned => resolved
2020-09-01 22:40 Gnomi Resolution open => fixed
2020-09-01 22:40 Gnomi Fixed in Version => 3.6.3