[PATCH v2 app-xdm 4/4] man: build man page using sed rather than the C preprocessor

Alan Coopersmith alan.coopersmith at oracle.com
Wed Sep 1 08:25:44 PDT 2010


Thanks - Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

Gaetan Nadon wrote:
> This fixes misalignments to correctly display \n and \ for sample file.
> No source code changes needed to fix that.
> 
> Replace XCOMM IMakefile comment with #.
> 
> Replace #if with:
> .if !'x.VARNAME'x.' .ig
> [man page text]
> ..
> 
> If $(VARNAME) is empty, the man page text is shown
> If $(VARNAME) is not empty, the man page text is skipped
> 
> Or replace #if with:
> .if 'VARNAME'' .ig
> [man page text]
> ..
> 
> If $(VARNAME) is empty, the man page text is skipped
> If $(VARNAME) is not empty, the man page text is shown
> 
> In DisplayManager.randomDevice, the default /dev/urandom is no longer
> displayed with double-quotes which is consistent with other
> default values. This was a cpp side-effect.
> 
> Tested on Debian with groff and Solaris with nroff
> 
> Co-authored-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
> ---
>  Makefile.am  |   39 ++++++++++++++-------------------------
>  configure.ac |    9 ++++-----
>  xdm.man.cpp  |   33 ++++++++++++++++++---------------
>  3 files changed, 36 insertions(+), 45 deletions(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index c8e60d8..b226282 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -119,33 +119,22 @@ noinst_DATA = $(noinst_man_PRE:man.cpp=@APP_MAN_SUFFIX@)
>  MAINTAINERCLEANFILES = ChangeLog INSTALL
>  CLEANFILES = $(appman_DATA) $(noinst_DATA)
>  EXTRA_DIST = $(appman_PRE) $(noinst_man_PRE)
> -
> -include $(top_srcdir)/cpprules.in
> -
> -XORGRELSTRING = @PACKAGE_STRING@
> -  XORGMANNAME = X Version 11
> -
> -MANDEFS = \
> -	-D__xorgversion__="\"$(XORGRELSTRING)\" \"$(XORGMANNAME)\"" \
> -	-DCHOOSERPATH="$(xdmlibdir)/chooser" -DXDMLOGDIR="$(XDMLOGDIR)" \
> -	-DXDMDIR="$(XDMCONFIGDIR)" -DBINDIR="$(bindir)" \
> -	-DXDMPIDDIR="$(XDMPIDDIR)" -DXDMXAUTHDIR="$(XDMXAUTHDIR)" \
> -	-DDEF_USER_PATH="$(DEF_USER_PATH)" \
> -	-DDEF_SYSTEM_PATH="$(DEF_SYSTEM_PATH)" \
> -	-DDEF_GREETER_LIB="$(DEF_GREETER_LIB)" \
> -	-D__appmansuffix__=$(APP_MAN_SUFFIX) \
> -	-D__filemansuffix__=$(FILE_MAN_SUFFIX) \
> -	-D__libmansuffix__=$(LIB_MAN_SUFFIX) \
> -	-D__miscmansuffix__=$(MISC_MAN_SUFFIX) \
> -	-D__drivermansuffix__=$(DRIVER_MAN_SUFFIX) \
> -	-D__adminmansuffix__=$(ADMIN_MAN_SUFFIX) 
> -
> -CPP_FILES_FLAGS = $(MANDEFS) $(RANDOMMANDEFS) $(EXTRAMANDEFS)
> -
> -SUFFIXES += .$(APP_MAN_SUFFIX) .man.cpp
> +SUFFIXES   = .$(APP_MAN_SUFFIX) .man.cpp
> +
> +MAN_SUBSTS +=	-e 's|CHOOSERPATH|$(xdmlibdir)/chooser|g' \
> +		-e 's|XDMLOGDIR|$(XDMLOGDIR)|g' \
> +		-e 's|XDMDIR|$(XDMCONFIGDIR)|g' \
> +		-e 's|BINDIR|$(bindir)|g' \
> +		-e 's|XDMPIDDIR|$(XDMPIDDIR)|g' \
> +		-e 's|XDMXAUTHDIR|$(XDMXAUTHDIR)|g' \
> +		-e 's|DEF_USER_PATH|$(DEF_USER_PATH)|g' \
> +		-e 's|DEF_SYSTEM_PATH|$(DEF_SYSTEM_PATH)|g' \
> +		-e 's|DEF_GREETER_LIB|$(DEF_GREETER_LIB)|g' \
> +		-e 's|DEV_RANDOM|$(DEV_RANDOM)|g' \
> +		-e 's|ARC4_RANDOM|$(ARC4_RANDOM)|g'
>  
>  .man.cpp.$(APP_MAN_SUFFIX):
> -	$(cpp_verbose)$(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@
> +	$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
>  
>  #
>  #  xdmshell
> diff --git a/configure.ac b/configure.ac
> index e5b9a46..dd23034 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -198,18 +198,17 @@ fi
>  if test x$RANDOM_DEVICE != xno ; then
>  	AC_DEFINE_UNQUOTED(DEV_RANDOM,"$RANDOM_DEVICE",
>  		[Define to device that provides random data source])
> -	RANDOMMANDEFS="$RANDOMMANDEFS -DDEV_RANDOM=\\\"$RANDOM_DEVICE\\\""
> +		DEV_RANDOM=$RANDOM_DEVICE
>  fi
> -
> +AC_SUBST(DEV_RANDOM)
>  
>  AC_CHECK_FUNC(arc4random, [HAS_ARC4_RANDOM="yes"], [HAS_ARC4_RANDOM="no"])
>  AM_CONDITIONAL(HAS_ARC4_RANDOM, test x$HAS_ARC4_RANDOM = xyes)
>  if test x$HAS_ARC4_RANDOM = xyes ; then
>  	AC_DEFINE(ARC4_RANDOM, 1, [Define to use arc4random() function])
> -	RANDOMMANDEFS="$RANDOMMANDEFS -DARC4_RANDOM"
> +	ARC4_RANDOM=1
>  fi
> -
> -AC_SUBST(RANDOMMANDEFS)
> +AC_SUBST(ARC4_RANDOM)
>  
>  # FIXME: find out how to check for these things. Note that Kerberos was
>  # turned off everywhere but on OpenBSD.
> diff --git a/xdm.man.cpp b/xdm.man.cpp
> index 2545212..dfe0fcf 100644
> --- a/xdm.man.cpp
> +++ b/xdm.man.cpp
> @@ -343,20 +343,23 @@ in the section
>  A list of additional environment variables, separated by white space,
>  to pass on to the \fIXsetup\fP,
>  \fIXstartup\fP, \fIXsession\fP, and \fIXreset\fP programs.
> -#if !defined(ARC4_RANDOM)
> +.\" The command "if 'x.A'x' .ig" causes everything up to .. to be ignored
> +.\" if A is replaced by an empty string in the sed processing, otherwise
> +.\" it will be output as normal.
> +.if !'x.ARC4_RANDOM'x.' .ig
>  .IP \fBDisplayManager.randomFile\fP
>  A file to checksum to generate the seed of authorization keys.
>  This should be a file that changes frequently.
>  The default is \fI/dev/mem\fP.
> -#endif
> -#ifdef DEV_RANDOM
> +..
> +.if 'x.DEV_RANDOM'x.' .ig
>  .IP \fBDisplayManager.randomDevice\fP
>  A file to read 8 bytes from to generate the seed of authorization keys.
>  The default is \fI DEV_RANDOM \fP. If this file cannot be read, or if a
>  read blocks for more than 5 seconds, xdm falls back to using a checksum
>  of \fBDisplayManager.randomFile\fP to generate the seed.
> -#endif
> -#if !defined(ARC4_RANDOM)
> +..
> +.if !'x.ARC4_RANDOM'x.' .ig
>  .IP \fBDisplayManager.prngdSocket\fP
>  .IP \fBDisplayManager.prngPort\fP
>  A UNIX domain socket name or a TCP socket port number on local host on
> @@ -369,7 +372,7 @@ be specified. The default is to use the Unix-domain socket
>  On systems that don't have such a daemon, a fall-back entropy
>  gathering system, based on various log file contents hashed by the MD5
>  algorithm is used instead.
> -#endif
> +..
>  .IP \fBDisplayManager.greeterLib\fP
>  On systems that support a dynamically-loadable greeter library, the
>  name of the library.  The default is
> @@ -676,13 +679,13 @@ Here is an example Xaccess file:
>  .LP
>  .ta 2i 4i
>  .nf
> -XCOMM
> -XCOMM Xaccess \- XDMCP access control file
> -XCOMM
> +#
> +# Xaccess \- XDMCP access control file
> +#
>  
> -XCOMM
> -XCOMM Direct/Broadcast query entries
> -XCOMM
> +#
> +# Direct/Broadcast query entries
> +#
>  
>  !xtra.lcs.mit.edu	# disallow direct/broadcast service for xtra
>  bambi.ogi.edu	# allow access from this particular display
> @@ -691,9 +694,9 @@ bambi.ogi.edu	# allow access from this particular display
>  *.deshaw.com	NOBROADCAST	# allow only direct access
>  *.gw.com			# allow direct and broadcast
>  
> -XCOMM
> -XCOMM Indirect query entries
> -XCOMM
> +#
> +# Indirect query entries
> +#
>  
>  %HOSTS	expo.lcs.mit.edu xenon.lcs.mit.edu \\
>  	excess.lcs.mit.edu kanga.lcs.mit.edu


-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list