MCPcopy Create free account
hub / github.com/Singular/Singular / feHelp

Function feHelp

Singular/fehelp.cc:90–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 *****************************************************************/
89EXTERN_VAR BOOLEAN FE_OPT_NO_SHELL_FLAG;
90void feHelp(char *str)
91{
92 str = strclean(str);
93 if (str == NULL) {heBrowserHelp(NULL); return;}
94
95 if (strlen(str) > MAX_HE_ENTRY_LENGTH - 2) // need room for extra **
96 str[MAX_HE_ENTRY_LENGTH - 3] = '\0';
97
98 BOOLEAN key_is_regexp = (strchr(str, '*') != NULL);
99
100
101 heEntry_s hentry;
102 memset(&hentry,0,sizeof(hentry));
103 char* idxfile = feResource('x' /*"IdxFile"*/);
104
105 // Try exact match of help string with key in index
106 if (!key_is_regexp && (idxfile != NULL) && heKey2Entry(idxfile, str, &hentry))
107 {
108 heBrowserHelp(&hentry);
109 return;
110 }
111
112 // Try to match approximately with key in index file
113 if (idxfile != NULL)
114 {
115 if (heCurrentHelpBrowser == NULL) feHelpBrowser(NULL, 0);
116 assume(heCurrentHelpBrowser != NULL);
117
118 StringSetS("");
119 int found = heReKey2Entry(idxfile, str, &hentry);
120
121
122 if (found == 0)
123 {
124 // try proc help and library help
125 if (! key_is_regexp && heOnlineHelp(str)) return;
126
127 // Try to match with str*
128 char mkey[MAX_HE_ENTRY_LENGTH];
129 strcpy(mkey, str);
130 strcat(mkey, "*");
131 found = heReKey2Entry(idxfile, mkey, &hentry);
132 // Try to match with *str*
133 if (found == 0)
134 {
135 mkey[0] = '*';
136 strcpy(mkey + 1, str);
137 strcat(mkey, "*");
138 found = heReKey2Entry(idxfile, mkey, &hentry);
139 }
140
141 // Print warning and return if nothing found
142 if (found == 0)
143 {
144 Warn("No help for topic '%s' (not even for '*%s*')", str, str);
145 WarnS("Try '?;' for general help");
146 WarnS("or '?Index;' for all available help topics.");
147 return;

Callers 1

grammar.ccFile · 0.85

Calls 13

strcleanFunction · 0.85
heBrowserHelpFunction · 0.85
feResourceFunction · 0.85
heKey2EntryFunction · 0.85
feHelpBrowserFunction · 0.85
StringSetSFunction · 0.85
heReKey2EntryFunction · 0.85
heOnlineHelpFunction · 0.85
WarnFunction · 0.85
WarnSFunction · 0.85
StringEndSFunction · 0.85
PrintSFunction · 0.85

Tested by

no test coverage detected