Repository: tesseract-ocr/tesseract
File: src/api/baseapi.cpp (C++)

Code before:
/** Minimum sensible image size to be worth running tesseract. */
    const int kMinRectSize = 10;
/** Character returned when Tesseract couldn't recognize as anything. */
    const char kTesseractReject = '~';
/** Character used by UNLV error counter as a reject. */
    const char kUNLVReject = '~';
/** Character used by UNLV as a suspect marker. */
    const char kUNLVSuspect = '^';
/**
 * Filename used for input image file, from which to derive a name to search
 * for a possible UNLV zone file, if none is specified by SetInputName.
 */
    const char* kInputFile = "noname.tif";
/**
 * Temp file used for storing current parameters before applying retry values.
 */
    const char* kOldVarsFile = "failed_vars.txt";
/** Max string length of an int.  */
    const int kMaxIntSize = 22;

/* Add all available languages recursively.
*/
    static void addAvailableLanguages(const STRING &datadir, const STRING &base,
                                      GenericVector<STRING>* langs)
    {
        const STRING base2 = (base.string()[0] == '\0') ? base : base + "/";
        const size_t extlen = sizeof(kTrainedDataSuffix);
#ifdef _WIN32
        WIN32_FIND_DATA data;
    HANDLE handle = FindFirstFile((datadir + base2 + "*").string(), &data);
    if (handle != INVALID_HANDLE_VALUE) {
      BOOL result = TRUE;
      for (; result;) {
        char *name = data.cFileName;
        // Skip '.', '..', and hidden files
        if (name[0] != '.') {
          if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ==
              FILE_ATTRIBUTE_DIRECTORY) {
            addAvailableLanguages(datadir, base2 + name, langs);
          } else {
            size_t len = strlen(name);
            if (len > extlen && name[len - extlen] == '.' &&
                strcmp(&name[len - extlen + 1], kTrainedDataSuffix) == 0) {
              name[len - extlen] = '\0';
              langs->push_back(base2 + name);
            }
          }
        }
        result = FindNextFile(handle, &data);
      }
      FindClose(handle);

Review comment (suggestion):
You can use C++ comments, and Tesseract uses indentation steps of 2, so at least most of this commit is not needed or even not wanted at all.

Code after:
/** Minimum sensible image size to be worth running tesseract. */
const int kMinRectSize = 10;
/** Character returned when Tesseract couldn't recognize as anything. */
const char kTesseractReject = '~';
/** Character used by UNLV error counter as a reject. */
const char kUNLVReject = '~';
/** Character used by UNLV as a suspect marker. */
const char kUNLVSuspect = '^';
/**
 * Filename used for input image file, from which to derive a name to search
 * for a possible UNLV zone file, if none is specified by SetInputName.
 */
const char* kInputFile = "noname.tif";
/**
 * Temp file used for storing current parameters before applying retry values.
 */
const char* kOldVarsFile = "failed_vars.txt";
/** Max string length of an int.  */
const int kMaxIntSize = 22;

/* Add all available languages recursively.
*/
static void addAvailableLanguages(const STRING &datadir, const STRING &base,
                                  GenericVector<STRING>* langs)
{
  const STRING base2 = (base.string()[0] == '\0') ? base : base + "/";
  const size_t extlen = sizeof(kTrainedDataSuffix);
#ifdef _WIN32
    WIN32_FIND_DATA data;
    HANDLE handle = FindFirstFile((datadir + base2 + "*").string(), &data);
    if (handle != INVALID_HANDLE_VALUE) {
      BOOL result = TRUE;
      for (; result;) {
        char *name = data.cFileName;
        // Skip '.', '..', and hidden files
        if (name[0] != '.') {
          if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ==
              FILE_ATTRIBUTE_DIRECTORY) {
            addAvailableLanguages(datadir, base2 + name, langs);
          } else {
            size_t len = strlen(name);
            if (len > extlen && name[len - extlen] == '.' &&
                strcmp(&name[len - extlen + 1], kTrainedDataSuffix) == 0) {
              name[len - extlen] = '\0';
              langs->push_back(base2 + name);
            }
          }
        }
        result = FindNextFile(handle, &data);
      }
      FindClose(handle);