Skip to content

Commit

Permalink
chore: more coding standards revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed Sep 7, 2023
1 parent df97f16 commit 3236d25
Show file tree
Hide file tree
Showing 32 changed files with 972 additions and 743 deletions.
40 changes: 40 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,44 @@ UseTab: AlignWithSpaces
IndentWidth: 4
TabWidth: 4
AllowShortFunctionsOnASingleLine: Empty
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: true
AfterNamespace: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
IndentAccessModifiers: false
IndentCaseLabels: true
IndentExternBlock: NoIndent
IndentGotoLabels: false
IndentPPDirectives: AfterHash
IndentWrappedFunctionNames: true
InsertBraces: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
LineEnding: LF
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PPIndentWidth: -1
PackConstructorInitializers: NextLine
PointerAlignment: Right
ReferenceAlignment: Pointer
ReflowComments: true
SeparateDefinitionBlocks: Always
SortIncludes: CaseInsensitive
...
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ indent_size = 4
[*.{c,cpp,h,hpp}]
indent_style = tab

[*.{yml,yaml,m4,w32}]
[*.{yml,yaml,m4,w32,clang-format}]
indent_size = 2

[package.xml]
Expand Down
6 changes: 4 additions & 2 deletions src/ecma402/calendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include <unicode/uenum.h>
#include <unicode/uloc.h>

int ecma402_availableCanonicalCalendars(const char **values) {
int ecma402_availableCanonicalCalendars(const char **values)
{
UEnumeration *enumeration = NULL;
UErrorCode status = U_ZERO_ERROR;
const char *identifier;
Expand Down Expand Up @@ -49,6 +50,7 @@ int ecma402_availableCanonicalCalendars(const char **values) {
return ecma402_sortAndRemoveDuplicates((char **)values, valuesCount, ecma402_strToLower);
}

int ecma402_calendarsOfLocale(ecma402_locale *locale, const char **values) {
int ecma402_calendarsOfLocale(ecma402_locale *locale, const char **values)
{
return ecma402_keywordsOfLocale(locale, ICU_KEYWORD_CALENDAR, values);
}
6 changes: 4 additions & 2 deletions src/ecma402/category.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

#include <string.h>

int ecma402_supportedValuesForCategory(const char *category, const char **values) {
int ecma402_supportedValuesForCategory(const char *category, const char **values)
{
if (strcmp(ECMA402_CATEGORY_CALENDAR, category) == 0) {
return ecma402_availableCanonicalCalendars(values);
} else if (strcmp(ECMA402_CATEGORY_COLLATION, category) == 0) {
Expand All @@ -39,7 +40,8 @@ int ecma402_supportedValuesForCategory(const char *category, const char **values
return 0;
}

int ecma402_capacityForCategory(const char *category) {
int ecma402_capacityForCategory(const char *category)
{
if (strcmp(ECMA402_CATEGORY_CALENDAR, category) == 0) {
return ECMA402_CALENDAR_CAPACITY;
} else if (strcmp(ECMA402_CATEGORY_COLLATION, category) == 0) {
Expand Down
6 changes: 4 additions & 2 deletions src/ecma402/collation.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include <unicode/uenum.h>
#include <unicode/uloc.h>

int ecma402_availableCanonicalCollations(const char **values) {
int ecma402_availableCanonicalCollations(const char **values)
{
UEnumeration *enumeration = NULL;
UErrorCode status = U_ZERO_ERROR;
const char *identifier;
Expand Down Expand Up @@ -56,6 +57,7 @@ int ecma402_availableCanonicalCollations(const char **values) {
return ecma402_sortAndRemoveDuplicates((char **)values, valuesCount, ecma402_strToLower);
}

int ecma402_collationsOfLocale(ecma402_locale *locale, const char **values) {
int ecma402_collationsOfLocale(ecma402_locale *locale, const char **values)
{
return ecma402_keywordsOfLocale(locale, ICU_KEYWORD_COLLATION, values);
}
6 changes: 4 additions & 2 deletions src/ecma402/currency.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#include <unicode/ucurr.h>
#include <unicode/uenum.h>

int ecma402_availableCanonicalCurrencies(const char **values) {
int ecma402_availableCanonicalCurrencies(const char **values)
{
UEnumeration *enumeration = NULL;
UErrorCode status = U_ZERO_ERROR;
const char *identifier;
Expand All @@ -44,7 +45,8 @@ int ecma402_availableCanonicalCurrencies(const char **values) {
return ecma402_sortAndRemoveDuplicates((char **)values, valuesCount, ecma402_strToUpper);
}

int ecma402_currenciesOfLocale(ecma402_locale *locale, const char **values) {
int ecma402_currenciesOfLocale(ecma402_locale *locale, const char **values)
{
int count = ecma402_keywordsOfLocale(locale, ICU_KEYWORD_CURRENCY, values);

for (int i = 0; i < count; i++) {
Expand Down
21 changes: 14 additions & 7 deletions src/ecma402/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

static void storeError(ecma402_errorStatus *status, const char *format, va_list vargs);

ecma402_errorStatus *ecma402_initErrorStatus(void) {
ecma402_errorStatus *ecma402_initErrorStatus(void)
{
ecma402_errorStatus *status;

status = (ecma402_errorStatus *)malloc(sizeof(*status));
Expand All @@ -36,23 +37,26 @@ ecma402_errorStatus *ecma402_initErrorStatus(void) {
return status;
}

void ecma402_freeErrorStatus(ecma402_errorStatus *status) {
void ecma402_freeErrorStatus(ecma402_errorStatus *status)
{
if (status->errorMessage) {
free(status->errorMessage);
}

free(status);
}

bool ecma402_hasError(ecma402_errorStatus *status) {
bool ecma402_hasError(ecma402_errorStatus *status)
{
if (!status) {
return false;
}

return status->ecma != ZERO_ERROR;
}

void ecma402_error(ecma402_errorStatus *status, const char *format, ...) {
void ecma402_error(ecma402_errorStatus *status, const char *format, ...)
{
va_list args;

if (!status) {
Expand All @@ -64,7 +68,8 @@ void ecma402_error(ecma402_errorStatus *status, const char *format, ...) {
va_end(args);
}

void ecma402_ecmaError(ecma402_errorStatus *status, ecma402_errorCode errorCode, const char *format, ...) {
void ecma402_ecmaError(ecma402_errorStatus *status, ecma402_errorCode errorCode, const char *format, ...)
{
va_list args;

if (!status) {
Expand All @@ -78,7 +83,8 @@ void ecma402_ecmaError(ecma402_errorStatus *status, ecma402_errorCode errorCode,
va_end(args);
}

void ecma402_icuError(ecma402_errorStatus *status, UErrorCode errorCode, const char *format, ...) {
void ecma402_icuError(ecma402_errorStatus *status, UErrorCode errorCode, const char *format, ...)
{
va_list args;

if (!status) {
Expand All @@ -93,7 +99,8 @@ void ecma402_icuError(ecma402_errorStatus *status, UErrorCode errorCode, const c
va_end(args);
}

static void storeError(ecma402_errorStatus *status, const char *format, va_list vargs) {
static void storeError(ecma402_errorStatus *status, const char *format, va_list vargs)
{
char *message;

if (status->ecma == ZERO_ERROR) {
Expand Down
3 changes: 2 additions & 1 deletion src/ecma402/hour_cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "ecma402/locale.h"

int ecma402_hourCyclesOfLocale(ecma402_locale *locale, const char **values) {
int ecma402_hourCyclesOfLocale(ecma402_locale *locale, const char **values)
{
return ecma402_keywordsOfLocale(locale, ICU_KEYWORD_HOUR_CYCLE, values);
}
Loading

0 comments on commit 3236d25

Please sign in to comment.