[OpenAFS-devel] Re: dumpstuff.c: ReadString: ?

Peter Somogyi psomogyi@gamax.hu
Mon, 7 Nov 2005 16:38:53 +0100


Sorry, please ignore this mail.
I've got it.

On Monday 07 November 2005 16.30, you wrote:
> Hi,
>
> I'm analyzing volser/dumpstuff.c.
> I can't understand the second part of this function:
>
> static void
> ReadString(register struct iod *iodp, register char *to, register int maxa)
> {
>     register int c;
>     while (maxa--) {
> 	if ((*to++ = iod_getc(iodp)) == 0)
> 	    break;
>     }
>     if (to[-1]) {
> 	while ((c = iod_getc(iodp)) && c != EOF);
> 	to[-1] = 0;
>     }
> }
>
> What I don't really understand, what's that to[-1] stuff there?
> (Anyway: is it correct in C having array index of -1? I haven't seen such
> before...) If anybody knows the answer, please tell me.

-- 
Peter Somogyi
Software Developer, Gamax Ltd.
1114 Budapest, Bartok B. u 15/d
Tel.: +36-1-381-0544
e-mail: psomogyi@gamax.hu