We appreciate your interest in contributing to FastCSV-C! This document provides guidelines and instructions for contributing to the core C library of the FastCSV project.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
-
Clone your fork:
git clone https://github.com/csvtoolkit/FastCSV-C.git cd FastCSV-C -
Set up build environment:
# Create build directory mkdir build && cd build # Configure with CMake cmake .. # Build make
-
Run tests:
make test
- Use C89/ANSI C for maximum compatibility
- Follow existing code style
- Keep functions focused and under 50 lines where possible
- Use meaningful variable and function names
- Add comments for complex logic
- Include documentation for public API functions
- Functions: lowercase with underscores (
csv_reader_init) - Types: CamelCase (
CSVReader) - Constants: uppercase with underscores (
CSV_MAX_BUFFER_SIZE) - Private functions: prefix with underscore (
_csv_internal_function)
// Function definition style
int csv_reader_function(CSVReader* reader, const char* arg) {
// 4-space indentation
if (reader == NULL) {
return 0;
}
// Variables declared at start of blocks
int result;
char* buffer;
// Clear error handling
if (some_condition) {
return 0;
}
return 1;
}- Always free allocated memory
- Check for NULL after allocations
- Use appropriate buffer sizes
- Document memory ownership in function comments
- Handle cleanup in error cases
- Return 0/NULL for errors, 1/valid pointer for success
- Set appropriate error messages
- Clean up resources on error paths
- Document error conditions in function headers
- Add tests for new functionality
- Test both success and failure cases
- Test edge cases
- Test memory management
- Follow existing test patterns
void test_csv_reader_init(void) {
// Setup
CSVConfig* config = csv_config_new();
// Test case
CSVReader* reader = csv_reader_init_with_config(config);
assert(reader != NULL);
// Cleanup
csv_reader_free(reader);
csv_config_free(config);
}/**
* Initializes a new CSV reader with the given configuration.
*
* @param config Pointer to a valid CSVConfig object
* @return CSVReader* on success, NULL on failure
* @note Caller is responsible for freeing the returned reader
*/
CSVReader* csv_reader_init_with_config(CSVConfig* config);- Update README.md for new features
- Keep examples current
- Document breaking changes
- Update version numbers
- Update tests for new functionality
- Update documentation
- Follow coding standards
- Include clear commit messages
- One feature/fix per PR
- Reference any related issues
By contributing, you agree that your contributions will be licensed under the MIT License.