Skip to main content

Context aware spelling check for C/C++ source code files.

Project description

C Code Spell Correction

Context aware spelling check of comments and string literals in C/C++ source code files. Operation is non-interactive to facilitate operations on an existing large code base.

  1. First pass to collect terms from source code and propose corrections to comments.
$ ./cspell --out-dict code.dic --out-corrections fix.json code.c ...
  1. Edit candiate corrections in fix.json.

  2. Apply corrections

$ ./cspell --add-dict code.dic --corrections fix.json --modify code.c ...

The argument -f/--inputs reads a list of source files from a file.

Operation

cspell separates string literals and C/C++ comments from code. Tokens/terms found in code are automatically excluding from spell check.

So in the following, myfunc(), thearg, and retval will not be flagged as spelling errors.

/** Copyright 2021 Michael Davidsaver
*  Who can't spelll rite
*/
#include <stdio.h>
/** @brief special
 * @param thearg is the argument
 */
void myfunc(int thearg) {
    // myfunc() is a functon on thearg and retval
    int retval = thearg;
    if(thearg==42)
        printf("thearg is amagic value\n");
    /* another commment */
    return retval;
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cspell-0.0.1a1.tar.gz (6.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page