@@ -61,7 +61,7 @@ also give the namespace for its functions.
6161@<Parse the line as a probable section heading@> =
6262 string rewritten; in_strcpy(rewritten, "");
6363 if ((S->sect_language == C_FOR_INFORM_LANGUAGE) &&
64- (pattern_match(L->text, "(%C+) (%C+/%C+): (%c+)."))) {
64+ (pattern_match(L->text, "%[ (%C+)%] (%C+/%C+): (%c+)."))) {
6565 in_strcpy(S->sect_namespace, found_text1);
6666 in_strcpy(S->sigil, found_text2);
6767 in_strcpy(S->sect_title, found_text3);
@@ -72,8 +72,82 @@ also give the namespace for its functions.
7272 in_strcpy(S->sect_title, found_text2);
7373 L->text_operand = new_string(found_text2);
7474 L->category = SECTION_HEADING_LCAT;
75+ } else if (pattern_match(L->text, "%[(%C+::)%] (%c+).")) {
76+ in_strcpy(S->sect_namespace, found_text1);
77+ in_strcpy(S->sect_title, found_text2);
78+ @<Set the sigil to an automatic abbreviation of the relative pathname@>;
79+ L->text_operand = new_string(found_text2);
80+ L->category = SECTION_HEADING_LCAT;
81+ } else if (pattern_match(L->text, "(%c+).")) {
82+ in_strcpy(S->sect_title, found_text1);
83+ @<Set the sigil to an automatic abbreviation of the relative pathname@>;
84+ L->text_operand = new_string(found_text1);
85+ L->category = SECTION_HEADING_LCAT;
7586 }
7687
88+ @ If no sigil is supplied, we make one ourselves.
89+
90+ @<Set the sigil to an automatic abbreviation of the relative pathname@> =
91+ sprintf(S->sigil, "%s/", C->ch_sigil);
92+
93+ char *from = S->sect_title;
94+ int w = strlen(S->sigil);
95+ char *tail = S->sigil + w;
96+
97+ int letters_from_each_word = 5;
98+ do {
99+ @<Make the tail using this many consonants from each word@>;
100+ if (--letters_from_each_word == 0) break;
101+ } while (strlen(tail) > 5);
102+
103+ @<Terminate with disambiguating numbers in case of collisions@>;
104+
105+ @ We collapse words to an initial letter plus consonants: thus "electricity"
106+ would be "elctrcty", since we don't count "y" as a vowel here.
107+
108+ @<Make the tail using this many consonants from each word@> =
109+ int sn = 0, sw = w;
110+ if (from[sn] == SEP_CHAR) sn++;
111+ int letters_from_current_word = 0;
112+ while ((from[sn]) && (from[sn] != '.')) {
113+ if (from[sn] == ' ') letters_from_current_word = 0;
114+ else {
115+ if (letters_from_current_word < letters_from_each_word) {
116+ if (from[sn] != '-') {
117+ int l = tolower(from[sn]);
118+ if ((letters_from_current_word == 0) ||
119+ ((l != 'a') && (l != 'e') && (l != 'i') && (l != 'o') && (l != 'u'))) {
120+ S->sigil[sw++] = l; S->sigil[sw] = 0;
121+ letters_from_current_word++;
122+ }
123+ }
124+ }
125+ }
126+ sn++;
127+ }
128+
129+ @ We never want two sections to have the same sigil.
130+
131+ @<Terminate with disambiguating numbers in case of collisions@> =
132+ char *distail = S->sigil + strlen(S->sigil);
133+ int disnum = 0, collision = FALSE;
134+ do {
135+ if (disnum++ > 0) {
136+ int ldn = 5;
137+ if (disnum >= 1000) ldn = 4;
138+ else if (disnum >= 100) ldn = 3;
139+ else if (disnum >= 10) ldn = 2;
140+ else ldn = 1;
141+ sprintf(distail-ldn, "%d", disnum);
142+ }
143+ collision = FALSE;
144+ for (chapter *C = W->first_chapter; C; C = C->next_chapter)
145+ for (section *S2 = C->first_section; S2; S2 = S2->next_section)
146+ if ((S2 != S) && (strcmp(S2->sigil, S->sigil) == 0)) {
147+ collision = TRUE; break;
148+ }
149+ } while (collision);
150+
77151@ Note that we report an error if the command isn't one we recognise: we
78152don't simply ignore the squares and let it fall through into the tangler.
79153There used to be two other syntaxes for oddball commands (to force page
0 commit comments