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

Re: [wip patch] new zsh/attr module



2009/2/26 Mikael Magnusson <mikachu@xxxxxxxxx>:
> 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



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