Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Capitalization tuning

On Tue, 02 Sep 2008 08:36:45 +0900
"d.henman" <dhenman@xxxxxxxxx> wrote:
> zsh-developers:
>   I would be willing to write a new or modify the existing expansion flag
>   code for (C) capitalize,  so that it would use an array or list of word
>   separators, which a user could set, or allow the users to supply a word
>   seperator list list s:separator-list: for example, for filenames I
>   usually always, s/ /_/ , get rid of spaces in names, which apparently
>   the existing C flags treats write as a space.
> I have never looked at the source code.  But, there's always a first
> time.  If someone would lead to where the 'c' parameter expansion flag
> processing done, I'd look at it.  If it has too many interactions with
> other code, I'd leave it be as it might not be worth the effort.  Any ideas?

It's in casemodify() in hist.c.  You could add, say, K as a flag with
delimiters like s and a string of additional word characters to do this; that
would be in paramsubst() in subst.c (which is very complicated).  You'd
need to pass the string down to casemodify() to be used if it wasn't NULL.

The big complication is with multibyte characters; you'd need to convert
the delimiters into an array of wide characters, remembering the string is
metafied (there are functions to handle this sort of conversion which are
already used for the string to be capitalized itself).

None of this is that different from things the shell does anyway, but a lot
of it probably isn't obvious at first sight.

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

Messages sorted by: Reverse Date, Date, Thread, Author