Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: type-checking for metafiedness? (was: Re: Cores almost on demand in patcompile())
- X-seq: zsh-workers 39647
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: type-checking for metafiedness? (was: Re: Cores almost on demand in patcompile())
- Date: Sat, 15 Oct 2016 08:30:40 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=uZpsP/Z/Lu1fMrMM UMR4rVl1rMM=; b=14YdfeufGwjiB2da2/3bALxxy8Coh4HFYuY9qkflQ40yTTBf gVERAd3skrFZKW4jLi0HyuCltpeCyCEL7gh6MOhsdEm1Nw0+1ZWFH7NafDJTYtsk OzgMG3Rw3uiTDXaHGojW4wCo2AavQKKVtHVLheqL6kAzqNWGOOYxjwA68WU=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=uZpsP/Z/Lu1fMrM MUMR4rVl1rMM=; b=CHzxSP8tT6vAYbpzPetGwnsCr6rHI9aTjy9XLKzPiGM9X4u h4O1qAumBVdzBUHD9HwsfTN4t3Igr1b8hA2Hq1gJYfMa56W+LXq1dpKnbLK6HmgW TOxPiAJyGFkfVKrxYkQd+XwKKEZuvfaD2dDfXJSLl0Mvks8I+nmXt3P1Iwtg=
- In-reply-to: <37947.1476486298@hydra.kiddle.eu>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVB=485r3nRz_pP3A-k-oq2pOp5qYUK7pE1VEApXb0pR1g@mail.gmail.com> <CAKc7PVDof_GEuoSv7pg8c1=spXfDkWopP5VR8dVHg-bxXVES1g@mail.gmail.com> <CAKc7PVCRtBBVONgiExopYYUv7x4-HN_QEYk-05aoqZihiCRgMw@mail.gmail.com> <CAH+w=7a7jc0Q2=M9aG5mttbazxfsHB-Cz=WwJzCvz_SdnbApRw@mail.gmail.com> <CGME20161011065321eucas1p22afaabbe1f17f26a1b3507619ed1d96f@eucas1p2.samsung.com> <20161011065105.GB16819@fujitsu.shahaf.local2> <20161013112251.329c0dbf@pwslap01u.europe.root.pri> <CAH+w=7ZArSYVkjcrbAmkeiWsmpiufbj9+DeNhORgKtYEXEkn7Q@mail.gmail.com> <20161014063625.GC11115@fujitsu.shahaf.local2> <37947.1476486298@hydra.kiddle.eu>
Oliver Kiddle wrote on Sat, Oct 15, 2016 at 01:04:58 +0200:
> Daniel Shahaf wrote:
> > > > This probably is a good idea, although the intermediate state where this
> > > > has been only partly done is likely to be a bit of a mess.
>
> Starting out with a simple typedef would at least add documentation and
> allow an incremental approach. Would still need to add .v everywhere en
> masse when going to a struct, though.
Does anyone have a way to get type checking that doesn't involve
adding .v everywhere? The solution doesn't _have_ to be portable; we
can use compiler-specific magic of gcc or clang, for example, so long as
some developers use that compiler routinely.
If we do the typedefs first, then adding .v later should be easy with
something like coccinelle's patching tool. (It allows doing
search/replace in terms of the C syntax tree.)
> I did some work on a code base that had a convention of uint8_t*
> for UTF-8. Seemed to work well as far as I could tell.
>
What's the advantage over chars or unsigned chars?
> For the history file we should perhaps consider not using locale
> dependent metafied strings. UTF-8 with an overlong encoding for a null
> perhaps? grep etc might still not like the overlong null but they should
> be rarer.
+1 to making the history file locale-agnostic.
> > allocated relative to each other, e.g., if the code assumes that
> > «ary[1] - ary[0] == 1+strlen(ary[0])» or otherwise uses the values of
>
> Even with char**, that condition is only likely if the array was
> created with a literal assignment. And it is easy to test for
> problems by forcing the size of the struct and running the test
> cases.
I was thinking of code that allocates multiple elements in a single
malloc() chunk:
char **array, *storage;
for (i = 0; i < LENGTH_OF_LIST; i++)
sum_of_lengths += strlen(list[i]) + 1;
storage = malloc(sum_of_lengths);
for (i = 0; i < LENGTH_OF_LIST; i++) {
array[i] = strcpy(storage, list[i]);
storage += strlen(array[i]) + 1;
}
> Oliver
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author