Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » NFormat should check if args were left
NFormat should check if args were left [message #2501] Sat, 15 April 2006 09:48 Go to next message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
IMHO the NFormat function should check if any args were not printed, so NFormat("%n", 23, 43) will bugcheck.

Could be something like (in format.cpp)
RegisterValueFormatter(L"vt", &StdFormatFormatter);
...
...
      if(*s == '\0') {
#ifdef _DEBUG
        if (pos < v.GetCount()) {
          LOG("Not enough formatter: " << pos << " but " << v.GetCount() << " arg(s)");
          NEVER();
        }
#else
        if (pos < v.GetCount()) {
          result << " !MOREARGS! ";
          for (int i= pos; i < v.GetCount(); ++i)
            result << v[i] << ' ';
        }
#endif
        return result;
      }
Re: NFormat should check if args were left [message #2552 is a reply to message #2501] Mon, 17 April 2006 19:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, a good idea, however things are not that easy: "pos < v.GetCount" even if all parameters were used (because you can apply them in arbitrary order, using position in formatting specifiers).

Would require some sort of bitset or Index, I am not sure whether it is worth the trouble...

Mirek

[Updated on: Mon, 17 April 2006 19:11]

Report message to a moderator

Re: NFormat should check if args were left [message #2556 is a reply to message #2552] Mon, 17 April 2006 20:42 Go to previous messageGo to next message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Thanks,
I see there is more work needed.
But I think it is worth the trouble. Especially with arg reordering in translations.
Re: NFormat should check if args were left [message #2557 is a reply to message #2556] Mon, 17 April 2006 21:35 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Actually, another question to investigate, especially when translations are considered, is whether it is really good idea in all cases. I can imagine scenarios where in certain language translations, some parameters are unused deliberately...

Mirek
Previous Topic: Moveable classes with virtual functions/Documentation error
Next Topic: conversion between data of a cell of the arrayctrl to int
Goto Forum:
  


Current Time: Sat Apr 27 10:32:33 CEST 2024

Total time taken to generate the page: 0.04259 seconds