<commit_before>This documents C coding conventions for Teem, and provides some rationale.
Feedback on how to better implement the rationale is very welcome on the 
teem-users mailing list; subscribe at:
http://lists.sourceforge.net/lists/listinfo/teem-users

============ Basic code formatting
Example function:

unsigned int
nrrdSpaceOriginGet(const Nrrd *nrrd,
                   double vector[NRRD_SPACE_DIM_MAX]) {
  unsigned int sdi, ret;

  if (nrrd && vector) {
    for (sdi=0; sdi<nrrd->spaceDim; sdi++) {
      vector[sdi] = nrrd->spaceOrigin[sdi];
    }
    for (sdi=nrrd->spaceDim; sdi<NRRD_SPACE_DIM_MAX; sdi++) {
      vector[sdi] = AIR_NAN;
    }
    ret = nrrd->spaceDim;
  } else {
    ret = 0;
  }
  return ret;
}

Note:
* No tabs, ever. (why: no two editors show them the same)
* two spaces per level of indentation
* In function definition (and only in definition), the function name
starts a new line (why: makes it trivial to use grep to
identify which source file contains the function definition)
* opening brace *not* on its own line
* closing brace gets its own line, except for if/else
* blank line between function variables and function code

Other code formatting points:

* If at all possible please keep lines to 78 characters, like the current line.<commit_msg>more about brace usage<commit_after>This documents C coding conventions for Teem, and provides some rationale.
Feedback on how to better implement the rationale is very welcome on the 
teem-users mailing list; subscribe at:
http://lists.sourceforge.net/lists/listinfo/teem-users

============ Basic code formatting
Example function:

unsigned int
nrrdSpaceOriginGet(const Nrrd *nrrd,
                   double vector[NRRD_SPACE_DIM_MAX]) {
  unsigned int sdi, ret;

  if (nrrd && vector) {
    for (sdi=0; sdi<nrrd->spaceDim; sdi++) {
      vector[sdi] = nrrd->spaceOrigin[sdi];
    }
    for (sdi=nrrd->spaceDim; sdi<NRRD_SPACE_DIM_MAX; sdi++) {
      vector[sdi] = AIR_NAN;
    }
    ret = nrrd->spaceDim;
  } else {
    ret = 0;
  }
  return ret;
}

Note:
* No tabs, ever. (why: no two editors show them the same)
* two spaces per level of indentation
* In function definition (and only in definition), the function name
starts a new line (why: makes it trivial to use grep to
identify which source file contains the function definition)
* opening brace *not* on its own line
* closing brace gets its own line, except for if/else
* braces around a branch even if there is only one statement
(why: there will eventually be more than one statement, even 
if only for debugging)
* blank line between function variables and function code

Other code formatting points:

* If at all possible please keep lines to 78 characters, like the current line.
{'fraction_non_alphanumeric': 0.08719445457862095, 'fraction_numerical': 0.002918642831083546, 'mean_word_length': 3.818980667838313, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3253422', 'n_tokens_mistral': 859, 'n_tokens_neox': 823, 'n_words': 343}