[Freeciv-Dev] [patch #4803] Probable incorrrect use of single equal sign in if statement

2014-06-15 Thread pepeto
Follow-up Comment #3, patch #4803 (project freeciv):

The single equal sign is here to assign the result of strrchr() to filename
within the if statement. It is not an incorrect usage here.

However, it could be clarified by:

if (NULL != (filename = strrchr(filepath, '/')))



___

Reply to this item at:

  http://gna.org/patch/?4803

___
  Message posté via/par Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #4803] Probable incorrrect use of single equal sign in if statement

2014-06-15 Thread Jon
Follow-up Comment #4, patch #4803 (project freeciv):

Thanks, I see my mistake, I was ignorant of that feature in the C language
(and close relatives).  I should have googled single equal sign if
statement.  

___

Reply to this item at:

  http://gna.org/patch/?4803

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #4803] Probable incorrrect use of single equal sign in if statement

2014-06-14 Thread Marko Lindqvist
Follow-up Comment #1, patch #4803 (project freeciv):

I've not yet checked the code in question carefully, but note that at least
use of double braces (( )) around it indicates that assignment (single
=) is there on purpose. With the limited context that is in the patch file
it also makes sense:
If strrchr() finds '/' in 'filepath', 'filename' points to character next to
that. If strrchr() does not find '/', but NULL gets assigned to 'filename'
(the else -branch) 'filename' then gets to point to beginning of the
'filepath'. It doesn't matter which value 'filename' had before entering that
block.

___

Reply to this item at:

  http://gna.org/patch/?4803

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #4803] Probable incorrrect use of single equal sign in if statement

2014-06-14 Thread Marko Lindqvist
Follow-up Comment #2, patch #4803 (project freeciv):

In general, using assignment within if:
- Value of the assignment operation is the same as the value assigned (var =
val has same value as val)
- For readability (and to avoid compiler warning) one should use braces when
value of the assignment operation is used (var = val) instead of just var =
val; compare var2 = var1 = val vs var2 = (var1 = val) )

___

Reply to this item at:

  http://gna.org/patch/?4803

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [patch #4803] Probable incorrrect use of single equal sign in if statement

2014-06-13 Thread Jon
URL:
  http://gna.org/patch/?4803

 Summary: Probable incorrrect use of single equal sign in if
statement
 Project: Freeciv
Submitted by: stratthinker
Submitted on: Sat 14 Jun 2014 12:51:49 AM UTC
Category: None
Priority: 5 - Normal
  Status: None
 Privacy: Public
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Discussion Lock: Any
 Planned Release: 

___

Details:

In the file srv_main.c I found on line 1244 this code
[code]
if ((filename = strrchr(filepath, '/'))) {
[/code]
shouldn't there be a double equal sign.
I have uploaded a patch to change it to a double equal sign.



___

File Attachments:


---
Date: Sat 14 Jun 2014 12:51:49 AM UTC  Name: srv_main.patch  Size: 440B   By:
stratthinker
Changed single equal sign to double equal sign
http://gna.org/patch/download.php?file_id=20999

___

Reply to this item at:

  http://gna.org/patch/?4803

___
  Message sent via/by Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev