RPM Community Forums

Mailing List Message of <rpm-devel>

Re: [CVS] RPM: rpm/ CHANGES configure.ac rpm/misc/ Makefile.am asprintf.h ...

From: devzero2000 <pinto.elia@gmail.com>
Date: Tue 29 Jul 2008 - 13:24:15 CEST
Message-ID: <b086760e0807290424k5bcfcad4s64e7f884d3428197@mail.gmail.com>
On Mon, Jul 28, 2008 at 4:53 PM, Jeff Johnson <n3npq@mac.com> wrote:

> This likely needs some context ...
>
> rpmmtree derived from BSD still has some *BSD peculier API usages,
> strtouq(), asprintf() and strvis()
> just to mention some of the portability issues.
>
> Normally I'd just rewrite rpmmtree.c to avoid the portability issues, and
> will likely do that with
> rpmmtree(8) somewhen soon as well.
>
> However, rpm.org is making heavy usage of something called "rasprintf", so
> some sort
> of malloc'ing printf simplifies stealing code from rpm.org. I prefer the
> well known asprintf(3) API,
> which is often present in system libraries, to a home rolled custom
> malloc'ing printf gadget API.
>
> strtouq(3) is almost certainly going to have some portability issues
> somewhere (my guess). Dunno
> the best answer, time to find out.


http://mirbsd.org/htman/i386/man3/strtoul.htm

So it is possibile to use strtoul(3) in place of strouq. And  strtoul  is
more portable , standard (C99) compliant




>
> And I still don't know what to do with the strvis(3) usages in rpmmtree.
> Internal to rpmmtree
> a while longer hurts little for now.


Perhaps it is necessary to introduce libedit, that have the implementation
of strvis, internal to RPM - for portabilty.
Or, perhaps better, to use internal only  the strvis function of vis.c in
libedit

http://koji.fedoraproject.org/packages/libedit/2.11/1.20080712cvs.fc10/src/libedit-2.11-1.20080712cvs.fc10.src.rpm

Regards



