openbsd-ports/editors/scintilla/patches/patch-gtk_PlatGTK_cxx
sturm a8ed68f4f2 Initial import of scintilla 1.54
Scintilla is a free source code editing component. As well as features
found in standard text editing components, Scintilla includes features
especially useful when editing and debugging source code. These include
support for syntax styling, error indicators, code completion and call
tips. The selection margin can contain markers like those used in debuggers
to indicate breakpoints and the current line. Styling choices are more open
than with many editors, allowing the use of proportional fonts, bold and
italics, multiple foreground and background colours and multiple fonts.

WWW: http://www.scintilla.org/

from Joerg Sonnenberger <joerg@bec.de> with patches from Andrew Dalgleisch
2003-08-14 18:24:30 +00:00

118 lines
3.9 KiB
Plaintext

$OpenBSD: patch-gtk_PlatGTK_cxx,v 1.1.1.1 2003/08/14 18:24:30 sturm Exp $
--- gtk/PlatGTK.cxx.orig 2003-08-13 16:46:23.000000000 +1000
+++ gtk/PlatGTK.cxx 2003-08-13 17:01:38.000000000 +1000
@@ -332,7 +332,7 @@ static void GenerateFontSpecStrings(cons
if (strchr(fontName, '-')) {
char tmp[300];
char *d1 = NULL, *d2 = NULL, *d3 = NULL;
- strncpy(tmp, fontName, sizeof(tmp) - 1);
+ strlcpy(tmp, fontName, sizeof(tmp));
d1 = strchr(tmp, '-');
// we know the first dash exists
d2 = strchr(d1 + 1, '-');
@@ -343,25 +343,25 @@ static void GenerateFontSpecStrings(cons
*d2 = '\0';
foundary[0] = '-';
foundary[1] = '\0';
- strncpy(faceName, tmp, foundary_len - 1);
- strncpy(charset, d2 + 1, charset_len - 1);
+ strlcpy(faceName, tmp, foundary_len);
+ strlcpy(charset, d2 + 1, charset_len);
} else if (d2) {
// fontface-isoxxx-x
*d1 = '\0';
- strcpy(foundary, "-*-");
- strncpy(faceName, tmp, faceName_len - 1);
- strncpy(charset, d1 + 1, charset_len - 1);
+ strlcpy(foundary, "-*-", foundary_len);
+ strlcpy(faceName, tmp, faceName_len);
+ strlcpy(charset, d1 + 1, charset_len);
} else {
// foundary-fontface
foundary[0] = '-';
foundary[1] = '\0';
- strncpy(faceName, tmp, faceName_len - 1);
- strncpy(charset, CharacterSetName(characterSet), charset_len - 1);
+ strlcpy(faceName, tmp, faceName_len);
+ strlcpy(charset, CharacterSetName(characterSet), charset_len);
}
} else {
- strncpy(foundary, "-*-", foundary_len);
- strncpy(faceName, fontName, faceName_len - 1);
- strncpy(charset, CharacterSetName(characterSet), charset_len - 1);
+ strlcpy(foundary, "-*-", foundary_len);
+ strlcpy(faceName, fontName, faceName_len);
+ strlcpy(charset, CharacterSetName(characterSet), charset_len);
}
}
@@ -371,7 +371,7 @@ static void SetLogFont(LOGFONT &lf, cons
lf.bold = bold;
lf.italic = italic;
lf.characterSet = characterSet;
- strncpy(lf.faceName, faceName, sizeof(lf.faceName) - 1);
+ strlcpy(lf.faceName, faceName, sizeof(lf.faceName));
}
/**
@@ -533,9 +533,8 @@ FontID FontCached::CreateNewFont(const c
// eg. adobe-courier-iso10646-1,*-courier-iso10646-1,*-*-*-*
if (strchr(fontName, ',')) {
// build a fontspec and use gdk_fontset_load
- int remaining = sizeof(fontset);
char fontNameCopy[1024];
- strncpy(fontNameCopy, fontName, sizeof(fontNameCopy) - 1);
+ strlcpy(fontNameCopy, fontName, sizeof(fontNameCopy));
char *fn = fontNameCopy;
char *fp = strchr(fn, ',');
for (;;) {
@@ -566,8 +565,7 @@ FontID FontCached::CreateNewFont(const c
// we are doing italic, add an oblique font
// to the list
if (italic && fontset[0] == '\0') {
- strncat(fontset, fontspec, remaining - 1);
- remaining -= strlen(fontset);
+ strlcat(fontset, fontspec, sizeof(fontset));
snprintf(fontspec,
sizeof(fontspec) - 1,
@@ -578,8 +576,7 @@ FontID FontCached::CreateNewFont(const c
charset);
}
- strncat(fontset, fontspec, remaining - 1);
- remaining -= strlen(fontset);
+ strlcat(fontset, fontspec, sizeof(fontset));
if (!fp)
break;
@@ -1967,8 +1964,7 @@ void ListBoxX::GetValue(int n, char *val
break;
}
if (text && len > 0) {
- strncpy(value, text, len);
- value[len - 1] = '\0';
+ strlcpy(value, text, len);
} else {
value[0] = '\0';
}
@@ -2197,7 +2193,7 @@ void Platform::DebugPrintf(const char *f
char buffer[2000];
va_list pArguments;
va_start(pArguments, format);
- vsprintf(buffer, format, pArguments);
+ vsnprintf(buffer, sizeof(buffer), format, pArguments);
va_end(pArguments);
Platform::DebugDisplay(buffer);
}
@@ -2217,8 +2213,7 @@ bool Platform::ShowAssertionPopUps(bool
void Platform::Assert(const char *c, const char *file, int line) {
char buffer[2000];
- sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
- strcat(buffer, "\r\n");
+ snprintf(buffer, sizeof(buffer), "Assertion [%s] failed at %s %d\r\n", c, file, line);
Platform::DebugDisplay(buffer);
abort();
}