[Toybox] Defect in Argument parsing for "#" and "-"

Ashwini Sharma ak.ashwini at gmail.com
Mon Jul 2 20:05:09 PDT 2012


Hi Rob,

 I was using '#' for accepting a integer parameter. As per the parsing logic
you used function atolx(), for converting the string to long. This
function assumes suffixes with the supplied string. There are
possibilities that user may not want suffixes to be there, i.e. any
alpha char in the argument should be treated as "Invalid Argument".

Also for the cases where user has only supplied a suffix, without any
number, atolx will return 0, which may not be the desired case.

I had a case where depth of traversal was to be defined as cmdline argument.
Giving "kmgtpe" would return zero, whereas I wanted it to only
integers as argument and no alpha characters.

Hence I am of the opinion that,

  1. It should be treated as "Invalid Argument" if no number is specified And
  2. It should be configurable, if a feature wants the suffixes to be
handled or not.

Please do provide your opinion.

regards,
Ashwini

 1341284709.0


More information about the Toybox mailing list