Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for {0:02X}, 'y' #57

Closed
tarwich opened this issue Jul 24, 2014 · 3 comments
Closed

Support for {0:02X}, 'y' #57

tarwich opened this issue Jul 24, 2014 · 3 comments

Comments

@tarwich
Copy link

tarwich commented Jul 24, 2014

I'm still getting an error here when calling fmt::format("{0:02X}", 'x'); and I think it's because it's not liking the number alignment, but... 'x' is a number in this case.

    // format.cc:444
    if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0)
      throw FormatError("invalid format specifier for char");
@tarwich
Copy link
Author

tarwich commented Jul 24, 2014

I was able to patch it with this horrible code. If for some reason you like it, I can make a pull request.

diff --git a/format.cc b/format.cc
index f57c0db..8e8cd42 100644
--- a/format.cc
+++ b/format.cc
@@ -440,8 +440,12 @@ class fmt::internal::ArgFormatter :
       default:
         internal::ReportUnknownType(spec_.type_, "char");
       }
-    }
-    if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0)
+   }
+   else {
+       if(spec_.align_ == ALIGN_NUMERIC)
+           throw FormatError("invalid format specifier for char");
+   }
+    if (spec_.flags_ != 0)
       throw FormatError("invalid format specifier for char");
     typedef typename fmt::BasicWriter<Char>::CharPtr CharPtr;
     CharPtr out = CharPtr();

@vitaut vitaut closed this as completed in a997de9 Jul 25, 2014
@vitaut
Copy link
Contributor

vitaut commented Jul 25, 2014

Fixed, sorry for the inconvenience (I forgot to test the previous fix and of course it was not working as expected).

@tarwich
Copy link
Author

tarwich commented Jul 25, 2014

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants