Wednesday, March 6, 2019

Gopher: Carriage Returns, Line Feeds and Tabs (oh my)

Part of the Gopher menu screens (aka directory listing) is that the protocol carefully specifies the line endings (CR-LF, a carriage-return followed by line-feed). The last line should be just a period (.) followed by a CR-LF. Each line is supposed to have exactly three tabs so that a single directory entity is

Type User_Name Selector Host Port

Let's see, from the current Gopher survey data, how many menu (directory) pages match these requirements!

As an FYI, CR, carriage return and \r all refer to the same character. The same goes for LF, line feed and \n. Just to make life extra confusing, in the C programming language a string with a \n in is often called a new-line and will be "expanded" to a \r\n on some operating systems depending on how the file is written.

First let's check out menus with incorrect line endings. Out of 2098 menus with some data,

  • 93% (1941) were completely correct; all lines ended with CR LF
  • 5% (95) ended with just LF and not CR
  • 3% (54) had a mix of CRLF and either LF or CR line endings
  • .3% (7) are a confusing mix of line endings
  • 1 had no line endings at all. This data was seemingly garbage but might be a TN3270 telnet session. Or it might not be!
  • 0 ended with just CR and no LF
Just for fun I also counted up the number of menus that included any LF CR pairs (where the developer got the line endings the wrong way around). There are 9 such menus.

This mix of line endings makes like for Gopher clients more complicated, of course :-(

Next up: that TAB analysis I promised at the start of this post!

No comments: