rsync-2.5.1 / popt patches

John E. Malmberg wb8tyw at qsl.net
Mon Jan 7 10:58:46 EST 2002


The following popt files need patches in order to compile using Compaq C 
on OpenVMS.  These patches should also be needed on a Tru64 or LINUX on 
ALPHA using Compaq C.  Except for the alloca issue, these should work on 
any ANSI compliant compiler.


Operating System: OpenVMS ALPHA V7.3
Compiler: Compaq C T6.5

Compiler switches: /WARN=ENABLE=(LEVEL4, QUESTCODE)


SYSTEM.H is doing tests on undefined macros, and if the target is not 
_GNUC__ or _AIX is assuming that a specific prototype exists.

This patch prototypes the alloca() function to be more consistent, but 
since any platform that supports the alloca() function should be able to 
provide a prototype, a specific prototype probably should not ever be 
needed.  More work is probably needed with the alloca definiton.

POPT.C was assuming that the presence of an alloca() function was based 
on the existance of HAVE_ALLOCA_H.  The macro HAVE_ALLOCA_H should only 
be indicating the presence of a header file.

The presence of an ALLOCA function should be based on the macro 
HAVE_ALLOCA.  This of course will require a change to the CONFIGURE 
scripts, which I can not test.

POPT.C also contained a conditional expression testing if the unsigned 
variable "argx" is greater than 0.  Since this value can never be less 
than 0, a more appropriate test is to check if the value is non-zero.
[Lint type diagnostic]


POPT.H, POPT.C have an error with the definition of the poptStrerror 
routine.

POPTHELP.C has an error with the definitions of the 
getTableTranslationDomain() and getArgDescrip() routines.

Having a const qualifier on function return value is not legal.
It is legal to return a const pointer.




EAGLE> type lcl_popt:system_h.gdiff
--- ref_popt:system.h   Fri Feb 23 19:32:22 2001
+++ lcl_popt:system.h   Sun Jan  6 08:42:28 2002
@@ -1,3 +1,4 @@
+/* Converted by prj_src:unix_c_to_vms_c.tpu AND prj_popt:system.tpu on 
6-JAN-2002 08:42:28.07 OPENVMS_AXP */
  #ifdef HAVE_CONFIG_H
  #include "config.h"
  #endif
@@ -7,7 +8,7 @@
  #include <fcntl.h>
  #include <limits.h>

-#if HAVE_MCHECK_H
+#ifdef HAVE_MCHECK_H
  #include <mcheck.h>
  #endif

@@ -15,7 +16,7 @@
  #include <stdlib.h>
  #include <string.h>

-#if HAVE_UNISTD_H
+#ifdef HAVE_UNISTD_H
  #include <unistd.h>
  #endif

@@ -27,14 +28,14 @@

  /* AIX requires this to be the first thing in the file.  */
  #ifndef __GNUC__
-# if HAVE_ALLOCA_H
+#ifdef HAVE_ALLOCA_H
  #  include <alloca.h>
  # else
  #  ifdef _AIX
  #pragma alloca
  #  else
  #   ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
+void * alloca(unsigned int x);
  #   endif
  #  endif
  # endif
@@ -44,7 +45,7 @@

  /*@only@*/ char * xstrdup (const char *str);

-#if HAVE_MCHECK_H && defined(__GNUC__)
+#if defined(HAVE_MCHECK_H) && defined(__GNUC__)
  #define        vmefail()       (fprintf(stderr, "virtual memory 
exhausted.\n"),
  exit(EXIT_FAILURE), NULL)
  #define xstrdup(_str)   (strcpy((malloc(strlen(_str)+1) ? : 
vmefail()), (_str))
)
  #else


EAGLE> type lcl_popt:popt_h.gdiff
--- ref_popt:popt.h     Fri Feb 23 19:32:22 2001
+++ lcl_popt:popt.h     Sun Jan  6 08:42:28 2002
@@ -1,3 +1,4 @@
+/* Converted by prj_src:unix_c_to_vms_c.tpu AND prj_popt:popt.tpu on 
6-JAN-2002 08:42:28.57 OPENVMS_AXP */
  /* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING
     file accompanying popt source distributions, available from
     ftp://ftp.redhat.com/pub/code/popt */
@@ -114,7 +115,7 @@
                 /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr);
  int poptParseArgvString(const char * s,
                 /*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr);
-/*@observer@*/ const char *const poptStrerror(const int error);
+/*@observer@*/ const char * poptStrerror(const int error);
  void poptSetExecPath(poptContext con, const char * path, int 
allowAbsolute);
  void poptPrintHelp(poptContext con, FILE * f, int flags);
  void poptPrintUsage(poptContext con, FILE * f, int flags);


EAGLE> type lcl_popt:popthelp.gdiff
--- ref_popt:popthelp.c Fri Feb 23 19:32:22 2001
+++ lcl_popt:popthelp.c Sun Jan  6 08:42:42 2002
@@ -1,3 +1,4 @@
+/* Converted by prj_src:unix_c_to_vms_c.tpu AND prj_popt:popthelp.tpu 
on  6-JAN-2002 08:42:42.26 OPENVMS_AXP */
  /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 
-*- */

  /* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING
@@ -26,7 +27,7 @@
  } ;


-/*@observer@*/ /*@null@*/ static const char *const
+/*@observer@*/ /*@null@*/ static const char *
  getTableTranslationDomain(const struct poptOption *table)
  {
    const struct poptOption *opt;
@@ -41,7 +42,7 @@
    return NULL;
  }

-/*@observer@*/ /*@null@*/ static const char *const
+/*@observer@*/ /*@null@*/ static const char *
  getArgDescrip(const struct poptOption * opt, const char 
*translation_domain)
  {
      if (!(opt->argInfo & POPT_ARG_MASK)) return NULL;



EAGLE> type lcl_popt:popt.gdiff
--- ref_popt:popt.c     Thu Mar 22 21:44:50 2001
+++ lcl_popt:popt.c     Sun Jan  6 08:42:33 2002
@@ -1,3 +1,4 @@
+/* Converted by prj_src:unix_c_to_vms_c.tpu AND prj_popt:popt.tpu on 
6-JAN-200
2 08:42:33.25 OPENVMS_AXP */
  /* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING
     file accompanying popt source distributions, available from
     ftp://ftp.redhat.com/pub/code/popt */
@@ -330,7 +331,7 @@
         for (i = os->next; i < os->argc; i++) {
             if (os->argb && PBM_ISSET(i, os->argb)) continue;
             if (*os->argv[i] == '-') continue;
-           if (--argx > 0) continue;
+           if (--argx != 0) continue;
             arg = os->argv[i];
             if (delete) {
                 if (os->argb == NULL) os->argb = PBM_ALLOC(os->argc);
@@ -399,7 +400,7 @@
      int done = 0;

      /* looks a bit tricky to get rid of alloca properly in this fn */
-#if HAVE_ALLOCA_H
+#ifdef HAVE_ALLOCA
  #define ALLOCA(x) alloca(x)
  #else
  #define ALLOCA(x) malloc(x)
@@ -710,7 +711,7 @@
  #define POPT_ERROR_BADQUOTE    -15     /* only from 
poptParseArgString() */
  #define POPT_ERROR_ERRNO       -16     /* only from 
poptParseArgString() */

-const char *const poptStrerror(const int error) {
+const char * poptStrerror(const int error) {
      switch (error) {
        case POPT_ERROR_NOARG:
         return POPT_("missing argument");





More information about the rsync mailing list