]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
improve sprintf a bit to match with documentation
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 Dec 2009 18:40:41 +0000 (18:40 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 Dec 2009 18:40:41 +0000 (18:40 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9655 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c

index 01b6f8f82d825ba38a1f016b987d413f0ea04b4e..1e67092920b24ee2b63816238377cda83df4fc30 100644 (file)
@@ -5709,6 +5709,10 @@ void VM_sprintf(void)
                                break;
                        case '%':
                                ++s;
+
+                               if(*s == '%')
+                                       goto verbatim;
+
                                // complete directive format:
                                // %3$*1$.*2$ld
                                
@@ -5868,11 +5872,14 @@ nolength:
                                        *f++ = 0;
                                        switch(*s)
                                        {
-                                               case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': case 'c': 
-                                                       o += dpsnprintf(o, end - o, formatbuf, width, precision, (int) (isfloat ? GETARG_FLOAT(thisarg) : GETARG_INT(thisarg)));
+                                               case 'd': case 'i':
+                                                       o += dpsnprintf(o, end - o, formatbuf, width, precision, (isfloat ? (int) GETARG_FLOAT(thisarg) : (int) GETARG_INT(thisarg)));
+                                                       break;
+                                               case 'o': case 'u': case 'x': case 'X': case 'c': 
+                                                       o += dpsnprintf(o, end - o, formatbuf, width, precision, (isfloat ? (unsigned int) GETARG_FLOAT(thisarg) : (unsigned int) GETARG_INT(thisarg)));
                                                        break;
                                                case 'e': case 'E': case 'f': case 'F': case 'g': case 'G':
-                                                       o += dpsnprintf(o, end - o, formatbuf, width, precision, (double) (isfloat ? GETARG_FLOAT(thisarg) : GETARG_INT(thisarg)));
+                                                       o += dpsnprintf(o, end - o, formatbuf, width, precision, (isfloat ? (double) GETARG_FLOAT(thisarg) : (double) GETARG_INT(thisarg)));
                                                        break;
                                                case 's':
                                                        o += dpsnprintf(o, end - o, formatbuf, width, precision, GETARG_STRING(thisarg));
@@ -5885,6 +5892,7 @@ nolength:
                                ++s;
                                break;
                        default:
+verbatim:
                                if(o < end - 1)
                                        *o++ = *s++;
                                break;