va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
- printf(": %s\n", strerror(err));
+ printf(": %s\n", util_strerror(err));
}
static void qcvmerror(qc_program *prog, const char *fmt, ...)
else printf("(none)");
printf("\n");
}
- fflush(stdout);
}
static qcint prog_enterfunction(qc_program *prog, prog_section_function *func)
const char *value;
} qcvm_parameter;
-qcvm_parameter *main_params = NULL;
+static qcvm_parameter *main_params = NULL;
#define CheckArgs(num) do { \
if (prog->argc != (num)) { \
qcany str;
CheckArgs(1);
num = GetArg(0);
- snprintf(buffer, sizeof(buffer), "%g", num->_float);
+ util_snprintf(buffer, sizeof(buffer), "%g", num->_float);
str.string = prog_tempstring(prog, buffer);
Return(str);
return 0;
qcany num;
CheckArgs(1);
str = GetArg(0);
- num._float = strtof(prog_getstring(prog, str->string), NULL);
+ num._float = (float)strtod(prog_getstring(prog, str->string), NULL);
Return(num);
return 0;
}
qcany str;
CheckArgs(1);
num = GetArg(0);
- snprintf(buffer, sizeof(buffer), "'%g %g %g'", num->vector[0], num->vector[1], num->vector[2]);
+ util_snprintf(buffer, sizeof(buffer), "'%g %g %g'", num->vector[0], num->vector[1], num->vector[2]);
str.string = prog_tempstring(prog, buffer);
Return(str);
return 0;
qcany str;
CheckArgs(1);
num = GetArg(0);
- snprintf(buffer, sizeof(buffer), "%i", num->_int);
+ util_snprintf(buffer, sizeof(buffer), "%i", num->_int);
str.string = prog_tempstring(prog, buffer);
Return(str);
return 0;
return 0;
}
+static int qc_floor(qc_program *prog)
+{
+ qcany *num, out;
+ CheckArgs(1);
+ num = GetArg(0);
+ out._float = floor(num->_float);
+ Return(out);
+ return 0;
+}
+
static prog_builtin qc_builtins[] = {
NULL,
&qc_print, /* 1 */
&qc_strcat, /* 10 */
&qc_strcmp, /* 11 */
&qc_normalize, /* 12 */
- &qc_sqrt /* 13 */
+ &qc_sqrt, /* 13 */
+ &qc_floor /* 14 */
};
static size_t qc_builtins_count = sizeof(qc_builtins) / sizeof(qc_builtins[0]);