
borneo.antonio at gmail
Apr 15, 2012, 2:38 AM
Post #5 of 7
(650 views)
Permalink
|
|
Re: [PATCH] Ignore leading and trailing whitespace in config file
[In reply to]
|
|
On Sun, Apr 15, 2012 at 3:59 AM, Florian Schlichting <fschlich [at] zedat> wrote: > Martin, Antonio, > > thanks a lot for your replies. It's encouraging to get positive feedback > so quickly! > >> All fields config_names[].name with "needsArgument==1" end with a ' ' >> that is considered part of the name. >> This ' ' can be striped away adding a check for a mandatory ' ' or >> '\t' after the name. >> In this way we add flexibility of using only tabs as separator. > > Good point. I've added that, plus a line to add a blank when printing > the configuration. And your addition for removing optional quotes. Also, > I hope I got the space/tab thing right this time, so please find the > entire patch attached - it seems to work correctly as far as my testing > goes. > > Florian > Florian, I'm not at my desk and cannot run tests nor compile. I'll check later... Does it apply to ./trunk/ or to ./branches/vpnc-nortel/ ? Just to know ,,, I will anyway apply on both with the proper modification. What is the deadline for including it in wheezy, as you write in another email? + /* skip further leading and trailing whitespace */ + for (start++; line[start] == ' ' || line[start] == '\t'; start++) + ; + for (llen--; line[llen] == ' ' || line[llen] == '\t' ; llen--) + line[llen] = 0; Is this part safe in case of *wrong* line made by: - valid option that need argument (e.g. "IPSec ID") - followed by just a set of ' ' and '\t' ? I mean, with a line like "IPSec ID\t\t\t\t" start will be increased till it points the end of string, then llen will go back till the first char not blank ('D' in my example). The value of startt would be higher than llen. I do not see any critical issue, since spaces are replaced with '\0'. Please help me to check if I'm missing some case. Probably it's better to evaluate llen as first, then start. Will force the example above to end with the same value for start and llen. - printf("%s%s\n", config_names[i].name, + printf("%s%s%s\n", config_names[i].name, + config_names[i].needsArgument ? " " : "", config_names[i].needsArgument ? config[config_names[i].nm] : ""); I agree using one ' ' as separator. '\t' would work too, but I like keeping ' ' for backward compatibility. It's missing the case of argument that starts or ends (or both) with a space. It would require to be enclosed between double quotes. There is also the additional case of an argument (password ?) that starts and ends with double quotes. Also in this case it need to be put within additional pair of quotes. It's ugly, but it's the only way to get from "--print-config" a config file that provides same values. The easier way would be to *always* put quotes, but the result would break backward compatibility. Good job. Thanks, Antonio _______________________________________________ vpnc-devel mailing list vpnc-devel [at] unix-ag https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel http://www.unix-ag.uni-kl.de/~massar/vpnc/
|