Coverage and Profiling report

Macro uman:
 — called:4 times — spent time:3.87 s
 — instrs:551 — covered:38%
 — branches:307 — covered:23%
1
Macro uman:
 — called:4 times — spent time:3.87 s
 — instrs:551 — covered:38%
 — branches:307 — covered:23%
function
uman(varargin)
3.87 s
2
    tmp = getversion("scilab");
3
    sci6 = tmp(1) > 5;
4
    //  if sci6, oldEmptyBehaviour("on"), end
5
    RelCharWidth = 1;
6
    //  init Scaling factor for non latin characters width (ja,zh)
7
    noWebBrowserMsg = _("uman", "uman: don''t kown how to open your web browser\n");
8
    //  FORMATING and partially PARSING OPTIONS
9
    //  ---------------------------------------
10
    if argn(2) == 0 then
0%100%
11
        uman("uman", "e");
12
        return;
13
    end
14
    if argn(2) == 3 then
0%100%
15
        tmp = convstr(varargin(3));
16
        if grep(tmp, "l") <> [] then
0%0%
17
            varargin(1) = varargin(1) + tmp;
18
        else
19
            varargin(1) = ("-" + tmp) + part(varargin(1), 2:$);
20
        end
21
    end
22
    if argn(2) == 1 then
20 ms 50%50%
23
        if varargin(1) == "-" then
10 ms 0%100%
24
            fun0 = "-";
25
            options = "";
26
        else
27
            if part(varargin(1), 1) == "-" then
10 ms 0%100%
28
                if grep(varargin(1), "c") <> [] then
0%0%
29
                    clc;
30
                end
31
                uman("uman");
32
                return;
33
            else
34
                fun0 = varargin(1);
10 ms
35
                options = "";
36
            end
37
        end
38
    else
39
        if (varargin(1) == "-") || (part(varargin(1), 1) <> "-") then
100%0%
40
            fun0 = varargin(1);
41
            options = varargin(2);
42
        else
43
            fun0 = varargin(2);
44
            options = varargin(1);
45
        end
46
    end
47
    options = convstr(options);
48
    options0 = options;
49
    //  useful in case of redirection (recursive => call)
50
    [options, LANG] = uman_splitOptionsLang(options);
51
    //  Option "@" is canceled when it is not alone:
52
    if (grep(options, "@") <> []) && (length(strsubst(options, "@", "")) > 0) then
0%100%
53
        options = strsubst(options, "@", "");
54
    end
55
    //  ========================================================================
56
    //  MAILING LISTS
57
    //  ------------- 
58
    if grep(options, "@") <> [] then
0%100%
59
        //  Building the query
60
        MailingListsQuery = "http://mailinglists.scilab.org/template/NamlServlet.jtp?macro=search_page&node=2602239&query=";
61
        //  TESTS in Subjects:
62
        // fun = "test & scilab"; r0 = "subject%3Atest+subject%3Ascilab"
63
        // r = test(fun), r==r0
64
        // fun = "test | scilab"; r0 = "subject%3A(test+OR+scilab)"
65
        // r = test(fun), r==r0
66
        // fun = "{test | scilab}"; r0 = "subject%3A(test+OR+scilab)"
67
        // r = test(fun), r==r0
68
        // fun = "~{test|scilab}"; r0 = "NOT+subject%3A(test+OR+scilab)"
69
        // r = test(fun), r==r0
70
        // fun = "test & scilab & ~{java|cpp}";  
71
        // r0 = "subject%3Atest+subject%3Ascilab+NOT+subject%3A(java+OR+cpp)";
72
        // r = test(fun), r==r0
73
        // fun = "~{java|cpp} & test & scilab";  
74
        // r0 = "NOT+subject%3A(java+OR+cpp)+subject%3Atest+subject%3Ascilab";
75
        // r = test(fun), r==r0
76
        // fun = "test & scilab & {image|signal} & ~{java|cpp}"
77
        // r0 = "subject%3Atest+subject%3Ascilab+subject%3A(image+OR+signal)+NOT+subject%3A(java+OR+cpp)";
78
        // r = test(fun), r==r0
79
        //  In subjects or in full messages?
80
        s = "+";
81
        fun = fun0;
82
        if part(fun, $) == "!" then
0%0%
83
            //  search only in subjects of messages.
84
            s = "+subject%3A";
85
            fun = part(fun, 1:($ - 1));
86
        else
87
            //  search in subjects + bodies
88
        end
89
        d = "!";
90
        //  regexp delimiter
91
        //  Authors part:
92
        tmp = tokens(fun, ">");
93
        if size(tmp, 1) > 1 then
0%0%
94
            authors = strcat(("author:" + stripblanks(tokens(tmp(1), "|"))) + " ");
95
            fun = " " + strcat(tmp(2:$), ">");
96
        else
97
            authors = "";
98
        end
99
        //  Max age part:
100
        tmp = tokens(fun, "<");
101
        if size(tmp, 1) > 1 then
0%0%
102
            max_age = "&days=" + tmp($);
103
            fun = strcat(tmp(1:($ - 1)), "<");
104
        else
105
            max_age = "";
106
        end
107
        fun = stripblanks(fun);
108
        //  Topics part
109
        if fun <> "" then
0%0%
110
            if (grep(fun, "&") == []) & (sum(grep(fun, ["~","(",")"])) < 2) then
0%0%
111
                fun = ("(" + fun) + ")";
112
            end
113
            tmp = ["%","!","?","#","[","]","-","+","*","/","^","$"];
114
            tmp = uman_strsubst(fun, tmp, "%" + dec2hex(ascii(tmp)));
115
            //  ":" must be protected with "\:" because of "subject:","author:","message:"
116
            tmp = uman_strsubst(tmp, ":", "%5C%3A");
117
            // 
118
            tmp = uman_strsubst(tmp, ["(",")"], ["{","}"]);
119
            tmp = uman_strsubst(tmp, (d + ["\s*\&\s*\~\{(.+)\}","\&?\s*\~\s*"]) + d, [("+NOT" + s) + "{$1}","+NOT" + s], "r");
120
            tmp = uman_strsubst(tmp, (d + ["\s*\|\s*"]) + d, ["+OR+"], "r");
121
            tmp = uman_strsubst(tmp, (d + ["\s*&\s*","\{\s*?(.+?)\s*\}"]) + d, [s,"($1)"], "r");
