Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rationale for 509 minimum character limit

Tags:

I've seen a lot of the minimal requirements that an ANSI C compiler must support like 31 arguments to a function, and most of the numbers seem to make some kind of sense.

However, I cannot see the reasoning for supporting at least 509 characters in a source line. 511 or 512 would make more sense, but 509 seems kind of arbitrary.

What is the reason for this number?

like image 909
Ryan Haining Avatar asked Oct 14 '13 17:10

Ryan Haining


2 Answers

This perhaps is to take account of possible CR + LF + '\0' characters and have a string representation of each line still fit into 512 bytes of memory.

like image 113
Digital Trauma Avatar answered Oct 02 '22 14:10

Digital Trauma


The C11 dr 5.2.4.1 limits are different than given by the OP. I suspect they come from C89.

4095 characters in a logical source line

4095 characters in a string literal (after concatenation)


[Edit] @jwodder suggested a more complete answer was needed.

Best I can provide: 512 bytes was the most common sector size for floppy, diskette and hard drive media circa mid 80 to mid 90s and likely contributed, along with @bizzehdee & @DigitalTrauma thoughts as to the curious 509 limit.

It was a very popular buffer size.

like image 25
chux - Reinstate Monica Avatar answered Oct 02 '22 13:10

chux - Reinstate Monica