PR_GetString should have been returning const char *. now does

This commit is contained in:
Bill Currie 2003-11-21 21:34:53 +00:00
parent 5a49e9fea4
commit cd8035319d
10 changed files with 45 additions and 39 deletions

View file

@ -221,7 +221,7 @@ int PR_InitRuntime (progs_t *pr);
//
qboolean PR_StringValid (progs_t *pr, int num);
char *PR_GetString(progs_t *pr, int num);
const char *PR_GetString(progs_t *pr, int num);
int PR_SetString(progs_t *pr, const char *s);
void PR_GarbageCollect (progs_t *pr);
@ -378,7 +378,7 @@ struct progs_s {
struct hashtab_s *protocols;
// debug info
char *debugfile;
const char *debugfile;
struct pr_debug_header_s *debug;
struct pr_auxfunction_s *auxfunctions;
struct pr_auxfunction_s **auxfunction_map;

View file

@ -89,7 +89,7 @@ plitem_t *PL_A_InsertObjectAtIndex (plitem_t *, plitem_t *, int ind);
plitem_t *PL_NewDictionary (void);
plitem_t *PL_NewArray (void);
plitem_t *PL_NewData (void *, int);
plitem_t *PL_NewString (char *);
plitem_t *PL_NewString (const char *);
void PL_FreeItem (struct plitem_s *);

View file

@ -115,7 +115,7 @@ bi_GIB_Builtin_Add (progs_t *pr)
{
bi_gib_resources_t *res = PR_Resources_Find (pr, "GIB");
bi_gib_builtin_t *builtin;
char *name = P_GSTRING (pr, 0);
const char *name = P_GSTRING (pr, 0);
func_t func = P_FUNCTION (pr, 1);
if (GIB_Builtin_Exists (name)) {
@ -139,7 +139,7 @@ bi_GIB_Builtin_Add (progs_t *pr)
static void
bi_GIB_Return (progs_t *pr)
{
char *str = P_GSTRING(pr, 0);
const char *str = P_GSTRING(pr, 0);
if (str)
GIB_Return (str);

View file

@ -602,15 +602,15 @@ PF_charcount (progs_t *pr)
static void
PF_sprintf (progs_t *pr)
{
char *format;
char *c; // current
char *out = 0;
char new_format[INT_WIDTH * 2 + 9]; // "%0-+ #." and conversion
int fmt_alternate, fmt_leadzero, fmt_leftjust, fmt_minwidth,
fmt_precision, fmt_signed, fmt_space, fmt_type, looping,
ret;
size_t new_format_i;
int curarg = 1, out_max = 32, out_size = 0;
const char *format;
const char *c; // current
char *out = 0;
char new_format[INT_WIDTH * 2 + 9]; // "%0-+ #." and conversion
int fmt_alternate, fmt_leadzero, fmt_leftjust, fmt_minwidth;
int fmt_precision, fmt_signed, fmt_space, fmt_type, looping;
int ret;
size_t new_format_i;
int curarg = 1, out_max = 32, out_size = 0;
format = P_GSTRING (pr, 0);
c = format;
@ -774,7 +774,7 @@ PF_sprintf (progs_t *pr)
}
}
} else if (*c == '%' && *(c + 1) == 's') {
char *s;
const char *s;
if (curarg > MAX_ARG)
goto maxargs;
s = P_GSTRING (pr, 0 + curarg);

View file

@ -369,12 +369,12 @@ PR_GlobalStringNoContents (progs_t *pr, int ofs, etype_t type)
void
ED_Print (progs_t *pr, edict_t *ed)
{
int l;
int l;
unsigned int i;
char *name;
int type;
ddef_t *d;
pr_type_t *v;
const char *name;
int type;
ddef_t *d;
pr_type_t *v;
if (ed->free) {
Sys_Printf ("FREE\n");

View file

@ -273,8 +273,8 @@ PR_ExecuteProgram (progs_t * pr, func_t fnum)
break;
case OP_ADD_S:
{
char *a = PR_GetString (pr, OPA.string_var);
char *b = PR_GetString (pr, OPB.string_var);
const char *a = PR_GetString (pr, OPA.string_var);
const char *b = PR_GetString (pr, OPB.string_var);
int lena = strlen (a);
int size = lena + strlen (b) + 1;
char *c = Hunk_TempAlloc (size);

View file

@ -118,10 +118,10 @@ ED_Write (progs_t *pr, QFile *f, edict_t *ed)
{
unsigned int i;
int j;
int type;
char *name;
ddef_t *d;
pr_type_t *v;
int type;
const char *name;
ddef_t *d;
pr_type_t *v;
Qprintf (f, "{\n");
@ -162,10 +162,10 @@ ED_Write (progs_t *pr, QFile *f, edict_t *ed)
void
ED_WriteGlobals (progs_t *pr, QFile *f)
{
ddef_t *def;
ddef_t *def;
unsigned int i;
char *name;
int type;
const char *name;
int type;
Qprintf (f, "{\n");
for (i = 0; i < pr->progs->numglobaldefs; i++) {

View file

@ -154,10 +154,10 @@ PR_LoadStrings (progs_t *pr)
void
PR_GarbageCollect (progs_t *pr)
{
char *str;
const char *str;
unsigned int i;
int j;
ddef_t *def;
ddef_t *def;
strref_t *sr;
for (i = 0; i < pr->dyn_str_size; i++)
@ -222,7 +222,7 @@ PR_StringValid (progs_t *pr, int num)
return get_string (pr, num) != 0;
}
char *
const char *
PR_GetString (progs_t *pr, int num)
{
char *str;

View file

@ -98,14 +98,20 @@ PL_NewData (void *data, int size)
return item;
}
plitem_t *
PL_NewString (char *str)
static plitem_t *
new_string (char *str)
{
plitem_t *item = PL_NewItem (QFString);
item->data = str;
return item;
}
plitem_t *
PL_NewString (const char *str)
{
return new_string (strdup (str));
}
void
PL_FreeItem (plitem_t *item)
{
@ -581,7 +587,7 @@ PL_ParsePropertyListItem (pldata_t *pl)
if (!str) {
return NULL;
} else {
return PL_NewString (str);
return new_string (str);
}
}
@ -591,7 +597,7 @@ PL_ParsePropertyListItem (pldata_t *pl)
if (!str) {
return NULL;
} else {
return PL_NewString (str);
return new_string (str);
}
}
} // switch

View file

@ -49,7 +49,7 @@ static __attribute__ ((unused)) const char rcsid[] =
static void
bi_print (progs_t *pr)
{
char *str;
const char *str;
str = P_GSTRING (pr, 0);
fprintf (stdout, "%s", str);
@ -77,7 +77,7 @@ bi_strerror (progs_t *pr)
static void
bi_open (progs_t *pr)
{
char *path = P_GSTRING (pr, 0);
const char *path = P_GSTRING (pr, 0);
int flags = P_INT (pr, 1);
int mode = P_INT (pr, 2);
R_INT (pr) = open (path, flags, mode);
@ -112,7 +112,7 @@ static void
bi_write (progs_t *pr)
{
int handle = P_INT (pr, 0);
char *buffer = P_GSTRING (pr, 1);
const char *buffer = P_GSTRING (pr, 1);
int count = P_INT (pr, 2);
R_INT (pr) = write (handle, buffer, count);