Skip to content

Commit

Permalink
vi: reformat source code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Aug 5, 2024
1 parent ea09c76 commit fdccc56
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
39 changes: 25 additions & 14 deletions bld/vi/c/sstyle_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ static int issymbol( int c )
static bool isdirective( const char *text, const char *directive )
{
int len = strlen( directive );
return( strncmp( text, directive, len ) == 0 && !isalnum( *(text + len) ) &&
*(text + len) != '_' );
return( strncmp( text, directive, len ) == 0
&& !isalnum( *(text + len) )
&& *(text + len) != '_' );
}

void InitCLine( const char *text )
Expand Down Expand Up @@ -159,7 +160,9 @@ static void getFloat( ss_block *ss_new, const char *start, int skip, int command
if( *end == 'f' || *end == 'F' || *end == 'l' || *end == 'L' ) {
break;
}
if( *end != '\0' && !isspace( *end ) && !issymbol( *end ) ) {
if( *end != '\0'
&& !isspace( *end )
&& !issymbol( *end ) ) {
if( *end != '\0' ) {
end++;
}
Expand Down Expand Up @@ -215,8 +218,7 @@ static void getNumber( ss_block *ss_new, const char *start, char top )
if( *end == '.' ) {
getFloat( ss_new, start, end - start + 1, AFTER_DOT );
return;
} else if( *end == 'e'
|| *end == 'E' ) {
} else if( *end == 'e' || *end == 'E' ) {
getFloat( ss_new, start, end - start + 1, AFTER_EXP );
return;
} else if( isdigit( *end ) ) {
Expand Down Expand Up @@ -320,7 +322,8 @@ static void getPreprocessor( ss_block *ss_new, const char *start )
// and then the keyword
directive = end;
for( ; *end != '\0'; ++end ) {
if( isspace( *end ) || issymbol( *end ) ) {
if( isspace( *end )
|| issymbol( *end ) ) {
break;
}
}
Expand Down Expand Up @@ -386,7 +389,8 @@ static void getChar( ss_block *ss_new, const char *start, int skip )
if( *end == '\'' ) {
break;
}
if( end[0] == '\\' && ( end[1] == '\\' || end[1] == '\'' ) ) {
if( end[0] == '\\'
&& ( end[1] == '\\' || end[1] == '\'' ) ) {
++end;
}
}
Expand Down Expand Up @@ -424,7 +428,9 @@ static void getCComment( ss_block *ss_new, const char *start, int skip )
lenCComment += skip;
flags.inCComment = true;
for( end = start + skip; *end != '\0'; ++end ) {
if( end[0] == '*' && end[1] == '/' && lenCComment > 1 ) {
if( end[0] == '*'
&& end[1] == '/'
&& lenCComment > 1 ) {
end += 2;
lenCComment += 2;
flags.inCComment = false;
Expand All @@ -443,7 +449,8 @@ static void getCPPComment( ss_block *ss_new, const char *start )
end = start;
SKIP_TOEND( end );
flags.inCPPComment = true;
if( *start == '\0' || end[-1] != '\\' ) {
if( *start == '\0'
|| end[-1] != '\\' ) {
flags.inCPPComment = false;
}
ss_new->type = SE_COMMENT;
Expand All @@ -459,7 +466,8 @@ static void getString( ss_block *ss_new, const char *start, int skip )
if( end[0] == '"' ) {
break;
}
if( end[0] == '\\' && ( end[1] == '\\' || end[1] == '"' ) ) {
if( end[0] == '\\'
&& ( end[1] == '\\' || end[1] == '"' ) ) {
++end;
}
}
Expand Down Expand Up @@ -593,7 +601,8 @@ void InitCFlags( linenum line_no )

// if not in a comment (and none above), we may be string or pp
if( !flags.inCComment ) {
if( topChar == '#' && !EditFlags.PPKeywordOnly ) {
if( topChar == '#'
&& !EditFlags.PPKeywordOnly ) {
flags.inPreprocessor = true;
}
if( withinQuotes ) {
Expand All @@ -615,7 +624,9 @@ void InitCFlags( linenum line_no )
while( text != starttext && *text != '/' ) {
text--;
}
if( text[1] == '*' && text[0] == '/' && text[-1] != '/' ) {
if( text[1] == '*'
&& text[0] == '/'
&& text[-1] != '/' ) {
if( text == starttext ) {
flags.inCComment = true;
lenCComment = 100;
Expand Down Expand Up @@ -707,8 +718,8 @@ void GetCBlock( ss_block *ss_new, const char *start, line *line, linenum line_no
return;
}

if( *firstNonWS == '#' &&
(!EditFlags.PPKeywordOnly || firstNonWS == start) ) {
if( *firstNonWS == '#'
&& (!EditFlags.PPKeywordOnly || firstNonWS == start) ) {
getPreprocessor( ss_new, start );
return;
}
Expand Down
4 changes: 2 additions & 2 deletions bld/vi/c/sstyle_m.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static bool isIf( const char *start )
&& ( start[1] == 'f' || start[1] == 'F' ) );
}

static void getPreproc( ss_block *ss_new, const char *start )
static void getPreprocessor( ss_block *ss_new, const char *start )
{
const char *end = start + 1;
const char *keyword;
Expand Down Expand Up @@ -250,7 +250,7 @@ void GetMkBlock( ss_block *ss_new, const char *start, int line )

// Preprocessor directives must start at beginning of line
if( (start[0] == '!') && (firstChar == start) ) {
getPreproc( ss_new, start );
getPreprocessor( ss_new, start );
return;
}

Expand Down
7 changes: 4 additions & 3 deletions bld/vi/c/sstyle_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ void InitRexxFlags( linenum line_no )

// if not in a comment (and none above), we may be string or pp
if( !flags.inCComment ) {
if( topChar == '#' && !EditFlags.PPKeywordOnly ) {
if( topChar == '#'
&& !EditFlags.PPKeywordOnly ) {
flags.inPreprocessor = true;
}
if( withinQuotes ) {
Expand Down Expand Up @@ -592,8 +593,8 @@ void GetRexxBlock( ss_block *ss_new, const char *start, line *line, linenum line
return;
}

if( *firstNonWS == '#' &&
(!EditFlags.PPKeywordOnly || firstNonWS == start) ) {
if( *firstNonWS == '#'
&& (!EditFlags.PPKeywordOnly || firstNonWS == start) ) {
getPreprocessor( ss_new, start );
return;
}
Expand Down

0 comments on commit fdccc56

Please sign in to comment.