Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Chris Sosnin <k.sosnin@tarantool.org>,
	tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 1/2] Refactor decNumberFromString
Date: Thu, 25 Jun 2020 00:22:41 +0200	[thread overview]
Message-ID: <f08541a8-e481-ce10-9bd0-ab041c1c136c@tarantool.org> (raw)
In-Reply-To: <7e17dc729687c7c61da5f761e4302e6e78b9d01f.1593017012.git.k.sosnin@tarantool.org>

Hi! Thanks for the patch!

Technically looks fine, although I didn't test it except for
the tests we already have. You probably should create a patchset
for the main repository with decnumber version bump + decimal.h
API update + unit tests in unit/decimal.c. Before this commit
is merged, so as you could fix any potential errors.

> diff --git a/decNumber.c b/decNumber.c
> index 85deb13..e248656 100644
> --- a/decNumber.c
> +++ b/decNumber.c
> @@ -545,7 +545,7 @@ char * decNumberToEngString(const decNumber *dn, char *string){
>  /*                                                                    */
>  /* If bad syntax is detected, the result will be a quiet NaN.         */
>  /* ------------------------------------------------------------------ */
> -decNumber * decNumberFromString(decNumber *dn, const char chars[],
> +const char * decNumberFromString(decNumber *dn, const char chars[],
>                                  decContext *set) {

1. The code style is absolutely dead, but it is consistently dead.
Part of its consistency was the multi-line argument alignment, the
same as in Tarantool. Here the second line should be aligned under
the first argument of the first line:

    const char * decNumberFromString(decNumber *dn, const char chars[],
                                     decContext *set) {

Not like this:

    const char * decNumberFromString(decNumber *dn, const char chars[],
                                    decContext *set) {

> diff --git a/decNumber.h b/decNumber.h
> index 85a3f3f..ffaa3d8 100644
> --- a/decNumber.h
> +++ b/decNumber.h
> @@ -101,19 +101,19 @@
>    /* decNumber public functions and macros                            */
>    /* ---------------------------------------------------------------- */
>    /* Conversions                                                      */
> -  decNumber * decNumberFromInt32(decNumber *, int32_t);
> -  decNumber * decNumberFromUInt32(decNumber *, uint32_t);
> -  decNumber * decNumberFromInt64(decNumber *, int64_t);
> -  decNumber * decNumberFromUInt64(decNumber *, uint64_t);
> -  decNumber * decNumberFromString(decNumber *, const char *, decContext *);
> -  char      * decNumberToString(const decNumber *, char *);
> -  char      * decNumberToEngString(const decNumber *, char *);
> -  uint32_t    decNumberToUInt32(const decNumber *, decContext *);
> -  uint64_t    decNumberToUInt64(const decNumber *, decContext *);
> -  int32_t     decNumberToInt32(const decNumber *, decContext *);
> -  int64_t     decNumberToInt64(const decNumber *, decContext *);
> -  uint8_t   * decNumberGetBCD(const decNumber *, uint8_t *);
> -  decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);
> +  decNumber  * decNumberFromInt32(decNumber *, int32_t);
> +  decNumber  * decNumberFromUInt32(decNumber *, uint32_t);
> +  decNumber  * decNumberFromInt64(decNumber *, int64_t);
> +  decNumber  * decNumberFromUInt64(decNumber *, uint64_t);
> +  const char * decNumberFromString(decNumber *, const char *, decContext *);
> +  char       * decNumberToString(const decNumber *, char *);
> +  char       * decNumberToEngString(const decNumber *, char *);
> +  uint32_t     decNumberToUInt32(const decNumber *, decContext *);
> +  uint64_t     decNumberToUInt64(const decNumber *, decContext *);
> +  int32_t      decNumberToInt32(const decNumber *, decContext *);
> +  int64_t      decNumberToInt64(const decNumber *, decContext *);
> +  uint8_t    * decNumberGetBCD(const decNumber *, uint8_t *);
> +  decNumber  * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t);

2. Lets not do so many changes. I think it is ok to break
the alignment in one line. Or you can wrap function name on
a next line, if you want.

So as it would be

    decNumber * decNumberFromUInt64(decNumber *, uint64_t);
    const char *
                decNumberFromString(decNumber *, const char *, decContext *);
    char      * decNumberToString(const decNumber *, char *);

Or break the alignment:

    decNumber * decNumberFromUInt64(decNumber *, uint64_t);
    const char * decNumberFromString(decNumber *, const char *, decContext *);
    char      * decNumberToString(const decNumber *, char *);

But I really don't like when alignment causes so many changes.

  reply	other threads:[~2020-06-24 22:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 16:53 [Tarantool-patches] [PATCH v2 0/2] decNumber utilites for SQL Chris Sosnin
2020-06-24 16:53 ` [Tarantool-patches] [PATCH v2 1/2] Refactor decNumberFromString Chris Sosnin
2020-06-24 22:22   ` Vladislav Shpilevoy [this message]
2020-06-25 14:21     ` Chris Sosnin
2020-06-24 16:53 ` [Tarantool-patches] [PATCH v2 2/2] Add IsInt method for checking the fractional part of a number Chris Sosnin
2020-06-24 22:23   ` Vladislav Shpilevoy
2020-06-25 14:22     ` Chris Sosnin
2020-06-25 21:04 ` [Tarantool-patches] [PATCH v2 0/2] decNumber utilites for SQL Vladislav Shpilevoy
2020-06-26 10:57 ` Serge Petrenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f08541a8-e481-ce10-9bd0-ab041c1c136c@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=k.sosnin@tarantool.org \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 1/2] Refactor decNumberFromString' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox