On 07/02/2012 10:05 PM, Ashwini Sharma wrote: > 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.
Understood. Question: why? > 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. I can grab a third character (maybe %) for literal long. The tradeoff here is between generic behavior (which can share code) and precise behavior that does exactly what you want. Some things need suffixes, so I made everything accept suffixes by default because I didn't see the harm. Apparently you do. Could you explain the harm to me? (It's not that much extra code, but it's extra code you can't configure out because it's in the generic code shared by all commands...) Thanks, Rob -- GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code. Either it's "mere aggregation", or a license violation. Pick one. _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net