all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Antlers <autumnalantlers@gmail.com>
To: 54846@debbugs.gnu.org, "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#54846] [PATCH] gnu: linux: Escape the values of string-type kconfig options
Date: Thu, 28 Apr 2022 20:18:04 +0000 (UTC)	[thread overview]
Message-ID: <abee34ec-7c50-415e-85b9-fd781cbca7cc@gmail.com> (raw)
In-Reply-To: <20220411022410.5606-1-autumnalantlers@gmail.com>

Yeah, sorry for the silence, there's been a lot going on and being able to use strings in the first place is a comportable baseline of functionality- I don't feel that one should implement implicit escaping of a field until confident that all the corner cases are handled, and think that there are some subtle warts left. Haven't had that time iron those out, but I'll be glad to polish the details and can follow up within about a week once I've addressed my remaining cornerns about correctness. Thanks for bearing with me I fumble my way through the conventions of the mailing list and formatting, nitpicks are what I'm here for c:

I think transform-string is a gem for the task, the inputs are flexible and the author specifically cites better performance than string-fold in the (ice-9 texinfo) source, but I appreciate your point and can happily specialize it in-line.

----------------------------------------

Apr 28, 2022 5:16:46 AM Ludovic Courtès <ludo@gnu.org>:

> Hi antlers,
>
> Did you have a chance to look into it?
>
> TIA,
> Ludo’.
>
> Ludovic Courtès <ludo@gnu.org> skribis:
>
>> Hi,
>>
>> antlers <autumnalantlers@gmail.com> skribis:
>>
>>> * gnu/packages/linux.scm (config->string): add escape-string
>>>
>>> Handles characters within the set
>>> (char-set-intersection char-set:ascii char-set:printing), removing
>>> those which are known to be unsupported.
>>
>> [...]
>>
>>> (define (config->string options)
>>> +  (define (escape-string str)
>>> +    "Returns STR with the escapes necessary to be read as a string-type
>>> +    option's value. Handles characters within the set (char-set-intersection
>>> +    char-set:ascii char-set:printing), removing those which are known to be
>>> +    unsupported."
>>
>> Nitpick: You can turn the docstring into a comment since the docstring
>> wouldn’t be accessible anyway.
>>
>>> +    (fold (match-lambda* (((match? fmt) str)
>>> +             (transform-string str match?
>>> +                       (cut format #f fmt <>))))
>>
>> Please avoid tabs.
>>
>> ‘transform-string’ is from (texinfo string-utils), which is not imported
>> here.  IMO, we’d rather avoid depending on this module since it’s really
>> designed for the Texinfo machinery.
>>
>>> +     str
>>> +     `((#\# "") ; No known way to escape # characters.
>>> +       (#\$ "$~a")
>>> +       ("\"\\'`" "\\~a")
>>> +       (";:()#" "\\\\~a")
>>> +       ("|" "\\\\\\~a")
>>> +       ;; No support for tabs, newlines, etc.
>>> +       (,(char-set->string (ucs-range->char-set 9 14)) ""))))
>>
>> I wonder if this should be implemented in terms of ‘string-fold’
>> instead:
>>
>>   (string-concatenate-reverse
>>     (string-fold (lambda (chr result)
>>                    (match chr
>>                      (#\# (cons "" result))
>>                      ;; …
>>                      (_ (cons (string chr) result))))
>>                  '()
>>                  str))
>>
>> Thoughts?
>>
>> Thanks,
>> Ludo’.





  parent reply	other threads:[~2022-04-28 20:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  2:24 [bug#54846] [PATCH] gnu: linux: Escape the values of string-type kconfig options antlers
2022-04-11  5:08 ` [bug#54713] " Elijah Harding
2022-04-12 21:39 ` [bug#54846] " Ludovic Courtès
2022-04-28 12:16   ` Ludovic Courtès
2022-04-28 20:18 ` Antlers [this message]
2022-05-08  4:48   ` antlers
2022-05-17 15:54     ` bug#54846: " Antlers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abee34ec-7c50-415e-85b9-fd781cbca7cc@gmail.com \
    --to=autumnalantlers@gmail.com \
    --cc=54846@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.