It was a "feature" of standard Pascal that there was no universal "string" type, every length was a separate type. That is, "string of length 40" is a different type from "string of length 50"; a function can be declared to accept arguments of either one type or the other, not both. (In fact Pascal had no string type at all, it had arrays, for which the same problem applies: arrays of different lengths are different types.)
This used to be one of the most annoying things about programming with Pascal, and it was the main thing that Brian Kernighan (the "K" in "K&R" of the C programming language) complained about in his “Why Pascal is Not My Favorite Programming Language” (written around the same time that Knuth was writing TeX in Pascal).
This inconvenience is the main reason that TeX does its own string handling (see Part 4 / §38 onwards in the program) (I'd started writing a bit about this here) -- mostly when it needs strings, it just uses an offset into a giant
str_pool array of a pre-declared size, e.g. string
n means whatever characters are in positions
str_start[n+1] - 1 of the
But occasionally it needs to use strings that are actually arrays in Pascal, to pass to system calls or assign to variables for example. If you look at your string constant
the type of
pool_name is not "string", but something like "an array of 40 chars". Later when
pool_name is used (§51), in
name_of_file := pool_name;
the variable that it assigns to is of type (see §26)
name_of_file : packed array [1 .. file_name_size] of char;
i.e. it's also an array of 40 characters, which is why the assignment is possible. This
name_of_file is then passed to the system routines
rewrite, as seen in the next section §27 (and as explained in Marcel Krüger's answer).
Elsewhere in the program you'll see routines to convert TeX strings (i.e. consecutive positions of the
str_pool array, as mentioned above), into Pascal strings, specifically into the Pascal string
pack_file_name of section 519 you mention is one of those.
The idea is that if a string has been stored in a TeX string (e.g. when the user writes
\input foo.tex, the
str_pool array would contain the 7 characters
foo.tex), then TeX would set
name_length appropriately (here, 7) and then call this
pack_file_name procedure, which will assign the Pascal string
name_of_file to be
foo.tex followed by spaces, so that
reset(..., name_of_file, ...) can act on that string. If the characters were not cleared by adding spaces, then
reset (as implemented by the Pascal-H runtime) could get an incorrect filename and try to open it.
[Note: Actually the format of file names was different and very inconsistent then, see Part 28: File names, §511 onwards -- file names at Stanford had a "name", "extension", and "area" which might be something like
[1, DEK]. So
pack_file_name needs to combine these different TeX strings into a single Pascal string. But we can ignore that complication; the example of
foo.tex is enough for this explanation.]