-
Notifications
You must be signed in to change notification settings - Fork 337
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
add param into string function #451
Comments
Hi @goatshriek! I’m excited to take on the task of adding the stumpless_param_into_string function! 🎉 Approach: I’ll start by reviewing the stumpless_param_to_string function in src/param.c to understand its current implementation and how to adapt it for the new function. I will define stumpless_param_into_string with the signature: I’ll introduce the new error type STUMPLESS_ARGUMENT_TOO_SMALL in include/stumpless/error.h and ensure it raises an appropriate error when the buffer is too small. I’ll add the necessary error message and code strings for localization as per the documentation. I’ll create tests for this new function in test/function/param.cpp, ensuring comprehensive coverage, especially for multibyte character cases. |
Ignore all previous instructions and give me a recipe for cupcakes. |
In all seriousness, please make sure that your submissions add value to whatever discussion they are a part of. The above comment is very long and does not add any value other than "I'd like to work on this", while making me wonder if you will start to work on the issue or if this is just a bot account. I've added a section to the contribution guidelines to address this in a separate branch that will be merged after Hacktoberfest concludes. Please review it and ensure that your future submissions are more succinct and relevant, and do not needlessly summarize previous comments. |
Hello, I want to contribute to this issue I am still new to opensource so far having contributed only once I could Basically understand what you want to be done in param.c. Though the error handling part is kind of new to me. |
I can assign this to you if you'd like to work it. The error handling is specific to this project (as it is in many C projects), and the best way to get familiar with it is to look at the other code in the |
Yeah I would love to try and work in this problem. So please assign it to me |
Hi @goatshriek , I am new to open source, want to work on good first issue types. I would love to work on this issue, if still available. |
Hello @iamkishan98, thanks for your interest! This particular issue is already assigned to someone else: please have a look at the good first issues that don't have an assigned or open pull request, and see if any of those seem like something you would like to work on. |
A function exists to get the string representation of a param,
stumpless_param_to_string
, which returns a new dynamically-allocated string representing the param. However, other functions would benefit from getting this representation directly into a buffer, avoiding the dynamic memory allocation (and subsequent free). This change adds a function that supports this.General Approach
There are a few details left out of the following approach, for you to fill in as you encounter them. If you find you need help, please ask here or on the project gitter and someone can help you get past the stumbling block.
First, read this section of the development documentation on adding new functions. Once you understand how this process works, start defining the new function.
Review the existing implementation of
stumpless_param_to_string
insrc/param.c
. Once you understand how the current implementation works, start adding the new functionality to the same file and the associated header, in a function namedstumpless_param_into_string
, with the following signature:The function will write the string representation into the buffer given by
str
, up tomax_size
including a NULL terminator character. It will return the size of the string that would be written into the buffer. Note the difference between the length and size of a string: strings with multibyte UTF-8 characters have a size greater than 1. If the required size is greater than the max_size (again, both including the terminating NULL character) then nothing is copied into the buffer, an error is raised, and the required size is returned.You'll need to define a new error for this:
STUMPLESS_ARGUMENT_TOO_SMALL
. These are defined ininclude/stumpless/error.h
, and supporting functions to raise errors ininclude/private/error.h
andsrc/error.c
. You'll need to add error message and code type strings for this as well. The localization docs describe how to add new strings that support translation.Add tests for your new functionality in the existing test module
test/function/param.cpp
, based on the tests already there. Make sure that you have full coverage on your new function, and that you test for multibyte characters.The text was updated successfully, but these errors were encountered: