134affccfd
based on diffs from new maintainer Jeremy Evans <jeremyevans0 at gmail.com>
225 lines
7.3 KiB
Plaintext
225 lines
7.3 KiB
Plaintext
$OpenBSD: patch-src_SciTEBuffers_cxx,v 1.2 2007/01/18 10:56:27 steven Exp $
|
|
--- src/SciTEBuffers.cxx.orig Wed May 31 04:46:17 2006
|
|
+++ src/SciTEBuffers.cxx Wed May 31 04:46:17 2006
|
|
@@ -774,15 +774,15 @@ void SciTEBase::BuffersMenu() {
|
|
#if PLAT_WIN
|
|
|
|
if (pos < 10) {
|
|
- sprintf(entry, "&%d ", (pos + 1) % 10 ); // hotkey 1..0
|
|
- sprintf(titleTab, "&%d ", (pos + 1) % 10); // add hotkey to the tabbar
|
|
+ snprintf(entry, sizeof(entry), "&%d ", (pos + 1) % 10 ); // hotkey 1..0
|
|
+ snprintf(titleTab, sizeof(entry), "&%d ", (pos + 1) % 10); // add hotkey to the tabbar
|
|
}
|
|
#endif
|
|
|
|
if (buffers.buffers[pos].IsUntitled()) {
|
|
SString untitled = LocaliseString("Untitled");
|
|
- strcat(entry, untitled.c_str());
|
|
- strcat(titleTab, untitled.c_str());
|
|
+ strlcat(entry, untitled.c_str(), sizeof(entry));
|
|
+ strlcat(titleTab, untitled.c_str(), sizeof(titleTab));
|
|
} else {
|
|
SString path = buffers.buffers[pos].AsInternal();
|
|
#if PLAT_WIN
|
|
@@ -794,22 +794,22 @@ void SciTEBase::BuffersMenu() {
|
|
amp += 2;
|
|
}
|
|
#endif
|
|
- strcat(entry, path.c_str());
|
|
+ strlcat(entry, path.c_str(), sizeof(entry));
|
|
|
|
char *cpDirEnd = strrchr(entry, pathSepChar);
|
|
if (cpDirEnd) {
|
|
- strcat(titleTab, cpDirEnd + 1);
|
|
+ strlcat(titleTab, cpDirEnd + 1, sizeof(titleTab));
|
|
} else {
|
|
- strcat(titleTab, entry);
|
|
+ strlcat(titleTab, entry, sizeof(titleTab));
|
|
}
|
|
}
|
|
// For short file names:
|
|
//char *cpDirEnd = strrchr(buffers.buffers[pos]->fileName, pathSepChar);
|
|
- //strcat(entry, cpDirEnd + 1);
|
|
+ //strlcat(entry, cpDirEnd + 1, sizeof(entry));
|
|
|
|
if (buffers.buffers[pos].isDirty) {
|
|
- strcat(entry, " *");
|
|
- strcat(titleTab, " *");
|
|
+ strlcat(entry, " *", sizeof(entry));
|
|
+ strlcat(titleTab, " *", sizeof(titleTab));
|
|
}
|
|
|
|
SetMenuItem(menuBuffers, menuStart + pos + 1, itemID, entry);
|
|
@@ -874,10 +874,10 @@ void SciTEBase::SetFileStackMenu() {
|
|
entry[0] = '\0';
|
|
#if PLAT_WIN
|
|
|
|
- sprintf(entry, "&%d ", (stackPos + 1) % 10);
|
|
+ snprintf(entry, sizeof(entry), "&%d ", (stackPos + 1) % 10);
|
|
#endif
|
|
|
|
- strcat(entry, recentFileStack[stackPos].AsInternal());
|
|
+ strlcat(entry, recentFileStack[stackPos].AsInternal(), sizeof(entry));
|
|
SetMenuItem(menuFile, MRU_START + stackPos + 1, itemID, entry);
|
|
}
|
|
}
|
|
@@ -1294,8 +1294,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
char *endPath = strchr(startPath, '\"');
|
|
int length = endPath - startPath;
|
|
if (length > 0) {
|
|
- strncpy(sourcePath, startPath, length);
|
|
- sourcePath[length] = 0;
|
|
+ strlcpy(sourcePath, startPath, length);
|
|
}
|
|
endPath++;
|
|
while (*endPath && !isdigitchar(*endPath)) {
|
|
@@ -1314,8 +1313,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
if (cdoc[i] == ':' && isdigitchar(cdoc[i + 1])) {
|
|
int sourceNumber = atoi(cdoc + i + 1) - 1;
|
|
if (i > 0) {
|
|
- strncpy(sourcePath, cdoc, i);
|
|
- sourcePath[i] = 0;
|
|
+ strlcpy(sourcePath, cdoc, i);
|
|
}
|
|
return sourceNumber;
|
|
}
|
|
@@ -1331,8 +1329,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
char *endPath = strchr(start, '(');
|
|
int length = endPath - start;
|
|
if ((length > 0) && (length < MAX_PATH)) {
|
|
- strncpy(sourcePath, start, length);
|
|
- sourcePath[length] = 0;
|
|
+ strlcpy(sourcePath, start, length);
|
|
}
|
|
endPath++;
|
|
return atoi(endPath) - 1;
|
|
@@ -1369,8 +1366,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
int length = space2 - space;
|
|
|
|
if (length > 0) {
|
|
- strncpy(sourcePath, space, length);
|
|
- sourcePath[length] = '\0';
|
|
+ strlcpy(sourcePath, space, length);
|
|
return atoi(space2) - 1;
|
|
}
|
|
}
|
|
@@ -1383,8 +1379,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
char *line = strstr(cdoc, " line ");
|
|
int length = line - (at + 4);
|
|
if (at && line && length > 0) {
|
|
- strncpy(sourcePath, at + 4, length);
|
|
- sourcePath[length] = 0;
|
|
+ strlcpy(sourcePath, at + 4, length);
|
|
line += 6;
|
|
return atoi(line) - 1;
|
|
}
|
|
@@ -1396,8 +1391,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
char *line = strstr(cdoc, ":line ");
|
|
if (in && line && (line > in)) {
|
|
in += 4;
|
|
- strncpy(sourcePath, in, line - in);
|
|
- sourcePath[line - in] = 0;
|
|
+ strlcpy(sourcePath, in, line - in);
|
|
line += 6;
|
|
return atoi(line) - 1;
|
|
}
|
|
@@ -1415,8 +1409,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
char *quote = strstr(fileStart, "'");
|
|
size_t length = quote - fileStart;
|
|
if (quote && length > 0) {
|
|
- strncpy(sourcePath, fileStart, length);
|
|
- sourcePath[length] = '\0';
|
|
+ strlcpy(sourcePath, fileStart, length);
|
|
}
|
|
line += lenLine;
|
|
return atoi(line) - 1;
|
|
@@ -1434,8 +1427,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
if (strchr("\t\n\r \"$%'*,;<>?[]^`{|}", cdoc[j])) {
|
|
j++;
|
|
}
|
|
- strncpy(sourcePath, &cdoc[j], i - j);
|
|
- sourcePath[i - j] = 0;
|
|
+ strlcpy(sourcePath, &cdoc[j], i - j);
|
|
// Because usually the address is a searchPattern, lineNumber has to be evaluated later
|
|
return 0;
|
|
}
|
|
@@ -1452,8 +1444,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
if (line && file && (line > file)) {
|
|
file += lenFile;
|
|
size_t length = line - file;
|
|
- strncpy(sourcePath, file, length);
|
|
- sourcePath[length] = '\0';
|
|
+ strlcpy(sourcePath, file, length);
|
|
line += lenLine;
|
|
return atoi(line) - 1;
|
|
}
|
|
@@ -1476,8 +1467,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
file++;
|
|
}
|
|
size_t length = strlen(file);
|
|
- strncpy(sourcePath, file, length);
|
|
- sourcePath[length] = '\0';
|
|
+ strlcpy(sourcePath, file, length);
|
|
return atoi(line) - 1;
|
|
}
|
|
}
|
|
@@ -1500,8 +1490,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
file++;
|
|
char *endfile = strchr(file, ')');
|
|
size_t length = endfile - file;
|
|
- strncpy(sourcePath, file, length);
|
|
- sourcePath[length] = '\0';
|
|
+ strlcpy(sourcePath, file, length);
|
|
line++;
|
|
return atoi(line) - 1;
|
|
}
|
|
@@ -1521,11 +1510,10 @@ int DecodeMessage(char *cdoc, char *sour
|
|
if (line && file && (line > file)) {
|
|
file += lenFile;
|
|
size_t length = line - file;
|
|
- strncpy(sourcePath, file, length);
|
|
- sourcePath[length] = '\0';
|
|
+ strlcpy(sourcePath, file, length);
|
|
line += lenLine;
|
|
length = column - line;
|
|
- strncpy(line, line, length);
|
|
+ strlcpy(line, line, length);
|
|
return atoi(line) - 1;
|
|
}
|
|
break;
|
|
@@ -1545,12 +1533,11 @@ int DecodeMessage(char *cdoc, char *sour
|
|
if (line && file && (line > file)) {
|
|
file += lenFile;
|
|
size_t length = line - file;
|
|
- strncpy(sourcePath, file, length);
|
|
- sourcePath[length] = '\0';
|
|
+ strlcpy(sourcePath, file, length);
|
|
line += lenLine;
|
|
if ((lineend > line)) {
|
|
length = lineend - line;
|
|
- strncpy(line, line, length);
|
|
+ strlcpy(line, line, length);
|
|
return atoi(line) - 1;
|
|
}
|
|
}
|
|
@@ -1590,8 +1577,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
char *endPath = strchr(startPath, ':');
|
|
int length = endPath - startPath;
|
|
if (length > 0) {
|
|
- strncpy(sourcePath, startPath, length);
|
|
- sourcePath[length] = 0;
|
|
+ strlcpy(sourcePath, startPath, length);
|
|
int sourceNumber = atoi(endPath+1) - 1;
|
|
return sourceNumber;
|
|
}
|
|
@@ -1605,8 +1591,7 @@ int DecodeMessage(char *cdoc, char *sour
|
|
char *endPath = strchr(startPath, '\t');
|
|
if (endPath) {
|
|
int length = endPath - startPath;
|
|
- strncpy(sourcePath, startPath, length);
|
|
- sourcePath[length] = 0;
|
|
+ strlcpy(sourcePath, startPath, length);
|
|
return 0;
|
|
}
|
|
break;
|