summaryrefslogtreecommitdiff
path: root/support/relabel
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/relabel
Initial commit
Diffstat (limited to 'support/relabel')
-rw-r--r--support/relabel/README30
-rw-r--r--support/relabel/Relabeldocument.txt286
-rw-r--r--support/relabel/relabel.doc261
-rw-r--r--support/relabel/relabeli.pas502
-rw-r--r--support/relabel/relabelmac.hqx261
-rw-r--r--support/relabel/relabelmac.pas503
-rw-r--r--support/relabel/relex2i.txt166
-rw-r--r--support/relabel/relex2m.txt191
-rw-r--r--support/relabel/relex3i.txt158
-rw-r--r--support/relabel/relex3m.txt156
10 files changed, 2514 insertions, 0 deletions
diff --git a/support/relabel/README b/support/relabel/README
new file mode 100644
index 0000000000..b517b7286b
--- /dev/null
+++ b/support/relabel/README
@@ -0,0 +1,30 @@
+ THE RELABEL SYSTEM
+
+By Peter Ungar, 4/22/1994, laxa@acfcluster.nyu.edu, 914 723 7187
+
+ RELABEL is a system for convenient relabeling in mathematical
+manuscripts as one makes changes. It is intended to be used with
+TeX or LaTeX source texts, but can be used with any text file
+and possibly even with some formatted files.
+
+ The greatest advantage of RELABEL compared to any TeX macro
+based reference system, such as the one in LaTeX, is that with
+the latter one gets a permanent discrepancy between the labels in
+the source text and the typeset text.
+
+ RELABEL also requires less extra typing than the LaTeX macros;
+usually just a single byte in each label or reference in addition
+to what will be printed.
+
+ The following RELABEL files are available:
+
+ Relabeldocument.txt Detailed instructions for using RELABEL on
+ Macintosh or MS-DOS computers.
+ relabeli.exe (binary) executable MS-DOS RELABEL program
+ relabeli.pas Turbo Pascal source text for the above
+ relabelmac.exe (macbinary) executable Macintosh RELABEL program
+ relabelmac.pas Turbo Pascal for Macintosh source text for the above
+ relex2i.txt and relex3i.txt: Example files for IBM-compatible computers
+ relex2i.txt and relex3m.txt: Example files for Macintosh computers.
+
+(This file slightly updated 2008-Aug-18, JH.) \ No newline at end of file
diff --git a/support/relabel/Relabeldocument.txt b/support/relabel/Relabeldocument.txt
new file mode 100644
index 0000000000..d9de637b50
--- /dev/null
+++ b/support/relabel/Relabeldocument.txt
@@ -0,0 +1,286 @@
+ GENERAL DESCRIPTION OF "RELABEL".
+
+ Peter Ungar, peterungar@yahoo.com Aug. 18, 2008
+
+WARNINGS. If your .TeX files contain extended characters (characters
+coded by bytes > 127) then this program will not work for you.
+Relabeli.exe and Relabelmac assume the only extended characters in
+the file are the ones put in to tell Relabel what kind of item the
+subsequent characters are the identifier of.
+
+ TeX ignores lines starting with % but Relabel is not programmed to
+do that. Hence extended characters have to be removed
+from commented-out text for the relabeling to work correctly.
+
+-------------------------------------------
+
+ The program RELABEL is designed to make it easy to renumber the
+items and change the references to them in a text file after you have
+inserted or deleted or moved material. LaTeX does this at the
+typesetting stage, but that creates a discrepancy between labels in
+the source text and the typeset text. It also involves more typing than RELABEL.
+
+ The MS-DOS version of RELABEL, Relabeli.exe, works on Windows Vista and
+earlier versions but both the file to be relabeled and the output file must
+obey MS-DOS filename rules: at most 8 characters before the . and no spaces.
+I don't know whether Relabelmac works on current Macintosh computers.
+
+ To use RELABEL, you normally have to type only a single
+character in addition to what would be in an old-fashioned
+typescript, to tag the string which follows as an identifier for
+one of 10 kinds of items. If you are referring to an item which
+has not appeared yet, you have to type a second character to
+indicate that this is a reference.
+
+ In LaTeX the term "label" is used for the occurrence of, say,
+3.2.13 next to the formula, and "reference" for its occurrence
+elsewhere. We shall mostly use the same terminology and use
+"identifier" when mean "a label or a reference".
+
+ TYPES OF IDENTIFIERS.
+
+ RELABEL has provision for identifiers of chapters, sections,
+subsections, definitions, theorems, lemmas, figures, formulas,
+problems and at-large items. At-large items are numbered
+consecutively in the entire file; photo-reproductions printed on
+special paper are usually numbered this way.
+
+ When RELABEL encounters a subsection heading, the numbers of
+all non-heading items other than at-large items are reset to 1.
+These item numbers form six independent series but RELABEL treats
+them in the same way. In particular, "lemma"-s are not reset
+after each theorem. Section headings reset the subsection count
+too. A new chapter identifier resets the section count only in
+3-level mode, explained below. It is allowed that some chapters
+contain sections and others not, and some sections can contain
+subsections and others not. A chapter or section may contain some
+material before the sections or subsections start.
+
+ THREE OR TWO LEVELS OF TEXT UNITS.
+
+ RELABEL can work with either 3 levels of text units (chapter,
+section, subsection) or 2 levels (section, subsection.) In the
+3-level mode section numbers are reset to 1 at the beginning of
+each chapter except the first. All other counts are reset to 1 at
+the beginning of each section or subsection, except for the count
+of "at large items" which starts with 1 and is not reset.
+3-level mode does not mean that chapters must have sections and
+sections must have subsections, only that they may have them.
+
+ If you give RELABEL the wrong number of levels, you will get
+error messages.
+ ABBREVIATED IDENTIFIERS.
+
+ In 3-level mode a full identifier must contain the chapter
+identifier and, if we are in a section or subsection, then those
+identifiers too. The full identifier of Theorem 4 of chapter 1,
+section 2, subsection 3, with the theorem tag
+would be 1.2.3.4. Part or all of a section may not be
+in a subsection, and part or all of a chapter may not be in any
+section. In such parts a full identifier is correspondingly
+shorter. If chapter 1 has no sections then the full label
+of theorem 4 would be 1.4. (See later about alternative label
+tags for Macintosh and MS-DOS computers.)
+
+ In 2-level mode you can still use chapter labels but sections
+are numbered consecutively even after you have entered a new chapter.
+Therefore, a chapter identifier is not needed in a full identifier
+of another type of item; the section number suffices to make the
+label unique in the entire text. Putting the chapter number there
+too will cause an error.
+
+ Labels and references to items of the at-large type should NOT
+include a text unit identifier.
+
+ You may omit ALL the text unit identifiers (chapter, section,
+subsection) in a label or reference; RELABEL will understand that
+the text unit is the current one. If you refer to another text
+unit, you may not omit ANY identifier, even if you are referring
+to another subsection of the present section. RELABEL will also
+be confused if you omit some but not all of the identifiers of
+the current text unit. Apart from this, you need not be
+consistent; you may omit all unit identifiers in one label or
+reference and put them all in in the next. You can choose whether
+your output have abbreviated or full labels. IF YOU WANT TO MOVE
+MATERIAL AROUND, USE RELABEL TO CREATE A FILE WITH UNABBREVIATED
+LABELS. Then you can move, say, Problem 2 from Section 6 into
+Section 7 which also has a Problem 2, and they will be assigned
+different numbers when you run RELABEL again.
+
+ You may abbreviate labels of sections and subsections but in its
+output RELABEL always writes these out in full. In section and
+subsection labels RELABEL will even correctly interpret partially
+abbreviated labels, i.e. in 3-level mode you can omit the
+identifier of the current chapter but retain the identifier of
+the currect section.
+
+ LABEL TAGS IN OUTPUT OPTION
+
+ If further revisions are to be made in the file, we want to
+retain the special symbols which identify the various kinds of
+labels and references. If you are using WinEdt and MikTeX, you can
+typeset from a source text with the label tags in it; MikTeX ignores
+the tags. In case your TeX program does not ignore extended characters,
+RELABEL gives the option of an output file without label tags.
+
+ NAMES OF FILES
+
+ RELABELi.exe is an old MS-DOS program. Input and output file names
+must consist of 8 or fewer characters and contain no spaces. Otherwise
+RELABELi.exe hangs up without a message.
+
+ The Macintosh version makes a name for the output file by
+appending either an R or a T to the name of the input file. R
+is for Relabeled and it is appended when the output file still
+contains the label tags. T stands for TeX source text, and is
+appended if the "no label tags in the output file" option is
+selected.
+
+
+ In case the Macintosh version, RELABELMAC, still works on your
+Macintosh, note the following. The Creator of the output files is
+*TEX, for convenient use with the excellent TeX program
+TEXTURES. You can change the creator in the program by
+looking for the TEXTURES creator code *TEX using ResEdit.
+
+ SPECIFICATION OF IDENTIFIERS.
+
+ The chapter number, if any, the section number, subsection
+number and the number of the item within the unit are separated
+by periods(.). Because of this, RELABEL will go wrong if you assign
+formula numbers containing decimal points, e.g. 1.5 for something
+inserted between 1 and 2. The identifiers you give to chapters,
+sections and items within a section should consist of digits and
+letters of the English alphabet (ASCII characters 48-57, 65-90
+and 97-122). You can use 1a instead of 1.5. Lower and
+uppercase letters are considered distinct. The parts of the label
+separated by .'s should contain at most 12 symbols. When the
+program is reading a label and it encounters a space or any other
+symbol which is not a digit or a small letter or ., it concludes
+that the label has been read, and that the symbol at hand is the
+one following the label. RELABEL recognizes a . immediately
+following the label which is not followed by a character or digit
+as not part of the label. Thus, when you have proved it, you can
+write
+
+Theorem 1.5. Perfect numbers are even.
+
+
+ TAGS INDICATING THE KIND OF ITEM
+
+ To indicate what something like 5 or 12.JohnSmith is the label
+of, we place an extended character just before the identifier.
+There are two different tags that can be used for each type of item.
+The reason is that some extended characters are easier to type on
+Windows computers while others are easier on Macs. The input file may contain either one of the choices in each place, so that Relabeli.exe can process
+a file written on a Macintosh, conversely.
+
+ At large ferers to items numbered consecutively in the entire file.
+An identifier of such an item should not have chapter, section and subsection identifiers and will be changed to a single number.
+
+ MS-DOS MACINTOSH
+
+ At large: ASCII 220: Option a, ASCII 140:
+ fiGure: ASCII 221: Option g, ASCII 169:
+ Formula: ASCII 222: Option f, ASCII 196:
+ Problem: ASCII 223: Option p, ASCII 185:
+ Definition: ASCII 224: Option d, ASCII 182:
+ Theorem: ASCII 225: Option t, ASCII 160:
+ Lemma: ASCII 226: Option l, ASCII 194:
+ Chapter: ASCII 227: Option c, ASCII 141:
+ Section: ASCII 228: Option s, ASCII 167:
+ suBsection: ASCII 229: Option b, ASCII 186:
+
+Reference tag: ASCII 222: Option f, ASCII 196:
+
+The blank Option t is bewildering but if you copy and paste it works.
+
+ To produce, say, byte 222 when using MS-DOS programs, hold down
+ALT and press the 2 key ON THE NUMERIC KEYPAD 3 times. (If this
+does not work, try locking or unlocking the numeric key pad.)
+
+WARNING TO WinEdt users: In all the settings I was able to try,
+WinEdt produced extended characters different from the above when I used the ALT key.
+To get the required byte into the text select CHARACTER MAP from the
+TOOLS menu. Double clicking a character will insert it into the
+text where the caret is. Another way: type the characters into a
+Wordpad text file, keep that window open and copy and paste the characters.
+
+ In the MS-DOS bytes we chose, only the last digit varies, which
+makes typing relatively easy. To help remember the last digit,
+note that in the top row of the keypad we have chapter, section
+and subsection; in the second row, definition, theorem, lemma; in
+the third row, figure, formula, problem. For the at-LARGE
+type of item we use the LARGE 0 key in the fourth row. Since
+formula is the most frequently occurring item, we utilized the
+most convenient code for it, and also for the reference tag.
+
+ Both the MS-DOS and the Macintosh versions of RELABEL recognize
+either code, or a mixture of the two, in the input. They change it
+to the one used in their respective systems in the output.
+
+ The symbols associated with the characters depend on the font.
+On MS-DOS computers one gets different characters if one uses
+different country codes. Users of languages other than English
+may find that some of the 18 bytes we used in tags are needed for
+use in text and have to be replaced.
+
+ Note also that in some fonts some bytes > 127 produce symbols
+also associated with bytes < 128. Therefore, if you see an
+ordinary character in the above the tag list, it does not
+necessarily mean there will be a conflict with RELABEL.
+
+ REFERENCE TAGS
+
+ RELABEL checks whether an identifier has occurred earlier. If
+not, it treats it as a label, i.e. the occurrence of an identifier
+next to the item it is identifying, rather than a reference. If
+we make a reference to an item which has not yet occurred, we have
+to tag it as a reference. This is done by putting just after the
+tag which specifies the item kind, one of the two reference
+tags shown in the table. Wneh you have run a file through
+RELABEL, backward as well as forward references will have
+the reference tag, which enables us to move material to any
+other place in the text.
+
+ EXAMPLE FILES
+
+ Two example files are provided so that the reader can see how
+RELABEL works and experiment with it. The files have
+memnonic labels, which RELABEL replaces with numbered labels.
+RELEX3 has 3 levels of text units, RELEX2 has 2. (RELEX2
+will also produce 1 error message.) The files are almost the
+same. If you produce a relabeled file with the labels written out
+in full and the label tags left in, you can move items and
+even entire text units to other places. If you then use RELABEL
+again, the text units and items will be provided with appropriate
+new labels.
+
+ ERROR HANDLING
+
+ If you make a mistake when typing the input file name or input
+a letter when a number is expected or vice versa, RELABEL will
+crash. On the Macintosh it may even cause a system crash and
+output a message that a system file may have been damaged. In
+fact, the disk drive is not activated on these occasions and
+hence no disk file is affected. (If one compiles the Macintosh
+version with THINK PASCAL or with METROWERKS PASCAL, the
+resulting applications will not cause system crashes in these
+circumstances but the THINK PASCAL 3.0 product takes about 3 times
+longer to relabel our example files on the MAC+, and the
+METROWERKS PASCAL v.1.3 product takes about 10 times as long.)
+
+ If a label has a wrong format or RELABEL can not find a label
+which is referred to, there will be an error message and you can
+choose to exit RELABEL. (Relex2 has one reference to a
+nonexistent label.) Try to complete the run. In the output file
+the incorrect identifiers are replaced by ??? which should make
+it easy to find the errors in the input file.
+
+ It helps to avoid errors to put the reference tag into all
+references, not just forward references. If you make a tagged
+reference to a nonexistent label, e.g. because of a typing error,
+RELABEL gives an error message. If the identifier is not tagged
+as a reference but has the correct format, RELABEL will consider
+it to be a new label and assign the next available number for
+that kind of item.
diff --git a/support/relabel/relabel.doc b/support/relabel/relabel.doc
new file mode 100644
index 0000000000..cd1e535c4d
--- /dev/null
+++ b/support/relabel/relabel.doc
@@ -0,0 +1,261 @@
+ GENERAL DESCRIPTION OF "RELABEL".
+
+ Peter Ungar, 914 723 7187 May 25, 1994
+
+ The program RELABEL is designed to make it easy to renumber the
+items and change the references to them when you want to
+insert or delete material or move it to another part of the
+manuscript. LaTeX has a clumsy mechanism of this sort, which gets
+into action at the typesetting stage. It creates a permanent
+discrepancy between labels in the source text and the final
+version. It also involves more typing than RELABEL.
+
+ To use RELABEL, you normally have to type only a single
+character in addition to what would be in an old-fashioned
+typescript, to tag the string which follows as an identifier for
+one of 9 kinds of items. If you are referring to an item which
+has not appeared yet, you have to type a second character to
+indicate that this is a reference.
+
+ In LaTeX the term "label" is used for the occurrence of, say,
+3.2.13 next to the formula, and "reference" for its occurrence
+elsewhere. We shall mostly use the same terminology and use
+"identifier" when mean "a label or a reference".
+
+ TYPES OF IDENTIFIERS.
+
+ RELABEL has provision for identifiers of chapters, sections,
+subsections, definitions, theorems, lemmas, figures, formulas,
+problems and at-large items. At-large items are numbered
+consecutively in the entire file; photo-reproductions printed on
+special paper are usually numbered this way.
+
+ When RELABEL encounters a subsection heading, the numbers of
+all non-heading items other than at-large items are reset to 1.
+These item numbers form six independent series but RELABEL treats
+them in the same way. In particular, "lemma"-s are not reset
+after each theorem. Section headings reset the subsection count
+too. A new chapter identifier resets the section count only in
+3-level mode, explained below. It is allowed that some chapters
+contain sections and others not, and some sections can contain
+subsections and others not. A chapter or section may contain some
+material before the sections or subsections start.
+
+ If you do not want item numbers reset each time you start a
+subsection, use a non-heading type tag you do not need, e.g.
+Lemma, to label subsections.
+
+ THREE OR TWO LEVELS OF TEXT UNITS.
+
+ RELABEL can work with either 3 levels of text units (chapter,
+section, subsection) or 2 levels (section, subsection.) In the
+3-level mode section numbers are reset to 1 at the beginning of
+each chapter except the first. All other counts are reset to 1 at
+the beginning of each section or subsection, except for the count
+of "at large items" which starts with 1 and is not reset.
+3-level mode does not mean that chapters must have sections and
+sections must have subsections, only that they may have them.
+
+ If you give RELABEL the wrong number of levels, you will get
+error messages. RELABEL does not have a built-in option to
+change a text from 2-level to 3-level mode or vice versa, although
+one can trick it into doing that.
+
+ ABBREVIATED IDENTIFIERS.
+
+ In 3-level mode a full identifier must contain the chapter
+identifier and, if we are in a section or subsection, then those
+identifiers too. The full identifier of Theorem 4 of chapter 1,
+section 2, subsection 3, with the theorem tag (Macintosh version)
+would be 1.2.3.4. Part or all of a section may not be
+in a subsection, and part or all of a chapter may not be in any
+section. In such parts a full identifier is correspondingly
+shorter. If chapter 1 has no sections then the full label
+of theorem 4 would be 1.4. (See later about alternative label
+tags for Macintosh and MS-DOS computers.)
+
+ In 2-level mode you can still use chapter labels but sections
+are numbered consecutively. Therefore, a chapter identifier
+is not needed in a full identifier of another type of item and
+will cause an error if used.
+
+ Labels and references to items of the at-large type should NOT
+include a text unit identifier.
+
+ You may omit ALL the text unit identifiers (chapter, section,
+subsection) in a label or reference; RELABEL will understand that
+the text unit is the current one. If you refer to another text
+unit, you may not omit ANY identifier, even if you are referring
+to another subsection of the present section. RELABEL will also
+be confused if you omit some but not all of the identifiers of
+the current text unit. Apart from this, you need not be
+consistent; you may omit all unit identifiers in one label or
+reference and put them all in in the next. You can choose whether
+your output have abbreviated or full labels. IF YOU WANT TO MOVE
+MATERIAL AROUND, USE RELABEL TO CREATE A FILE WITH UNABBREVIATED
+LABELS. Then you can move, say, Problem 2 from Section 6 into
+Section 7 which also has a Problem 2, and they will be assigned
+different numbers when you run RELABEL again.
+
+ You may abbreviate labels of sections and subsections but in its
+output RELABEL always writes these out in full. In section and
+subsection labels RELABEL will even correctly interpret partially
+abbreviated labels, i.e. in 3-level mode you can omit the
+identifier of the current chapter but retain the identifier of
+the currect section.
+
+ LABEL TAGS IN OUTPUT OPTION
+
+ If further revisions are to be made in the file, we want to
+retain the special symbols which identify the various kinds of
+labels and references. We do not want them in the final version.
+
+ NAMES OF THE OUTPUT FILES
+
+ The Macintosh version makes a name for the output file by
+appending either an R or a T to the name of the input file. R
+is for Relabeled and it is appended when the output file still
+contains the label tags. T stands for TeX source text, and is
+appended if the "no label tags in the output file" option is
+selected.
+
+ MS-DOS users do not have the luxury of being able to lengthen
+file names. The MS-DOS version of RELABEL asks you to give a name
+to the output file.
+
+ In the Macintosh version the Creator of the output files is
+*TEX, for convenient use with the excellent TeX program
+TEXTURES. You can easily change TextCreator in the source text of
+the program. Less easily, you can change the compiled program by
+looking for the TEXTURES creator code *TEX using ResEdit.
+
+ SPECIFICATION OF IDENTIFIERS.
+
+ The chapter number, if any, the section number, subsection
+number and the number of the item within the unit are separated
+by .-s. Because of this, RELABEL will go wrong if you assign
+formula numbers containing decimal points, e.g. 1.5 for something
+inserted between 1 and 2. The identifiers you give to chapters,
+sections and items within a section should consist of ASCII
+characters 48-57, 65-90 and 97-122, digits and letters of the
+English alphabet, so you can use 1a instead of 1.5. Lower and
+uppercase letters are considered distinct. The parts of the label
+separated by .'s should contain at most 12 symbols. When the
+program is reading a label and it encounters a space or any other
+symbol which is not a digit or a small letter or ., it concludes
+that the label has been read, and that the symbol at hand is the
+one following the label. RELABEL recognizes a . immediately
+following the label which is not followed by a character or digit
+as not part of the label. Thus, when you have proved it, you can
+write
+
+Theorem 1.5. Perfect numbers are even.
+
+
+ TAGS INDICATING THE KIND OF ITEM
+
+ To indicate what something like 5 or 12.JohnSmith is the label
+of, we immediately precede the label (without leaving a space) by
+a certain character. Characters with bytes < 128 could not be
+used because they are needed for the text. We have to allow two
+alternative label tags for each of our 10 types of item
+because what is easy to remember and write on the Macintosh is
+difficult on MS-DOS computers and vice versa.
+
+ MACINTOSH MS-DOS
+
+ 0: At large: Option a, ASCII 141: ASCII 220:
+ 1: Chapter: Option c, ASCII 141: ASCII 227:
+ 2: Section: Option s, ASCII 167: ASCII 228:
+ 3: suBsection: Option b, ASCII 186: ASCII 229:
+ 4: fiGure: Option g, ASCII 169: ASCII 221:
+ 5: Formula: Option f, ASCII 196: ASCII 222:
+ 6: Problem: Option p, ASCII 185: ASCII 223:
+ 7: Definition: Option d, ASCII 182: ASCII 224:
+ 8: Theorem: Option t, ASCII 160: ASCII 225:
+ 9: Lemma: Option l, ASCII 194: ASCII 226:
+
+Reference tag: Option f, ASCII 196: ASCII 222:
+
+ To produce, say, byte 222 when using MS-DOS programs, hold down
+ALT and press the 2 key ON THE NUMERIC KEYPAD 3 times. (If this
+does not work, try locking or unlocking the numeric key pad.)
+
+ In the MS-DOS bytes we chose, only the last digit varies, which
+makes typing relatively easy. To help remember the last digit,
+note that in the top row of the keypad we have chapter, section
+and subsection; in the second row, definition, theorem, lemma; in
+the third row, figure, formula, problem. For the at-LARGE
+type of item we use the LARGE 0 key in the fourth row. Since
+formula is the most frequently occurring item, we utilized the
+most convenient code for it, and also for the reference tag.
+
+ Both the MS-DOS and the Macintosh versions of RELABEL recognize
+either code, or a mixture of the two, in the input. They change it
+to the one used in their respective systems in the output.
+
+ The symbols associated with the characters depend on the font.
+On MS-DOS computers one gets different characters if one uses
+different country codes. Users of languages other than English
+may find that some of the 18 bytes we used in tags are needed for
+use in text and have to be replaced.
+
+ Note also that in some fonts some bytes > 127 produce symbols
+also associated with bytes < 128. Therefore, if you see an
+ordinary character in the above the tag list, it does not
+necessarily mean there will be a conflict with RELABEL.
+
+ REFERENCE TAGS
+
+ RELABEL checks whether an identifier has occurred earlier. If
+not, it treats it as a label, i.e. the occurrence of an identifier
+next to the item it is identifying, rather than a reference. If
+we make a reference to an item which has not yet occurred, we have
+to tag it as a reference. This is done by putting just after the
+tag which specifies the item kind, one of the two reference
+tags shown in the table. Wneh you have run a file through
+RELABEL, backward as well as forward references will have
+the reference tag, which enables us to move material to any
+other place in the text.
+
+ EXAMPLE FILES
+
+ Two example files are provided so that the reader can see how
+RELABEL works and experiment with it. The files have
+memnonic labels, which RELABEL replaces with numbered labels.
+RELEX3 has 3 levels of text units, RELEX2 has 2. (RELEX2
+will also produce 1 error message.) The files are almost the
+same. If you produce a relabeled file with the labels written out
+in full and the label tags left in, you can move items and
+even entire text units to other places. If you then use RELABEL
+again, the text units and items will be provided with appropriate
+new labels.
+
+ ERROR HANDLING
+
+ If you make a mistake when typing the input file name or input
+a letter when a number is expected or vice versa, RELABEL will
+crash. On the Macintosh it may even cause a system crash and
+output a message that a system file may have been damaged. In
+fact, the disk drive is not activated on these occasions and
+hence no disk file is affected. (If one compiles the Macintosh
+version with THINK PASCAL or with METROWERKS PASCAL, the
+resulting applications will not cause system crashes in these
+circumstances but the THINK PASCAL 3.0 product takes about 3 times
+longer to relabel our example files on the MAC+, and the
+METROWERKS PASCAL v.1.3 product takes about 10 times as long.)
+
+ If a label has a wrong format or RELABEL can not find a label
+which is referred to, there will be an error message and you can
+choose to exit RELABEL. (Relex2 has one reference to a
+nonexistent label.) Try to complete the run. In the output file
+the incorrect identifiers are replaced by ??? which should make
+it easy to find the errors in the input file.
+
+ It helps to avoid errors to put the reference tag into all
+references, not just forward references. If you make a tagged
+reference to a nonexistent label, e.g. because of a typing error,
+RELABEL gives an error message. If the identifier is not tagged
+as a reference but has the correct format, RELABEL will consider
+it to be a new label and assign the next available number for
+that kind of item.
diff --git a/support/relabel/relabeli.pas b/support/relabel/relabeli.pas
new file mode 100644
index 0000000000..7610da260f
--- /dev/null
+++ b/support/relabel/relabeli.pas
@@ -0,0 +1,502 @@
+PROGRAM relabeli; {Relabel program for IBM-compatible computers, to
+be compiled by Turbo Pascal.
+ Written by Peter Ungar, 914 723 7187, June 7th, 94, Mar. 5th, 95,
+Mar. 31, 95}
+{Change of Mar. 5, 1995: In case of a reference to a nonexistent label,
+RELABEL is supposed to print out the nonexistent label. Before this
+correction this failed to work in most cases.
+ Change of Mar. 31: Message asking for starting chapter number
+and section number changed to disallow -1. RELABEL is programmed
+to regard the character - as not part of a label.
+ Aslo, the message in case of a reference to a nonexistent label
+was made clearer. }
+{$N-}
+LABEL 1,3,8,9;
+
+TYPE stringarray=array[1..6] of string[12];
+
+ (* LaTeX calls the identifier "label" when it occurs next to
+ the item, and "reference" elsewhere. I loosely follow this usage,
+ and use "identifier" for an occurrence of a string which
+ could be a label or a reference. In text written
+ for RELABEL, as in typeset books, labels and references
+ are not marked as such by the author. RELABEL regards the first
+ occurrence of an identifier as the label, unless it is marked as a
+ (forward) reference.
+ The program makes two passes over the text. The first
+ involves reading only. The program takes down each identifier at its
+ first occurrence which is not marked as a reference
+ and assigns to it the next
+ available serial number. These pairs of old and new labels are
+ stored in the labelentry file. Next, the text is read again and
+ written out to a new file, with each identifier changed to its new
+ value.
+
+ Stringarrays will hold identifiers, including those parts of the
+ identifiers which are implicit, i.e. if we omit the identifier(s)
+ of the current text unit, RELABEL will put them in.
+ The entries of the stringarray are:
+ a) If SectionReset=TRUE (3-level mode): chapteri.d., section i.d.,
+ subsection i.d. and the identifier of the object.
+ If the item does not apply, e.g. if we are not in a subsection,
+ the corresponding entry is the empty string '';
+ b) If SectionReset=FALSE, i.e. sections are numbered
+ consecutively, then chapter numbers are not needed in i.d.s and
+ the first entry of the string array is empty except in the
+ i.d. of a chapter. *)
+
+ (* We use the following pointer construction to get around the fact
+ that Turbo Pascal allots a space of only 64K to
+ all regularly declared variables, but can utilize memory outside
+ that limited space for variables created by NEW statements. *)
+
+ labelentry=RECORD oldlabel:stringarray;
+ newlabel:array[1..4] of integer;
+ secondpassoccurred:boolean;
+ END;
+ labelentryp=^labelentry;
+ sublistp=array[-1..2000] of labelentryp;
+ mainlistp=^sublistp;
+
+ (* Oldlabel is a stringarray. The labels in the old text may
+ contain lowercase letters as well as digits.
+ Newlabel is represented by an array of integers, the
+ chapter number etc. This will be made into a string when there is
+ a reference to the label.*)
+
+ VAR i,j,k,n,implicit,ImplAdj,SerialNo,
+ FirstChapter,FirstSection,LabelKind:integer;
+ (* ImplAdj (ImplicitAdjustment) is 0 if section numbers are reset
+ at the beginning of each chapter and 1 if they are not, and
+ hence chapter numbers are not needed in labels other than chapter
+ labels.
+ SerialNo will hold the serial number of the first occurrence
+ of a label in the array holding all labels of its kind.
+ FirstChapter, FirstSection are the numbers to be assigned to the
+ first chapter and the first section of the file. RELABEL asks an
+ input of this when the program starts, in case you want 0, 1 or
+ larger numbers if the file is from the middle of a manuscript. *)
+ totalcount, currentcount:array[0..9] of integer;
+ s,filename,outputfilename:string;
+ labelstring:string[51];
+ sta,empty,current:stringarray;
+
+ (* totalcount will say how many labels of the 9 kinds we have
+ so far. currentcount gives the counts of the 9 kinds since they
+ were last reset.
+ current contains the chapter, section
+ and subsection identifiers of the current text unit. *)
+
+ mainlist:array[0..9] of mainlistp;
+ SectionReset,ForwardRef, LabeltagsInOutput, omit,
+ PeriodFollows, FirstChapterlabel, FirstSectionlabel: boolean;
+(* Sectionreset: Each chapter starts with section 1.*)
+
+ incoming, outgoing:text;
+ c,ans:char;
+
+FUNCTION min(i,j:integer):integer;
+BEGIN
+ IF i<j THEN min:=i ELSE min:=j
+END;
+
+FUNCTION max(i,j:integer):integer;
+BEGIN
+ IF i<j THEN max:=j ELSE max:=i
+END;
+
+PROCEDURE IntToStr(a:integer; VAR s:string);
+ (*Writes a as a string s*)
+ LABEL 9;
+ VAR d:integer;
+ BEGIN
+ s:='';
+ IF a<0 THEN BEGIN s:='-'; a:=-a END;
+ IF a=0 THEN BEGIN s:='0'; GOTO 9 END;
+ d:=10000;
+ WHILE (a DIV d)=0 DO d:=d DIV 10;
+ WHILE d>0 DO BEGIN s:=s+chr(48+(a DIV d)); a:= a MOD d; d:=d DIV 10 END;
+ 9:END;
+
+ FUNCTION labelsymbol(c:char):boolean;
+(* TRUE if c is a symbol allowed in a label, i.e. a digit or
+ a lowercase letter. *)
+ VAR x:integer;
+ BEGIN x:=ord(c);
+ labelsymbol:=(((48<=x) AND (x<=57)) OR ((97<=x) AND (x<=122))
+ OR ((65<=x) AND (x<=90)))
+ END;
+
+ PROCEDURE ReadLabel(VAR star:stringarray; VAR c:char);
+ (* Reads the components of a label from the incoming stream and
+ puts its components into the stringarray star, including
+ the implicit items. If section numbers are not reset in each
+ chapter then the empty string is put in the chapter designator
+ location star[1] except in the case of chapter labels. *)
+ LABEL 2,5,9;
+ VAR i,implicit:integer; str:string[12];
+ BEGIN
+ k:=0; star:=empty; PeriodFollows:=FALSE;
+ (* k will count the number of parts separated by .'s in the label. *)
+ 2: str:='';
+ WHILE labelsymbol(c) DO BEGIN
+ str:=str+c;
+ read(incoming,c);
+ END;
+ k:=k+1; star[k+ImplAdj]:=str;
+ IF c='.' THEN BEGIN
+ (* Another part of the label is coming, or there is a . after
+ the label. *)
+ read(incoming,c);
+ IF labelsymbol(c) THEN GOTO 2
+ ELSE PeriodFollows:=TRUE;
+ END;
+ (* Now we have all k items of the label in the stringarray star.
+ We want the program to work so that, if desired, the chapter, section
+ and subsection labels may be omitted and then they are understood to
+ refer to the current chapter, section or subsection.
+ We reconstruct the omitted parts of the label. We assemble it
+ in star and then if it is a new label we put it into the mainlist.
+ If the number of levels is 3 then the
+ components of star are: Chapter label, Section label, Subsection
+ label and item label. If any of these are missing or not applicable,
+ the corresponding label is ''. A subsection label is missing
+ if the section is not divided into subsections. A subsection
+ label is inapplicable if the label is a chapter or section label.
+ If the number of levels is 2
+ then a label of anything except a chapter is complete without the
+ chapter label, and star[1]:='' for all such items.
+ The label of a nonreset item should not contain chapter, section
+ or subsection identifiers. *)
+ IF (LabelKind > 1) AND ((k+ImplAdj) > min(LabelKind,4)) THEN BEGIN
+ writeln('Found a label with too many parts. If you have 2 levels');
+ writeln('section numbers then nonchapter labels should not contain');
+ writeln('a chapter identifier.');
+ GOTO 5;
+ END;
+ IF ((LabelKind=0) AND (k>1)) THEN BEGIN
+ writeln(' An at-large item label with more than one part. ');
+5: write('LabelKind= '); write(LabelKind,' ');
+ FOR i:=1+ImplAdj TO k+ImplAdj-1 DO write(sta[i],'.');
+ writeln(sta[k+ImplAdj]);
+ write(' Continue? y or n '); readln(ans);
+ IF ans='n' THEN BEGIN close(incoming); halt END;
+ END; (* of error handling. *)
+ IF LabelKind=0 THEN BEGIN
+ star[4]:=star[1+implAdj]; star[1+ImplAdj]:='';
+ END;
+ IF LabelKind=1 THEN BEGIN
+ star[1]:=star[1+ImplAdj]; star[2]:='';GOTO 9 END;
+ IF (2<=LabelKind) AND (LabelKind<=3) THEN BEGIN
+ implicit:=LabelKind-k-ImplAdj;
+ IF implicit>0 THEN BEGIN
+ FOR i:=LabelKind DOWNTO implicit+1 DO star[i]:=star[i-implicit];
+ FOR i:=1+ImplAdj TO implicit+ImplAdj DO star[i]:=current[i];
+ END;
+ END;
+ IF (labelkind >= 4) THEN BEGIN
+ IF k+ImplAdj<4 THEN BEGIN
+ star[4]:=star[k+ImplAdj]; star[k+ImplAdj]:='' END;
+ IF k=1 THEN FOR i:=1+ImplAdj to 3 DO star[i]:=current[i];
+ (*This must be a label of an item in the current text unit.*)
+ END;
+9:END; (* of procedure readlabel. Note that c is the first symbol after
+ the label at this stage, or the first symbol after the period
+ if there was a period immediately after the label. *)
+
+ FUNCTION InList(st:StringArray;VAR SerialNo:integer):boolean;
+ (* TRUE if the label st is already in the mainlist.
+ This function is also used to compute the index SerialNo of
+ the label in the array of that LabelKind*)
+ LABEL 9;
+ VAR i:integer; bool:boolean;
+ BEGIN
+ IF totalcount[LabelKind] = 0 THEN InList:=FALSE
+ ELSE
+ FOR i:=totalcount[LabelKind] DOWNTO 1 DO
+ BEGIN
+ bool:=TRUE;
+ WITH mainlist[LabelKind]^[i]^ DO
+ FOR j:=1 TO 4 DO bool:=bool AND (oldlabel[j]=st[j]);
+ IF bool THEN BEGIN
+ InList:=TRUE;
+ SerialNo:=i;
+ (* mainlist[LabelKind]^[SerialNo] is the record where this
+ label and the new label which is to replace it can be found.*)
+ GOTO 9 END;
+ END;
+ InList:=FALSE; (* The label is not in mainlist. *)
+9:END;
+
+
+ PROCEDURE AddToList(sta:stringarray);
+(* We have a new label which is not a forward reference. Add it to mainlist*)
+ VAR i:integer;
+ BEGIN
+ totalcount[LabelKind]:=totalcount[LabelKind]+1;
+ currentcount[LabelKind]:=currentcount[LabelKind]+1;
+ (* If the new label is a chapter, section or subsection label then
+ the counts of subordinate items have to be reset.*)
+ IF (0<LabelKind) AND (LabelKind <=3) THEN BEGIN
+ current[labelkind]:=sta[labelkind];
+ FOR i:=max(labelkind+1,ImplAdj+2) TO 9 DO BEGIN
+ currentcount[i]:=0; current[i]:=''
+ END;
+ IF (FirstChapterlabel AND (Labelkind=1)) THEN BEGIN
+ currentcount[1]:=Firstchapter; FirstChapterlabel:=FALSE
+ END;
+ IF (FirstSectionlabel AND (Labelkind=2)) THEN BEGIN
+ currentcount[2]:=Firstsection; FirstSectionlabel:=FALSE
+ END;
+ END; (* of adjusting the label counts and the array of current chapter,
+ section and subsection to account for the new label.
+ Next add a new blank record where we will put the label we just found,
+ and the label which will replace it. *)
+
+ new(mainlist[LabelKind]^[totalcount[LabelKind]]);
+ WITH mainlist[LabelKind]^[totalcount[LabelKind]]^ DO BEGIN
+ oldlabel:=sta;
+ FOR i:=1 to 4 DO newlabel[i]:=0;
+ IF LabelKind=0 THEN newlabel[4]:=currentcount[0];
+ IF LabelKind=1 THEN newlabel[1]:=currentcount[1];
+ IF LabelKind>=2 THEN
+ FOR i:=1+ImplAdj TO min(3,LabelKind) DO newlabel[i]:=currentcount[i];
+ IF LabelKind>=4 THEN newlabel[4]:=currentcount[labelkind];
+ (* Newlabel[1] is 0 if sections are numbered
+ consecutively and chapter numbers occur only in chapter labels.*)
+ SecondPassOccurred:=FALSE;
+ END; (* of preparing new mainlist entry *)
+ END; (* of processing the new label *)
+
+ PROCEDURE MakeNewLabelstring(VAR newlabelstring:string;
+ labelkind,SerialNo:integer);
+ LABEL 9;
+ VAR j:integer;s:string;
+ InUnitRef:boolean;
+ BEGIN
+ WITH mainlist[LabelKind]^[SerialNo]^ DO
+ BEGIN
+ newlabelstring:='';
+ IF LabelKind=0 THEN
+ BEGIN IntToStr(newlabel[4],newlabelstring);
+ GOTO 9 END; (* Of LabelKind=0 (at-large item label) case *)
+
+ IF LabelKind=1 THEN
+ BEGIN IntToStr(newlabel[1],newlabelstring);
+ GOTO 9 END; (* Of LabelKind=1 (i.e. chapterlabel) case *)
+
+ IF omit AND (LabelKind>3) THEN BEGIN
+ (* Find whether the reference is to the current unit of the text.*)
+ InUnitRef:=TRUE;
+ FOR j:=1+ImplAdj TO 3 DO
+ InUnitRef:=InUnitRef AND (newlabel[j]=currentcount[j]);
+ IF InUnitRef THEN BEGIN
+ IntToStr(newlabel[4],newlabelstring); GOTO 9 END;
+ END; (* Of making label without chapter,section and subsection
+ number. Note we exit to 9 only if such a label has been made. *)
+ FOR j:=1+ImplAdj TO min(LabelKind,4) DO
+ IF OldLabel[j]<>'' THEN BEGIN
+ IntToStr(newlabel[j],s);
+ IF newlabelstring='' THEN newlabelstring:=s
+ ELSE newlabelstring:=newlabelstring+'.'+s;
+ END;
+ END; (* of WITH statement *)
+9:END;
+
+ FUNCTION LabelTag(LabelKind:integer):char; (* For error message.*)
+ BEGIN
+ CASE LabelKind OF
+ 0: LabelTag:= chr(220); (* at-large item *)
+ 1: LabelTag:= chr(227); (* chapter *)
+ 2: LabelTag:= chr(228); (* section *)
+ 3: LabelTag:= chr(229); (* subsection *)
+ 4: LabelTag:= chr(221); (* figure *)
+ 5: LabelTag:= chr(222); (* formula *)
+ 6: LabelTag:= chr(223); (* problem *)
+ 7: LabelTag:= chr(224); (* definition *)
+ 8: LabelTag:= chr(225); (* theorem *)
+ 9: LabelTag:= chr(226); (* lemma *)
+ END;
+ END;
+
+ (* Main program begins here.*)
+BEGIN
+1: FOR i:=1 TO 4 DO empty[i]:=''; current:=empty;
+ writeln('File to be renumbered. If it is not in the same directory as');
+ writeln('RELABEL, then give path name.');
+ readln(filename);
+ writeln(' Name of relabeled file: ');
+ readln(OutputFileName);
+ writeln('Is the labeling based on 3 levels (Chapter, Section, Subsection');
+ writeln('or 2 levels (Section, Subsection)? (Input 3 or 2)');
+ readln(i); SectionReset:=(i=3); ImplAdj:=3-i;
+ (*ImplAdj (Implicit Adjustment) = 1 if chapter numbers are superfluous
+ in labels, 0 otherwise.*)
+ writeln('Do you want the chapter, section and subsection numbers in');
+ writeln('the new file if they are all the current ones (y or n)');
+ writeln('(Chapter numbers are included only in 3-level mode.)');
+ readln(ans); omit:=ans='n';
+ writeln('Do you want the label tags to remain in the output?');
+ readln(ans); LabeltagsInOutput:=ans='y';
+ FOR i:=0 TO 9 DO currentcount[i]:=0;
+ TotalCount:=CurrentCount;
+ writeln('Input the starting number >= 0 you want for chapters');
+ readln(FirstChapter);
+ currentcount[1]:=FirstChapter-1; FirstChapterlabel:=TRUE;
+ writeln('Input the number >= 0 you want for the first section');
+ readln(FirstSection);
+ currentcount[2]:=FirstSection-1; FirstSectionlabel:=TRUE;
+ writeln('I will beep when ready');
+ (* Next create the arrays for storing the various types of labels. *)
+
+ FOR i:=0 TO 9 DO new(mainlist[i]);
+
+ Assign(incoming,filename);
+ Reset(incoming);
+ read(incoming, c);
+ WHILE eof(incoming)=FALSE DO
+ BEGIN
+ IF ord(c) > 128 THEN BEGIN
+ CASE c OF (* cases of Macintosh labels *)
+ '': LabelKind:=0;
+ '': LabelKind:=1;
+ '': LabelKind:=2;
+ '': LabelKind:=3;
+ '': LabelKind:=4;
+ '': LabelKind:=5;
+ '': LabelKind:=6;
+ '': LabelKind:=7;
+ '': LabelKind:=8;
+ '': LabelKind:=9;
+ ELSE (* In case the file comes from MS-DOS user of RELABEL *)
+ IF ((227 <= ord(c)) AND (ord(c)<= 229))
+ THEN LabelKind:= ord(c)-226
+ ELSE IF ((221 <= ord(c)) AND (ord(c)<= 226))
+ THEN LabelKind:= ord(c)-217
+ ELSE IF ord(c)=220 THEN LabelKind:=0
+ ELSE GOTO 8; (* c is not a label tag *)
+ END;
+ read(incoming, c);
+ IF ((ord(c) = 196) OR (ord(c)=222)) THEN GOTO 8
+ ELSE readlabel(sta,c);
+
+ (* Do readlabel and the work below only if this is not
+ labeled to be a reference.
+ Next, we check if this is a repeat occurrence of a label.
+ If not, enter in the list of labels and increase the count
+ of labels of the kind we found.*)
+
+ IF NOT InList(sta,SerialNo) THEN AddToList(sta);
+ END; (* of processing a label *)
+ 8:read(incoming,c)
+ END; (* of WHILE loop which reads characters of the file *)
+
+ writeln('First pass completed. I am starting to write the new file.');
+
+ Reset(incoming);
+
+ Assign(outgoing, outputfilename);
+ Rewrite(outgoing);
+
+ current:=empty;
+ FOR i:=0 TO 9 DO currentcount[i]:=0;
+ currentcount[1]:=FirstChapter-1;
+ currentcount[2]:=FirstSection-1;
+
+ (* We need to redo current to be able to restore the implicit
+ parts of the labels as we encounter them on the second pass. *)
+
+3:read(incoming,c);
+ WHILE eof(incoming)=FALSE DO
+ BEGIN
+ IF ord(c) >=128 THEN BEGIN (* A label may begin here. *)
+ CASE c OF
+(* If we have a labelkind indicator used with Macintosh, convert it. *)
+ '': c:=chr(220);
+ '': c:=chr(227);
+ '': c:=chr(228);
+ '': c:=chr(229);
+ '': c:=chr(225);
+ '': c:=chr(226);
+ '': c:=chr(224);
+ '': c:=chr(222);
+ '': c:=chr(221);
+ '': c:=chr(223);
+ END; (* Of replacing Macintosh labels. *)
+ ForwardRef:=FALSE;
+ LabelKind:=ord(c)-220;
+ IF ((labelkind < 0) OR (LabelKind > 9)) THEN BEGIN
+ (*The symbol is not a labelkind indicator. Write & exit.*)
+ write(outgoing,c); GOTO 3
+ END
+ ELSE IF LabelKind > 6 THEN LabelKind:=LabelKind-6
+ ELSE IF LabelKind>0 THEN LabelKind:= LabelKind+3;
+ (* End of determining LabelKind *)
+ IF LabeltagsInOutput THEN write(outgoing,c);
+ read(incoming,c);
+ IF c=chr(196) THEN c:=chr(222); {Translate Macintosh forward ref. ind.}
+ IF c=chr(222) THEN BEGIN
+ ForwardRef:=TRUE;
+ IF LabeltagsInOutput THEN write(outgoing,c);
+ read(incoming,c)
+ END;
+ readlabel(sta,c);
+ IF NOT(InList(sta,SerialNo)) THEN BEGIN
+ writeln('Label not found in list on second pass.');
+ writeln('You may have referred to a nonexistent label');
+ writeln('or the level number you entered may be wrong.');
+ write('LabelKind: ', LabelKind,' Label: ');
+ FOR i:=1+ImplAdj TO min(LabelKind-1, 3) DO
+ IF sta[i] <> '' THEN write(sta[i],'.');
+ IF ((LabelKind = 0) OR (LabelKind > 3)) THEN writeln(sta[4])
+ ELSE writeln(sta[LabelKind]);
+ write('Should I go on, with "???" in this reference? y or n ');
+ readln(ans);
+ IF ans='n' THEN BEGIN close(incoming);close(outgoing);halt END;
+ write(outgoing,'???'); GOTO 9;
+ END; (* Of message and output, we had a reference to unknown label.*)
+ IF NOT ForwardRef THEN BEGIN
+ WITH mainlist[labelkind]^[SerialNo]^ DO BEGIN
+ IF (NOT secondpassoccurred)THEN BEGIN
+(* Should be here? currentcount[labelkind]:=currentcount[labelkind]+1; *)
+ IF (0<labelkind) AND (LabelKind<4) THEN BEGIN
+ currentcount[labelkind]:=currentcount[labelkind]+1;
+ (* This is not a reference but the label of a new *)
+ (* subdivision. Adjust current subdiv.*)
+ current[labelkind]:=oldlabel[labelkind];
+ IF (currentcount[1]>FirstChapter)
+ OR (currentcount[2]>FirstSection) THEN BEGIN
+ FOR i:=max(labelkind+1,ImplAdj+2) TO 3 DO BEGIN
+ current[i]:=''; currentcount[i]:=0;
+ END;
+ END;
+ END; (* Of dealing with the label of a new heading. *)
+ secondpassoccurred:=TRUE;
+ END
+ ELSE IF LabeltagsInOutput THEN write(outgoing,'');
+ (* We have a reference.*)
+ END; (* Of WITH mainlist...*)
+ END; (* Of NOT ForwardRef *)
+ (* Now we are ready to get the new label and convert it to a
+ string. This can not be done once for all since the string
+ may be shorter in a reference to the item from within
+ the same subunit. Doing the job from scratch each time just
+ because we may need one or the other of two expressions
+ is admittedly inelegant but seldom are there many references
+ to one item. *)
+ MakeNewLabelstring(s,LabelKind, SerialNo);
+ write(outgoing,s);
+9: IF PeriodFollows THEN write(outgoing,'.');
+ END (* of assembling and writing the new label. *)
+ ELSE BEGIN (* ord(c)<128, certainly not a labelkind symbol*)
+ write(outgoing,c);
+ read(incoming,c);
+ END; (* of IF ord(c)>=128..ELSE statement. *)
+ END; (* Return to the beginning of the WHILE eof(incoming)=FALSE cycle *)
+ write(outgoing,c); (* write the last symbol of the file *)
+ close(outgoing);close(incoming);
+ writeln(chr(7),'"',outputfilename,'"', 'written on disk.');
+ FOR i:=0 TO 9 DO dispose(mainlist[i]);
+ write('Relabel another file? (y or n)');
+ readln(c); IF c='y' THEN GOTO 1;
+ END.
diff --git a/support/relabel/relabelmac.hqx b/support/relabel/relabelmac.hqx
new file mode 100644
index 0000000000..9e8aea7ff2
--- /dev/null
+++ b/support/relabel/relabelmac.hqx
@@ -0,0 +1,261 @@
+(This file must be converted with BinHex 4.0)
+:"e*&6%&#48`!39"36$q3"!#3#$#mCp`!N!3"!*!$-(i!!#pq!*!$2M8!N!403Ir
+r*!"P3!#3"!(JrrmN!'9,!*!%(&Ir"e*&6%&#48`#!*!$39"36$q3"!%!rj!%!*!
+%'q-!!%&38%`rN!3"!2q3"!#3%UYr`pm!N!B`[!#3!dTQrrmN!'a4!*!%(Plrrb3
+!E&`!N!3GK2rr*!"XC`#3"'cjrrmN!'ab!*!%8,,rrb3!EDX!N!4i22rr*!"Zj!#
+3"$ArN!-N!(%T!*!%B9Irrb3!F63!N!3Z5[rr*!"dK3#3"%+@rrmN!(53!!#3"'C
+8rrmN!(3!N!-B!*!$+!!!"[i!N!-)!*!$)#p)2c`!!DR`!!![AJ#3!`%J3b3!5%,
+%`5B"5%2'`04$5%+3!m$"d))Q#%je)%-L4(J!5S"U"%5!H2p+J@S%4)&'4#3"NS&
+f)01"NS*N!Y+#dB"4brrd4S"+4'F#4)")4%T%C`*%J5B)+!P1G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G#"`BA0c)'0[EA"XCA4PC#iJ55"KE5"cG'&bG'PZCb"dEb"hFQPdC5"
+dD'8JEQ9h)'CTE'8Z!#e-38*&6#"16e3J4Np96N3J58iJ6%P69#"26L"648026N3
+J8%&68biJ49*56e)Y@8p9)%e"@5")39C&)#"548C&8P*&4#"86b"")%j26N9B590
+848j8)%a"3N9-,dp5)&P295"039NJ5%&@45"&6P4&8N9%)&4)45"A8Np14b"-49C
+&6#"198e#49)Z#daKBQ9X5fPZC$SJ#5!J6'&LC@`k)"&$EfjdD@jeC6mJH5"[FL"
+Z)!-rN!-!!""hFQPdG'9Z)'pZ)'4TFfXZ!"j5C@aKBQ9X)'&ZEh4SCA)JCQPXC6m
+J+(NJEh)JELN!6VV9C%kki#C1ZZ2%6VV`b+Rd!!!"!*!$-(i!!#pq!*!$2J!c'E)
+#P!#3!a`!2J!!3dp%43!"!!S!!2rr!*!&-hTL!!(rra3!!"`!-hTbNim:
diff --git a/support/relabel/relabelmac.pas b/support/relabel/relabelmac.pas
new file mode 100644
index 0000000000..f5b671181e
--- /dev/null
+++ b/support/relabel/relabelmac.pas
@@ -0,0 +1,503 @@
+PROGRAM relabelmac; {For Turbo Pascal for Macintosh.}
+{Peter Ungar, 914 723 7187, June 7, 1994; Mar. 5th, Mar. 31th 1995}
+{Change of Mar. 5, 1995: In case of a reference to a nonexistent label,
+RELABEL is supposed to print out the nonexistent label. Before this
+correction this failed to work in most cases.
+Change of Mar. 31: The messages to input the numbers of the first
+chapter and the first section were changed. The old messages said -1 was
+allowed, but RELABEL is programmed to regard the symbol - as
+not part of a label.
+ Also, the error message for nonexistent labels was made clearer.}
+
+LABEL 1,3,8,9;
+
+TYPE stringarray=array[1..6] of string[12];
+
+ (* LaTeX calls the identifier "label" when it occurs next to
+ the item, and "reference" elsewhere. I apologize for not having
+ observed this distinction. I should have used "identifier" for
+ an occurrence of a string which could be a label or a reference,
+ but for the most part I called it a label. In text written
+ for RELABEL, as in typeset books, labels and references
+ are not marked as such by the author. RELABEL regards the first
+ occurrence of an identifier as the label, unless it is marked as a
+ forward reference.
+ The program makes two passes over the text. The first
+ involves reading only. The program takes down each label at its
+ first nonforward occurrence and assigns to it the next
+ available serial number. These pairs of old and new labels are
+ stored in the labelentry file. Next, the text is read again and
+ written out to a new file, with each label changed to its new
+ value.
+
+ Stringarrays will hold labels, including those parts of the label
+ which are implicit, i.e. if we omit the chapter label or the
+ chapter and section label or the chapter, section and subsection
+ label when those are the current ones.
+ The entries of the stringarray are:
+ a) If SectionReset=TRUE: chapterlabel, sectionlabel,
+ subsection label and the identifier of the object of the label.
+ If the item does not apply, e.g. if we are not in a subsection,
+ the corresponding entry is the empty string '';
+ b) If SectionReset=FALSE, i.e. sections are numbered
+ consecutively, then chapter numbers are not needed in labels and
+ the first entry of the string array is empty except in the
+ label of a chapter. *)
+
+ (* We use the following pointer construction to get around the fact
+ that Turbo Pascal allots a space of only 32K to
+ all regularly declared variables, but can utilize memory outside
+ that limited space for variables created by NEW statements. *)
+
+ labelentry=RECORD oldlabel:stringarray;
+ newlabel:array[1..4] of integer;
+ secondpassoccurred:boolean;
+ END;
+ labelentryp=^labelentry;
+ sublistp=array[-1..2000] of labelentryp;
+ mainlistp=^sublistp;
+
+ (* Oldlabel is a stringarray. The labels in the old text may
+ contain lowercase letters as well as digits.
+ Newlabel is represented by an array of integers, the
+ chapter number etc. This will be made into a string when there is
+ a reference to the label.*)
+
+ VAR i,j,k,n,implicit,ImplAdj,SerialNo,
+ FirstChapter,FirstSection,LabelKind:integer;
+ (* ImplAdj (ImplicitAdjustment) is 0 if section numbers are reset
+ at the beginning of each chapter and 1 if they are not, and
+ hence chapter numbers are not needed in labels other than chapter
+ labels.
+ SerialNo will hold the serial number of the first occurrence
+ of a label in the array holding all labels of its kind.
+ FirstChapter, FirstSection are the numbers to be assigned to the
+ first chapter and the first section of the file. RELABEL asks an
+ input of this when the program starts, in case you want 0, 1 or
+ larger numbers if the file is from the middle of a manuscript. *)
+ totalcount, currentcount:array[0..9] of integer;
+ (* countstarts gives where the numbering of chapters, sections
+ subsections and other labeled items begins; the program sets
+ the last two equal to 1. *)
+ s,filename,outputfilename, filenameend:string;
+ labelstring:string[51];
+ sta,empty,current:stringarray;
+
+ (* totalcount will say how many labels of the 10 kinds we have
+ so far. currentcount gives the counts of the 10 kinds since they
+ were last reset.
+ current contains the current chapterlabel, section
+ label and subsection label. *)
+
+ mainlist:array[0..9] of mainlistp;
+ SectionReset,ForwardRef, LabeltagsInOutput, omit,
+ PeriodFollows, FirstChapterLabel, FirstSectionLabel: boolean;
+(* Sectionreset: Each chapter starts with section 1.*)
+
+ incoming, outgoing:text;
+ c,ans:char;
+
+FUNCTION min(i,j:integer):integer;
+BEGIN
+ IF i<j THEN min:=i ELSE min:=j
+END;
+
+FUNCTION max(i,j:integer):integer;
+BEGIN
+ IF i<j THEN max:=j ELSE max:=i
+END;
+
+PROCEDURE IntToStr(a:integer; VAR s:string);
+ (*Writes a as a string s*)
+ LABEL 9;
+ VAR d:integer;
+ BEGIN
+ s:='';
+ IF a<0 THEN BEGIN s:='-'; a:=-a END;
+ IF a=0 THEN BEGIN s:='0'; GOTO 9 END;
+ d:=10000;
+ WHILE (a DIV d)=0 DO d:=d DIV 10;
+ WHILE d>0 DO BEGIN s:=s+chr(48+(a DIV d)); a:= a MOD d; d:=d DIV 10 END;
+ 9:END;
+
+ FUNCTION labelsymbol(c:char):boolean;
+(* TRUE if c is a symbol allowed in a label, i.e. a digit or
+ a lowercase letter. *)
+ VAR x:integer;
+ BEGIN x:=ord(c);
+ labelsymbol:=(((48<=x) AND (x<=57)) OR ((97<=x) AND (x<=122))
+ OR ((65<=x) AND (x<=90)))
+ END;
+
+ PROCEDURE ReadLabel(VAR star:stringarray; VAR c:char);
+ (* Reads the components of a label from the incoming stream and
+ puts its components into the stringarray star, including
+ the implicit items. If section numbers are not reset in each
+ chapter (2 levels of test units) then the empty string is put in
+ the chapter designator location star[1] except in the case of
+ chapter labels. *)
+ LABEL 2,5,9;
+ VAR i,implicit:integer; str:string[12];
+ BEGIN
+ k:=0; star:=empty; PeriodFollows:=FALSE;
+ (* k will count the number of parts separated by .'s in the label. *)
+ 2: str:='';
+ WHILE labelsymbol(c) DO BEGIN
+ str:=str+c;
+ read(incoming,c);
+ END;
+ k:=k+1; star[k+ImplAdj]:=str;
+ IF c='.' THEN BEGIN
+ (* Another part of the label is coming, or there is a . after
+ the label. *)
+ read(incoming,c);
+ IF labelsymbol(c) THEN GOTO 2
+ ELSE PeriodFollows:=TRUE;
+ END;
+ (* Now we have all k items of the label in the stringarray star.
+ We want the program to work so that, if desired, the chapter, section
+ and subsection labels may be omitted and then they are understood to
+ refer to the current chapter, section or subsection.
+ We reconstruct the omitted parts of the label. We assemble it
+ in star and then if it is a new label we put it into the mainlist.
+ If the number of levels is 3, then the
+ components of star are: Chapter label, Section label, Subsection
+ label and item label. If any of these are missing or not applicable,
+ the corresponding label is ''. A subsection label is missing
+ if the section is not divided into subsections. A subsection
+ label is inapplicable if the label is a chapter or section label.
+ If the number of levels is 2, (ImplAdj=1) then a label of
+ anything except a chapter is complete without the chapter label,
+ and star[1]:='' for all such items. *)
+ IF (LabelKind > 1) AND ((k+ImplAdj) > min(LabelKind, 4)) THEN BEGIN
+ writeln('Found a label with too many parts. If you have 2 levels,');
+ writeln('only a chapter label should contain a chapter identifier.');
+ GOTO 5;
+ END;
+ IF ((LabelKind=0) AND (k>1)) THEN BEGIN
+ writeln(' An at-large item label with more than one part: ');
+5: write('LabelKind: ',Labelkind,' Label: ');
+ FOR i:=1+ImplAdj TO k+ImplAdj-1 DO write(sta[i],'.');
+ writeln(sta[k+ImplAdj]);
+ writeln('Continue? y or n '); readln(ans);
+ IF ans='n' THEN BEGIN close(incoming); halt END;
+ END; (* Of error handling. *)
+ IF LabelKind=0 THEN BEGIN
+ star[4]:=star[1+ImplAdj]; star[1+ImplAdj]:='';
+ END;
+ IF LabelKind=1 THEN BEGIN
+ star[1]:=star[1+ImplAdj]; star[2]:='';GOTO 9 END;
+ IF (2<=LabelKind) AND (LabelKind<=3) THEN BEGIN
+ implicit:=LabelKind-k-ImplAdj;
+ IF implicit>0 THEN BEGIN
+ FOR i:=LabelKind DOWNTO implicit+1 DO star[i]:=star[i-implicit];
+ FOR i:=1+ImplAdj TO implicit+ImplAdj DO star[i]:=current[i];
+ END;
+ END;
+ IF (labelkind >= 4) THEN BEGIN
+ IF k+ImplAdj<4 THEN BEGIN
+ star[4]:=star[k+ImplAdj]; star[k+ImplAdj]:='' END;
+ IF k=1 THEN FOR i:=1+ImplAdj to 3 DO star[i]:=current[i];
+ (*This must be a label of an item in the current text unit.*)
+ END;
+9:END; (* of procedure readlabel. Note that c is the first symbol after
+ the label at this stage, or the first symbol after the period
+ if there was a period immediately after the label. *)
+
+ FUNCTION InList(st:StringArray;VAR SerialNo:integer):boolean;
+ (* TRUE if the label st is already in the mainlist.
+ This function is also used to compute the index SerialNo of
+ the label in the array of that LabelKind*)
+ LABEL 9;
+ VAR i:integer; bool:boolean;
+ BEGIN
+ IF totalcount[LabelKind]=0 THEN InList:=FALSE
+ ELSE FOR i:=totalcount[LabelKind] DOWNTO 1 DO
+ BEGIN
+ bool:=TRUE;
+ WITH mainlist[LabelKind]^[i]^ DO
+ FOR j:=1 TO 4 DO bool:=bool AND (oldlabel[j]=st[j]);
+ IF bool THEN BEGIN
+ InList:=TRUE;
+ SerialNo:=i;
+ (* mainlist[LabelKind]^[SerialNo] is the record where this
+ label and the new label which is to replace it can be found.*)
+ GOTO 9 END;
+ END;
+ InList:=FALSE; (* The label is not in mainlist. *)
+9:END;
+
+
+ PROCEDURE AddToList(sta:stringarray);
+(* We have a new label which is not a forward reference. Add it to mainlist*)
+ VAR i:integer;
+ BEGIN
+ totalcount[LabelKind]:=totalcount[LabelKind]+1;
+ currentcount[LabelKind]:=currentcount[LabelKind]+1;
+ (* If the new label is a chapter, section or subsection label then
+ the counts of subordinate items have to be reset.*)
+
+ IF (0<LabelKind) AND (LabelKind<=3) THEN BEGIN
+ current[labelkind]:=sta[labelkind];
+ FOR i:=max(labelkind+1,ImplAdj+2) TO 9 DO BEGIN
+ currentcount[i]:=0; current[i]:='';
+ END;
+ IF (FirstChapterLabel AND (labelkind=1)) THEN BEGIN
+ CurrentCount[1]:=FirstChapter; FirstChapterLabel:=False
+ END;
+ IF (FirstSectionLabel AND (labelkind=2)) THEN BEGIN
+ CurrentCount[2]:=FirstSection; FirstSectionLabel:=False
+ END;
+ END; (* of adjusting the label counts and the array of current chapter,
+ section and subsection to account for the new label.
+ Next add a new blank record where we will put the label we just found,
+ and the label which will replace it. *)
+
+ new(mainlist[LabelKind]^[totalcount[LabelKind]]);
+ WITH mainlist[LabelKind]^[totalcount[LabelKind]]^ DO BEGIN
+ oldlabel:=sta;
+ FOR i:=1 to 4 DO newlabel[i]:=0;
+ IF LabelKind=0 THEN newlabel[4]:= currentcount[0];
+ IF LabelKind=1 THEN newlabel[1]:=currentcount[1];
+ IF LabelKind>=2 THEN
+ FOR i:=1+ImplAdj TO min(3,LabelKind) DO newlabel[i]:=currentcount[i];
+ IF LabelKind>=4 THEN newlabel[4]:=currentcount[labelkind];
+ (* Newlabel[1] is 0 if sections are numbered
+ consecutively and chapter numbers occur only in chapter labels.*)
+ SecondPassOccurred:=FALSE;
+ END; (* of preparing new mainlist entry *)
+ END; (* of processing the new label *)
+
+ PROCEDURE MakeNewLabelstring(VAR newlabelstring:string;
+ labelkind,SerialNo:integer);
+ LABEL 9;
+ VAR j:integer;s:string;
+ InUnitRef:boolean;
+ BEGIN
+ WITH mainlist[LabelKind]^[SerialNo]^ DO
+ BEGIN
+ newlabelstring:='';
+ IF LabelKind=0 THEN
+ BEGIN IntToStr(newlabel[4],newlabelstring);
+ GOTO 9 END; (* Of LabelKind=0 (at large label) case *)
+ IF LabelKind=1 THEN
+ BEGIN IntToStr(newlabel[1],newlabelstring);
+ GOTO 9 END; (* Of LabelKind=1 (i.e. chapterlabel) case *)
+
+ IF omit AND (LabelKind>3) THEN BEGIN
+ (* Find whether the reference is to the current unit of the text.*)
+ InUnitRef:=TRUE;
+ FOR j:=1+ImplAdj TO 3 DO
+ InUnitRef:=InUnitRef AND (newlabel[j]=currentcount[j]);
+ IF InUnitRef THEN BEGIN
+ IntToStr(newlabel[4],newlabelstring); GOTO 9 END;
+ END; (* Of making label without chapter,section and subsection
+ number. Note we exit to 9 only if such a label has been made. *)
+ FOR j:=1+ImplAdj TO min(LabelKind,4) DO
+ IF OldLabel[j] <> '' THEN BEGIN
+ IntToStr(newlabel[j],s);
+ IF newlabelstring='' THEN newlabelstring:=s
+ ELSE newlabelstring:=newlabelstring+'.'+s;
+ END;
+ END; (* of WITH statement *)
+9:END;
+
+ FUNCTION LabelTag(LabelKind:integer):char; (* For error message.*)
+ BEGIN
+ CASE LabelKind OF
+ 0: LabelTag:= ''; {Option a, At large item ASCII 140}
+ 1: LabelTag:= ''; {Option c, Chapter ASCII 141}
+ 2: LabelTag:= ''; {Option s, Section ASCII 167}
+ 3: LabelTag:= ''; {Option b, suBsection ASCII 186}
+ 4: LabelTag:= ''; {Option g, fiGure ASCII 169}
+ 5: LabelTag:= ''; {Option f, Formula ASCII 196}
+ 6: LabelTag:= ''; {Option p, Problem ASCII 185}
+ 7: LabelTag:= ''; {Option d, Definition ASCII 182}
+ 8: LabelTag:= ''; {Option t, Theorem ASCII 160}
+ 9: LabelTag:= ''; {Option l, Lemma ASCII 194}
+ (* In the IBM-compatible version of RELABEL different label tags are used.
+ Their ASCII numbers are 227, 228, 229, 221, 222,..., 226 *)
+ END;
+ END; (* Main program begins here.*)
+BEGIN
+1: FOR i:=1 TO 4 DO empty[i]:=''; current:=empty;
+ writeln('File to be renumbered. If it is not in the same folder as RENUMBER');
+ writeln('then give path name, e.g. HardDisk:Calculus Book Folder:Ch3 ');
+ readln(filename);
+ writeln('Do you have a 2 level (Section, possibly subsection) or');
+ writeln('3 level (Chapter, section, subsection) hierarchy of text units?');
+ write('Input 2 or 3 ');
+ readln(i); SectionReset:= i=3; ImplAdj:=3-i;
+ (*ImplAdj (Implicit Adjustment) = 1 if chapter numbers are superfluous
+ in labels, 0 otherwise.*)
+ writeln('Do you want the chapter, section and subsection numbers');
+ writeln('in the new file if they are all the current ones (y or n) ');
+ writeln('(Chapter numbers are included only if you have 3 levels)');
+ readln(ans); omit:=ans='n';
+ writeln('Do you want the label tags to remain in the output? y or n: ');
+ readln(ans); LabeltagsInOutput:=ans='y';
+ IF labeltagsinoutput THEN filenameend:='R' ELSE filenameend:='T';
+ FOR i:=0 TO 9 DO currentcount[i]:=0;
+ TotalCount:=CurrentCount;
+ writeln('Input the number >= 0 you want for the first chapter');
+ readln(FirstChapter);
+ currentcount[1]:=FirstChapter-1; FirstChapterLabel:=TRUE;
+ writeln('Input the number >= 0 you want for the first section');
+ readln(FirstSection);
+ currentcount[2]:=FirstSection-1; FirstSectionLabel:=TRUE;
+ writeln('I will beep when ready');
+ (* Next create the arrays for storing the various types of labels. *)
+
+ FOR i:=0 TO 9 DO new(mainlist[i]);
+
+ Reset(incoming,filename{,50000}); (* Use large buffer to spare disk drive *)
+ read(incoming, c);
+ WHILE eof(incoming)=FALSE DO
+ BEGIN
+ IF ord(c) > 128 THEN BEGIN
+ CASE c OF
+ '': LabelKind:=0;
+ '': LabelKind:=1;
+ '': LabelKind:=2;
+ '': LabelKind:=3;
+ '': LabelKind:=4;
+ '': LabelKind:=5;
+ '': LabelKind:=6;
+ '': LabelKind:=7;
+ '': LabelKind:=8;
+ '': LabelKind:=9;
+ OTHERWISE (* In case the file comes from MS-DOS user of RELABEL *)
+ IF ((227 <= ord(c)) AND (ord(c)<= 229))
+ THEN LabelKind:= ord(c)-226
+ ELSE IF ((221 <= ord(c)) AND (ord(c)<= 226))
+ THEN LabelKind:= ord(c)-217
+ ELSE IF ord(c)=220 THEN LabelKind:=0
+ ELSE GOTO 8;
+ END;
+ read(incoming, c);
+ IF (c<>'') THEN readlabel(sta,c) ELSE GOTO 8;
+
+ (* Do readlabel and the work below only if this is not
+ labeled to be a reference.
+ Next, we check if this is a repeat occurrence of a label.
+ If not, enter in the list of labels and increase the count
+ of labels of the kind we found.*)
+
+ IF NOT InList(sta,SerialNo) THEN AddToList(sta);
+ END; (* of processing a label *)
+ 8:read(incoming,c)
+ END; (* of loop which reads characters of the file *)
+
+ writeln('First pass completed. I am starting to write the new file.');
+
+ Reset(incoming);
+
+ outputfilename:=filename+filenameend;
+ (*If we choose to retain the tags of the labels in the renumbered
+ file then its name is original file name with R appended,
+ if the tags are stripped from the labels, S is appended.*)
+ TextCreator:='*TEX';
+ Rewrite(outgoing,outputfilename{,50000});
+ (* Use large buffers to avoid frequent disk operation *)
+
+ current:=empty;
+ FOR i:=0 TO 9 DO currentcount[i]:=0;
+ currentcount[1]:=FirstChapter-1;
+ currentcount[2]:=FirstSection-1;
+
+ (* We need to redo current to be able to restore the implicit
+ parts of the labels as we encounter them on the second pass. *)
+
+3:read(incoming,c);
+ WHILE eof(incoming)=FALSE DO
+ BEGIN
+ IF ord(c) >=128 THEN BEGIN (* A label may begin here. *)
+ (* Check for and convert MS-DOS label tags *)
+ IF ord(c)=220 THEN BEGIN LabelKind:=0; c:=labeltag(0) END;
+ IF ((227 <= ord(c)) AND (ord(c)<= 229)) THEN BEGIN
+ LabelKind:= ord(c)-226; c:=labeltag(labelkind) END;
+ IF ((221 <= ord(c)) AND (ord(c)<= 226)) THEN BEGIN
+ LabelKind:= ord(c)-217; c:=labeltag(labelkind) END; {Of DOS conv.}
+ ForwardRef:=FALSE;
+ CASE c OF
+ '': LabelKind:=0;
+ '': LabelKind:=1;
+ '': LabelKind:=2;
+ '': LabelKind:=3;
+ '': LabelKind:=4;
+ '': LabelKind:=5;
+ '': LabelKind:=6;
+ '': LabelKind:=7;
+ '': LabelKind:=8;
+ '': LabelKind:=9
+ OTHERWISE BEGIN (*The symbol is not a labelkind indicator*)
+ write(outgoing,c); GOTO 3;
+ END;
+ END; (* of CASEs. We did not GOTO 3, c is a labeltag. *)
+ IF LabeltagsInOutput THEN write(outgoing,c);
+ read(incoming,c);
+ IF c=chr(222) THEN c:='';
+ IF c='' THEN BEGIN
+ ForwardRef:=TRUE;
+ IF LabeltagsInOutput THEN write(outgoing,c);
+ read(incoming,c)
+ END;
+ readlabel(sta,c);
+ IF NOT(InList(sta,SerialNo)) THEN BEGIN
+ writeln('LABEL NOT FOUND IN LIST ON SECOND PASS. ERROR');
+ writeln('YOU MAY HAVE REFERRED TO A NONEXISTENT LABEL');
+ writeln('OR YOU MAY HAVE ENTERED THE WRONG LEVEL NUMBER.');
+ write('LabelKind: ',Labelkind,' Label in full form: ');
+ FOR i:=1+ImplAdj TO min(LabelKind-1, 3) DO
+ IF sta[i] <> '' THEN write(sta[i],'.');
+ IF ((LabelKind = 0) OR (LabelKind > 3)) THEN writeln(sta[4])
+ ELSE writeln(sta[LabelKind]);
+ writeln('Continue (with ??? in this reference)? y or n ');
+ readln(ans);
+ IF ans='n' THEN BEGIN close(incoming); close(outgoing); halt END;
+ write(outgoing,'???'); GOTO 9;
+ END; (* Of message and output, we had a reference to unknown label.*)
+ IF NOT ForwardRef THEN BEGIN
+ WITH mainlist[labelkind]^[SerialNo]^ DO BEGIN
+ IF (NOT secondpassoccurred)THEN BEGIN
+ IF (0<LabelKind) AND (labelkind<4) THEN BEGIN
+ currentcount[labelkind]:=currentcount[labelkind]+1;
+ (* This is not a reference but the label of a new *)
+ (* subdivision. Adjust current subdiv.*)
+ current[labelkind]:=oldlabel[labelkind];
+ IF (currentcount[1]>FirstChapter)
+ OR (currentcount[2]>FirstSection) THEN BEGIN
+ FOR i:=max(labelkind+1,ImplAdj+2) TO 3 DO BEGIN
+ current[i]:=''; currentcount[i]:=0;
+ END;
+ END;
+ END; (* Of dealing with the label of a new heading. *)
+ secondpassoccurred:=TRUE;
+ END
+ ELSE IF LabeltagsInOutput THEN write(outgoing,'');
+ (* We have a reference.*)
+ END; (* Of WITH mainlist...*)
+ END; (* Of NOT ForwardRef *)
+ (* Now we are ready to get the new label and convert it to a
+ string. This can not be done once for all since the string
+ may be shorter in a reference to the item from within
+ the same subunit. Doing the job from scratch each time just
+ because we may need one or the other of two expressions
+ is admittedly inelegant but seldom are there many references
+ to one item. *)
+ MakeNewLabelstring(s,LabelKind, SerialNo);
+ write(outgoing,s);
+9: IF PeriodFollows THEN write(outgoing,'.');
+ END (* of assembling and writing the new label. *)
+ ELSE BEGIN (* ord(c)<128, certainly not a labelkind symbol*)
+ write(outgoing,c);
+ read(incoming,c);
+ END; (* of IF ord(c)>=128..ELSE statement. *)
+ END; (* Return to the beginning of the WHILE eof(incoming)=FALSE cycle *)
+ write(outgoing,c); (* write the last symbol of the file *)
+ close(outgoing);close(incoming);
+ writeln(chr(7),'"',outputfilename,'"', 'written on disk.');
+ FOR i:=0 TO 9 DO dispose(mainlist[i]);
+ write('Relabel another file? (y or n)');
+ readln(c); IF c='y' THEN GOTO 1;
+ END.
diff --git a/support/relabel/relex2i.txt b/support/relabel/relex2i.txt
new file mode 100644
index 0000000000..8389739bbc
--- /dev/null
+++ b/support/relabel/relex2i.txt
@@ -0,0 +1,166 @@
+RelabelExample2 file for IBM-compatible computers.
+
+Chapter in. Introduction.
+
+Section le. Levels.
+
+Definition levelsdef. This file is in-
+tended for using RELABEL in 2-level
+mode. The hierarchy of text units is
+section and subsection.
+Chapter labels are treated as nothing
+more than a set of labels which are
+not reset when we enter a new section.
+Subsection numbers are reset to 1 in
+each new section and all item numbers
+are reset to 1 in each subsection.
+
+Section di. Directions.
+
+Def def. This file is intended to
+show how the program relabel works and
+to help you experiment with it. The
+"chapters", "sections" etc. all have
+memnonic labels, which the program
+RELABEL replaces by numbers in the
+output file. Run the program using
+this file as input and compare the
+output file with this file. View the
+original and relabeled files side
+by side. Close this file before you
+start.
+
+PROBLEM WARNING. This text is
+intended to illustrate renumbering
+when section numbers do NOT restart
+in each chapter. CHAPTER IDENTIFIERS
+SHOULD NOT OCCUR EXCEPT IN CHAPTER
+LABELS. RELABEL WILL GET CONFUSED IF
+CHAPTER IDENTIFIERS ARE USED IN
+ANY OTHER LABEL OR REFERENCE.
+
+
+Section su. Suggestions.
+
+ Note that if you just move Horst
+of Ithaca to Hopewell, he will be
+married label-wise to Hope of Hopewell
+insofar as they will share the same
+label. This is because they both
+started out with the label ho.
+That is OK as long as they are not
+in the same town.
+If you run RELABEL before
+moving Horst, and ask for chapter
+numbers etc. not to be omitted,
+then you can move Horst to Hopewell
+and RELABEL again, and this time
+Horst and Hope will have distinct
+labels.
+
+CHAPTER ca. State of California
+
+Section ca. Campers in California
+
+am Amanda at large
+ca Forward ref. to Cathy at large
+Fig.ca Carl
+Fig.al Alfred
+Fig.ad. Adele Smith
+Fig. adelejones Adele Jones
+forw.Ref. to or.be Betty
+Ref. to Fig. al Alfred
+Forward Ref. to nonexistent label
+ne Nobody
+Forward ref. to to.it.ho Horst
+of Ithaca
+
+Section or Orange County
+
+
+Fig.bo Bob
+Fig.be Betty
+Ref. to adelejones Adele Jones
+Ref. to or.be Betty
+Ref. to be Betty
+Ref. to Fig. al Alfred
+
+SubSection sa. Town of Santa Ana
+
+Fig.ch Charles
+Fig.ca Cathy
+Forwardref to me.pr.da Dan
+
+Section mo Monterey County
+
+Subsection loc Town of Lockwood
+
+ed Edward
+
+CHAPTER nj. State of New Jersey
+
+Section cam. Campers in New Jersey
+
+ Note that we can not use ca as
+identifier for this section because
+we used ca as identifier for
+the section Camping in California.
+This file is intended for not resetting
+the section numbers in each new
+chapter. When this option is used,
+chapter identifiers are used only
+in chapter labels and the same
+section label can not be used in
+different chapters. When the reset
+option is used, a chapter identifier
+are part of the full label of
+every item and RELABEL will not be
+confused if the same identifier
+is used for sections in different
+chapters, even if you do not type
+the full label but only the
+abbreviated form, i.e., the last item.
+Note that ca is used three times, as
+a chapter identifier, a section
+identifier and an item identifier.
+
+Fig.el Elaine
+
+Section me. Mercer County
+
+Subsection pr. Town of Princeton
+
+Fig.fr Frank of Princeton
+da Dan
+
+Subsection ho. Town of Hopewell
+
+ho Hope of Hopewell
+Fig.dor Doris
+Fig.er Erwin
+
+CHAPTER ny State of New York
+
+Section to Tompkins County
+
+Subsection it Town of Ithaca
+
+ho Horst of Ithaca
+ForwardRef. to we.ea.fr Frank of
+Eastchester.
+
+Section we Westchester County
+
+Subsection ea Town of Eastchester
+
+Fig. fr Frank, born in Eastchester
+Ref. to me.ho.dor Doris
+Ref. to nj New Jersey State
+Ref. to me.pr Princeton, town of
+Ref. to fr Frank, born in Eastchester
+Ref. to me.pr.fr Frank, born in Princeton
+Ref. to am Amanda at large
+ca Cathy at large.
+Ca Calvin at large
+
+ End of Pseudobook
diff --git a/support/relabel/relex2m.txt b/support/relabel/relex2m.txt
new file mode 100644
index 0000000000..9eebc62887
--- /dev/null
+++ b/support/relabel/relex2m.txt
@@ -0,0 +1,191 @@
+RelabelExample2 file for Macintosh.
+
+Chapter in. Introduction.
+
+Section le. Levels.
+
+Definition levels. This file is an
+example file for using RELABEL in 2-level
+mode. The hierarchy of text units is
+section and subsection.
+Chapter labels are not part of any
+other identifier but when a new
+chapter starts RELABEL resets to 1 all
+all counts except the section count
+and the count for "at large" items.
+Subsection numbers are reset to 1 in
+each new section and all item numbers
+except "at large" are reset to 1 in
+each subsection.
+
+
+Section di. Directions.
+
+Def def. This file is intended to
+show how the program relabel works and
+to help you experiment with it. The
+"chapters", "sections" etc. all have
+memnonic labels, which the program
+RELABEL replaces by numbers in the
+output file. Run the program using
+this file as input and compare the
+output file with this file. View the
+original and relabeled files side by
+side. Close this file before you
+start.
+
+Subsection howtorefer. Reference format
+
+In 2-level mode all references to
+items in other text units must
+contain a section identitier and, if
+the item is in a subsection, the
+subsection identifier must also be
+supplied. The section identifier must
+be given even if it you are referring
+to an item in another sucsection of
+the current section. You have the
+option of omitting ALL unit
+identifiers if you are referring to a
+label in the same text unit, i.e., if
+no section or subsection starts
+between the label and the reference.
+ Exception: items of the type "at
+large" are not considered part of any
+particular text unit and references
+to them should NOT contain text unit
+identifiers.
+
+
+Section su. Suggestions.
+
+ Note that if you just move Horst
+of Ithaca to Hopewell, he will be
+married label-wise to Hope of Hopewell
+insofar as they will share the same
+label before and after relabeling.
+This is because they both started out
+with the label ho. That is OK as
+long as they are not in the same text
+unit. If you want to move Horst from
+Ithaca to Hopewell, run RELABEL before
+moving Horst, and ask for section
+numbers etc. to be retained. Then
+you can move Horst to Hopewell. This
+time Horst and Hope will have
+different labels but the label of
+Horst will reflect his former rather
+than his present location. To correct
+this, run RELABEL again. You can ask
+for abbreviated or full labels, and
+this time Horst and Hope will have
+distinct labels.
+
+Forward ref. to me.ho.ho Hope of Hopewell
+Forward ref. to to.it.ho Horst of Ithaca
+
+CHAPTER ca. State of California
+
+Section ca. Campers in California
+
+Forward ref. to At large alt Alton
+At large al Albert
+At large Al Allyson
+Fig.ca Carl
+Fig.al Alfred
+Fig.ad. Adele Smith
+Fig. adelejones Adele Jones
+forw.Ref. to or.be Betty
+Ref. to Fig. al Alfred
+Forward Ref. to nonexistent label
+ne Nobody
+Forward ref. to to.it.ho Horst
+of Ithaca
+
+Section or Orange County
+
+
+Fig.bo Bob
+Fig.be Betty
+Ref. to adelejones Adele Jones
+Ref. to or.be Betty
+Ref. to be Betty
+Ref. to Fig. al Alfred
+
+SubSection sa. Santa Ana
+
+Fig.ch Charles
+Fig.ca Cathy
+Forwardref to me.pr.da Dan
+
+Section mo Monterey County
+
+Subsection loc Lockwood
+
+ed Edward
+
+CHAPTER nj. State of New Jersey
+
+Section cam. Campers in New Jersey
+
+ Note that we can not use ca as
+identifier for this section because
+we used ca as identifier for
+the section Camping in California.
+This file is intended for not resetting
+the section numbers in each new
+chapter. When this option is used,
+chapter identifiers are used only
+in chapter labels and the same
+section label can not be used in
+different chapters. When the reset
+option is used, a chapter identifier
+are part of the full label of
+every item and RELABEL will not be
+confused if the same identifier
+is used for sections in different
+chapters, even if you do not type
+the full label but only the
+abbreviated form, i.e., the last item.
+Note that ca is used three times, as
+a chapter identifier, a section
+identifier and an item identifier.
+
+Fig.el Elaine
+
+Section me. Mercer County
+
+Subsection pr. Princeton
+
+Fig.fr Frank, born in Princeton
+da Dan
+
+Subsection ho. Village of Hopewell
+
+ho Hope of Hopewell
+Fig.dor Doris
+Fig.er Erwin
+
+CHAPTER ny State of New York
+
+Section to Tompkins County
+
+Subsection it City of Ithaca
+
+ho Horst of Ithaca
+ForwardRef. to we.ea.fr Frank, born in
+Eastchester.
+
+Section we Westchester County
+
+Subsection ea Eastchester (a town in Westchester)
+
+alt Alton
+Ref. to at large Al Allyson
+Fig. fr Frank, born in Eastchester
+Ref. to me.ho.dor Doris
+Ref. to nj New Jersey State
+Ref. to me.pr Princeton, town of
+Ref. to fr Frank, born in Eastchester
+Ref. to me.pr.fr Frank, born in Princeton
+ End of Pseudobook
diff --git a/support/relabel/relex3i.txt b/support/relabel/relex3i.txt
new file mode 100644
index 0000000000..132b37fc27
--- /dev/null
+++ b/support/relabel/relex3i.txt
@@ -0,0 +1,158 @@
+RELABEL EXAMPLE3 FILE FOR MS-DOS COMPUTERS.
+
+Chapter intro. Introduction.
+
+Definition levels. This file is in-
+tended for using RELABEL in 3-level
+mode. The hierarchy of text units is
+chapter, section and subsection.
+Section numbers are reset to 1 in each
+new chapter except the first. Sub-
+section numbers are reset to 1 in
+each new section and all item numbers
+are reset to 1 in each subsection.
+
+This file is intended to show how the
+program relabel works and to help you
+experiment with it. The "chapters",
+"sections" etc. all have memnonic
+labels, which the program RELABEL
+replaces by numbers in the output file.
+Run the program using this file as
+input and compare the output file with
+this file. Close this file before you
+start.
+
+After running RELABEL, open this file
+and the relabeled version in
+windows side by side, and compare the
+two files. These lines are short to
+facilitate this.
+
+WARNING WARNING. RELABEL can deal with
+two kinds of files, and asks you which
+kind you have. If we restart the
+section numbers at the beginning of
+each chapter then a full label of all
+items must contain the chapter label,
+although in references to items in the
+current text unit you may omit ALL text
+unit identifiers. If we do not
+restart section numbers in each chapter
+then RELABEL disregards chapter
+identifiers except in chapter labels.
+If you include a chapter identifier in a
+nonchapter label RELABEL will get
+confused. Conversely, if section
+numbers are to start from 1 in each
+chapter, all references to other text
+units must contain a chapter identitier.
+
+Section sugg. Suggestions
+
+ Note that if you just move Horst
+of Ithaca to Hopewell, he will be
+married label-wise to Hope of Hopewell
+insofar as they will share the same
+label. This is because they both
+started out with the label ho.
+That is OK as long as they are not
+in the same town.
+If you run RELABEL before
+moving Horst, and ask for chapter
+numbers etc. not to be omitted,
+then you can move Horst to Hopewell
+and RELABEL again, and this time
+Horst and Hope will have distinct
+labels.
+
+PROBLEM WARNING. IF YOU HAVE LABELS IN
+A FILE WHICH ARE "AT LARGE" IN
+CHAPTERS, I.E. NOT IN A SECTION WITHIN
+THE CHAPTER. AND YOU SELECT THE "DO NOT
+RESET SECTION NUMBERS IN EACH CHAPTER"
+OPTION THEN CHAPTER NUMBERS WILL BE
+OMITTED FROM ALL LABELS, EXCEPT CHAPTER
+LABELS, EVEN INTERNALLY AND THE RELABEL
+PROGRAM WILL NOT BE ABLE TO FIGURE OUT
+WHAT THE LABELS LOOSE IN THE CHAPTER
+SHOULD BE. RELABEL EXAMPLE 2 IS SUCH A
+FILE.
+
+CHAPTER ca. State of California
+
+Campers in California:
+
+ca Cathy, at large in the US
+Fig.al Alfred
+Fig.ad. Adele Smith
+Fig. adelejones Adele Jones
+forw.Ref. to ca.or.be Betty
+Ref. to Fig. al Alfred
+Forward ref. to ny.to.it.ho Horst of Ithaca.
+Forward ref. to Ca Calvin, at large in Ithaca.
+
+Section or. Orange County
+
+
+Fig.bo Bob
+Fig.be Betty
+Ref. to ca.adelejones Adele Jones
+Ref. to ca.or.be Betty
+Ref. to be Betty
+Ref. to Fig. ca.al Alfred
+
+SubSection sa. Town of Santa Ana
+
+Fig.ch Charles
+Fig.ca Cathy
+Forwardref to Fig.nj.el Elaine
+Forwardref to nj.me.pr.da Dan
+
+Sectionmo. Monterey County
+
+Subsection loc. Town of Lockwood
+
+ed Edward
+
+CHAPTER nj State of New Jersey.
+
+Fig.el Elaine
+
+Section me Mercer County
+
+Subsection pr Town of Princeton
+
+Fig.fr Frank, born in Princeton
+da Dan
+
+Subsection ho Town of Hopewell
+
+ho Hope of Hopewell
+Fig.dor Doris
+Fig.er Erwin
+al Alvin, at large
+
+CHAPTER ny State of New York
+
+Section to Tompkins County
+
+Subsection it Town of Ithaca
+
+Ca Calvin, at large
+Ref. to al Alvin, at large in Hopewell
+ho Horst of Ithaca
+Forward ref. to ny.we.ea.fr Frank,
+born in Eastchester
+
+Section we Westchester County
+
+Subsection ea Town of Eastchester
+
+Fig. fr Frank of Eastchester
+Ref. to nj.me.ho.dor Doris
+Ref. to nj New Jersey State
+Ref. to nj.me.pr Princeton, town of
+Ref. to fr Frank of Eastchester
+Ref. to nj.me.pr.fr Frank, born in Princeton
+ End of Pseudobook
diff --git a/support/relabel/relex3m.txt b/support/relabel/relex3m.txt
new file mode 100644
index 0000000000..bd73098377
--- /dev/null
+++ b/support/relabel/relex3m.txt
@@ -0,0 +1,156 @@
+RELABEL EXAMPLE3 FILE FOR MACINTOSH.
+
+Chapter intro. Introduction.
+
+Definition levels. This file is in-
+tended for seeing RELABEL work in 3-
+level mode. The hierarchy of text units
+is chapter, section and subsection.
+Section numbers are reset to 1 in each
+new chapter except the first. Sub-
+section numbers are reset to 1 in
+each new section and all item numbers
+are reset to 1 in each subsection.
+
+The "chapters",
+"sections" etc. all have memnonic
+labels, which the program RELABEL
+replaces by numbers in the output file.
+Run the program using this file as
+input and compare the output file with
+this file. Close this file before you
+start.
+
+After running RELABEL, open this file
+and the relabeled version in
+windows side by side, and compare the
+two files. These lines are short to
+facilitate this.
+
+Section howtorefer Reference format.
+
+In 3-level mode all references to
+items in other text units must
+contain a chapter identitier and, if
+the item is in a section or
+subsection, those identifiers must
+also be supplied even if the chapter
+and section number are the current
+ones. You have the option of omitting
+ALL unit identifiers if you are
+referring to a label in the same text
+unit, i.e., if no section or
+subsection starts between the label
+and the reference.
+ Exception: items of the type "at
+large" are not considered part of any
+particular text unit and references
+to them should NOT contain text unit
+identifiers.
+
+Section sugg. Suggestions
+
+ Note that if you just move Horst of
+Ithaca to Hopewell, he will be
+married label-wise to Hope of Hopewell
+insofar as they will share the same
+label before and after relabeling.
+This is because they both started out
+with the label ho. That is OK as
+long as they are not in the same text
+unit. If you want to move Horst from
+Ithaca to Hopewell, run RELABEL before
+moving Horst, and ask for section
+numbers etc. to be retained. Then
+you can move Horst to Hopewell. This
+time Horst and Hope will have
+different labels but the label of
+Horst will reflect his former rather
+than his present location. To correct
+this, run RELABEL again. You can ask
+for abbreviated or full labels, and
+this time Horst and Hope will have
+distinct labels.
+
+Forward ref. to nj.me.ho.ho Hope of Hopewell
+Forward ref. to ny.to.it.ho Horst of Ithaca
+
+CHAPTER ca. State of California
+
+Campers in California:
+
+Fig.al Alfred
+Fig.ad. Adele Smith
+Fig. adelejones Adele Jones
+forw.Ref. to ca.or.be Betty
+Ref. to Fig. al Alfred
+Forward ref. to Al Allyson, at large
+
+Forward ref. to ny.to.it.ho Horst of Ithaca.
+
+Section or. Orange County
+
+Forward ref. to At large alt Alton
+At large al Albert
+At large Al Allyson
+Fig.bo Bob
+Fig.be Betty
+Ref. to ca.adelejones Adele Jones
+Ref. to ca.or.be Betty
+Ref. to be Betty
+Ref. to Fig. ca.al Alfred
+
+SubSection sa. Town of Santa Ana
+
+Fig.ch Charles
+Fig.ca Cathy
+Forwardref to Fig.nj.el Elaine
+Forwardref to nj.me.pr.da Dan
+
+Section mo. Monterey County
+
+Subsection loc. Town of Lockwood
+
+ed Edward
+
+CHAPTER nj State of New Jersey.
+
+Fig.el Elaine
+
+Section me Mercer County
+
+Subsection pr Town of Princeton
+
+Fig.fr Frank, born in Princeton
+da Dan
+
+Subsection ho Town of Hopewell
+
+ho Hope of Hopewell
+Fig.dor Doris
+Fig.er Erwin
+
+CHAPTER ny State of New York
+
+Section to Tompkins County
+
+Subsection it Town of Ithaca
+ho Horst of Ithaca
+Forward ref. to ny.we.ea.fr Frank,
+born in Eastchester
+
+Section we Westchester County
+
+Subsection ea Town of Eastchester
+
+At large alt Alton
+Ref. to at large Al Allyson
+Fig. fr Frank of Eastchester
+Ref. to Fig.nj.me.ho.dor Doris
+Ref. to Fig.nj New Jersey State
+Ref. to Fig.nj.me.pr Princeton, town of
+Ref. to Fig.fr Frank of Eastchester
+Ref. to Fig.nj.me.pr.fr Frank, born in Princeton
+ End of Pseudobook
+
+