Message: Re: /control/foreach possible bug Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

More Re: /control/foreach possible bug 

Forum: (Graphical) User Interfaces
Re: Warning /control/foreach possible bug (C Mos)
Re: Idea Re: /control/foreach possible bug (C Mos)
Date: 26 Apr, 2014
From: C Mos <C Mos>

Ok so I did a tracing of the bug and this is what I find out.


First point: based on the guidance of "/control/alias":

  Command /control/alias
  Guidance :
  Set an alias.
  String can be aliased by this command.
  The string may contain one or more spaces,
  the string must be enclosed by double quotes (").
  To use an alias, enclose the alias name with
  parenthis "{" and "}".


Now when one executes

  /contol/foreach macrofile liasname candidates

the string "candidates" gets tokenized, broken into parts. The first token STARTS with the character '"' and the last token FINISHES with '"' character. The function SetAlias():

handles the first token perfectly but it fails to handle the last token. The code of SetAlias() assumes that either

  1)the value of the alias is enclosed in double quotes '"' 
  2)or the value of the alias starts with a double quote "'"

However the function cannot handle when the value of the alias finishes ONLY with a single quote '"'. Again, this problem arises because the original list of candidates got tokenized.


[Best solution] Rewrite G4UImanager::SetAlias() function to strip first the double quotes at the beginning of the aliasValue follow by (and INDEPENDENTLY from the first stripped) removing the double quotes at the end.

[Second solution] Redefine the function in G4SubString operator()(const char* str=" \t\n",size_t l=0)

so to include the double quotes '"' as a tokenizer delimiter. This solution is not the best as it has the potential to break functionality in case other functions are already managing double quotes in their own way. However I want to bring forward this solution because it has the potential to reduce code, it could be a nice fix and one would not need to worry bout double quotes anymore :).


C Mos

 Add Message Add Message
to: "Re: /control/foreach possible bug"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews

[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]