trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #590: JIRA TRAFODION-2099 Add support for b...
Date Tue, 12 Jul 2016 15:24:56 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/590#discussion_r70461463
  
    --- Diff: core/sql/common/str.cpp ---
    @@ -997,19 +997,40 @@ Lng32 str_decode(void *tgt, Lng32 tgtMaxLen, const char *src, Lng32
srcLen)
       return length;
     }
     
    -// Strips leading and trailing blanks. src will contain a NULL after the
    +// Strips leading and/or trailing blanks. src will contain a NULL after the
     // end of the first non-blank character.The length of the "stripped" string
    -// is returned in len
    -
    -void str_strip_blanks(char *src , Lng32 &len)
    +// is returned in len.
    +// Returns pointer to the start of string after leading blanks.
    +char * str_strip_blanks(char *src , Lng32 &len, 
    +                        NABoolean stripLeading,
    +                        NABoolean stripTrailing
    +                        )
     {
    +  if (! src)
    +    return NULL;
    +
       len = str_len(src)-1;
    -  while ((len >= 0) && (src[len] == ' '))
    -    len--;
    +  if (len <= 0)
    +    return src;
    --- End diff --
    
    Hmmm... Isn't len a reference parameter? Therefore it is an output as well as an input.
Perhaps it should be pass by value instead?
    
    Let's take another example. Suppose the input string is ' ' (that is, one blank). The
code as written would calculate len = 0 at line 1012, then the 'if' at line 1013 is true,
and we return src without stripping a blank. Seems like we should return the empty string
instead?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message