poke-devel
[Top][All Lists]
Advanced

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

Re: [COMMITTED 4/4] poked,pokefmt: get rid of `err.h'


From: Jose E. Marchesi
Subject: Re: [COMMITTED 4/4] poked,pokefmt: get rid of `err.h'
Date: Sun, 11 Feb 2024 12:38:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

> `err.h' is not available on some (old) systems.  This commit
> replace them with a local implementation.
>
> 2024-02-11  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>
>       * poked/poked.c (#include <err.h>): Remove.
>       (#include <stdarg.h>): Add.
>       (err): New function.
>       (errx): Likewise.
>       * pokefmt/pokefmt.l (#include <err.h>): Remove.
>       (#include <stdarg.h>): Add.
>       (err): New function.
>       (errx): Likewise.
> ---
>
> Hi Jose.
>
> Do you think this is safe to be included in the maint/poke-4?

Yes, but please mind the code style. (space before open parentheses).

>
>
> Regards,
> Mohammad-Reza
>
>
>  ChangeLog         | 11 +++++++++++
>  poked/poked.c     | 30 +++++++++++++++++++++++++++++-
>  pokefmt/pokefmt.l | 33 ++++++++++++++++++++++++++++++++-
>  3 files changed, 72 insertions(+), 2 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index 5c4071f2..1e3cf704 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,14 @@
> +2024-02-11  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
> +
> +     * poked/poked.c (#include <err.h>): Remove.
> +     (#include <stdarg.h>): Add.
> +     (err): New function.
> +     (errx): Likewise.
> +     * pokefmt/pokefmt.l (#include <err.h>): Remove.
> +     (#include <stdarg.h>): Add.
> +     (err): New function.
> +     (errx): Likewise.
> +
>  2024-02-11  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
>  
>       * poked/usock.c (usock_handle_notif): Handle `EWOULDBLOCK'
> diff --git a/poked/poked.c b/poked/poked.c
> index 9cb8de50..aa67d8ce 100644
> --- a/poked/poked.c
> +++ b/poked/poked.c
> @@ -22,8 +22,8 @@
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> +#include <stdarg.h>
>  
> -#include <err.h>
>  #include <getopt.h>
>  #include <pthread.h>
>  #include <unistd.h>
> @@ -33,6 +33,34 @@
>  #include "libpoke.h"
>  #include "configmake.h"
>  
> +//--- err and errx implementation
> +
> +static void
> +errx(int eval, const char *fmt, ...)
> +{
> +  va_list ap;
> +
> +  va_start (ap, fmt);
> +  vfprintf (stderr, fmt, ap);
> +  va_end (ap);
> +  fprintf (stderr, "\n");
> +  exit (eval);
> +}
> +
> +static void
> +err(int eval, const char *fmt, ...)
> +{
> +  va_list ap;
> +
> +  va_start (ap, fmt);
> +  vfprintf (stderr, fmt, ap);
> +  va_end (ap);
> +  fprintf (stderr, ": %s\n", strerror (errno));
> +  exit (eval);
> +}
> +
> +//---
> +
>  pk_compiler pkc;
>  struct usock *srv;
>  
> diff --git a/pokefmt/pokefmt.l b/pokefmt/pokefmt.l
> index f95f54f5..ac69bef0 100644
> --- a/pokefmt/pokefmt.l
> +++ b/pokefmt/pokefmt.l
> @@ -130,8 +130,8 @@ struct source_range
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> +#include <stdarg.h>
>  
> -#include <err.h>
>  #include <getopt.h>
>  #include <unistd.h>
>  
> @@ -139,6 +139,9 @@ struct source_range
>  #include "libpoke.h"
>  #include "pk-utils.h"
>  
> +static void errx(int eval, const char *fmt, ...);
> +static void err(int eval, const char *fmt, ...);
> +
>  struct poke
>  {
>    pk_compiler compiler;
> @@ -257,6 +260,34 @@ main (int argc, char *argv[])
>    return 0;
>  }
>  
> +//--- err and errx implementation
> +
> +static void
> +errx(int eval, const char *fmt, ...)
> +{
> +  va_list ap;
> +
> +  va_start (ap, fmt);
> +  vfprintf (stderr, fmt, ap);
> +  va_end (ap);
> +  fprintf (stderr, "\n");
> +  exit (eval);
> +}
> +
> +static void
> +err(int eval, const char *fmt, ...)
> +{
> +  va_list ap;
> +
> +  va_start (ap, fmt);
> +  vfprintf (stderr, fmt, ap);
> +  va_end (ap);
> +  fprintf (stderr, ": %s\n", strerror (errno));
> +  exit (eval);
> +}
> +
> +//---
> +
>  static void
>  pokefmt_version (void)
>  {



reply via email to

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