On Sun, Aug 14, 2016 at 12:25:18AM -0700, Philip Guenther wrote:
> 
> strtoq() and strtouq() are already provided as just aliases of strtoll() 
> and strotull(); let's do the same with qabs() and qdiv() instead of having 
> them as fully separate functions.
> 
> Similarly, they don't need separate manpages, so roll them into the same 
> manpages as llabs(3) and lldiv(3), call the deprecated, and kill the Xr's 
> to the old pages.  You'll need to manually remove 
> /usr/share/man/q{abs,div}.3 and run makewhatis to get it to show the new 
> versions, I believe.
> 
> ok?

OK.


> 
> Philip
> 
> 
> Index: hidden/stdlib.h
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/hidden/stdlib.h,v
> retrieving revision 1.7
> diff -u -p -r1.7 stdlib.h
> --- hidden/stdlib.h   13 Mar 2016 18:34:21 -0000      1.7
> +++ hidden/stdlib.h   14 Aug 2016 06:59:39 -0000
> @@ -119,8 +119,8 @@ PROTO_DEPRECATED(nrand48);
>  PROTO_DEPRECATED(posix_openpt);
>  PROTO_DEPRECATED(ptsname);
>  PROTO_NORMAL(putenv);
> -PROTO_DEPRECATED(qabs);
> -PROTO_DEPRECATED(qdiv);
> +/*PROTO_DEPRECATED(qabs);    alias of llabs */
> +/*PROTO_DEPRECATED(qdiv);    alias of lldiv */
>  PROTO_NORMAL(qsort);
>  PROTO_DEPRECATED(radixsort);
>  PROTO_STD_DEPRECATED(rand);
> Index: stdlib/Makefile.inc
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/stdlib/Makefile.inc,v
> retrieving revision 1.60
> diff -u -p -r1.60 Makefile.inc
> --- stdlib/Makefile.inc       2 May 2016 12:59:24 -0000       1.60
> +++ stdlib/Makefile.inc       14 Aug 2016 07:13:40 -0000
> @@ -11,8 +11,8 @@ SRCS+=      a64l.c abort.c atexit.c atoi.c at
>       realpath.c remque.c setenv.c strtoimax.c \
>       strtol.c strtoll.c strtonum.c strtoul.c strtoull.c strtoumax.c \
>       system.c tfind.c tsearch.c _rand48.c drand48.c erand48.c jrand48.c \
> -     lcong48.c lrand48.c mrand48.c nrand48.c seed48.c srand48.c qabs.c \
> -     qdiv.c _Exit.c icdb.c
> +     lcong48.c lrand48.c mrand48.c nrand48.c seed48.c srand48.c \
> +     _Exit.c icdb.c
>  
>  .if (${MACHINE_CPU} == "i386")
>  SRCS+=       abs.S div.S labs.S ldiv.S
> @@ -27,5 +27,5 @@ MAN+=       a64l.3 abort.3 abs.3 alloca.3 atex
>       bsearch.3 div.3 ecvt.3 exit.3 getenv.3 getopt.3 getopt_long.3 \
>       getsubopt.3 hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 \
>       lldiv.3 lsearch.3 malloc.3 posix_memalign.3 posix_openpt.3 ptsname.3 \
> -     qabs.3 qdiv.3 qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \
> +     qsort.3 radixsort.3 rand48.3 rand.3 random.3 realpath.3 \
>       strtod.3 strtonum.3 strtol.3 strtoul.3 system.3 tsearch.3
> Index: stdlib/div.3
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/stdlib/div.3,v
> retrieving revision 1.11
> diff -u -p -r1.11 div.3
> --- stdlib/div.3      5 Jun 2013 03:39:23 -0000       1.11
> +++ stdlib/div.3      14 Aug 2016 07:12:29 -0000
> @@ -55,8 +55,7 @@ and
>  .Sh SEE ALSO
>  .Xr imaxdiv 3 ,
>  .Xr ldiv 3 ,
> -.Xr lldiv 3 ,
> -.Xr qdiv 3
> +.Xr lldiv 3
>  .Sh STANDARDS
>  The
>  .Fn div
> Index: stdlib/imaxdiv.3
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/stdlib/imaxdiv.3,v
> retrieving revision 1.6
> diff -u -p -r1.6 imaxdiv.3
> --- stdlib/imaxdiv.3  30 Nov 2014 21:21:59 -0000      1.6
> +++ stdlib/imaxdiv.3  14 Aug 2016 07:12:34 -0000
> @@ -57,8 +57,7 @@ and
>  .Sh SEE ALSO
>  .Xr div 3 ,
>  .Xr ldiv 3 ,
> -.Xr lldiv 3 ,
> -.Xr qdiv 3
> +.Xr lldiv 3
>  .Sh STANDARDS
>  The
>  .Fn imaxdiv
> Index: stdlib/labs.3
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/stdlib/labs.3,v
> retrieving revision 1.13
> diff -u -p -r1.13 labs.3
> --- stdlib/labs.3     30 Nov 2014 21:21:59 -0000      1.13
> +++ stdlib/labs.3     14 Aug 2016 07:11:36 -0000
> @@ -44,6 +44,8 @@
>  .Fn labs "long i"
>  .Ft long long
>  .Fn llabs "long long j"
> +.Ft quad_t
> +.Fn qabs "quad_t j"
>  .Sh DESCRIPTION
>  The
>  .Fn labs
> @@ -53,6 +55,11 @@ The
>  .Fn llabs
>  function returns the absolute value of the long long integer
>  .Fa j .
> +The
> +.Fn qabs
> +function is a deprecated equivalent of
> +.Fn llabs
> +and is provided for backwards compatibility with legacy programs.
>  .Sh SEE ALSO
>  .Xr abs 3 ,
>  .Xr cabs 3 ,
> Index: stdlib/ldiv.3
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/stdlib/ldiv.3,v
> retrieving revision 1.12
> diff -u -p -r1.12 ldiv.3
> --- stdlib/ldiv.3     17 Jul 2013 05:42:11 -0000      1.12
> +++ stdlib/ldiv.3     14 Aug 2016 07:09:58 -0000
> @@ -57,8 +57,7 @@ and
>  .Sh SEE ALSO
>  .Xr div 3 ,
>  .Xr imaxdiv 3 ,
> -.Xr lldiv 3 ,
> -.Xr qdiv 3
> +.Xr lldiv 3
>  .Sh STANDARDS
>  The
>  .Fn ldiv
> Index: stdlib/llabs.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/stdlib/llabs.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 llabs.c
> --- stdlib/llabs.c    8 Jan 2007 19:39:25 -0000       1.3
> +++ stdlib/llabs.c    14 Aug 2016 07:00:26 -0000
> @@ -36,3 +36,5 @@ llabs(long long j)
>  {
>       return (j < 0 ? -j : j);
>  }
> +
> +__weak_alias(qabs, llabs);
> Index: stdlib/lldiv.3
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/stdlib/lldiv.3,v
> retrieving revision 1.5
> diff -u -p -r1.5 lldiv.3
> --- stdlib/lldiv.3    30 Nov 2014 21:21:59 -0000      1.5
> +++ stdlib/lldiv.3    14 Aug 2016 07:15:11 -0000
> @@ -41,6 +41,8 @@
>  .In stdlib.h
>  .Ft lldiv_t
>  .Fn lldiv "long long num" "long long denom"
> +.Ft qdiv_t
> +.Fn qdiv "quad_t num" "quad_t denom"
>  .Sh DESCRIPTION
>  The
>  .Fn lldiv
> @@ -54,11 +56,15 @@ members named
>  .Fa quot
>  and
>  .Fa rem .
> +The
> +.Fn qdiv
> +function is a deprecated equivalent of
> +.Fn lldiv
> +and is provided for backwards compatibility with legacy programs.
>  .Sh SEE ALSO
>  .Xr div 3 ,
>  .Xr imaxdiv 3 ,
> -.Xr ldiv 3 ,
> -.Xr qdiv 3
> +.Xr ldiv 3
>  .Sh STANDARDS
>  The
>  .Fn lldiv
> Index: stdlib/lldiv.c
> ===================================================================
> RCS file: /data/src/openbsd/src/lib/libc/stdlib/lldiv.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 lldiv.c
> --- stdlib/lldiv.c    13 Jan 2006 17:58:09 -0000      1.1
> +++ stdlib/lldiv.c    14 Aug 2016 07:00:34 -0000
> @@ -48,3 +48,5 @@ lldiv(long long num, long long denom)
>       }
>       return (r);
>  }
> +
> +__weak_alias(qdiv, lldiv);
> Index: stdlib/qabs.3
> ===================================================================
> RCS file: stdlib/qabs.3
> diff -N stdlib/qabs.3
> --- stdlib/qabs.3     5 Jun 2013 03:39:23 -0000       1.13
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,56 +0,0 @@
> -.\" Copyright (c) 1990, 1991 The Regents of the University of California.
> -.\" All rights reserved.
> -.\"
> -.\" This code is derived from software contributed to Berkeley by
> -.\" the American National Standards Committee X3, on Information
> -.\" Processing Systems.
> -.\"
> -.\" Redistribution and use in source and binary forms, with or without
> -.\" modification, are permitted provided that the following conditions
> -.\" are met:
> -.\" 1. Redistributions of source code must retain the above copyright
> -.\"    notice, this list of conditions and the following disclaimer.
> -.\" 2. Redistributions in binary form must reproduce the above copyright
> -.\"    notice, this list of conditions and the following disclaimer in the
> -.\"    documentation and/or other materials provided with the distribution.
> -.\" 3. Neither the name of the University nor the names of its contributors
> -.\"    may be used to endorse or promote products derived from this software
> -.\"    without specific prior written permission.
> -.\"
> -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
> -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> -.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
> -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> CONSEQUENTIAL
> -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
> STRICT
> -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> -.\" SUCH DAMAGE.
> -.\"
> -.\"  $OpenBSD: qabs.3,v 1.13 2013/06/05 03:39:23 tedu Exp $
> -.\"
> -.Dd $Mdocdate: June 5 2013 $
> -.Dt QABS 3
> -.Os
> -.Sh NAME
> -.Nm qabs
> -.Nd return the absolute value of a quad integer
> -.Sh SYNOPSIS
> -.In stdlib.h
> -.Ft quad_t
> -.Fn qabs "quad_t j"
> -.Sh DESCRIPTION
> -The
> -.Fn qabs
> -function returns the absolute value of the quad integer
> -.Fa j .
> -.Sh SEE ALSO
> -.Xr abs 3 ,
> -.Xr cabs 3 ,
> -.Xr floor 3 ,
> -.Xr imaxabs 3 ,
> -.Xr labs 3
> -.Sh BUGS
> -The absolute value of the most negative integer remains negative.
> Index: stdlib/qabs.c
> ===================================================================
> RCS file: stdlib/qabs.c
> diff -N stdlib/qabs.c
> --- stdlib/qabs.c     8 Aug 2005 08:05:37 -0000       1.5
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,37 +0,0 @@
> -/*   $OpenBSD: qabs.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */
> -/*-
> - * Copyright (c) 1990 The Regents of the University of California.
> - * All rights reserved.
> - *
> - * Redistribution and use in source and binary forms, with or without
> - * modification, are permitted provided that the following conditions
> - * are met:
> - * 1. Redistributions of source code must retain the above copyright
> - *    notice, this list of conditions and the following disclaimer.
> - * 2. Redistributions in binary form must reproduce the above copyright
> - *    notice, this list of conditions and the following disclaimer in the
> - *    documentation and/or other materials provided with the distribution.
> - * 3. Neither the name of the University nor the names of its contributors
> - *    may be used to endorse or promote products derived from this software
> - *    without specific prior written permission.
> - *
> - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
> - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
> - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> - * SUCH DAMAGE.
> - */
> -
> -#include <stdlib.h>
> -
> -quad_t
> -qabs(quad_t j)
> -{
> -     return(j < 0 ? -j : j);
> -}
> Index: stdlib/qdiv.3
> ===================================================================
> RCS file: stdlib/qdiv.3
> diff -N stdlib/qdiv.3
> --- stdlib/qdiv.3     5 Jun 2013 03:39:23 -0000       1.10
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,61 +0,0 @@
> -.\" Copyright (c) 1990, 1991 The Regents of the University of California.
> -.\" All rights reserved.
> -.\"
> -.\" This code is derived from software contributed to Berkeley by
> -.\" Chris Torek and the American National Standards Committee X3,
> -.\" on Information Processing Systems.
> -.\"
> -.\" Redistribution and use in source and binary forms, with or without
> -.\" modification, are permitted provided that the following conditions
> -.\" are met:
> -.\" 1. Redistributions of source code must retain the above copyright
> -.\"    notice, this list of conditions and the following disclaimer.
> -.\" 2. Redistributions in binary form must reproduce the above copyright
> -.\"    notice, this list of conditions and the following disclaimer in the
> -.\"    documentation and/or other materials provided with the distribution.
> -.\" 3. Neither the name of the University nor the names of its contributors
> -.\"    may be used to endorse or promote products derived from this software
> -.\"    without specific prior written permission.
> -.\"
> -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
> -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
> PURPOSE
> -.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
> -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
> CONSEQUENTIAL
> -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
> STRICT
> -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> -.\" SUCH DAMAGE.
> -.\"
> -.\"  $OpenBSD: qdiv.3,v 1.10 2013/06/05 03:39:23 tedu Exp $
> -.\"
> -.Dd $Mdocdate: June 5 2013 $
> -.Dt QDIV 3
> -.Os
> -.Sh NAME
> -.Nm qdiv
> -.Nd return quotient and remainder from division
> -.Sh SYNOPSIS
> -.In stdlib.h
> -.Ft qdiv_t
> -.Fn qdiv "quad_t num" "quad_t denom"
> -.Sh DESCRIPTION
> -The
> -.Fn qdiv
> -function computes the value
> -.Fa num Ns / Ns Fa denom
> -and returns the quotient and remainder in a structure named
> -.Li qdiv_t
> -that contains two
> -.Li quad integer
> -members named
> -.Fa quot
> -and
> -.Fa rem .
> -.Sh SEE ALSO
> -.Xr div 3 ,
> -.Xr imaxdiv 3 ,
> -.Xr ldiv 3 ,
> -.Xr lldiv 3
> Index: stdlib/qdiv.c
> ===================================================================
> RCS file: stdlib/qdiv.c
> diff -N stdlib/qdiv.c
> --- stdlib/qdiv.c     8 Aug 2005 08:05:37 -0000       1.5
> +++ /dev/null 1 Jan 1970 00:00:00 -0000
> @@ -1,50 +0,0 @@
> -/*   $OpenBSD: qdiv.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */
> -/*
> - * Copyright (c) 1990 Regents of the University of California.
> - * All rights reserved.
> - *
> - * This code is derived from software contributed to Berkeley by
> - * Chris Torek.
> - *
> - * Redistribution and use in source and binary forms, with or without
> - * modification, are permitted provided that the following conditions
> - * are met:
> - * 1. Redistributions of source code must retain the above copyright
> - *    notice, this list of conditions and the following disclaimer.
> - * 2. Redistributions in binary form must reproduce the above copyright
> - *    notice, this list of conditions and the following disclaimer in the
> - *    documentation and/or other materials provided with the distribution.
> - * 3. Neither the name of the University nor the names of its contributors
> - *    may be used to endorse or promote products derived from this software
> - *    without specific prior written permission.
> - *
> - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
> - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
> - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> - * SUCH DAMAGE.
> - */
> -
> -#include <stdlib.h>          /* qdiv_t */
> -
> -qdiv_t
> -qdiv(quad_t num, quad_t denom)
> -{
> -     qdiv_t r;
> -
> -     /* see div.c for comments */
> -
> -     r.quot = num / denom;
> -     r.rem = num % denom;
> -     if (num >= 0 && r.rem < 0) {
> -             r.quot++;
> -             r.rem -= denom;
> -     }
> -     return (r);
> -}
> 

Reply via email to