Feature #1903
openimprove format of output from ruledit/ruleup
0%
Description
Don't you just hate it when there's a long helptext (like for a government), nicely formatted with newlines (like in the standard supplied rulesets), and then ruledit/ruleup turns it into a single line hundreds of chars long. And you're viewing it in a text editor that doesn't wrap long lines, cause you don't want wrapping when you're looking at C code. Let's do better.
Files
Updated by Dean Brown 8 days ago
- File 1903.patch added
This doesn't do everything possible to keep line lengths < LINE_BREAK, but does deal with "helptext=..." and long lists of "...","...", like the lists of actions in actions.ruleset and lists of "flags=" in units.ruleset. Not dealt with are "helptxt" strings within
flags={"name","helptxt"
class_flags={"name","helptxt"
in units.ruleset - there is only 1 instance in the supplied rulesets of a lengthy string. Also the Achievements in game.ruleset have strings for first_msg and cons_msg that could be long but there are no instances in the supplied rulesets.
The routine make_escapes() needed to be changed because as written it messed up the added new line chars. It was only called from entry_to_file() in registry_ini.c so I moved it from support.c/h to registry_ini.c and rewrote and renamed it.
Did a lot of testing - made sure running supplied rulesets thru new ruledit doesn't change appearance of helptext in the client help viewer. Also tested hacked input with edge cases and perverse strings. A token > 70 chars and no delimiters doesn't get split.
I discovered issue #1893 while testing, that issue and this one are independent and there's no need for a block.
Updated by Marko Lindqvist 8 days ago
Without reading the patch too carefully: Does it handle UTF-8 correctly? (i.e. not injecting newlines in the middle of a character)
You seem to have dropped backslash handling ('\\') from make_escapes(). Is that intentional?
The other secfiles we write in addition to rulesets are the savegames and client options files. I suppose you have tested that there's no changes to how they turn out with this patch?
Updated by Dean Brown 8 days ago
- File 1903.patch 1903.patch added
Good catch on UTF-8, testing with "Agōgē of Sparta" shows a problem. Fixed the patch to test for high bit.
Yes backslash handling ('\\') is intentional. Otherwise inserting "\n\0x0A" doesn't work.
Yes tested savegames and client options files - the latter are unchanged, savegames wind up a little easier to read and still work OK.