TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
453 stars 141 forks source link

added missing 3rd argument to WIN32 _snprintf_s() #12

Closed fjhub closed 10 years ago

fjhub commented 10 years ago

Closes #11.

TooTallNate commented 10 years ago

Can't we do this implicitly by turning the #define here into a macro?

TooTallNate commented 10 years ago

Thanks for the patch by the way :)

fjhub commented 10 years ago

I thought about that in order to keep things clean but wasn't sure how to handle the variable argument nature of the call. I guess I should have done a quick search on this. I believe it could be handled with something like:

define snprintf _snprintf_s(a,b, _TRUNCATE, __VA_ARGS__)

but I haven't tested this.

I recently got burned on my assumption that snprintf in unix/linux was the same on windows until I came across some non-ascii characters showing up in some data.

glad to help out...your tools have proven to be invaluable.

fjhub commented 10 years ago

oops..I think I clicked too soon. should have been _TRUNCATE, __VA_ARGS__

fjhub commented 10 years ago

nope...it looks as if the underscores were removed. should be one before TRUNCATE and 2 before and after VA_ARGS.

TooTallNate commented 10 years ago

A totally proper macro probably isn't necessary. We're only passing in 1 var arg in both instances in this file, so we could probably get away with avoiding the __VA_ARGS__ part. Either way is fine with me really.

Glad to hear this module has been useful for you :)

TooTallNate commented 10 years ago

Merged. Thanks!

TooTallNate commented 10 years ago

Though to be honest, I'm curious why this StackOverflow thread doesn't mention _TRUNCATE: http://stackoverflow.com/questions/12430346/define-snprintf-s-to-snprintf

fjhub commented 10 years ago

Not sure why it's not mentioned. Guess you have come across the right thread or get burned by it to know. Sorry it took so long to get back to you on this...I just noticed you came out with a new version and thought I should get busy.

On Sun, Jun 8, 2014 at 1:04 PM, Nathan Rajlich notifications@github.com wrote:

Though to be honest, I'm curious why this StackOverflow thread doesn't mention _TRUNCATE: http://stackoverflow.com/questions/12430346/define-snprintf-s-to-snprintf

— Reply to this email directly or view it on GitHub https://github.com/TooTallNate/ref/pull/12#issuecomment-45442114.

NOTICE: This message, including any attachments, is only for the use of the intended recipient(s) and may contain confidential and privileged information, or information otherwise protected from disclosure by law. If the reader of this message is not the intended recipient, you are hereby notified that any use, disclosure, copying, dissemination or distribution of this message or any of its attachments is strictly prohibited. If you received this message in error, please contact the sender immediately by reply email and destroy this message, including all attachments, and any copies thereof.