summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/vsnprintf.c83
-rw-r--r--vcnet/file_chooser.vcproj4
-rw-r--r--vcnet/fltkforms.vcproj1
-rw-r--r--vcnet/fluid.vcproj5
-rw-r--r--vcnet/help.vcproj4
-rw-r--r--vcnet/pixmap_browser.vcproj4
-rw-r--r--vcnet/valuators.vcproj1
7 files changed, 49 insertions, 53 deletions
diff --git a/src/vsnprintf.c b/src/vsnprintf.c
index acf9d6c0a..cebe04296 100644
--- a/src/vsnprintf.c
+++ b/src/vsnprintf.c
@@ -42,10 +42,10 @@ int fl_vsnprintf(char* buffer, size_t bufsize, const char* format, va_list ap) {
sign, /* Sign of format width */
size, /* Size character (h, l, L) */
type; /* Format type character */
- const char *bufformat; /* Start of format */
int width, /* Width of field */
prec; /* Number of characters of precision */
char tformat[100], /* Temporary format string for sprintf() */
+ *tptr, /* Pointer into temporary format */
temp[1024]; /* Buffer for formatted numbers */
char *s; /* Pointer to string */
int slen; /* Length of string */
@@ -62,45 +62,69 @@ int fl_vsnprintf(char* buffer, size_t bufsize, const char* format, va_list ap) {
while (*format) {
if (*format == '%') {
- bufformat = format;
- format ++;
+ tptr = tformat;
+ *tptr++ = *format++;
if (*format == '%') {
- *bufptr++ = *format++;
+ if (bufptr && bufptr < bufend) *bufptr++ = *format;
+ bytes ++;
+ format ++;
continue;
- } else if (strchr(" -+#\'", *format)) sign = *format++;
- else sign = 0;
+ } else if (strchr(" -+#\'", *format)) {
+ *tptr++ = *format;
+ sign = *format++;
+ } else sign = 0;
if (*format == '*') {
// Get width from argument...
format ++;
width = va_arg(ap, int);
+ snprintf(tptr, sizeof(tformat) - (tptr - tformat), "%d", width);
+ tptr += strlen(tptr);
} else {
width = 0;
- while (isdigit(*format & 255)) width = width * 10 + *format++ - '0';
+ while (isdigit(*format & 255)) {
+ if (tptr < (tformat + sizeof(tformat) - 1)) *tptr++ = *format;
+ width = width * 10 + *format++ - '0';
+ }
}
if (*format == '.') {
+ if (tptr < (tformat + sizeof(tformat) - 1)) *tptr++ = *format;
format ++;
if (*format == '*') {
// Get precision from argument...
format ++;
prec = va_arg(ap, int);
+ snprintf(tptr, sizeof(tformat) - (tptr - tformat), "%d", prec);
+ tptr += strlen(tptr);
} else {
prec = 0;
- while (isdigit(*format & 255)) prec = prec * 10 + *format++ - '0';
+ while (isdigit(*format & 255)) {
+ if (tptr < (tformat + sizeof(tformat) - 1)) *tptr++ = *format;
+ prec = prec * 10 + *format++ - '0';
+ }
}
} else prec = -1;
if (*format == 'l' && format[1] == 'l') {
size = 'L';
+ if (tptr < (tformat + sizeof(tformat) - 2)) {
+ *tptr++ = 'l';
+ *tptr++ = 'l';
+ }
format += 2;
- } else if (*format == 'h' || *format == 'l' || *format == 'L') size = *format++;
+ } else if (*format == 'h' || *format == 'l' || *format == 'L') {
+ if (tptr < (tformat + sizeof(tformat) - 1)) *tptr++ = *format;
+ size = *format++;
+ }
if (!*format) break;
- type = *format++;
+ if (tptr < (tformat + sizeof(tformat) - 1)) *tptr++ = *format;
+ type = *format++;
+ *tptr = '\0';
switch (type) {
case 'E' : /* Floating point formats */
@@ -108,11 +132,7 @@ int fl_vsnprintf(char* buffer, size_t bufsize, const char* format, va_list ap) {
case 'e' :
case 'f' :
case 'g' :
- if ((format - bufformat + 1) > sizeof(tformat) ||
- (width + 2) > sizeof(temp)) break;
-
- strncpy(tformat, bufformat, (size_t)(format - bufformat));
- tformat[format - bufformat] = '\0';
+ if ((width + 2) > sizeof(temp)) break;
sprintf(temp, tformat, va_arg(ap, double));
@@ -138,11 +158,7 @@ int fl_vsnprintf(char* buffer, size_t bufsize, const char* format, va_list ap) {
case 'o' :
case 'u' :
case 'x' :
- if ((format - bufformat + 1) > sizeof(tformat) ||
- (width + 2) > sizeof(temp)) break;
-
- strncpy(tformat, bufformat, (size_t)(format - bufformat));
- tformat[format - bufformat] = '\0';
+ if ((width + 2) > sizeof(temp)) break;
sprintf(temp, tformat, va_arg(ap, int));
@@ -161,11 +177,7 @@ int fl_vsnprintf(char* buffer, size_t bufsize, const char* format, va_list ap) {
break;
case 'p' : /* Pointer value */
- if ((format - bufformat + 1) > sizeof(tformat) ||
- (width + 2) > sizeof(temp)) break;
-
- strncpy(tformat, bufformat, (size_t)(format - bufformat));
- tformat[format - bufformat] = '\0';
+ if ((width + 2) > sizeof(temp)) break;
sprintf(temp, tformat, va_arg(ap, void *));
@@ -223,26 +235,7 @@ int fl_vsnprintf(char* buffer, size_t bufsize, const char* format, va_list ap) {
break;
case 'n' : /* Output number of chars so far */
- if ((format - bufformat + 1) > sizeof(tformat) ||
- (width + 2) > sizeof(temp)) break;
-
- strncpy(tformat, bufformat, (size_t)(format - bufformat));
- tformat[format - bufformat] = '\0';
-
- sprintf(temp, tformat, va_arg(ap, int));
-
- bytes += strlen(temp);
-
- if (bufptr) {
- if ((bufptr + strlen(temp)) > bufend) {
- strncpy(bufptr, temp, (size_t)(bufend - bufptr));
- bufptr = bufend;
- break;
- } else {
- strcpy(bufptr, temp);
- bufptr += strlen(temp);
- }
- }
+ *(va_arg(ap, int *)) = bytes;
break;
}
} else {
diff --git a/vcnet/file_chooser.vcproj b/vcnet/file_chooser.vcproj
index 900d49980..39f16b693 100644
--- a/vcnet/file_chooser.vcproj
+++ b/vcnet/file_chooser.vcproj
@@ -40,7 +40,7 @@
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib"
- IgnoreDefaultLibraryNames="libcd"
+ IgnoreDefaultLibraryNames="libcmtd"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\file_chooser_/file_chooserd.pdb"
SubSystem="2"
@@ -105,7 +105,7 @@
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib"
- IgnoreDefaultLibraryNames="libcd"
+ IgnoreDefaultLibraryNames="libcmt"
ProgramDatabaseFile=".\Release/file_chooser.pdb"
SubSystem="2"
TargetMachine="1"/>
diff --git a/vcnet/fltkforms.vcproj b/vcnet/fltkforms.vcproj
index 34f4d5da9..bf9695f97 100644
--- a/vcnet/fltkforms.vcproj
+++ b/vcnet/fltkforms.vcproj
@@ -3,6 +3,7 @@
ProjectType="Visual C++"
Version="7.10"
Name="fltkforms"
+ ProjectGUID="{03B1D81E-6803-4DCD-8D2C-3758462EF9BA}"
SccProjectName=""
SccLocalPath="">
<Platforms>
diff --git a/vcnet/fluid.vcproj b/vcnet/fluid.vcproj
index 85e799d2d..a46e6467c 100644
--- a/vcnet/fluid.vcproj
+++ b/vcnet/fluid.vcproj
@@ -3,6 +3,7 @@
ProjectType="Visual C++"
Version="7.10"
Name="fluid"
+ ProjectGUID="{CA3316EA-0D67-4463-A97E-F5578EAC5CC3}"
SccProjectName=""
SccLocalPath="">
<Platforms>
@@ -40,7 +41,7 @@
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib"
- IgnoreDefaultLibraryNames="libcd"
+ IgnoreDefaultLibraryNames="libcmtd"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\fluid__0/fluidd.pdb"
SubSystem="2"
@@ -106,7 +107,7 @@
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib"
- IgnoreDefaultLibraryNames="libcd"
+ IgnoreDefaultLibraryNames="libcmt"
ProgramDatabaseFile=".\fluid___/fluid.pdb"
SubSystem="2"
TargetMachine="1"/>
diff --git a/vcnet/help.vcproj b/vcnet/help.vcproj
index 3bb0d07e4..4997f302f 100644
--- a/vcnet/help.vcproj
+++ b/vcnet/help.vcproj
@@ -41,7 +41,7 @@
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib"
- IgnoreDefaultLibraryNames="libcd"
+ IgnoreDefaultLibraryNames="libcmt"
ProgramDatabaseFile=".\Release/help.pdb"
SubSystem="2"
TargetMachine="1"/>
@@ -104,7 +104,7 @@
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib"
- IgnoreDefaultLibraryNames="libcd"
+ IgnoreDefaultLibraryNames="libcmtd"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\help_/helpd.pdb"
SubSystem="2"
diff --git a/vcnet/pixmap_browser.vcproj b/vcnet/pixmap_browser.vcproj
index 97e18a04f..97d4adfee 100644
--- a/vcnet/pixmap_browser.vcproj
+++ b/vcnet/pixmap_browser.vcproj
@@ -40,7 +40,7 @@
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib"
- IgnoreDefaultLibraryNames="libcd"
+ IgnoreDefaultLibraryNames="libcmtd"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\pixmap_browser_/pixmap_browserd.pdb"
SubSystem="2"
@@ -105,7 +105,7 @@
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib"
- IgnoreDefaultLibraryNames="libcd"
+ IgnoreDefaultLibraryNames="libcmt"
ProgramDatabaseFile=".\Release/pixmap_browser.pdb"
SubSystem="2"
TargetMachine="1"/>
diff --git a/vcnet/valuators.vcproj b/vcnet/valuators.vcproj
index b678c4b43..5dfb91a21 100644
--- a/vcnet/valuators.vcproj
+++ b/vcnet/valuators.vcproj
@@ -3,6 +3,7 @@
ProjectType="Visual C++"
Version="7.10"
Name="valuators"
+ ProjectGUID="{9D950D8D-CD7F-4163-8E57-65016DB10E3E}"
SccProjectName=""
SccLocalPath="">
<Platforms>