mirror of https://github.com/mkerrisk/man-pages
Move example into proper EXAMPLE section.
This commit is contained in:
parent
3787794c31
commit
894d8eb522
|
@ -20,7 +20,7 @@
|
|||
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
|
||||
.\" USA.
|
||||
.\"
|
||||
.TH WORDEXP 3 2008-06-14 "" "Linux Programmer's Manual"
|
||||
.TH WORDEXP 3 2008-07-14 "" "Linux Programmer's Manual"
|
||||
.SH NAME
|
||||
wordexp, wordfree \- perform word expansion like a posix-shell
|
||||
.SH SYNOPSIS
|
||||
|
@ -80,30 +80,6 @@ More precisely, it does not free
|
|||
its argument, but it frees the array
|
||||
.I we_wordv
|
||||
and the strings that points to.
|
||||
.SS Example
|
||||
First a small example.
|
||||
The output is approximately that of "ls [a-c]*.c".
|
||||
.LP
|
||||
.nf
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
wordexp_t p;
|
||||
char **w;
|
||||
int i;
|
||||
|
||||
wordexp("[a-c]*.c", &p, 0);
|
||||
w = p.we_wordv;
|
||||
for (i=0; i < p.we_wordc; i++)
|
||||
printf("%s\en", w[i]);
|
||||
wordfree(&p);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
.fi
|
||||
.SS "The string argument"
|
||||
Since the expansion is the same as the expansion by the shell (see
|
||||
.BR sh (1))
|
||||
|
@ -209,6 +185,30 @@ and
|
|||
are provided in glibc since version 2.1.
|
||||
.SH "CONFORMING TO"
|
||||
POSIX.1-2001
|
||||
.SH EXAMPLE
|
||||
The output of the following example program
|
||||
is approximately that of "ls [a-c]*.c".
|
||||
.LP
|
||||
.nf
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
wordexp_t p;
|
||||
char **w;
|
||||
int i;
|
||||
|
||||
wordexp("[a-c]*.c", &p, 0);
|
||||
w = p.we_wordv;
|
||||
for (i=0; i < p.we_wordc; i++)
|
||||
printf("%s\en", w[i]);
|
||||
wordfree(&p);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
.fi
|
||||
.SH "SEE ALSO"
|
||||
.BR fnmatch (3),
|
||||
.BR glob (3)
|
||||
|
|
Loading…
Reference in New Issue