OpenCoverage

help.def

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/help.def
Source codeSwitch to Preprocessed file
LineSourceCount
1This file is help.def, from which is created help.c.-
2It implements the builtin "help" in Bash.-
3-
4Copyright (C) 1987-2015 Free Software Foundation, Inc.-
5-
6This file is part of GNU Bash, the Bourne Again SHell.-
7-
8Bash is free software: you can redistribute it and/or modify-
9it under the terms of the GNU General Public License as published by-
10the Free Software Foundation, either version 3 of the License, or-
11(at your option) any later version.-
12-
13Bash is distributed in the hope that it will be useful,-
14but WITHOUT ANY WARRANTY; without even the implied warranty of-
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
16GNU General Public License for more details.-
17-
18You should have received a copy of the GNU General Public License-
19along with Bash. If not, see <http://www.gnu.org/licenses/>.-
20-
21$PRODUCES help.c-
22-
23$BUILTIN help-
24$FUNCTION help_builtin-
25$DEPENDS_ON HELP_BUILTIN-
26$SHORT_DOC help [-dms] [pattern ...]-
27Display information about builtin commands.-
28-
29Displays brief summaries of builtin commands. If PATTERN is-
30specified, gives detailed help on all commands matching PATTERN,-
31otherwise the list of help topics is printed.-
32-
33Options:-
34 -d output short description for each topic-
35 -m display usage in pseudo-manpage format-
36 -s output only a short usage synopsis for each topic matching-
37 PATTERN-
38-
39Arguments:-
40 PATTERN Pattern specifying a help topic-
41-
42Exit Status:-
43Returns success unless PATTERN is not found or an invalid option is given.-
44$END-
45-
46#include <config.h>-
47-
48#if defined (HELP_BUILTIN)-
49#include <stdio.h>-
50-
51#if defined (HAVE_UNISTD_H)-
52# ifdef _MINIX-
53# include <sys/types.h>-
54# endif-
55# include <unistd.h>-
56#endif-
57-
58#include <errno.h>-
59-
60#include <filecntl.h>-
61#include <stddef.h>-
62-
63#include "../bashintl.h"-
64-
65#include "../shell.h"-
66#include "../builtins.h"-
67#include "../execute_cmd.h"-
68#include "../pathexp.h"-
69#include "common.h"-
70#include "bashgetopt.h"-
71-
72#include <glob/strmatch.h>-
73#include <glob/glob.h>-
74-
75#ifndef errno-
76extern int errno;-
77#endif-
78-
79extern const char * const bash_copyright;-
80extern const char * const bash_license;-
81-
82static void show_builtin_command_help __P((void));-
83static int open_helpfile __P((char *));-
84static void show_desc __P((char *, int));-
85static void show_manpage __P((char *, int));-
86static void show_longdoc __P((int));-
87-
88/* Print out a list of the known functions in the shell, and what they do.-
89 If LIST is supplied, print out the list which matches for each pattern-
90 specified. */-
91int-
92help_builtin (list)-
93 WORD_LIST *list;-
94{-
95 register int i;-
96 char *pattern, *name;-
97 int plen, match_found, sflag, dflag, mflag, m, pass, this_found;-
98-
99 dflag = sflag = mflag = 0;-
100 reset_internal_getopt ();-
101 while ((i = internal_getopt (list, "dms")) != -1)
(i = internal_... "dms")) != -1Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
102 {-
103 switch (i)-
104 {-
105 case 'd':
never executed: case 'd':
0
106 dflag = 1;-
107 break;
never executed: break;
0
108 case 'm':
never executed: case 'm':
0
109 mflag = 1;-
110 break;
never executed: break;
0
111 case 's':
never executed: case 's':
0
112 sflag = 1;-
113 break;
never executed: break;
0
114 CASE_HELPOPT;
never executed: return (258);
never executed: case -99:
0
115 default:
never executed: default:
0
116 builtin_usage ();-
117 return (EX_USAGE);
never executed: return (258);
0
118 }-
119 }-
120 list = loptend;-
121-
122 if (list == 0)
list == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
123 {-
124 show_shell_version (0);-
125 show_builtin_command_help ();-
126 return (EXECUTION_SUCCESS);
executed 1 time by 1 test: return (0);
Executed by:
  • Self test
1
127 }-
128-
129 /* We should consider making `help bash' do something. */-
130-
131 if (glob_pattern_p (list->word->word))
glob_pattern_p...t->word->word)Description
TRUEnever evaluated
FALSEnever evaluated
0
132 {-
133 printf ("%s", ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1)));-
134 print_word_list (list, ", ");-
135 printf ("'\n\n");-
136 }
never executed: end of block
0
137-
138 for (match_found = 0, pattern = ""; list; list = list->next)
listDescription
TRUEnever evaluated
FALSEnever evaluated
0
139 {-
140 pattern = list->word->word;-
141 plen = strlen (pattern);-
142-
143 for (pass = 1, this_found = 0; pass < 3; pass++)
pass < 3Description
TRUEnever evaluated
FALSEnever evaluated
0
144 {-
145 for (i = 0; name = shell_builtins[i].name; i++)
name = shell_builtins[i].nameDescription
TRUEnever evaluated
FALSEnever evaluated
0
146 {-
147 QUIT;
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEnever evaluated
interrupt_stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
148-
149 /* First pass: look for exact string or pattern matches.-
150 Second pass: look for prefix matches like bash-4.2 */-
151 if (pass == 1)
pass == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
152 m = (strcmp (pattern, name) == 0) ||
never executed: m = ( __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( pattern ) && __builtin_constant_p ( name ) && (__s1_len = __builtin_strlen ( pattern ), __s2_len = __builtin_strlen ( name ), (!((size_t)(const void *)(( pattern ) + 1) - (size_t)(c...[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( pattern , name )))); }) == 0) || (strmatch (pattern, name, (extended_glob ? (1 << 5) : 0)) != 1);
never executed: __result = (((const unsigned char *) (const char *) ( pattern ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
( __extension_...)))); }) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
153 (strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH);
never executed: m = ( __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( pattern ) && __builtin_constant_p ( name ) && (__s1_len = __builtin_strlen ( pattern ), __s2_len = __builtin_strlen ( name ), (!((size_t)(const void *)(( pattern ) + 1) - (size_t)(c...[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( pattern , name )))); }) == 0) || (strmatch (pattern, name, (extended_glob ? (1 << 5) : 0)) != 1);
(strmatch (pat...5) : 0)) != 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
154 else-
155 m = strncmp (pattern, name, plen) == 0;
never executed: m = (__extension__ (__builtin_constant_p ( plen ) && ((__builtin_constant_p ( pattern ) && strlen ( pattern ) < ((size_t) ( plen ))) || (__builtin_constant_p ( name ) && strlen ( name ) < ((size_t) ( plen )))) ? __extension__ ({ size_t __s1_len, __s2_len;...st char *) ( name ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( pattern , name )))); }) : strncmp ( pattern , name , plen ))) == 0;
never executed: __result = (((const unsigned char *) (const char *) ( pattern ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( name ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__builtin_constant_p ( plen )Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons..._p ( pattern )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( patte...e_t) ( plen ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( name )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( name ...e_t) ( plen ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
156-
157 if (m)
mDescription
TRUEnever evaluated
FALSEnever evaluated
0
158 {-
159 this_found = 1;-
160 match_found++;-
161 if (dflag)
dflagDescription
TRUEnever evaluated
FALSEnever evaluated
0
162 {-
163 show_desc (name, i);-
164 continue;
never executed: continue;
0
165 }-
166 else if (mflag)
mflagDescription
TRUEnever evaluated
FALSEnever evaluated
0
167 {-
168 show_manpage (name, i);-
169 continue;
never executed: continue;
0
170 }-
171-
172 printf ("%s: %s\n", name, _(shell_builtins[i].short_doc));-
173-
174 if (sflag == 0)
sflag == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
175 show_longdoc (i);
never executed: show_longdoc (i);
0
176 }
never executed: end of block
0
177 }
never executed: end of block
0
178 if (pass == 1 && this_found == 1)
pass == 1Description
TRUEnever evaluated
FALSEnever evaluated
this_found == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
179 break;
never executed: break;
0
180 }
never executed: end of block
0
181 }
never executed: end of block
0
182-
183 if (match_found == 0)
match_found == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
184 {-
185 builtin_error (_("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern);-
186 return (EXECUTION_FAILURE);
never executed: return (1);
0
187 }-
188-
189 fflush (stdout);-
190 return (EXECUTION_SUCCESS);
never executed: return (0);
0
191}-
192-
193void-
194builtin_help ()-
195{-
196 int ind;-
197 ptrdiff_t d;-
198-
199 current_builtin = builtin_address_internal (this_command_name, 0);-
200 if (current_builtin == 0)
current_builtin == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
201 return;
never executed: return;
0
202-
203 d = current_builtin - shell_builtins;-
204-
205#if defined (__STDC__)-
206 ind = (int)d;-
207#else-
208 ind = (int)d / sizeof (struct builtin);-
209#endif-
210-
211 printf ("%s: %s\n", this_command_name, _(shell_builtins[ind].short_doc));-
212 show_longdoc (ind); -
213}
never executed: end of block
0
214-
215static int-
216open_helpfile (name)-
217 char *name;-
218{-
219 int fd;-
220-
221 fd = open (name, O_RDONLY);-
222 if (fd == -1)
fd == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
223 {-
224 builtin_error (_("%s: cannot open: %s"), name, strerror (errno));-
225 return -1;
never executed: return -1;
0
226 }-
227 return fd;
never executed: return fd;
0
228}-
229-
230/* By convention, enforced by mkbuiltins.c, if separate help files are being-
231 used, the long_doc array contains one string -- the full pathname of the-
232 help file for this builtin. */-
233static void-
234show_longdoc (i)-
235 int i;-
236{-
237 register int j;-
238 char * const *doc;-
239 int fd;-
240-
241 doc = shell_builtins[i].long_doc;-
242-
243 if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL)
docDescription
TRUEnever evaluated
FALSEnever evaluated
doc[0]Description
TRUEnever evaluated
FALSEnever evaluated
*doc[0] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
doc[1] == (char *) ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
244 {-
245 fd = open_helpfile (doc[0]);-
246 if (fd < 0)
fd < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
247 return;
never executed: return;
0
248 zcatfd (fd, 1, doc[0]);-
249 close (fd);-
250 }
never executed: end of block
0
251 else if (doc)
docDescription
TRUEnever evaluated
FALSEnever evaluated
0
252 for (j = 0; doc[j]; j++)
doc[j]Description
TRUEnever evaluated
FALSEnever evaluated
0
253 printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
never executed: printf ("%*s%s\n", 4, " ", dcgettext (((void *)0), doc[j] , 5) );
0
254}
never executed: end of block
0
255-
256static void-
257show_desc (name, i)-
258 char *name;-
259 int i;-
260{-
261 register int j, r;-
262 char **doc, *line;-
263 int fd, usefile;-
264-
265 doc = (char **)shell_builtins[i].long_doc;-
266-
267 usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL);
docDescription
TRUEnever evaluated
FALSEnever evaluated
doc[0]Description
TRUEnever evaluated
FALSEnever evaluated
*doc[0] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
doc[1] == (char *) ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
268 if (usefile)
usefileDescription
TRUEnever evaluated
FALSEnever evaluated
0
269 {-
270 fd = open_helpfile (doc[0]);-
271 if (fd < 0)
fd < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
272 return;
never executed: return;
0
273 r = zmapfd (fd, &line, doc[0]);-
274 close (fd);-
275 /* XXX - handle errors if zmapfd returns < 0 */-
276 }
never executed: end of block
0
277 else-
278 line = doc ? doc[0] : (char *)NULL;
never executed: line = doc ? doc[0] : (char *) ((void *)0) ;
docDescription
TRUEnever evaluated
FALSEnever evaluated
0
279-
280 printf ("%s - ", name);-
281 for (j = 0; line && line[j]; j++)
lineDescription
TRUEnever evaluated
FALSEnever evaluated
line[j]Description
TRUEnever evaluated
FALSEnever evaluated
0
282 {-
283 putchar (line[j]);-
284 if (line[j] == '\n')
line[j] == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
285 break;
never executed: break;
0
286 }
never executed: end of block
0
287 -
288 fflush (stdout);-
289-
290 if (usefile)
usefileDescription
TRUEnever evaluated
FALSEnever evaluated
0
291 free (line);
never executed: sh_xfree((line), "./help.def", 291);
0
292}
never executed: end of block
0
293-
294/* Print builtin help in pseudo-manpage format. */-
295static void-
296show_manpage (name, i)-
297 char *name;-
298 int i;-
299{-
300 register int j;-
301 char **doc, *line;-
302 int fd, usefile;-
303-
304 doc = (char **)shell_builtins[i].long_doc;-
305-
306 usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL);
docDescription
TRUEnever evaluated
FALSEnever evaluated
doc[0]Description
TRUEnever evaluated
FALSEnever evaluated
*doc[0] == '/'Description
TRUEnever evaluated
FALSEnever evaluated
doc[1] == (char *) ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
307 if (usefile)
usefileDescription
TRUEnever evaluated
FALSEnever evaluated
0
308 {-
309 fd = open_helpfile (doc[0]);-
310 if (fd < 0)
fd < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
311 return;
never executed: return;
0
312 zmapfd (fd, &line, doc[0]);-
313 close (fd);-
314 }
never executed: end of block
0
315 else-
316 line = doc ? _(doc[0]) : (char *)NULL;
never executed: line = doc ? dcgettext (((void *)0), doc[0] , 5) : (char *) ((void *)0) ;
docDescription
TRUEnever evaluated
FALSEnever evaluated
0
317-
318 /* NAME */-
319 printf ("NAME\n");-
320 printf ("%*s%s - ", BASE_INDENT, " ", name);-
321 for (j = 0; line && line[j]; j++)
lineDescription
TRUEnever evaluated
FALSEnever evaluated
line[j]Description
TRUEnever evaluated
FALSEnever evaluated
0
322 {-
323 putchar (line[j]);-
324 if (line[j] == '\n')
line[j] == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
325 break;
never executed: break;
0
326 }
never executed: end of block
0
327 printf ("\n");-
328-
329 /* SYNOPSIS */-
330 printf ("SYNOPSIS\n");-
331 printf ("%*s%s\n\n", BASE_INDENT, " ", _(shell_builtins[i].short_doc));-
332-
333 /* DESCRIPTION */-
334 printf ("DESCRIPTION\n");-
335 if (usefile == 0)
usefile == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
336 {-
337 for (j = 0; doc[j]; j++)
doc[j]Description
TRUEnever evaluated
FALSEnever evaluated
0
338 printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
never executed: printf ("%*s%s\n", 4, " ", dcgettext (((void *)0), doc[j] , 5) );
0
339 }
never executed: end of block
0
340 else-
341 {-
342 for (j = 0; line && line[j]; j++)
lineDescription
TRUEnever evaluated
FALSEnever evaluated
line[j]Description
TRUEnever evaluated
FALSEnever evaluated
0
343 {-
344 putchar (line[j]);-
345 if (line[j] == '\n')
line[j] == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
346 printf ("%*s", BASE_INDENT, " ");
never executed: printf ("%*s", 4, " ");
0
347 }
never executed: end of block
0
348 }
never executed: end of block
0
349 putchar ('\n');-
350-
351 /* SEE ALSO */-
352 printf ("SEE ALSO\n");-
353 printf ("%*sbash(1)\n\n", BASE_INDENT, " ");-
354-
355 /* IMPLEMENTATION */-
356 printf ("IMPLEMENTATION\n");-
357 printf ("%*s", BASE_INDENT, " ");-
358 show_shell_version (0);-
359 printf ("%*s", BASE_INDENT, " ");-
360 printf ("%s\n", _(bash_copyright));-
361 printf ("%*s", BASE_INDENT, " ");-
362 printf ("%s\n", _(bash_license));-
363-
364 fflush (stdout);-
365 if (usefile)
usefileDescription
TRUEnever evaluated
FALSEnever evaluated
0
366 free (line);
never executed: sh_xfree((line), "./help.def", 366);
0
367}
never executed: end of block
0
368-
369static void-
370dispcolumn (i, buf, bufsize, width, height)-
371 int i;-
372 char *buf;-
373 size_t bufsize;-
374 int width, height;-
375{-
376 int j;-
377 int dispcols;-
378 char *helpdoc;-
379-
380 /* first column */-
381 helpdoc = _(shell_builtins[i].short_doc);-
382-
383 buf[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
(shell_builtin....flags & 0x01)Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-38
384 strncpy (buf + 1, helpdoc, width - 2);-
385 buf[width - 2] = '>'; /* indicate truncation */-
386 buf[width - 1] = '\0';-
387 printf ("%s", buf);-
388 if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
((i << 1) >= n...hell_builtins)Description
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
(i+height >= n...hell_builtins)Description
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
0-38
389 {-
390 printf ("\n");-
391 return;
never executed: return;
0
392 }-
393-
394 dispcols = strlen (buf);-
395 /* two spaces */-
396 for (j = dispcols; j < width; j++)
j < widthDescription
TRUEevaluated 489 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
38-489
397 putc (' ', stdout);
executed 489 times by 1 test: _IO_putc ( ' ' , stdout) ;
Executed by:
  • Self test
489
398-
399 /* second column */-
400 helpdoc = _(shell_builtins[i+height].short_doc);-
401-
402 buf[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
(shell_builtin....flags & 0x01)Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-38
403 strncpy (buf + 1, helpdoc, width - 3);-
404 buf[width - 3] = '>'; /* indicate truncation */-
405 buf[width - 2] = '\0';-
406-
407 printf ("%s\n", buf);-
408}
executed 38 times by 1 test: end of block
Executed by:
  • Self test
38
409-
410#if defined (HANDLE_MULTIBYTE)-
411static void-
412wdispcolumn (i, buf, bufsize, width, height)-
413 int i;-
414 char *buf;-
415 size_t bufsize;-
416 int width, height;-
417{-
418 int j;-
419 int dispcols, dispchars;-
420 char *helpdoc;-
421 wchar_t *wcstr;-
422 size_t slen, n;-
423-
424 /* first column */-
425 helpdoc = _(shell_builtins[i].short_doc);-
426-
427 wcstr = 0;-
428 slen = mbstowcs ((wchar_t *)0, helpdoc, 0);-
429 if (slen == -1)
slen == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
430 {-
431 dispcolumn (i, buf, bufsize, width, height);-
432 return;
never executed: return;
0
433 }-
434-
435 /* No bigger than the passed max width */-
436 if (slen >= width)
slen >= widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
437 slen = width - 2;
never executed: slen = width - 2;
0
438 wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (width + 2));-
439 n = mbstowcs (wcstr+1, helpdoc, slen + 1);-
440 wcstr[n+1] = L'\0';-
441-
442 /* Turn tabs and newlines into spaces for column display, since wcwidth-
443 returns -1 for them */-
444 for (j = 1; j < n; j++)
j < nDescription
TRUEnever evaluated
FALSEnever evaluated
0
445 if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
wcstr[j] == L'\n'Description
TRUEnever evaluated
FALSEnever evaluated
wcstr[j] == L'\t'Description
TRUEnever evaluated
FALSEnever evaluated
0
446 wcstr[j] = L' ';
never executed: wcstr[j] = L' ';
0
447-
448 /* dispchars == number of characters that will be displayed */-
449 dispchars = wcsnwidth (wcstr+1, slen, width - 2);-
450 /* dispcols == number of columns required to display DISPCHARS */-
451 dispcols = wcswidth (wcstr+1, dispchars) + 1; /* +1 for ' ' or '*' */-
452-
453 wcstr[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? L' ' : L'*';
(shell_builtin....flags & 0x01)Description
TRUEnever evaluated
FALSEnever evaluated
0
454-
455 if (dispcols >= width-2)
dispcols >= width-2Description
TRUEnever evaluated
FALSEnever evaluated
0
456 {-
457 wcstr[dispchars] = L'>'; /* indicate truncation */-
458 wcstr[dispchars+1] = L'\0';-
459 }
never executed: end of block
0
460-
461 printf ("%ls", wcstr);-
462 if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
((i << 1) >= n...hell_builtins)Description
TRUEnever evaluated
FALSEnever evaluated
(i+height >= n...hell_builtins)Description
TRUEnever evaluated
FALSEnever evaluated
0
463 {-
464 printf ("\n");-
465 free (wcstr);-
466 return;
never executed: return;
0
467 }-
468-
469 /* at least one space */-
470 for (j = dispcols; j < width; j++)
j < widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
471 putc (' ', stdout);
never executed: _IO_putc ( ' ' , stdout) ;
0
472-
473 /* second column */-
474 helpdoc = _(shell_builtins[i+height].short_doc);-
475 slen = mbstowcs ((wchar_t *)0, helpdoc, 0);-
476 if (slen == -1)
slen == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
477 {-
478 /* for now */-
479 printf ("%c%s\n", (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*', helpdoc);-
480 free (wcstr);-
481 return;
never executed: return;
0
482 }-
483-
484 /* Reuse wcstr since it is already width wide chars long */-
485 if (slen >= width)
slen >= widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
486 slen = width - 2;
never executed: slen = width - 2;
0
487 n = mbstowcs (wcstr+1, helpdoc, slen + 1);-
488 wcstr[n+1] = L'\0'; /* make sure null-terminated */-
489-
490 /* Turn tabs and newlines into spaces for column display */-
491 for (j = 1; j < n; j++)
j < nDescription
TRUEnever evaluated
FALSEnever evaluated
0
492 if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
wcstr[j] == L'\n'Description
TRUEnever evaluated
FALSEnever evaluated
wcstr[j] == L'\t'Description
TRUEnever evaluated
FALSEnever evaluated
0
493 wcstr[j] = L' ';
never executed: wcstr[j] = L' ';
0
494-
495 /* dispchars == number of characters that will be displayed */-
496 dispchars = wcsnwidth (wcstr+1, slen, width - 2);-
497 dispcols = wcswidth (wcstr+1, dispchars) + 1; /* +1 for ' ' or '*' */-
498 -
499 wcstr[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? L' ' : L'*';
(shell_builtin....flags & 0x01)Description
TRUEnever evaluated
FALSEnever evaluated
0
500-
501 /* The dispchars-1 is there for terminals that behave strangely when you-
502 have \n in the nth column for terminal width n; this is what bash-4.3-
503 did. */-
504 if (dispcols >= width - 2)
dispcols >= width - 2Description
TRUEnever evaluated
FALSEnever evaluated
0
505 {-
506 wcstr[dispchars-1] = L'>'; /* indicate truncation */-
507 wcstr[dispchars] = L'\0';-
508 }
never executed: end of block
0
509-
510 printf ("%ls\n", wcstr);-
511-
512 free (wcstr);-
513}
never executed: end of block
0
514#endif /* HANDLE_MULTIBYTE */-
515-
516static void-
517show_builtin_command_help ()-
518{-
519 int i, j;-
520 int height, width;-
521 char *t, blurb[128];-
522-
523 printf (-
524_("These shell commands are defined internally. Type `help' to see this list.\n\-
525Type `help name' to find out more about the function `name'.\n\-
526Use `info bash' to find out more about the shell in general.\n\-
527Use `man -k' or `info' to find out more about commands not in this list.\n\-
528\n\-
529A star (*) next to a name means that the command is disabled.\n\-
530\n"));-
531-
532 width = default_columns ();-
533-
534 width /= 2;-
535 if (width > sizeof (blurb))
width > sizeof (blurb)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
536 width = sizeof (blurb);
never executed: width = sizeof (blurb);
0
537 if (width <= 3)
width <= 3Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
538 width = 40;
never executed: width = 40;
0
539 height = (num_shell_builtins + 1) / 2; /* number of rows */-
540-
541 for (i = 0; i < height; i++)
i < heightDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-38
542 {-
543 QUIT;
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
0-38
544-
545#if defined (HANDLE_MULTIBYTE)-
546 if (MB_CUR_MAX > 1)
(__ctype_get_m...ur_max ()) > 1Description
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
0-38
547 wdispcolumn (i, blurb, sizeof (blurb), width, height);
never executed: wdispcolumn (i, blurb, sizeof (blurb), width, height);
0
548 else-
549#endif-
550 dispcolumn (i, blurb, sizeof (blurb), width, height);
executed 38 times by 1 test: dispcolumn (i, blurb, sizeof (blurb), width, height);
Executed by:
  • Self test
38
551 }-
552}
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
553#endif /* HELP_BUILTIN */-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2