aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-08-01 16:48:21 +1000
committerNeil <nyamatongwe@gmail.com>2022-08-01 16:48:21 +1000
commit987598c6d853eac0a99bbf97f4fe847874652ed3 (patch)
tree3d639ab2a73389c4b6393a7377475af94f7fdce4 /src
parent6db9764146c11637c6cc3d6749a566f17e6f3429 (diff)
downloadscintilla-mirror-987598c6d853eac0a99bbf97f4fe847874652ed3.tar.gz
Avoid some warnings from Code Analysis.
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx4
-rw-r--r--src/Platform.h2
-rw-r--r--src/PositionCache.cxx7
-rw-r--r--src/RESearch.cxx31
4 files changed, 24 insertions, 20 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index c2c31f0d1..08ee3fc6a 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -1937,9 +1937,7 @@ SelectionPosition Editor::RealizeVirtualSpace(const SelectionPosition &position)
}
void Editor::AddChar(char ch) {
- char s[2];
- s[0] = ch;
- s[1] = '\0';
+ const char s[1] {ch};
InsertCharacter(std::string_view(s, 1), CharacterSource::DirectInput);
}
diff --git a/src/Platform.h b/src/Platform.h
index ce04d9b22..b0d12888d 100644
--- a/src/Platform.h
+++ b/src/Platform.h
@@ -319,7 +319,7 @@ struct ListOptions {
class ListBox : public Window {
public:
ListBox() noexcept;
- virtual ~ListBox() noexcept override;
+ ~ListBox() noexcept override;
static std::unique_ptr<ListBox> Allocate();
virtual void SetFont(const Font *font)=0;
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 23733c3a0..fc27dce77 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -87,11 +87,12 @@ LineLayout::~LineLayout() {
void LineLayout::Resize(int maxLineLength_) {
if (maxLineLength_ > maxLineLength) {
Free();
- chars = std::make_unique<char[]>(maxLineLength_ + 1);
- styles = std::make_unique<unsigned char []>(maxLineLength_ + 1);
+ const size_t lineAllocation = maxLineLength_ + 1;
+ chars = std::make_unique<char[]>(lineAllocation);
+ styles = std::make_unique<unsigned char []>(lineAllocation);
// Extra position allocated as sometimes the Windows
// GetTextExtentExPoint API writes an extra element.
- positions = std::make_unique<XYPOSITION []>(maxLineLength_ + 1 + 1);
+ positions = std::make_unique<XYPOSITION []>(lineAllocation + 1);
if (bidiData) {
bidiData->Resize(maxLineLength_);
}
diff --git a/src/RESearch.cxx b/src/RESearch.cxx
index 15f3d6281..9a2981ffe 100644
--- a/src/RESearch.cxx
+++ b/src/RESearch.cxx
@@ -305,6 +305,7 @@ constexpr unsigned char escapeValue(unsigned char ch) noexcept {
case 'r': return '\r';
case 't': return '\t';
case 'v': return '\v';
+ default: break;
}
return 0;
}
@@ -353,7 +354,7 @@ int RESearch::GetBackslashExpression(
// I choose to interpret unexpected syntax in a logical way instead
// of reporting errors. Otherwise, we can stick on, eg., PCRE behaviour.
incr = 0; // Most of the time, will skip the char "naturally".
- int c;
+ int c = 0;
int result = -1;
const unsigned char bsc = *pattern;
if (!bsc) {
@@ -433,16 +434,18 @@ int RESearch::GetBackslashExpression(
const char *RESearch::Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) noexcept {
char *mp=nfa; /* nfa pointer */
- char *lp; /* saved pointer */
+ char *lp=nullptr; /* saved pointer */
char *sp=nfa; /* another one */
- char *mpMax = mp + MAXNFA - BITBLK - 10;
+ const char * mpMax = mp + MAXNFA - BITBLK - 10;
int tagi = 0; /* tag stack index */
int tagc = 1; /* actual tag count */
- int n;
- char mask; /* xor mask -CCL/NCL */
- int c1, c2, prevChar;
+ int n = 0;
+ char mask = 0; /* xor mask -CCL/NCL */
+ int c1 = 0;
+ int c2 = 0;
+ int prevChar = 0;
if (!pattern || !length) {
if (sta)
@@ -753,7 +756,7 @@ const char *RESearch::Compile(const char *pattern, Sci::Position length, bool ca
*
*/
int RESearch::Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp) {
- unsigned char c;
+ unsigned char c = 0;
Sci::Position ep = NOTFOUND;
char *ap = nfa;
@@ -841,12 +844,14 @@ int RESearch::Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Positio
#define CCLSKIP 34 /* [CLO] CCL 32 bytes END */
Sci::Position RESearch::PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap) {
- int op, c, n;
- Sci::Position e; /* extra pointer for CLO */
- Sci::Position bp; /* beginning of subpat... */
- Sci::Position ep; /* ending of subpat... */
- Sci::Position are; /* to save the line ptr. */
- Sci::Position llp; /* lazy lp for LCLO */
+ int op = 0;
+ int c = 0;
+ int n = 0;
+ Sci::Position e = 0; /* extra pointer for CLO */
+ Sci::Position bp = 0; /* beginning of subpat... */
+ Sci::Position ep = 0; /* ending of subpat... */
+ Sci::Position are = 0; /* to save the line ptr. */
+ Sci::Position llp = 0; /* lazy lp for LCLO */
while ((op = *ap++) != END)
switch (op) {