On Sun, 15 Apr 2012, Carlos R. Mafra escribió:

> On Sun, 15 Apr 2012 at 23:09:39 +0200, Rodolfo García Peñas wrote:
> >  
> > -   if (instance && class) {
> > -           char *buffer;
> > -           buffer = wmalloc(strlen(instance) + strlen(class) + 2);
> > -           sprintf(buffer, "%s.%s", instance, class);
> > +   if (instance || class) {
> > +           buffer = StrConcatDot(instance, class, False);
> 
> Why didn't you keep the original && instead of changing it to || and 
> using False?
> 
> I didn't like this extra parameter in StrConcatDot(). The name of the
> function suggests that a dot will be added, making it depend on
> the extra parameter confuses things, imho.
> 
> I think it is better to have StrConcatDot() always add the dot, because
> that's what the name suggests.

Hi!

thanks a lot for your review. Please, take a look that you push 
"WindowMaker: getnameforicon() function splitted"
and this function uses StrConcatDot with the boolean argument, then the current 
next branch fails to build.

About your question. I did it for these reasons:

- With the current (without Bool) StrConcat adds the point, then we can use for 
these options:

"a.b", "a.", ".b" and "."

- With the boolean argument:

True: "a.b", "a.", ".b" and "."
False: "ab" "a", "b" and ""

In the code, we found this code in various files:

if (instance && class) -> to get "a.b"
else if (instance) -> sometimes to get "a" others "a."
else if (class) -> like instance, "b" or ".b"
else -> sometimes "" or "."

Then, I thought the boolean parameter is interesting.

Why I changed && for ||?

Because the old function did only "a.b" if we use &&.
Now, with the new function if "a and b", "a" or "b" exists (using ||), we can 
use StrConcatDot can to the work:

Old code:

if (a && b) -> x = StrConcatDot(a, b) -> "a.b"
else if (a) -> x = a                  -> "a"
else if (b) -> x = b                  -> "b"
else        -> x = ""                 -> ""

New code

if (a || b) -> x = StrConcatDot (a, b, False)
else        -> x = ""

if a and b -> x = "a.b"
if a only  -> x = "a"
if b only  -> x = "b"

About your other mails, sorry for the "point" and for the "*" in the functions. 
I tried to avoid mistakes, but... 

Please, tell me if you prefer the original or the new StrConcatDot after this 
mail. Don't forget the next branch!

Thanks Carlos,
kix
-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


--
To unsubscribe, send mail to [email protected].

Reply via email to