122
            if grep(tmp, ((d + "^\") + ["+NOT\+",s]) + d, "r") == [] then
0%0%
123
                tmp = s + tmp;
124
            end
125
        else
126
            tmp = "";
127
        end
128
        tmp = (authors + part(tmp, 2:$)) + max_age;
129
        MailingListsQuery = MailingListsQuery + tmp;
130
        //  DISPLAY
131
        uman_openURL(MailingListsQuery, noWebBrowserMsg);
132
        //  QUIT
133
        return;
134
    end
135
    //  ========================================================================
136
    // 
137
    //  PREPROCESSING "wb" pattern
138
    //  --------------------------
139
    //  The pattern may have from 1 to 4 parts a,b > c < d :
140
    //  $component1|component2:author1|author2>topic1|topic2..<Ndays
141
    components = [];
142
    authors = [];
143
    urlQuery = "";
144
    tmp = strsplit(fun0, ">");
11 ms
145
    if size(tmp, 1) > 1 then
0%100%
146
        trail = strcat(tmp(2:$), ">");
147
        tmp = stripblanks(strsplit(tmp(1), "/"));
148
        if (size(tmp, 1) == 1) & (tmp <> "") then
0%0%
149
            authors = stripblanks(tokens(tmp, "|"));
150
        else
151
            components = stripblanks(tokens(tmp(1), "|"));
152
            if (size(components, 1) == 1) & (components == "") then
0%0%
153
                components = [];
154
            end
155
            authors = stripblanks(tokens(tmp(2), "|"));
156
            if (size(authors, 1) == 1) & (authors == "") then
0%0%
157
                authors = [];
158
            end
159
        end
160
        //  substitutions:
161
        components = strcat(components, ",");
162
        compaliases = (((((((((((((((((("atomssys:atoms,atomsgui:ATOMS GUI," + "atomsportal:Atoms Portal&product=Scilab websites") + "&product=Atoms Portal&component=Miscellaneous,") + "atoms:atoms&component=atoms gui") + "&product=Scilab websites&component=Atoms Portal") + "&product=ATOMS Portal&component=Miscellaneous,") + "api:api_scilab,call:call_scilab,") + "codeimprove:Code improvement,cli:Console as CLI,") + "iodata:Data import/export,demos:Demonstrations,ide:desktop,") + "helppages:Documentation pages,helpsys:Documentation system,") + "link:Dynamic Link,editvar:Editvar/Browsevar,") + "browsevar:Editvar/Browsevar,varbrowser:Editvar/Browsevar,") + "filebrowser:File browser,graphicsexport:Graphics export,") + "io:Input / output,instal:Install,java:Java features,") + "translation:Localization,matlab2scilab:m2sci,matfiles:Mat files,") + "maths:Numerical Math,math:Numerical Math,scipad:Old editor (Scipad),") + "optim:Optimization,") + "parser:Parser/Lexer,parse:Parser/Lexer,lexer:Parser/Lexer,") + "parallel:PVM,editor:SciNotes,stat:Statistics,text:Strings,") + "tests:Tests &amp; Testing system,uicomp:uicontrol";
163
        compaliases = matrix(tokens(compaliases, [",",":"]), 2, -1);
164
        components = uman_strsubst(("," + components) + ",", ("," + compaliases(1, :)) + ",", ("," + compaliases(2, :)) + ",");
165
        components = tokens(components, ",");
166
    else
167
        trail = tmp;
168
    end
169
    //  Components
170
    if components <> [] then
0%100%
171
        urlQuery = urlQuery + strcat(("component=" + components) + "&");
172
    end
173
    //  Authors
174
    i = 1;
175
    for tmp = authors' do
×0
176
        tmp2 = msprintf("f%d=commenter&o%d=substring&v%d=%s&", i, i, i, tmp);
177
        tmp3 = msprintf("f%d=reporter&o%d=substring&v%d=%s&", i + 1, i + 1, i + 1, tmp);
178
        urlQuery = (urlQuery + tmp2) + tmp3;
179
        i = i + 2;
180
    end
181
    if authors <> [] then
0%100%
182
        urlQuery = urlQuery + "j_top=OR&";
183
    end
184
    //  Topic & max_age
185
    tmp = strsplit(trail, "<");
186
    if size(tmp, 1) == 1 then
100%0%
187
        fun0 = stripblanks(trail);
188
    else
189
        if isnum(tmp($)) then
0%0%
190
            fun0 = strcat(tmp(1:($ - 1)), "<");
191
            urlQuery = (urlQuery + msprintf("chfieldfrom=%dd&", evstr(tmp($)))) + "chfieldto=Now&";
192
        else
193
            fun0 = stripblanks(trail);
194
        end
195
    end
196
    //  ========================================================================
197
    //  MERGING DEFAULT OPTIONS
198
    //  -----------------------
199
    if isdef("umanDefaultOptions", "n") then
0%100%
200
        dopt = convstr(umanDefaultOptions);
201
        dopt = uman_strsubst(dopt, ["w","@"], "");
202
        //  "w"|"@" not supported in defaults
203
        [dopt, dLANG] = uman_splitOptionsLang(dopt);
204
        //  Calling options d,e,h,b,a overrides any a|s default ones
205
        if (grep(options, ["d","e","h","b","a","u"]) <> []) & (grep(dopt, ["a","s"]) <> []) then
0%0%
206
            dopt = uman_strsubst(dopt, ["a","s"], "");
207
        end
208
        //  Calling options d,e,h,b,a,s overrides default u
209
        if (grep(options, ["d","e","h","b","a","s"]) <> []) & (grep(dopt, "u") <> []) then
0%0%
210
            dopt = uman_strsubst(dopt, "u", "");
211
        end
212
        //  Calling option u overrides any d,e,h,b,a default ones
213
        if (grep(options, "u") <> []) & (grep(dopt, ["d","e","h","b","a"]) <> []) then
0%0%
214
            dopt = uman_strsubst(dopt, ["d","e","h","b","a"], "");
215
        end
216
        options = options + dopt;
217
    end
218
    //  FINAL LANGUAGE
219
    //  --------------
220
    if LANG == "" then
100%0%
221
        if ~isdef("dLANG", "l") || (dLANG == "") then
100%0%
222
            LANG = part(getlanguage(), 1:2);
223
        else
224
            LANG = dLANG;
225
        end
226
    end
227
    //  OPTIONS ANALYSIS
228
    //  ----------------
229
    fun = fun0;
230
    if grep(options, "a") <> [] then
25%75%
231
        options = strsubst(options, "a", "deh");
232
    end
233
    fun = uman_strsubst(fun, "/^%/", "percent", "r");
1 ms
234
    //  This substitution will have to be cancelled in "wb" mode before calling
235
    //   the bug page. Nevertheless, it is required to search the right page
236
    //   to determine the related module (or scilab) and the related bug page 
237
    //   to be opened.
238
    //  option "s" (summary) kills option "b" (bug), "w" (web) and "@" (mailinglists)
239
    if grep(options, "s") <> [] then
25%75%
240
        options = uman_strsubst(options, ["b","w","@"], "");
241
    end
242
    //  option "u" (usage) kills options d,e,b,h,a,s,g
243
    if grep(options, "u") <> [] then
0%100%
244
        options = uman_strsubst(options, ["d","e","b","h","a","s","g"], "");
245
    end
246
    bugOnWeb = (grep(options, "w") <> []) & (grep(options, "b") <> []);
247
    //  SETTING THE LANGUAGE
248
    //  --------------------
249
    supportedLANG = ["en_US","fr_FR","ja_JP","de_DE","pt_BR","ru_RU","zh_CN","fa_IR"];
250
    i = grep(supportedLANG, ("/^" + LANG) + "_/", "r");
251
    if i == [] then
0%100%
252
        LANG = "en_US";
253
    else
254
        LANG = supportedLANG(i);
255
    end
256
    //  REDIRECTIONS for Symbols. Translation for "%" in fun names
257
    //  ----------------------------------------------------------
258
    if ~bugOnWeb then
25 ms 100%0%
259
        fun = uman_strsubst(fun, ["/\{/","/\}/"], ["[","]"], "r");
11 ms
260
        sub = "assignation,great,  > ,  < ,   [    ,   ]    ,  :  ,   //   ,";
261
        ids = "insertion  ,less ,less,less,brackets,brackets,colon,comments,";
262
        sub = sub + "    <>    ,   ~=     ,   <=     ,   >=     ,";
263
        ids = ids + "comparison,comparison,comparison,comparison,";
264
        sub = sub + "  =  ,    ==    ,";
265
        ids = ids + "equal,comparison,";
266
        //  bug with these ones, due to Scilab parser. 
267
        //  Must be set within quotes: uman "=="
268
        sub = sub + "  &   ,  |  , ~ ,   $  , . , []  ,";
269
        ids = ids + "and_op,or_op,not,dollar,dot,empty,";
270
        //  % automaticaly replaced with percent 
271
        sub = sub + "  -  ,  + ,  * , .* ,  /  , ./  ,  /. , .^  , **  , ^ , .*.,    \    ,";
272
        ids = ids + "minus,plus,star,star,slash,slash,slash,power,power,hat,kron,backslash,";
273
        sub = sub + "    \.     ,     *.    ,    ./.    ,    .\.    ,";
274
        ids = ids + "overloading,overloading,overloading,overloading,";
275
        sub = sub + "  '' ,    ;    ";
276
        ids = ids + "quote,semicolon";
277
        sub = sub + "";
278
        ids = ids + "";
279
        sub = [stripblanks(strsplit(sub, ","));","];
12 ms
280
        ids = [stripblanks(strsplit(ids, ","));"comma"];
2 ms
281
        i = find(fun == sub);
282
        if i <> [] then
0%100%
283
            fun = ids(i(1));
284
        end
285
        if grep(fun, " ") then
0%100%
286
            fun = strsubst(fun, " ", "_");
287
        end
288
    end
289
    //  If the query includes "property" or "properties", "d" description flag 
290
    //   is made mandatory
291
    if (grep(convstr(fun), "propert") <> []) && (grep(options, "d") == []) then
0%100%
292
        options = "d" + options;
293
    end
294
    //  OTHER INITIALISATIONS
295
    //  ---------------------
296
    //  Case sensitivity for the extraction
297
    if convstr(fun) == fun then
50%50%
298
        casse = "-C";
299
        //  case-insensitive
300
    else
301
        casse = "";
302
        //  case-sensitive
303
    end
304
    //  Setting the unzip application vs OS to extract pages from JAR archives
305
    if getos() == "Windows" then
100%0%
306
        unzip = ((pathconvert(SCI + "\tools\zip\") + "unzip.exe ") + casse) + " -o -q ";
307
        // unzip2 = pathconvert(SCI+"\tools\gzip\") + "gzip.exe "
308
    else
309
        unzip = ("unzip " + casse) + " ";
310
    end
311
    //  Miscellaneous init
312
    fs = filesep();
313
    unzippedFile = "";
314
    //  = flag for "File Not Found"
315
    //  Directories storing unzipped HTML files
316
    //  ---------------------------------------
317
    //   Root directory
318
    manDir = pathconvert(SCIHOME + "\uman\");
319
    if fileinfo(manDir) == [] then
0%100%
320
        mkdir(manDir);
321
    end
322
    //  Main directory for Scilab HTML extracted pages
323
    manScilabDir = pathconvert(manDir + "HTML_pages_Scilab\");
324
    if fileinfo(manScilabDir) == [] then
0%100%
325
        mkdir(manScilabDir);
326
        //  only once. Scilab files don't need to be refreshed
327
    end
328
    //  Main directory for ATOMS and other contribs HTML extracted pages
329
    manAtomsDir = pathconvert(manDir + "HTML_pages_Contrib\");
330
    if fileinfo(manAtomsDir) == [] then
0%100%
331
        mkdir(manAtomsDir);
332
    else
333
        //  Refresh option => deleting all extracted HTML pages in manAtomsDir
334
        if grep(options, "r") <> [] then
0%100%
335
            rmdir(manAtomsDir, "s");
336
            mkdir(manAtomsDir);
337
        end
338
    end
339
    //  Listing JAR files: Scilab + ATOMS/Contrib(all_users) + ATOMS/Contrib(user)
340
    //  ==========================================================================
341
    //  We need this part also for bugOnWeb: if the pattern matches an external
342
    //   function (e.g. from ATOMS), the external module must be identified
343
    //   in order to target the right online bug report place
344
    jarListFile = manDir + "jarListe.txt";
345
    i = fileinfo(jarListFile);
1 ms
346
    //  If the list of JAR files does not exist, or if the "r" (reload / refresh) 
347
    //   option is used, we rebuild and record it and re-extract jhelpmap.jhm files :
348
    if (i == []) || (grep(options, "r") <> []) then
0%100%
349
        //  Building the list of JAR files
350
        //  ------------------------------
351
        //  Returns de column of paths to ALL JAR files (not only for LANG or en_US)
352
        function flist = dirjar(path)
353
            //  path must be ended with filesep()
354
            if isdir(path) then
355
                if getos() == "Windows" then
356
                    flist = unix_g(("dir /s /b " + path) + "scilab_*_help.jar 2> nul");
357
                else
358
                    if getos() == "Linux" then
359
                        flist = unix_g(("find " + path) + " -name scilab_*_help.jar 2> /dev/null");
360
                    else
361
                        flist = unix_g(("find 2>/dev/null " + path) + "scilab_*_help.jar");
362
                    end
363
                end
364
                if flist == "" then
365
                    flist = [];
366
                end
367
            else
368
                flist = [];
369
            end
370
        endfunction
371
        //  Let's GO:
372
        jarList = [];
373
        //  Scilab trunk:
374
        path = pathconvert(pathconvert(SCI) + "modules\helptools\jar\");
375
        jarList = [jarList;dirjar(path)];
376
        //  Contrib (ATOMS and others) : ALL USERS
377
        path = pathconvert(pathconvert(SCI) + "contrib\");
378
        jarList = [jarList;dirjar(path)];
379
        //  USER : ATOMS
380
        path = pathconvert(pathconvert(SCIHOME) + "atoms\");
381
        jarList = [jarList;dirjar(path)];
382
        //  USER : other contribs
383
        path = pathconvert(pathconvert(SCIHOME) + "contrib\");
384
        jarList = [jarList;dirjar(path)];
385
        //  OTHER PATHS provided in umanUserPaths
386
        global("umanUserPaths");
387
        if (umanUserPaths <> []) & (type(umanUserPaths) == 10) then
0%0%
388
            for p = umanUserPaths(:)' do
×0
389
                if isdir(p) then
0%0%
390
                    jarList = [jarList;dirjar(pathconvert(p))];
391
                end
392
            end
393
        end
394
        //  Recording the list:
395
        csvWrite(jarList, jarListFile, ascii(9));
396
    else
397
        jarList = mgetl(jarListFile);
398
    end
399
    //  Various initializations
400
    //  -----------------------
401
    module = "";
402
    clang = getlanguage();
403
    //  Extraction of jhelpmap.jhm files
404
    //  ================================
405
    //  as well needed by the "wb" option (for forge's tickets)
406
    //  Directory storing jhelpmap.jhm files renamed as moduleName_la_RG.jhm
407
    //   or scilab_la_RG.jhm, where la_RG is the language_ReGion code (en_US, etc)
408
    jhmListFile = manDir + "jhmListe.txt";
409
    mapDir = (manDir + "jhelpMaps") + fs;
410
    if ~isdir(mapDir) then
0%100%
411
        mkdir(mapDir);
412
        mkdir((mapDir + "scilab") + fs);
413
        //  subdir for fixed scilab_la_RG.jhm files
414
    else
415
        if grep(options, "r") <> [] then
0%100%
416
            mdelete(mapDir + "*.jhm");
417
        end
418
    end
419
    if (i == []) || (grep(options, "r") <> []) then
0%100%
420
        //  From the list of selected JAR files, for each file, extracts its 
421
        //   jhelpmap.jhm in a common directory, and renames it according to the
422
        //   module AND language tag.
423
        //  "unzip" includes the options -C: case-insensitive -o: overwrite -q: quiet
424
        fs = filesep();
425
        pattern = pathconvert("\modules\helptools\jar\scilab_", %F);
426
        jhmListe = [];
427
        for jar = jarList' do
×0
428
            //  Module name related to the .jar file = ?
429
            if grep(jar, pattern) <> [] then
0%0%
430
                module = "scilab";
431
            else
432
                //  The name of the module (such as stored in %helps(:,2))
433
                //   is retrieved through the file name ~\etc\modulename.start
434
                tmp = fullpath((dirname(jar) + fs) + "..\etc\*.start");
435
                tmp = dir(tmp);
436
                startfile = tmp.name(1);
437
                module = basename(startfile);
438
            end
439
            lang = uman_strsubst(jar, "|.*?_([a-z]{2}_[A-Z]{2})_help.jar|", "$1", "r");
440
            subDir = (("scilab_" + lang) + "_help") + fs;
441
            zippedMap = subDir + "jhelpmap.jhm";
442
            if getos() == "Windows" then
0%0%
443
                jar = getshortpathname(jar);
444
                //  strips blanks from the path
445
            end
446
            // command = unzip + """"+jar + """ """ + zippedMap + """ -d """+manDir+""""
447
            command = (((unzip + jar) + " ") + zippedMap) + " -d ";
448
            if module == "scilab" then
0%0%
449
                command = command + manScilabDir;
450
                unzippedMapFrom = (manScilabDir + subDir) + "jhelpmap.jhm";
451
                unzippedMapTo = (((("scilab" + fs) + module) + "_") + lang) + ".jhm";
452
            else
453
                command = command + manAtomsDir;
454
                unzippedMapFrom = (manAtomsDir + subDir) + "jhelpmap.jhm";
455
                unzippedMapTo = ((module + "_") + lang) + ".jhm";
456
            end
457
            status = host(command);
458
            [s, m] = movefile(unzippedMapFrom, mapDir + unzippedMapTo);
459
            jhmListe = [jhmListe;[module,unzippedMapTo,jar]];
460
        end
461
        //  Removing duplicates .jhm: the last is kept (has overwritten previous ones)
462
        jhmListe = jhmListe($:1, :);
463
        [tmp, k] = unique(jhmListe(:, 2));
464
        jhmListe = jhmListe(gsort(k, "g", "i"), :);
465
        csvWrite(jhmListe, jhmListFile);
466
    else
467
        jhmListe = csvRead(jhmListFile, [], [], "string");
468
    end
469
    //  Building 2 lists of jhmHelpMaps, ordered by lang: 
470
    //    1) for Scilab   2) for external modules 
471
    //  =================================================
472
    function k = uman_orderJhmHMapsByLang(c, external?)
473
        //  c = jhmListe(:,2) : column of module_##_##.jhm names
474
        //  external? : boolean %T whether only external modules are considered
475
        //                      %T whether only native Scilab is considered
476
        //  LANG and clang external contextual variables are used.
477
        // 
478
        //  The language has priority:
479
        //  Chosen language (or default)
480
        if external? then
481
            //  Chosen language (or default)
482
            k = grep(c, ((("|^[^\" + fs) + "]+_") + LANG) + "\.jhm|", "r");
483
            //  Otherwise: Session's language
484
            if clang <> LANG then
485
                k = [k,grep(c, ((("|^[^\" + fs) + "]+_") + clang) + "\.jhm|", "r")];
486
            end
487
            //  Otherwise, finally: en_US
488
            if (LANG <> "en_US") & (clang <> "en_US") then
489
                k = [k,grep(c, ("|^[^\" + fs) + "]+_en_US\.jhm|", "r")];
490
            end
491
        else
492
            k = find(c == (((("scilab" + fs) + "scilab_") + LANG) + ".jhm"));
493
            if clang <> LANG then
494
                k = [k,find(c == (((("scilab" + fs) + "scilab_") + clang) + ".jhm"))];
495
            end
496
            if (LANG <> "en_US") & (clang <> "en_US") then
497
                k = [k,find(c == (("scilab" + fs) + "scilab_en_US.jhm"))];
498
            end
499
        end
500
    endfunction
501
    //  Scilab list:
502
    k = find(jhmListe(:, 1) == "scilab");
503
    tmp = jhmListe(k, :);
504
    k2 = uman_orderJhmHMapsByLang(tmp(:, 2), %F);
505
    jhmScilab = jhmListe(k(k2), :);
506
    //  List for external modules (ATOMS & contribs):
507
    k = find(jhmListe(:, 1) <> "scilab");
508
    tmp = jhmListe(k, :);
509
    if tmp <> [] then
10 ms 100%0%
510
        k2 = uman_orderJhmHMapsByLang(tmp(:, 2), %T);
10 ms
511
        jhmModules = jhmListe(k(k2), :);
512
    else
513
        jhmModules = [];
514
    end
515
    //  SEARCHING FOR THE RIGHT HELP TARGET (module, page, local macro, web pointer)
516
    //  ===================================
517
    htmlName = "";
518
    localMacro = "";
519
    webId = "";
520
    //  Id for an ATOMS, a FE, or another external ressource
521
    jhmLine = [];
522
    if casse == "-C" then
50%50%
523
        grepCase = "i";
524
    else
525
        grepCase = "";
526
    end
527
    if grep(fun, ["|","/","\","*",":","[","("]) == [] then
539.005 ms 100%0%
528
        //  Priorities: Scilab > external modules > local macro > web pointer
529
        //  -----------------------------------------------------------------
530
        funR = "";
531
        if grep(options, "x") == [] then
539.005 ms 100%0%
532
            //  PRIORITIES for Soft mormal mode AND "x"==[] :
533
            //  (Shortcuts)Scilab
534
            //  (ex2in) Scilab
535
            //  Modules 
536
            //  local
537
            //  (ex2ex) Modules
538
            //  (ex2key) Scilab
539
            [fun1s, optmp] = uman_get_equiv(fun, options, "shortcuts");
82.001 ms
540
            [htmlName, jhmLine] = uman_findItemInJHelpMaps(fun1s, jhmScilab, mapDir, grepCase);
457.003 ms
541
            if htmlName == "" then
0%100%
542
                //  (ex2in) Scilab
543
                [fun2s, optmp] = uman_get_equiv(fun, options, "ex2in");
544
                if fun2s <> fun1s then
0%0%
545
                    [htmlName, jhmLine] = uman_findItemInJHelpMaps(fun2s, jhmScilab, mapDir, grepCase);
546
                    if htmlName <> "" then
0%0%
547
                        funR = fun2s;
548
                        options = optmp;
549
                    end
550
                end
551
            else
552
                funR = fun1s;
553
                options = optmp;
554
            end
555
            //  Modules
556
            if (htmlName == "") && (jhmModules <> []) then
0%100%
557
                [htmlName, jhmLine] = uman_findItemInJHelpMaps(fun, jhmModules, mapDir, grepCase);
558
                if htmlName <> "" then
0%0%
559
                    funR = fun;
560
                end
561
            end
562
            //  Local
563
            if htmlName == "" then
0%100%
564
                localMacro = uman_find_localMacro(fun);
565
                if localMacro <> "" then
0%0%
566
                    funR = fun;
567
                end
568
            end
569
            //  (ex2ex) Modules
570
            if ((htmlName == "") && (localMacro == "")) && (jhmModules <> []) then
0%100%
571
                [fun2m, optmp] = uman_get_equiv(fun, options, "ex2ex");
572
                if fun2m <> fun then
0%0%
573
                    [htmlName, jhmLine] = uman_findItemInJHelpMaps(fun2m, jhmModules, mapDir, grepCase);
574
                    if htmlName <> "" then
0%0%
575
                        funR = fun2m;
576
                        options = optmp;
577
                    end
578
                end
579
            end
580
            //  RESULTS: If htmlName=="" & localMacro=="" then funR==""
581
            //   otherwise funR~=""
582
        else
583
            //  "x": ------------------------------------------------------------
584
            //  PRIORITIES for Soft normal mode AND "x" :
585
            //  Modules
586
            //  (faux-amis)(ex2in) Scilab
587
            //  (ex2ex) Modules
588
            //  local
589
            //  (shortcuts) Scilab
590
            //  (ex2key) Scilab
591
            //  Modules
592
            if jhmModules <> [] then
0%0%
593
                [htmlName, jhmLine] = uman_findItemInJHelpMaps(fun, jhmModules, mapDir, grepCase);
594
            end
595
            //  (faux-amis)(ex2in) Scilab
596
            if htmlName == "" then
0%0%
597
                [fun1s, optmp] = uman_get_equiv(fun, options, "exin2in");
598
                [fun1s, optmp] = uman_get_equiv(fun1s, options, "ex2in");
599
                [htmlName, jhmLine] = uman_findItemInJHelpMaps(fun1s, jhmScilab, mapDir, grepCase);
600
                if htmlName <> "" then
0%0%
601
                    funR = fun1s;
602
                    options = optmp;
603
                end
604
            end
605
            //  (ex2ex) Modules 
606
            if (htmlName == "") & (jhmModules <> []) then
0%0%
607
                [fun1m, optmp] = uman_get_equiv(fun, options, "ex2ex");
608
                [htmlName, jhmLine] = uman_findItemInJHelpMaps(fun1m, jhmModules, mapDir, grepCase);
609
                if htmlName <> "" then
0%0%
610
                    funR = fun1m;
611
                    options = optmp;
612
                end
613
            end
614
            //  local
615
            if htmlName == "" then
0%0%
616
                localMacro = uman_find_localMacro(fun);
617
                if localMacro <> "" then
0%0%
618
                    funR = fun;
619
                end
620
            end
621
            //  (shortcuts) Scilab
622
            if (htmlName == "") & (localMacro == "") then
0%0%
623
                [fun2s, optmp] = uman_get_equiv(fun, options, "shortcuts");
624
                if fun2s <> fun1s then
0%0%
625
                    [htmlName, jhmLine] = uman_findItemInJHelpMaps(fun2s, jhmScilab, mapDir, grepCase);
626
                    if htmlName <> "" then
0%0%
627
                        funR = fun2s;
628
                        options = optmp;
629
                    end
630
                end
631
            end
632
        end
633
        //  if "x"
634
        //  (ex2key) Scilab (common to "x" & ~"x" at the end):
635
        if (htmlName == "") && (localMacro == "") then
0%100%
636
            [fun3, optmp] = uman_get_equiv(fun, options, "ex2key");
637
            funR = fun3;
638
            options = optmp;
639
        end
640
        fun = funR;
641
    end
642
    //  Module identification & informations (atoms, forge, website)
643
    //  ------------------------------------------------------------
644
    module = "";
645
    if jhmLine <> [] then
100%0%
646
        module = jhmLine(1);
647
    end
648
    //  
649
    AF = uman_get_atoms_forge();
143.001 ms
650
    AFid = AF(:, 2);
1 ms
651
    webRef = [];
652
    if module <> "scilab" then
0%100%
653
        k = [];
654
        if module <> "" then
0%0%
655
            k = find(AFid == module);
656
            if k == [] then
0%0%
657
                k = find(convstr(AFid) == convstr(module));
658
            end
659
        else
660
            if fun == convstr(fun) then
0%0%
661
                k = find(convstr(AFid) == fun);
662
            else
663
                k = find(AFid == fun);
664
            end
665
            if k == [] then
0%0%
666
                //  We then try after redirection:
667
                fun1e = uman_get_equiv(fun, options, "ex2ex");
668
                if fun1e == convstr(fun1e) then
0%0%
669
                    k = find(convstr(AFid) == fun1e);
670
                else
671
                    k = find(AFid == fun1e);
672
                end
673
            end
674
        end
675
        if k <> [] then
0%0%
676
            webRef = AF(k, :);
677
            //  1: type  2: module_id  3: forge_id  4: website
678
            module = webRef(2);
679
        end
680
    end
681
    //  List of installed ATOMS modules
682
    //  -------------------------------
683
    atomsInstalled = atomsGetInstalled();
42 ms
684
    if atomsInstalled <> [] then
100%0%
685
        atomsInstalled(:, 4) = getshortpathname(pathconvert(atomsInstalled(:, 4)));
686
    end
687
    isATOMSinstalled = find(atomsInstalled(:, 1) == module) <> [];
688
    //  Now we have:
689
    //  -----------
690
    //  htmlName: the HTML reference to extract (if found)
691
    //  module  : the name of the external module (if relevant)
692
    //  isATOMSinstalled : boolean about the module (if any)
693
    //  localMacro: the name of the local macro (if it exists)
694
    //  For "wb", required infos are now available => DISPLAY
695
    //  ========================================================================
696
    //  BUGZILLA | TICKET / FORGE | WEBSITE
697
    //  ===================================
698
    //  Default place for Scilab or mixed items:
699
    //   "&o1=regexp&f1=short_desc&v1=(^|[^a-zA-Z_])£([^0-9a-zA-Z_%3D%3B]|$)"+..
700
    BugzillaSearch = ((("http://bugzilla.scilab.org/buglist.cgi" + "?product=Scilab software&query_format=advanced") + "&short_desc_type=regexp&short_desc=(^|[^a-zA-Z_])£([^0-9a-zA-Z_%3D%3B]|$)") + "&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED") + "&bug_status=RESOLVED&";
701
    //  £ will be replaced with the item name
702
    //     if %t | urlQuery==""
703
    BugzillaSearch = (BugzillaSearch + urlQuery) + "order=resolution,bug_id DESC";
704
    //     else
705
    //         BugzillaSearch = BugzillaSearch + urlQuery + ..
706
    //                         "order=changeddate DESC%2Cbug_id DESC&"
707
    //     end
708
    BugReport = "";
709
    if bugOnWeb then
0%100%
710
        //  Bug number provided: no other infos required => Display
711
        //  -------------------------------------------------------
712
        if grep(fun0, "/^[0-9]+$/", "r") == 1 then
0%0%
713
            //  item = bug number
714
            url = "http://bugzilla.scilab.org/" + fun0;
715
            uman_openURL(url, noWebBrowserMsg);
716
            return;
717
        end
718
        //  Setting the right bug report place for externals
719
        //  ------------------------------------------------
720
        //  ATOMS modules registered for "uman"
721
        if (module <> "scilab") && (webRef <> []) then
0%0%
722
            //  If the external module is an ATOMS with a public forge: 
723
            //  Tickets are on it
724
            if webRef(3) <> "" then
0%0%
725
                BugReport = ("http://forge.scilab.org/index.php/p/" + webRef(3)) + "/issues/";
726
                BugzillaSearch = BugReport + "search/?q=";
727
                if htmlName <> "" then
0%0%
728
                    BugzillaSearch = BugzillaSearch + fun;
729
                else
730
                    BugzillaSearch = BugzillaSearch + fun0;
731
                end
732
            else
733
                //  If in ATOMS (without forge): => we target ATOMS comments
734
                if webRef(1) == "a" then
0%0%
735
                    tmp = ("http://atoms.scilab.org/toolboxes/" + module) + "/#comments_remove";
736
                else
737
                    if webRef(1) == "fe" then
0%0%
738
                        //  FileExchange
739
                        tmp = stripblanks(webRef(4)) + "/#comments_remove";
740
                    else
741
                        if webRef(1) == "fo" then
0%0%
742
                            //  Forge without ATOMS
743
                            tmp = ("http://forge.scilab.org/index.php/p/" + stripblanks(webRef(2))) + "/issues/search/?q=";
744
                            if htmlName <> "" then
0%0%
745
                                tmp = tmp + fun;
746
                            else
747
                                tmp = tmp + fun0;
748
                            end
749
                        else
750
                            //  Otherwise we target verbatim the indicated website
751
                            tmp = stripblanks(webRef(4));
752
                        end
753
                    end
754
                end
755
                BugReport = tmp;
756
                BugzillaSearch = tmp;
757
            end
758
            //  Installed ATOMS module BUT unregistered for uman:
759
        else
760
            if isATOMSinstalled then
0%0%
761
                tmp = ("http://atoms.scilab.org/toolboxes/" + module) + "/#comments_remove";
762
                BugReport = tmp;
763
                BugzillaSearch = tmp;
764
                //  Other Contrib modules
765
            else
766
                if (module <> "scilab") && (htmlName <> "") then
0%0%
767
                    BugzillaSearch = "";
768
                end
769
            end
770
        end
771
        if BugzillaSearch <> "" then
0%0%
772
            fun = strsubst(fun, "/^percent/", "%", "r");
773
            // symbols = "><[]:<>~=<=>==&|$.**-+././.^.*.\.'';"
774
            if grep(fun, "/") <> [] then
0%0%
775
                delim = "!";
776
            else
777
                delim = "/";
778
            end
779
            tmp = uman_strsubst(fun, (delim + ["\\","&","\*","\.","\-","\:","\|\|","\]","\[","\(","\)","\$","\^","/"]) + delim, ["\\\\","%26","\\*","\\.","\\-","\\:","\\|\\|","\\]","\\[","\\(","\\)","\\%24","\\^","%2F"], "r");
780
            if tmp <> fun then
0%0%
781
                if tmp == "" then
0%0%
782
                    tmp = ".*";
783
                end
784
                url = strsubst(BugzillaSearch, "£", ("(" + tmp) + ")");
785
                //  tmp must be () in case of it has some | alternatives
786
            else
787
                tmp = fun0;
788
                if fun0 == "" then
0%0%
789
                    tmp = ".*";
790
                end
791
                url = strsubst(BugzillaSearch, "£", ("(" + tmp) + ")");
792
            end
793
            uman_openURL(url, noWebBrowserMsg);
794
        else
795
            //  NO SITE TO SEE BUGS....
796
        end
797
        return;
798
    end
799
    //  ========================================================================
800
    //  Targetting ONLINE help page (or site)
801
    //  =====================================
802
    printWeb = ((grep(options, "w") <> []) & (grep(options, "b") == [])) | ((unzippedFile == "") & (grep(options0, "w") <> []));
803
    if printWeb then
0%100%
804
        url = "";
805
        if webRef <> [] then
0%0%
806
            //  ATOMS module => open the ATOMS page
807
            if webRef(1) == "a" then
0%0%
808
                url = "https://atoms.scilab.org/toolboxes/" + webRef(2);
809
                //  FileExchange => open the FE page
810
            else
811
                if webRef(1) == "fe" then
0%0%
812
                    url = webRef(4);
813
                    //  Forge with no ATOMS => open the Forge home page
814
                else
815
                    if webRef(1) == "fo" then
0%0%
816
                        url = "http://forge.scilab.org/index.php/p/" + webRef(2);
817
                        //  Other external resource
818
                    else
819
                        url = webRef(4);
820
                    end
821
                end
822
            end
823
        else
824
            if or(module == ["","scilab"]) then
0%0%
825
                url = "https://help.scilab.org/docs/current/";
826
                supported_online = ["en_US","fr_FR","pt_BR","ru_RU","ja_JP"];
827
                if and(LANG <> supported_online) then
0%0%
828
                    langH = "en_US";
829
                else
830
                    langH = LANG;
831
                end
832
                //  if unzippedFile~=""
833
                if htmlName <> "" then
0%0%
834
                    //  url = url+langH+"/"+fun+".html"
835
                    //  url = url+langH+"/"+basename(unzippedFile)+".html"
836
                    //  For Type, Equal, etc: URL(web) ~= URL(jHelpMap):
837
                    if grep(htmlName, "/.+\-[0-9a-f]{32}\.html/", "r") then
0%0%
838
                        htmlName = strsubst(htmlName, "/\-[0-9a-f]{32}/", "", "r");
839
                    end
840
                    url = ((url + langH) + "/") + htmlName;
841
                else
842
                    //  query example: "cholesky+factorization"+AND+factors
843
                    url = ((url + langH) + "/search/") + fun0;
844
                end
845
            end
846
        end
847
        if url <> "" then
0%0%
848
            uman_openURL(url, noWebBrowserMsg);
849
        else
850
            disp("NO WEB REFERENCE AVAILABLE");
851
        end
852
        //  We don't return, because the "w" allows also "g"
853
    end
854
    //  ========================================================================
855
    //  Setting the flag allowing to target the console
856
    //  ...............................................
857
    //   - whatever is the "g" status (can duplicate the output)
858
    //   - whether "w" is not used, OR (NOT "wb" AND NOT Scilab module)
859
    printConsole = (grep(options, ["w","@"]) == []) | (~bugOnWeb & (module <> "scilab"));
860
    if printConsole && (grep(options, "j") == []) then
100%0%
861
        diary([], "pause");
862
        //  http://bugzilla.scilab.org/show_bug.cgi?id=12551
863
    end
864
    noContent = %F;
865
    //  set it to %t if [pattern] has no dedicated page
866
    //  HTML Page's extraction, if needed and not yet in cache
867
    //  ------------------------------------------------------
868
    if htmlName <> "" then
100%0%
869
        jar = jhmLine(3);
870
        //  JAR file that htmlName belongs to
871
        [tmp, tmp, tmp, lang] = regexp(jhmLine(2), "|_(.._..)\.jhm|");
872
        subDir = ("scilab_" + lang) + "_help";
873
        //  is the HTML of this jar unzipped ?
874
        zippedFile = (subDir + fs) + htmlName;
875
        if module == "scilab" then
100%0%
876
            outDir = manScilabDir;
877
            //  ended with / 
878
        else
879
            //  ATOMS and other contribs are mixed
880
            outDir = manAtomsDir;
881
            //  idem
882
        end
883
        unzipped = ((outDir + subDir) + fs) + htmlName;
884
        if isfile(unzipped) && (grep(options, "r") == []) then
100%0%
885
            unzippedFile = unzipped;
886
        else
887
            if isfile(unzipped) then
0%0%
888
                deletefile(unzipped);
889
            end
890
            if jar <> [] then
0%0%
891
                //  We extract the HTML file:
892
                command = ((((unzip + jar) + " ") + zippedFile) + " -d ") + outDir;
893
                status = host(command);
894
                if status == 0 then
0%0%
895
                    //  file found and extracted
896
                    unzippedFile = unzipped;
897
                end
898
            else
899
                status = 9;
900
                //  zip file not found
901
            end
902
        end
903
    end
904
    //  -------------------------------------------------------
905
    //  The required help file exists...
906
    //  --------------------------------
907
    if unzippedFile <> "" then
3.077 s 100%0%
908
        //  we go on on processing
909
        r = uman_grab(unzippedFile, fun, LANG);
2.937 s
910
        r.fun = fun0;
911
        //  Targetting the console
912
        //  ......................
913
        msg2 = "";
914
        if printConsole then
140 ms 100%0%
915
            if grep(options, "c") <> [] then
10 ms 25%75%
916
                clc();
10 ms
917
            else
918
                if grep(options, "u") == [] then
100%0%
919
                    //  separating zone
920
                    tmp = lines();
921
                    write(%io(2), part("=", ones(1, tmp(1))));
922
                end
923
            end
924
            //  item's page
925
            //  - - - - - -
926
            msg0 = "";
927
            if grep(options, "s") == [] then
130 ms 75%25%
928
                if module <> "scilab" then
0%100%
929
                    if webRef(1) == "a" then
0%0%
930
                        r.bug_report = BugReport;
931
                        r.bugs_known = BugzillaSearch;
932
                    else
933
                        r.bug_report = "";
934
                        r.bugs_known = "";
935
                    end
936
                end
937
                //  Display of the proper help page
938
                uman_disp(r, options);
70 ms
939
                //  Parent summary
940
                //  - - - -- - - -
941
            else
942
                tmp = strsplit(unzippedFile, fs);
943
                zippedFile = ((tmp($ - 1) + fs) + r.parentSummary) + ".html";
944
                tmp = strsplit(unzippedFile, fs);
10 ms
945
                outDir = strcat(tmp(1:($ - 2)), fs);
946
                unzippedFile = ((dirname(unzippedFile) + fs) + r.parentSummary) + ".html";
947
                if fileinfo(unzippedFile) == [] then
0%100%
948
                    command = ((((unzip + jar) + " ") + zippedFile) + " -d ") + outDir;
949
                    status = host(command);
950
                    //  status==0  <=> OK
951
                end
952
                //  Parsing the summary page ++++++++++++++++++++++++++
953
                html = mgetl(unzippedFile);
954
                search = ["<html>";
955
                          "<body>";
956
                          "<head>.*?</head>";
957
                          "<div class=""manualnavbar"">.*?</div>";
958
                          "</body>";
959
                          "</html>";
960
                          "<br />"];
961
                search = ("|" + search) + "|";
962
                replace = ["<div>","","","","","</div>",ascii(10)];
963
                html2 = uman_strsubst(strcat(html, " "), search, replace, "r");
964
                tmp = xmlReadStr(html2);
965
                simpleContent = %T;
966
                //  If language = ja|zh: we must assess the fraction of content in
967
                //  in japanese|chinese vs latin, in order to tune the average 
968
                //  character width used to wrap long lines
969
                lang = part(LANG, 1:2);
970
                if or(lang == ["ja","zh"]) then
0%100%
971
                    tmp2 = tmp.root.children(3).content;
972
                    //  <ul> list
973
                    RelCharWidth = uman_setRelCharWidth(tmp2, lang);
974
                end
975
                text = uman_xml2txt(tmp.root, " ");
50 ms
976
                tmp2 = strsplit(text(1), ">");
977
                if grep(tmp2(1), "Scilab") <> [] then
100%0%
978
                    tmp2(1) = "Scilab";
979
                end
980
                tmp2 = stripblanks(tmp2);
981
                tmp2(find(tmp2 == "")) = [];
982
                if (size(tmp2, "*") > 1) && (tmp2(1) == tmp2(2)) then
0%100%
983
                    tmp2(2) = [];
984
                end
985
                text(1) = strcat(tmp2, " > ") + ascii(10);
986
                text(2) = [];
987
                //  Removing extra blank lines in deepest sub-blocks
988
                i = find(text == " ");
989
                text(i) = [];
990
                //  Displaying the summary page +++++++++++++++++++++++
991
                write(%io(2), text);
992
                xmlDelete(tmp);
993
            end
994
            //  targeting the console
995
        end
996
    else
997
        //  The required help file DOES NOT EXIST
998
        //  -------------------------------------
999
        if grep(options, "w") == [] then
0%0%
1000
            //  Local macro:
1001
            //  -----------
1002
            if localMacro <> "" then
0%0%
1003
                if grep(options, "c") <> [] then
0%0%
1004
                    clc();
1005
                    mprintf("-> uman %s %s\n\n", fun0, options0);
1006
                end
1007
                head_comments(localMacro);
1008
                //  
1009
            else
1010
                //  No dedicated page
1011
                //  ----------------- 
1012
                msg = _("uman", " %s: ""%s"" has no dedicated page.\n");
1013
                mprintf(msg, "uman", fun0);
1014
                if webRef <> [] then
0%0%
1015
                    msg = _("uman %s w%s // should work.\n");
1016
                    mprintf(msg, fun0, options0);
1017
                end
1018
                noContent = %T;
1019
            end
1020
        end
1021
    end
1022
    if printConsole && (grep(options, "j") == []) then
100%0%
1023
        diary([], "resume");
1024
        //  http://bugzilla.scilab.org/12551
1025
    end
1026
    msg1 = "";
1027
    //  Using the helpbrowser
1028
    //  =====================
1029
    //  Must be after print in console => xml_grab() called and got r.parentsummary
1030
    if grep(options, "g") <> [] then
0%100%
1031
        global("%helps");
1032
        if ((module == "scilab") | (isATOMSinstalled & atomsIsLoaded(module))) | (find(convstr(%helps(:, 2)) == convstr(module)) <> []) then
0%0%
1033
            //  call the help browser in the chosen language
1034
            if grep(options, "s") <> [] then
0%0%
1035
                tmp = r.parentSummary;
1036
            else
1037
                if htmlName <> "" then
0%0%
1038
                    tmp = basename(htmlName);
1039
                end
1040
            end
1041
            helpbrowser(%helps(:, 1), tmp, LANG, %F);
1042
            //  fun = raw pattern => litteral search with the help browser            
1043
        else
1044
            if module == "" then
0%0%
1045
                //  For "g" and "w" options, the final target must be set
1046
                //  -----------------------------------------------------
1047
                //   - if not "x": any equivalence is used
1048
                //   - if "x": the initial fun0 is used
1049
                if grep(options, "x") == [] then
0%0%
1050
                    helpbrowser(%helps(:, 1), fun, LANG, %F);
1051
                    if fun <> fun0 then
0%0%
1052
                        msg1 = _("uman", " uman %s %s // used. Run: uman %s x%s // to really target ""%s""\n");
1053
                        msg1 = msprintf(msg1, fun, options0, fun0, options0, fun0);
1054
                    end
1055
                else
1056
                    helpbrowser(%helps(:, 1), fun0, LANG, %F);
1057
                    tmp = uman_get_equiv(fun0, options, "scilabFirst");
1058
                    //  | "ex2ex" | "exin2in"         
1059
                    if tmp <> fun0 then
0%0%
1060
                        msg1 = _("uman", " You may try: uman %s %s\n");
1061
                        msg1 = msprintf(msg1, tmp, strsubst(options, "x", ""));
1062
                    end
1063
                end
1064
            else
1065
                if module <> "" then
0%0%
1066
                    //  module known but unloaded
1067
                    msg1 = _("uman", " [%s] module NOT LOADED => UNVAILABLE in HELP BROWSER\n");
1068
                    msg1 = msprintf(msg1, module);
1069
                end
1070
            end
1071
        end
1072
    end
1073
    //  Display of messages
1074
    //  ===================
1075
    msg2 = "";
1076
    if (((grep(options, "w") <> []) && (module <> "")) && (module <> "scilab")) && (webRef(1) == "a") then
0%100%
1077
        msg2 = ((" [" + module) + "] ") + _("uman", "module EXTERNAL   => ONLINE help page UNAVAILABLE");
1078
    end
1079
    tmp = " " + part("-~", ones(1, max(length([msg1,msg2])) / 2) .*. [1,2]);
1080
    if (tmp <> "") && ((msg1 <> "") || (msg2 <> "")) then
0%100%
1081
        msg0 = (((" uman " + fun0) + " ") + options0) + " :";
1082
        if ~noContent then
0%0%
1083
            write(%io(2), tmp);
1084
            if msg0 <> "" then
0%0%
1085
                write(%io(2), msg0);
1086
            end
1087
        end
1088
        if msg1 <> "" then
0%0%
1089
            write(%io(2), msg1);
1090
        end
1091
        if msg2 <> "" then
0%0%
1092
            write(%io(2), msg2);
1093
        end
1094
        if ~noContent then
0%0%
1095
            write(%io(2), tmp);
1096
        end
1097
    end
1098
endfunction