lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi

In lstrlib.c, the preprocessor define FLAGS defines the flag characters that be used in string formatting (string.format()). It includes flags like 0, -, space, etc.  The flag to add thousands separators to a number ('), however, is missing.  Is there a reason for that?

I can use

print(string.format("%.2f", 1000000))

to print a number,  but with "stock" Lua I can not use

print(string.format("%'.2f", 1000000))

to print the number with thousands separator.

Adding an apostrophe to FLAGS in lstrlib.c makes it perfectly word.

I understand that the thousands separator flag is not part of C89, but a SuSv2 extension, which seems to be present on almost all (modern) operating systems.

Could FLAGS be something that could be overriden in luaconf.h?  It would be as simple as enclosing the definition of FLAGS in a #ifndef  FLAGS / #endif bracket.

Thanks,
Marc