From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Mon, 11 May 2015 09:58:53 +0200 Subject: [U-Boot] [PATCH v1 1/4] Kconfig: Enable usage of escape char '\' in string values In-Reply-To: References: <1431000847-22183-1-git-send-email-sr@denx.de> <1431000847-22183-2-git-send-email-sr@denx.de> Message-ID: <5550613D.9050009@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On 10.05.2015 16:48, Simon Glass wrote: > On 7 May 2015 at 06:13, Stefan Roese wrote: >> I might have missed something, but I failed to use the escape char '\' >> in strings. To pass a printf format string like "foo %d bar\n" via >> Kconfig to the code. >> >> Right now its not possible to use the escape character '\' in Kconfig >> string values correctly to e.g. set this string value "test output\n". >> The '\n' will be converted to 'n'. >> >> The current implementation removes some of the '\' chars from the input >> string in conf_set_sym_val(). Examples: >> >> '\' -> '' >> '\\' -> '\' >> '\\\' -> '\' >> '\\\\' -> '\\' >> ... >> >> And then doubles the backslash chars in the output string in >> sym_escape_string_value(). Example: >> >> '\' -> '' -> '' >> '\\' -> '\' -> '\\' >> '\\\' -> '\' -> '\\' >> '\\\\' -> '\\' -> '\\\\' >> ... >> >> As you see in these examples, its impossible to generate a single '\' >> charater in the output string as its needed for something like '\n'. >> >> This patch now changes this behavior to not drop some backslashes in >> conf_set_sym_val() and to not add new backslashes in the resulting >> output string. Removing the function sym_escape_string_value() >> completely as its not needed anymore. >> >> Signed-off-by: Stefan Roese >> Cc: Masahiro Yamada >> Cc: Simon Glass >> --- >> >> scripts/kconfig/confdata.c | 20 +++++++++----------- >> scripts/kconfig/symbol.c | 43 ------------------------------------------- >> 2 files changed, 9 insertions(+), 54 deletions(-) > > This looks right to me. But I do see one problem - the default string > for CONFIG_AUTOBOOT_PROMPT appears as: > > "Autoboot in %d secondsn" > > so something is still removing the \ in the Kconfig default; Right. Thanks for spotting. I'll fix this in v3. Thanks, Stefan