> On Jul 28, 2008, at 10:35 AM, Jeff Johnson wrote:
>
>   RPM Package Manager, CVS Repository
>>  http://rpm5.org/cvs/
>>
>>  ____________________________________________________________________________
>>
>>  Server: rpm5.org                         Name:   Jeff Johnson
>>  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
>>  Module: rpm                              Date:   28-Jul-2008 16:35:27
>>  Branch: HEAD                             Handle: 2008072814352501
>>
>>  Added files:
>>    rpm/misc                asprintf.h
>>  Modified files:
>>    rpm                     CHANGES configure.ac
>>    rpm/misc                Makefile.am
>>    rpm/rpmdb               rpmdb.c sqlite.c
>>    rpm/tools               rpmmtree.c
>>
>>  Log:
>>    - QNX: use strtouq() instead of strtoul() in rpmmtree.
>>    - QNX: retrofit asprintf.h (from XAR) for the deprived. rpmmtree uses
>>        (rewrite to eliminate asprintf is an alternative).
>>    - QNX: supply missing typedef's for uint32_t.
>>
>>  Summary:
>>    Revision    Changes     Path
>>    1.2509      +4  -0      rpm/CHANGES
>>    2.305       +1  -1      rpm/configure.ac
>>    1.34        +1  -1      rpm/misc/Makefile.am
>>    1.1         +92 -0      rpm/misc/asprintf.h
>>    1.253       +1  -1      rpm/rpmdb/rpmdb.c
>>    1.34        +1  -1      rpm/rpmdb/sqlite.c
>>    2.3         +10 -2      rpm/tools/rpmmtree.c
>>
>>  ____________________________________________________________________________
>>
>>  patch -p0 <<'@@ .'
>>  Index: rpm/CHANGES
>>
>>  ============================================================================
>>  $ cvs diff -u -r1.2508 -r1.2509 CHANGES
>>  --- rpm/CHANGES       20 Jul 2008 00:04:51 -0000      1.2508
>>  +++ rpm/CHANGES       28 Jul 2008 14:35:25 -0000      1.2509
>>  @@ -1,5 +1,9 @@
>>
>>   5.1.0 -> 5.2a0:
>>  +    - jbj: QNX: use strtouq() instead of strtoul() in rpmmtree.
>>  +    - jbj: QNX: retrofit asprintf.h (from XAR) for the deprived.
>> rpmmtree uses
>>  +     (rewrite to eliminate asprintf is an alternative).
>>  +    - jbj: QNX: supply missing typedef's for uint32_t.
>>       - jbj: add alternative %{sparcx} macro shorthand (bz #455972).
>>       - jbj: rpmio: add new link/unlink methods to loader map.
>>       - jbj: python: add rpm.Keyring/rpm.Pubkey subtype methods for
>> rpmkeyring.
>>  @@ .
>>  patch -p0 <<'@@ .'
>>  Index: rpm/configure.ac
>>
>>  ============================================================================
>>  $ cvs diff -u -r2.304 -r2.305 configure.ac
>>  --- rpm/configure.ac  15 Jul 2008 18:57:09 -0000      2.304
>>  +++ rpm/configure.ac  28 Jul 2008 14:35:25 -0000      2.305
>>  @@ -686,7 +686,7 @@
>>
>>   dnl checks for library functions (generic)
>>   AC_CHECK_FUNCS([dnl
>>  -    basename getaddrinfo getcwd getnameinfo getwd iconv inet_aton
>> confstr dnl
>>  +    asprintf basename getaddrinfo getcwd getnameinfo getwd iconv
>> inet_aton confstr dnl
>>       mtrace putenv realpath setenv clearenv stpcpy stpncpy strcspn strdup
>> dnl
>>       strndup strerror strtol strtoul strspn strstr sighold sigrelse
>> sigpause dnl
>>       sigprocmask sigemptyset sigaddset sigdelset sigsuspend madvise dnl
>>  @@ .
>>  patch -p0 <<'@@ .'
>>  Index: rpm/misc/Makefile.am
>>
>>  ============================================================================
>>  $ cvs diff -u -r1.33 -r1.34 Makefile.am
>>  --- rpm/misc/Makefile.am      28 Apr 2008 16:40:28 -0000      1.33
>>  +++ rpm/misc/Makefile.am      28 Jul 2008 14:35:26 -0000      1.34
>>  @@ -7,7 +7,7 @@
>>        -I$(top_srcdir)
>>
>>   EXTRA_DIST = \
>>  -     librpmmisc.vers \
>>  +     librpmmisc.vers asprintf.h \
>>        alloca.c        basename.c      err.c           error.c         \
>>        fakefork.c      fnmatch.c       getcwd.c        getmntent.c     \
>>        getwd.c         glob.c                          memcmp.c        \
>>  @@ .
>>  patch -p0 <<'@@ .'
>>  Index: rpm/misc/asprintf.h
>>
>>  ============================================================================
>>  $ cvs diff -u -r0 -r1.1 asprintf.h
>>  --- /dev/null 2008-07-28 16:33:00 +0200
>>  +++ asprintf.h        2008-07-28 16:35:26 +0200
>>  @@ -0,0 +1,92 @@
>>
>>  +//==============================================================================
>>  +//
>>  +// Copyright (C) 2005 Jason Evans <jasone@canonware.com>.  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(s),
>>  +//    this list of conditions and the following disclaimer unmodified
>> other than
>>  +//    the allowable addition of one or more copyright notices.
>>  +//
>>  +// 2. Redistributions in binary form must reproduce the above copyright
>>  +//    notice(s), this list of conditions and the following disclaimer in
>> the
>>  +//    documentation and/or other materials provided with the
>> distribution.
>>  +//
>>  +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) `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 COPYRIGHT HOLDER(S) 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.
>>  +//
>>
>>  +//==============================================================================
>>  +//
>>  +// Emulate vasprintf() and asprintf().
>>  +//
>>
>>  +//==============================================================================
>>  +
>>  +#include <stdlib.h>
>>  +#include <stdio.h>
>>  +#include <stdarg.h>
>>  +
>>  +static inline int
>>  +vasprintf(char **rResult, const char *aFormat, va_list aAp)
>>  +{
>>  +    int rVal;
>>  +    char *result;
>>  +    va_list ap;
>>  +#define XarAsprintfStartLen 16
>>  +
>>  +    result = (char *) malloc(XarAsprintfStartLen);
>>  +    if (result == NULL)
>>  +    {
>>  +     rVal = -1;
>>  +     goto RETURN;
>>  +    }
>>  +
>>  +    va_copy(ap, aAp);
>>  +    rVal = vsnprintf(result, XarAsprintfStartLen, aFormat, ap);
>>  +    va_end(ap);
>>  +
>>  +    if (rVal == -1)
>>  +    {
>>  +     goto RETURN;
>>  +    }
>>  +    else if (rVal >= XarAsprintfStartLen)
>>  +    {
>>  +     free(result);
>>  +     result = (char *) malloc(rVal + 1);
>>  +     if (result == NULL)
>>  +     {
>>  +         rVal = -1;
>>  +         goto RETURN;
>>  +     }
>>  +
>>  +     va_copy(ap, aAp);
>>  +     rVal = vsnprintf(result, rVal + 1, aFormat, aAp);
>>  +     va_end(ap);
>>  +    }
>>  +
>>  +    *rResult = result;
>>  +    RETURN:
>>  +#undef XarAsprintfStartLen
>>  +    return rVal;
>>  +}
>>  +
>>  +static inline int
>>  +asprintf(char **rResult, const char *aFormat, ...)
>>  +{
>>  +    int rVal;
>>  +    va_list ap;
>>  +
>>  +    va_start(ap, aFormat);
>>  +    rVal = vasprintf(rResult, aFormat, ap);
>>  +    va_end(ap);
>>  +
>>  +    return rVal;
>>  +}
>>  @@ .
>>  patch -p0 <<'@@ .'
>>  Index: rpm/rpmdb/rpmdb.c
>>
>>  ============================================================================
>>  $ cvs diff -u -r1.252 -r1.253 rpmdb.c
>>  --- rpm/rpmdb/rpmdb.c 3 Jul 2008 18:01:19 -0000       1.252
>>  +++ rpm/rpmdb/rpmdb.c 28 Jul 2008 14:35:26 -0000      1.253
>>  @@ -46,7 +46,7 @@
>>
>>   /* XXX retrofit the *BSD typedef for the deprived. */
>>   #if defined(__QNXNTO__)
>>  -typedef      u_int32_t       uint32_t;
>>  +typedef      uint32_t        u_int32_t;
>>   #endif
>>
>>   /*@access dbiIndexSet@*/
>>  @@ .
>>  patch -p0 <<'@@ .'
>>  Index: rpm/rpmdb/sqlite.c
>>
>>  ============================================================================
>>  $ cvs diff -u -r1.33 -r1.34 sqlite.c
>>  --- rpm/rpmdb/sqlite.c        12 Mar 2008 19:41:13 -0000      1.33
>>  +++ rpm/rpmdb/sqlite.c        28 Jul 2008 14:35:26 -0000      1.34
>>  @@ -59,7 +59,7 @@
>>
>>   /* XXX retrofit the *BSD typedef for the deprived. */
>>   #if defined(__QNXNTO__)
>>  -typedef u_int32_t       uint32_t;
>>  +typedef uint32_t       u_int32_t;
>>   #endif
>>
>>   /*@unchecked@*/
>>  @@ .
>>  patch -p0 <<'@@ .'
>>  Index: rpm/tools/rpmmtree.c
>>
>>  ============================================================================
>>  $ cvs diff -u -r2.2 -r2.3 rpmmtree.c
>>  --- rpm/tools/rpmmtree.c      16 Jun 2008 09:41:28 -0000      2.2
>>  +++ rpm/tools/rpmmtree.c      28 Jul 2008 14:35:26 -0000      2.3
>>  @@ -43,6 +43,10 @@
>>   #include <signal.h>
>>   #include <stdarg.h>
>>
>>  +#if !defined(HAVE_ASPRINTF)
>>  +#include "asprintf.h"
>>  +#endif
>>  +
>>   #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
>> || defined(__DragonFly__) || defined(__APPLE__)
>>   #define      HAVE_ST_FLAGS   1       /* XXX TODO: should be AutoFu test
>> */
>>   #else
>>  @@ -53,6 +57,10 @@
>>   #define      st_mtimespec    st_mtim
>>   #endif
>>
>>  +#if defined(__QNXNTO__)
>>  +#define      st_mtimespec    st_mtime
>>  +#endif
>>  +
>>   #include <rpmio_internal.h>  /* XXX fdInitDigest() et al */
>>   #include <fts.h>
>>   #include <ugid.h>
>>  @@ -1015,7 +1023,7 @@
>>   /*==============================================================*/
>>
>>   /* XXX *BSD systems already have getmode(3) and setmode(3) */
>>  -#if defined(__linux__) || defined(__LCLINT__)
>>  +#if defined(__linux__) || defined(__LCLINT__) || defined(__QNXNTO__)
>>   #if !defined(HAVE_GETMODE) || !defined(HAVE_SETMODE)
>>
>>   #define      SET_LEN 6               /* initial # of bitcmd struct to
>> malloc */
>>  @@ -1500,7 +1508,7 @@
>>            /*@switchbreak@*/ break;
>>        case MTREE_KEYS_SIZE:
>>   /*@-unrecog@*/
>>  -         ip->sb.st_size = strtouq(val, &ep, 10);
>>  +         ip->sb.st_size = strtoul(val, &ep, 10);
>>   /*@=unrecog@*/
>>            if (*ep != '\0')
>>                mtree_error("invalid size %s", val);
>>  @@ .
>> ______________________________________________________________________
>> RPM Package Manager                                    http://rpm5.org
>> CVS Sources Repository                                rpm-cvs@rpm5.org
>>
>
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> Developer Communication List                        rpm-devel@rpm5.org
>
Received on Tue Jul 29 13:24:18 2008
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.