nuke the string api (never really liked it)

This commit is contained in:
Bill Currie 2003-04-08 02:35:09 +00:00
parent 5d40d7e8f3
commit 0b0dfcc38e
12 changed files with 6 additions and 159 deletions

View file

@ -67,6 +67,4 @@ void QFile_Progs_Init (struct progs_s *pr, int secure);
QFile **QFile_AllocHandle (struct progs_s *pr, qfile_resources_t *res);
void QFS_Progs_Init (struct progs_s *pr);
void String_Progs_Init (struct progs_s *pr);
#endif//__QF_csqc_h

View file

@ -452,7 +452,6 @@ Menu_Init (void)
QFS_Progs_Init (&menu_pr_state);
PR_Cmds_Init (&menu_pr_state);
R_Progs_Init (&menu_pr_state);
String_Progs_Init (&menu_pr_state);
confirm_quit = Cvar_Get ("confirm_quit", "1", CVAR_ARCHIVE, NULL,
"confirm quit command");

View file

@ -12,4 +12,4 @@ libQFcsqc_la_LDFLAGS= -version-info 1:0:0
libQFcsqc_la_SOURCES=\
bi_cbuf.c bi_cmd.c bi_cvar.c bi_file.c bi_hash.c bi_init.c \
bi_inputline.c bi_plist.c \
bi_qfile.c bi_qfs.c bi_string.c
bi_qfile.c bi_qfs.c

View file

@ -43,7 +43,6 @@ static void (*const inputline_progs_init)(progs_t *) = InputLine_Progs_Init;
static void (*const plist_progs_init)(progs_t *) = Plist_Progs_Init;
static void (*const qfile_progs_init)(progs_t *, int) = QFile_Progs_Init;
static void (*const qfs_progs_init)(progs_t *) = QFS_Progs_Init;
static void (*const string_progs_init)(progs_t *) = String_Progs_Init;
void
BI_Init ()

View file

@ -1,132 +0,0 @@
/*
bi_string.c
CSQC string builtins
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
static __attribute__ ((unused)) const char rcsid[] =
"$Id$";
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include "QF/csqc.h"
#include "QF/progs.h"
#include "QF/zone.h"
/*
bi_String_ReplaceChar
Repalces a special character in a string with another
*/
static void
bi_String_ReplaceChar (progs_t *pr)
{
char old = P_INT (pr, 0);
char new = P_INT (pr, 1);
const char *src = P_STRING (pr, 2);
const char *s;
char *dst = Hunk_TempAlloc (strlen (src) + 1);
char *d;
for (d = dst, s = src; *s; d++, s++) {
if (*s == old)
*d = new;
else
*d = *s;
}
RETURN_STRING (pr, dst);
}
/*
bi_String_Cut
Cuts a specified part from a string
*/
static void
bi_String_Cut (progs_t *pr)
{
char pos = P_INT (pr, 0);
char len = P_INT (pr, 1);
const char *str = P_STRING (pr, 2);
char *dst = Hunk_TempAlloc ((strlen (str) - len) + 1);
int cnt;
memset (dst, 0, (strlen (str) - len) + 1);
strncpy(dst, str, pos);
str += pos;
for (cnt = 0; cnt < len; cnt++)
str++;
strcpy(dst, str);
RETURN_STRING (pr, dst);
}
/*
bi_String_Len
Gives back the length of the string
*/
static void
bi_String_Len (progs_t *pr)
{
const char *str = P_STRING (pr, 0);
R_INT (pr) = strlen(str);
}
/*
bi_String_GetChar
Gives the intervalue of a character in
a string
*/
static void
bi_String_GetChar (progs_t *pr)
{
const char *str = P_STRING (pr, 0);
int pos = P_INT (pr, 1);
int ret = 0;
if(pos > 0 && pos < strlen(str)) {
ret = (int)str[pos];
}
R_INT (pr) = ret;
}
void
String_Progs_Init (progs_t *pr)
{
PR_AddBuiltin (pr, "String_ReplaceChar", bi_String_ReplaceChar, -1);
PR_AddBuiltin (pr, "String_Cut", bi_String_Cut, -1);
PR_AddBuiltin (pr, "String_Len", bi_String_Len, -1);
PR_AddBuiltin (pr, "String_GetChar", bi_String_GetChar, -1);
}

View file

@ -31,7 +31,7 @@ EXTRA_DATA= $(menu_data)
menu_src= \
client_menu.qc controls_o.qc \
inputline_util.qc menu.r options.qc \
options_util.qc servlist.qc string.r
options_util.qc servlist.qc
%.qfo: %.r
$(QFCC) $(QCFLAGS) $(QCPPFLAGS) -c -o $@ $<

View file

@ -6,7 +6,6 @@
#include "InputLine.h"
#include "Rect.h"
#include "string.h"
#include "../include/string.h"
#include "math.h"
#include "cbuf.h"
#include "options.h"
@ -102,7 +101,7 @@ void () scan_saves =
if (!f)
continue;
Qgetline (f);
filenames[i] = String_ReplaceChar ('_', ' ', Qgetline (f));
filenames[i] = Qgetline (f);
loadable[i] = 1;
Qclose (f);
}

View file

@ -32,7 +32,6 @@
#include "debug.h"
#include "string.h"
#include "key.h"
#include "../include/string.h"
#include "options_util.h"
integer set_key_flag; // holds flag for the key-setting
@ -138,7 +137,7 @@ get_keyname =
} else {
keyname = Key_KeynumToString(keynum);
// cut away the "K_", thats maybe enough as description for now
keyname = String_Cut(0, 2, keyname);
//keyname = String_Cut(0, 2, keyname);
}
return keyname;
};

View file

@ -28,7 +28,7 @@
#include "cbuf.h"
#include "menu.h"
#include "system.h"
#include "../include/string.h"
#include "string.h"
#include "math.h"
#include "draw.h"
#include "cvar.h"

View file

@ -84,7 +84,7 @@ draw_item =
local integer i;
Draw_String (x, y, label);
for (i = x + String_Len (label) * 8; i < (x+spacing); i += 8) {
for (i = x + (integer) strlen (label) * 8; i < (x+spacing); i += 8) {
Draw_String (i, y, spacechar);
}
Draw_String (x + spacing, y, valstr);

View file

@ -1,9 +0,0 @@
#ifndef __string_h
#define __string_h
@extern string (integer old, integer new, string str) String_ReplaceChar;
@extern string (integer pos, integer len, string str) String_Cut;
@extern integer (string str) String_Len;
@extern integer (string str, integer pos) String_GetChar;
#endif

View file

@ -1,6 +0,0 @@
#include "string.h"
string (integer old, integer new, string str) String_ReplaceChar = #0;
string (integer pos, integer len, string str) String_Cut = #0;
integer (string str) String_Len = #0;
integer (string str, integer pos) String_GetChar = #0;