Changeset 1278


Ignore:
Timestamp:
09/09/23 15:22:45 (8 months ago)
Author:
Maciej Komosinski
Message:

When loading/parsing files, warn about unexpected characters after the multi-line string marker '~'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.cpp

    r1253 r1278  
    554554}
    555555
     556static SString getFileMessageFor(VirtFILE* f, ParamInterface::LoadOptions &options)
     557{
     558        SString fileinfo;
     559        const char* fname = f->VgetPath();
     560        if (fname != NULL)
     561                {
     562                fileinfo = SString::sprintf(" while reading from '%s'", fname);
     563                if (options.linenum)
     564                        fileinfo += SString::sprintf(" (line %d)", *options.linenum);
     565                }
     566        return fileinfo;
     567}
     568
    556569int ParamInterface::loadMultiLine(VirtFILE* f, LoadOptions &options)
    557570{
     
    600613                        if (seen[i])
    601614                        {
    602                                 SString fileinfo;
    603                                 const char* fname = f->VgetPath();
    604                                 if (fname != NULL)
    605                                 {
    606                                         fileinfo = SString::sprintf(" while reading from '%s'", fname);
    607                                         if (options.linenum)
    608                                                 fileinfo += SString::sprintf(" (line %d)", *options.linenum);
    609                                 }
     615                                SString fileinfo = getFileMessageFor(f,options);
    610616                                logPrintf("ParamInterface", "load", LOG_WARN, "Multiple '%s.%s' properties found%s", getName(), id(i), fileinfo.c_str());
    611617                        }
     
    616622                                if (p0[p_len + 1] == '~')
    617623                                {
     624                                        if (p0[p_len+2])
     625                                        {
     626                                                SString fileinfo = getFileMessageFor(f,options);
     627                                                logPrintf("ParamInterface", "load", LOG_WARN, "Ignored unexpected characters after '~': '%s' in '%s:'%s", p0+p_len+1, id(i), fileinfo.c_str());
     628                                        }
     629                               
    618630                                        SString s;
    619631                                        if (!readUntilTilde(f, s))
Note: See TracChangeset for help on using the changeset viewer.