gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 5/8] Test for number of mkdir() arguments


From: Pawel Kot
Subject: Re: [PATCH 5/8] Test for number of mkdir() arguments
Date: Tue, 4 Dec 2018 00:24:14 +0300

Hi Ladis,

On Mon, Dec 3, 2018 at 11:28 PM Ladislav Michl <address@hidden> wrote:
> there's an issue with changes like that one bellow.
> Currently each file including compat.h have to include
> config.h before on its own. That does not sound too
> convenient and is quite error prone as I just found
> testing mkdir patch on more configurations.

I remeber it being discussed. Still not quite sure why we did it that way.
I believe #include "config.h" from compat.h should be safe. Even without removing all others. I believe that whenever you need something from "config.h" you should explicitly include it.

Cheers,
Paweł

> So what about this change:
>
> diff --git a/include/compat.h b/include/compat.h
> index 8711c425..60974344 100644
> --- a/include/compat.h
> +++ b/include/compat.h
> @@ -18,6 +18,17 @@
>  #ifndef        _gnokii_compat_h
>  #define        _gnokii_compat_h
>
> +#if defined(HAVE_CONFIG_H)
> +#  include "config.h"
> +
> +#elif defined(WIN32) && defined(_MSC_VER)
> +#  include "windows-config.h"
> +
> +#else
> +#  error "compat.h requires config.h"
> +
> +#endif
> +
>  #include <stdlib.h>
>  #include <stdio.h>
>
> Perhaps ommiting windows-config.h part in the first round.
> Then we could delete config.h include from each file which
> also include compat.h. That is... almost each file.
>
> Objections?
>
>
> On Mon, Dec 03, 2018 at 10:42:06AM +0100, Ladislav Michl wrote:
> > Windows' mkdir() takes only 1 argument, so add a test for that.
> > ---
> >  configure.ac     |  1 +
> >  include/compat.h | 15 ++++++++++++++-
> >  2 files changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 379c7412..cd2064dd 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -902,6 +902,7 @@ AC_PROG_GCC_TRADITIONAL
> >  AC_FUNC_MEMCMP
> >  AC_TYPE_SIGNAL
> >  AC_FUNC_STRFTIME
> > +AC_FUNC_MKDIR
> >  AC_CHECK_FUNCS(mktime timegm gettimeofday select poll wcrtomb)
> >  AC_CHECK_FUNCS(strchr strdup strndup strstr strtol strtok strsep)
> >  AC_CHECK_FUNCS(asprintf vasprintf snprintf vsnprintf getpass setenv)
> > diff --git a/include/compat.h b/include/compat.h
> > index 009f5f0e..8711c425 100644
> > --- a/include/compat.h
> > +++ b/include/compat.h
> > @@ -199,6 +199,20 @@ int vasprintf(char **ptr, const char *format, va_list ap);
> >  time_t timegm(struct tm *tm);
> >  #endif
> >
> > +#if HAVE_MKDIR
> > +# if MKDIR_TAKES_ONE_ARG
> > +   /* Mingw32 */
> > +#  define mkdir(a,b) mkdir(a)
> > +# endif
> > +#else
> > +# if HAVE__MKDIR
> > +   /* plain Win32 */
> > +#  define mkdir(a,b) _mkdir(a)
> > +# else
> > +#  error "Don't know how to create a directory on this system."
> > +# endif
> > +#endif
> > +
> >  /*
> >   * The following code was taken from W. Richard Stevens'
> >   * "UNIX Network Programming", Volume 1, Second Edition.
> > @@ -219,7 +233,6 @@ time_t timegm(struct tm *tm);
> >  #ifdef WIN32
> >  #  ifdef _MSC_VER
> >  #    define inline __inline
> > -#    define mkdir(dirname, accessrights) _mkdir(dirname)
> >  #    define strcasecmp _stricmp
> >  #    define strncasecmp _strnicmp
> >  #    define __const const
> > --
> > 2.20.0.rc1
> >
> >
> > _______________________________________________
> > gnokii-users mailing list
> > address@hidden
> > https://lists.nongnu.org/mailman/listinfo/gnokii-users
>
> _______________________________________________
> gnokii-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/gnokii-users



--
Pawel Kot

reply via email to

[Prev in Thread] Current Thread [Next in Thread]