zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@sunsite.dk>
Subject: Re: [wip patch] new zsh/attr module
Date: Fri, 27 Feb 2009 01:48:15 +0100	[thread overview]
Message-ID: <237967ef0902261648i19f5c5b0jeb54fcd2eb135f92@mail.gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.00.0902262245590.27571@localhost>

2009/2/26 Mikael Magnusson <mikachu@gmail.com>:
> Hi,

> +static int
> +bin_getattr(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
> +{
> +    int ret = 0;
> +    int len;
> +    char value[256];
> +
> +    if (listxattr(*argv, NULL, 0) > 0) {
> +        if (0 < (len = getxattr(*argv, *(argv+1), value, 255))) {

It seems these *argv and the ones below need to be wrapped in unmeta()
to work with utf-8 filenames/values. Obviously I can't use unmeta()
twice in one function call though, can I call unmetafy() on the argv
values or will something be sad then? Can the length grow when I
unmetafy so I would need to alloc more space?

I also note the cap.c file doesn't unmeta(fy) its arguments so it
probably also doesn't work, but I don't have cap stuff so can't test.

Also, in unmeta() would putting a break; in the initial loop help? ie
    for (t = file_name; *t; t++) {
	if (*t == Meta) {
	    meta = 1;
+           break;
        }
    }

(or I suppose you could have *t && !meta)

My impression from looking at the code is that only metafy()ing can
grow the string, so it should be safe to just unmetafy() the strings,
assuming nothing breaks from me modifying the argv strings?

-- 
Mikael Magnusson


  parent reply	other threads:[~2009-02-27  0:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-26 21:55 Mikael Magnusson
2009-02-26 22:36 ` Mikael Magnusson
2009-02-27  0:48 ` Mikael Magnusson [this message]
2009-03-03 12:12 ` Peter Stephenson
2009-03-03 14:43   ` Mikael Magnusson
2009-03-03 16:35     ` Peter Stephenson
2009-03-03 16:51       ` Mikael Magnusson
2009-03-03 16:55         ` Peter Stephenson
2009-03-03 17:00           ` Mikael Magnusson
2009-11-03 18:52         ` Mikael Magnusson
2009-11-03 18:55           ` [PATCH 1/4] attr: add -h option to operate on symlinks without dereferencing Mikael Magnusson
2009-11-04 10:48             ` Peter Stephenson
2009-11-04 11:01               ` Mikael Magnusson
2009-11-04 11:36                 ` Peter Stephenson
2010-09-12 11:12             ` Mikael Magnusson
2009-11-03 18:56           ` [PATCH 2/4] attr: Make zlistattr return an array, zdelattr take several attrs Mikael Magnusson
2009-11-05  6:51             ` [PATCH 2/4] attr: Make zlistattr return an array, zdelattr takeseveral attrs Jun T.
2009-11-05  9:48               ` Mikael Magnusson
2009-11-03 18:57           ` [PATCH 3/4] attr: dynamically allocate memory for attributes Mikael Magnusson
2009-11-03 18:57           ` [PATCH 4/4] attr: Use descriptive variables for argv and allow setting values with embedded nuls Mikael Magnusson

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=237967ef0902261648i19f5c5b0jeb54fcd2eb135f92@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@sunsite.dk \
    /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 public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).