Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
e0df32ff
Commit
e0df32ff
authored
Aug 11, 2000
by
Mike McCormack
Committed by
Alexandre Julliard
Aug 11, 2000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created default c2man compatible perl script for generating
documentation, in case c2man isn't installed.
parent
7db03847
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
326 additions
and
2 deletions
+326
-2
configure
configure
+1
-1
configure.in
configure.in
+1
-1
c2man.pl
tools/c2man.pl
+324
-0
No files found.
configure
View file @
e0df32ff
...
...
@@ -2143,7 +2143,7 @@ else
fi
done
IFS
=
"
$ac_save_ifs
"
test
-z
"
$ac_cv_prog_C2MAN
"
&&
ac_cv_prog_C2MAN
=
"
true
"
test
-z
"
$ac_cv_prog_C2MAN
"
&&
ac_cv_prog_C2MAN
=
"
\$
(TOPSRCDIR)/tools/c2man.pl
"
fi
fi
C2MAN
=
"
$ac_cv_prog_C2MAN
"
...
...
configure.in
View file @
e0df32ff
...
...
@@ -70,7 +70,7 @@ AC_DECL_YYTEXT
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_LN_S
AC_CHECK_PROG(C2MAN,c2man,c2man,
true
)
AC_CHECK_PROG(C2MAN,c2man,c2man,
\$(TOPSRCDIR)/tools/c2man.pl
)
AC_PATH_PROG(LDCONFIG, ldconfig, true, /sbin:/usr/sbin:$PATH)
dnl Check for lint
...
...
tools/c2man.pl
0 → 100755
View file @
e0df32ff
#!/usr/bin/perl
#####################################################################################
#
# c2man.pl v0.1 Copyright (C) 2000 Mike McCormack
#
# Genenerates Documents from C source code.
#
# Input is source code with specially formatted comments, output
# is man pages. The functionality is meant to be similar to c2man.
# The following is an example provided in the Wine documentation.
#
# TODO:
# Write code to generate HTML output with the -Th option.
# Need somebody who knows about TROFF to help touch up the man page generation.
# Parse spec files passed with -w option and generate pages for the functions
# in the spec files only.
# Modify Makefiles to pass multiple C files to speed up man page generation.
# Use nm on the shared libraries specified in the spec files to determine which
# source files should be parsed, and only parse them.(requires wine to be compiled)
#
#####################################################################################
# Input from C source file:
#
# /******************************************************************
# * CopyMetaFile32A (GDI32.23)
# *
# * Copies the metafile corresponding to hSrcMetaFile to either
# * a disk file, if a filename is given, or to a new memory based
# * metafile, if lpFileName is NULL.
# *
# * RETURNS
# *
# * Handle to metafile copy on success, NULL on failure.
# *
# * BUGS
# *
# * Copying to disk returns NULL even if successful.
# */
# HMETAFILE32 WINAPI CopyMetaFile32A(
# HMETAFILE32 hSrcMetaFile, /* handle of metafile to copy */
# LPCSTR lpFilename /* filename if copying to a file */
# ) { ... }
#
#####################################################################################
# Output after processing with nroff -man
#
# CopyMetaFileA(3w) CopyMetaFileA(3w)
#
#
# NAME
# CopyMetaFileA - CopyMetaFile32A (GDI32.23)
#
# SYNOPSIS
# HMETAFILE32 CopyMetaFileA
# (
# HMETAFILE32 hSrcMetaFile,
# LPCSTR lpFilename
# );
#
# PARAMETERS
# HMETAFILE32 hSrcMetaFile
# Handle of metafile to copy.
#
# LPCSTR lpFilename
# Filename if copying to a file.
#
# DESCRIPTION
# Copies the metafile corresponding to hSrcMetaFile to
# either a disk file, if a filename is given, or to a new
# memory based metafile, if lpFileName is NULL.
#
# RETURNS
# Handle to metafile copy on success, NULL on failure.
#
# BUGS
# Copying to disk returns NULL even if successful.
#
# SEE ALSO
# GetMetaFileA(3w), GetMetaFileW(3w), CopyMetaFileW(3w),
# PlayMetaFile(3w), SetMetaFileBitsEx(3w), GetMetaFileBit-
# sEx(3w)
#
#####################################################################################
sub
output_manpage
{
my
(
$buffer
,
$apiref
)
=
@_
;
my
$parameters
;
my
$desc
;
# join all the lines of the description together and highlight the headings
for
(
@$buffer
)
{
s/\n//g
;
s/^\s*//g
;
s/\s*$//g
;
if
(
/^([A-Z]+)$/
)
{
$desc
=
$desc
.
".SH $1\n.PP\n"
;
}
elsif
(
/^$/
)
{
$desc
=
"$desc\n"
;
}
else
{
$desc
=
"$desc $_"
;
}
}
#seperate out all the parameters
$plist
=
join
(
' '
,
@$apiref
);
$name_type
=
$plist
;
$name_type
=~
s/\n//g
;
# remove newlines
$name_type
=~
s/\(.*$//
;
$name_type
=~
s/WINAPI//
;
#check that this is a function that we want
if
(
$funcdb
{
$apiname
.
"ORD"
}
eq
""
)
{
return
;
}
print
"Generating $apiname.$section\n"
;
$plist
=~
s/\n//g
;
# remove newlines
$plist
=~
s/^.*\(\s*//
;
# remove leading bracket and before
$plist
=~
s/\s*\).*$//
;
# remove trailing bracket and leftovers
$plist
=~
s/\s*,?\s*\/\*([^*]*)\*\// - $1,/g
;
# move the comma to the back
@params
=
split
(
/,/
,
$plist
);
# split parameters
for
(
@params
)
{
s/^\s*//
;
s/\s*$//
;
}
# figure the month and the year
@datetime
=
localtime
;
@months
=
(
"January"
,
"Febuary"
,
"March"
,
"April"
,
"May"
,
"June"
,
"July"
,
"August"
,
"September"
,
"October"
,
"November"
,
"December"
);
$date
=
"$months[$datetime[4]] $datetime[5]"
;
# create the manual page
$manfile
=
"$mandir/$apiname.$section"
;
open
(
MAN
,
">$manfile"
)
||
die
"Couldn't create the man page file $manfile\n"
;
print
MAN
".\\\" DO NOT MODIFY THIS FILE! It was generated by gendoc 1.0.\n"
;
print
MAN
".TH $apiname \"$section\" \"$date\" \"Wine API\" \"The Wine Project\"\n"
;
print
MAN
".SH NAME\n"
;
print
MAN
"$apiname ($apientry)\n"
;
print
MAN
".SH SYNOPSIS\n"
;
print
MAN
".PP\n"
;
print
MAN
"$name_type\n"
;
print
MAN
" (\n"
;
for
(
$i
=
0
;
$i
<
@params
;
$i
++
)
{
$x
=
(
$i
==
(
@params
-
1
))
?
""
:
","
;
$c
=
$params
[
$i
];
$c
=~
s/-.*//
;
print
MAN
" $c$x\n"
;
}
print
MAN
" );\n"
;
print
MAN
".SH PARAMETERS\n"
;
print
MAN
".PP\n"
;
for
(
$i
=
0
;
$i
<
@params
;
$i
++
)
{
print
MAN
" $params[$i]\n"
;
}
print
MAN
".SH DESCRIPTION\n"
;
print
MAN
".PP\n"
;
print
MAN
$desc
;
close
(
MAN
);
}
#
# extract the comments from source file
#
sub
parse_source
{
my
$file
=
$_
[
0
];
print
"Processing $file\n"
;
open
(
SOURCE
,
"<$file"
)
||
die
"Couldn't open the source file $file\n"
;
$state
=
0
;
while
(
<
SOURCE
>
)
{
if
(
$state
==
0
)
{
if
(
/^\/\**$/
)
{
# find the start of the comment /**************
$state
=
3
;
@buffer
=
();
}
}
elsif
(
$state
==
3
)
{
#extract the wine API name and DLLNAME.XXX string
if
(
/ *([A-Za-z_0-9]+) *\(([A-Za-z0-9_]+\.[0-9]+)\) *$/
)
{
$apiname
=
$1
;
$apientry
=
$2
;
$state
=
1
;
}
else
{
$state
=
0
;
}
}
elsif
(
$state
==
1
)
{
#save the comment text into buffer, removing leading astericks
if
(
/^ \*\//
)
{
$state
=
2
;
}
else
{
# find the end of the comment
if
(
s/^ \*//
)
{
@buffer
=
(
@buffer
,
$_
);
}
else
{
$state
=
0
;
}
}
}
elsif
(
$state
==
2
)
{
# check that the comment is followed by the declaration of
# a WINAPI function.
if
(
/WINAPI/
)
{
@apidef
=
(
$_
);
#check if the function's parameters end on this line
if
(
/\)/
)
{
output_manpage
(
\
@buffer
,
\
@apidef
);
$state
=
0
;
}
else
{
$state
=
4
;
}
}
else
{
$state
=
0
;
}
}
elsif
(
$state
==
4
)
{
@apidef
=
(
@apidef
,
$_
);
#find the end of the parameters list
if
(
/\)/
)
{
output_manpage
(
\
@buffer
,
\
@apidef
);
$state
=
0
;
}
}
}
close
(
SOURCE
);
}
# generate a database of functions to have man pages created from the source
# creates funclist and funcdb
sub
parse_spec
{
my
$spec
=
$_
[
0
];
my
$name
,
$type
,
$ord
,
$func
;
open
(
SPEC
,
"<$spec"
)
||
die
"Couldn't open the spec file $spec\n"
;
while
(
<
SPEC
>
)
{
if
(
/^#/
)
{
next
;
}
if
(
/^name/
)
{
next
;
}
if
(
/^type/
)
{
next
;
}
if
(
/^init/
)
{
next
;
}
if
(
/^rsrc/
)
{
next
;
}
if
(
/^import/
)
{
next
;
}
if
(
/^\s*$/
)
{
next
;
}
if
(
/^\s*([0-9]+)/
)
{
s/\(.*\)//
;
#remove all the args
(
$ord
,
$type
,
$name
,
$func
)
=
split
(
/\s+/
);
if
((
$type
eq
"stub"
)
||
(
$type
eq
"forward"
))
{
next
;}
if
(
$func
eq
""
)
{
next
;
}
@funclist
=
(
@funclist
,
$func
);
$funcdb
{
$func
.
"ORD"
}
=
$ord
;
$funcdb
{
$func
.
"TYPE"
}
=
$type
;
$funcdb
{
$func
.
"NAME"
}
=
$name
;
$funcdb
{
$func
.
"SPEC"
}
=
$spec
;
}
}
close
(
SPEC
);
}
######################################################################
#main starts here
$mandir
=
"man3w"
;
$section
=
"3"
;
#process args
while
(
@ARGV
)
{
if
(
$ARGV
[
0
]
eq
"-o"
)
{
# extract output directory
shift
@ARGV
;
$mandir
=
$ARGV
[
0
];
shift
@ARGV
;
next
;
}
if
(
$ARGV
[
0
]
=~
s/^-S//
)
{
# extract man section
$section
=
$ARGV
[
0
];
shift
@ARGV
;
next
;
}
if
(
$ARGV
[
0
]
=~
s/^-w//
)
{
# extract man section
shift
@ARGV
;
@specfiles
=
(
@specfiles
,
$ARGV
[
0
]
);
shift
@ARGV
;
next
;
}
if
(
$ARGV
[
0
]
=~
s/^-T//
)
{
die
"FIXME: Only NROFF supported\n"
;
}
if
(
$ARGV
[
0
]
=~
s/^-[LDiI]//
)
{
#compatible with C2MAN flags
shift
@ARGV
;
next
;
}
last
;
# stop after there's no more flags
}
#print "manual section: $section\n";
#print "man directory : $mandir\n";
#print "input files : @ARGV\n";
#print "spec files : @specfiles\n";
while
(
@specfiles
)
{
parse_spec
(
$specfiles
[
0
]);
shift
@specfiles
;
}
#print "Functions: @funclist\n";
while
(
@ARGV
)
{
parse_source
(
$ARGV
[
0
]);
shift
@ARGV
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment