cpp w/DOS line feeds
Jeffrey A Law
law@cygnus.com
Mon Jan 25 14:44:00 GMT 1999
In message < 199901252023.PAA07180@blastula.phys.columbia.edu >you write:
> The limit is the address space of the machine, which is why the check
> looks so strange. I can make the variable names more obvious - op is
> `output pointer' and ol is `output limit'. Or I can do things in
> terms of `offset' all the time, which might get better code. Or I
> could comment the check like so:
Try and use more descriptive variables (in general).
> if (op + count > ol) // we need more space if this is true
> {
> unsigned long offset = op - buf; // bytes already written
> len *= 2; // len == ol - buf == space we have
> // count <= 4096 and len >= 4096 (constraints)
> // so the multiply should've made the length
> // bigger than offset + count
> if (len < offset + count)
> {
> // but it didn't because the multiply overflowed.
> // (some OS's let a file be bigger than the address space)
> cpp_error (pfile, "file `%s' is too large",
> fp->ihash->name);
> return -1;
> }
I'm sure you already know this, C++ comments are not permitted. Also don't
put comments on the same line as code. Comments should generally be complete
sentences, including capitalization and punctuation.
I'm sure the code above was just some quick scribbling, but it doesn't
hurt to reiterate some of the general guidelines for others.
jeff
More information about the Gcc-patches
mailing list