Skip to content

Commit 464cb58

Browse files
committed
Minor clean-ups preparatory to defining distinct style constants for COBOL.
Include C++ headers, use unnamed namespace instead of static, remove inline, use nullptr. Related to #284.
1 parent 3877d63 commit 464cb58

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

lexers/LexCOBOL.cxx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@
88
** Updated by Rod Falck, Aug 2006 Converted to COBOL
99
**/
1010

11-
#include <stdlib.h>
12-
#include <string.h>
13-
#include <stdio.h>
14-
#include <stdarg.h>
15-
#include <assert.h>
16-
#include <ctype.h>
11+
#include <cstdlib>
12+
#include <cassert>
13+
#include <cstring>
14+
#include <cctype>
15+
#include <cstdio>
1716

1817
#include <string>
1918
#include <string_view>
@@ -38,23 +37,25 @@ using namespace Lexilla;
3837
#define IN_FLAGS 0xF
3938
#define NOT_HEADER 0x10
4039

41-
inline bool isCOBOLoperator(char ch)
40+
namespace {
41+
42+
bool isCOBOLoperator(char ch)
4243
{
4344
return isoperator(ch);
4445
}
4546

46-
inline bool isCOBOLwordchar(char ch)
47+
bool isCOBOLwordchar(char ch)
4748
{
4849
return IsASCII(ch) && (isalnum(ch) || ch == '-');
4950

5051
}
5152

52-
inline bool isCOBOLwordstart(char ch)
53+
bool isCOBOLwordstart(char ch)
5354
{
5455
return IsASCII(ch) && isalnum(ch);
5556
}
5657

57-
static int CountBits(int nBits)
58+
int CountBits(int nBits)
5859
{
5960
int count = 0;
6061
for (int i = 0; i < 32; ++i)
@@ -65,7 +66,7 @@ static int CountBits(int nBits)
6566
return count;
6667
}
6768

68-
static void getRange(Sci_PositionU start,
69+
void getRange(Sci_PositionU start,
6970
Sci_PositionU end,
7071
Accessor &styler,
7172
char *s,
@@ -78,12 +79,12 @@ static void getRange(Sci_PositionU start,
7879
s[i] = '\0';
7980
}
8081

81-
static void ColourTo(Accessor &styler, Sci_PositionU end, unsigned int attr) {
82+
void ColourTo(Accessor &styler, Sci_PositionU end, unsigned int attr) {
8283
styler.ColourTo(end, attr);
8384
}
8485

8586

86-
static int classifyWordCOBOL(Sci_PositionU start, Sci_PositionU end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, int nContainment, bool *bAarea) {
87+
int classifyWordCOBOL(Sci_PositionU start, Sci_PositionU end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, int nContainment, bool *bAarea) {
8788
int ret = 0;
8889

8990
char s[100];
@@ -143,7 +144,7 @@ static int classifyWordCOBOL(Sci_PositionU start, Sci_PositionU end, /*WordList
143144
return ret;
144145
}
145146

146-
static void ColouriseCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[],
147+
void ColouriseCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[],
147148
Accessor &styler) {
148149

149150
styler.StartAt(startPos);
@@ -315,7 +316,7 @@ static void ColouriseCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int i
315316
ColourTo(styler, lengthDoc - 1, state);
316317
}
317318

318-
static void FoldCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[],
319+
void FoldCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[],
319320
Accessor &styler) {
320321
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
321322
Sci_PositionU endPos = startPos + length;
@@ -377,11 +378,13 @@ static void FoldCOBOLDoc(Sci_PositionU startPos, Sci_Position length, int, WordL
377378
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
378379
}
379380

380-
static const char * const COBOLWordListDesc[] = {
381+
const char * const COBOLWordListDesc[] = {
381382
"A Keywords",
382383
"B Keywords",
383384
"Extended Keywords",
384-
0
385+
nullptr
385386
};
386387

388+
}
389+
387390
extern const LexerModule lmCOBOL(SCLEX_COBOL, ColouriseCOBOLDoc, "COBOL", FoldCOBOLDoc, COBOLWordListDesc);

0 commit comments

Comments
 (0)