Andre Poenitz <[EMAIL PROTECTED]> writes:

| On Wed, Nov 27, 2002 at 12:46:43PM +0100, Lars Gullik Bjønnes wrote:
| > can you try to change this to:
| >                 extension.insert(0u, 1, '.');
| > 
| > (or
| > 
| >                 extension.insert(static_cast<unsigned int>(0), 1, '.');
| > 
| > Hopefully the first one is enough. There are other options as well but
| > then we are entering ugly-land.
| 
| Why? 0u and static_cast<unsigned int>(0) are null pointer constants as much
| as '0'.

yes, that was what I was afraid of.
but anyhow, did you try 0u? 
| 
|            string extension(ext);
| -          if (extension[0] != '.') extension.insert(0, 1, '.');
| +          if (extension[0] != '.') extension.insert(0, ".");
|            vector<string> dirlist;
|            directory_iterator dit("dir");
| 
| would be a fix. But you know that, of course...

yes.

but I have a feeling that the right fix would be something like:

string extension;
if (!ext.empty() && ext[0] != '.')
        extension += '.';
extension += ext;

thus avoiding the whole issue. and imho simpler code too.

(according to the standard we should not need to check if ext is
empty, sine ext[0] should return '\0' when ext is empty, not sure if
we should count on that)

-- 
        Lgb

Reply via email to