aboutsummaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNathan Vance <nathav63@gmail.com>2015-02-27 15:00:06 -0500
committerNathan Vance <nathav63@gmail.com>2015-02-27 15:00:06 -0500
commit03b04f383c2897b6177e4feb0eb86b68e377f6dc (patch)
treef3d914b2010f01a32f59dabaa8b4881faeb9797c /util.c
parentNow counts special cards! (diff)
download7w-03b04f383c2897b6177e4feb0eb86b68e377f6dc.tar.gz
7w-03b04f383c2897b6177e4feb0eb86b68e377f6dc.tar.bz2
7w-03b04f383c2897b6177e4feb0eb86b68e377f6dc.zip
Added battles
Diffstat (limited to 'util.c')
-rw-r--r--util.c44
1 files changed, 1 insertions, 43 deletions
diff --git a/util.c b/util.c
index 2935600..20e8290 100644
--- a/util.c
+++ b/util.c
@@ -5,7 +5,7 @@
static void replace(char a[], char b[], int x, int y);
-#define POOLSIZE 10000
+#define POOLSIZE 100000
static int ipool[POOLSIZE];
static int *ipoolp = ipool;
@@ -28,48 +28,6 @@ char* get_chararray(int size)
return ret;
}
-/* In string a[], replace nth occerence of x[] with y[],
- or all occerences if n == 0. Note '.' is wild and
- the last . replaced will be returned. */
-char util_strreplace(char a[], char x[], char y[], int n) {
- int replaceAll = ! n;
- int i, j, lengthY;
- char dot = '\0';
- for(lengthY = 0; y[lengthY] != '\0'; lengthY++);
- for(i = 0; a[i] != '\0'; i++) {
- for(j = 0;; j++) {
- if(a[i+j] != x[j] && x[j] != '\0' && x[j] != '.') // '.' is wild
- break;
- if (x[j] == '.') dot = a[i+j];
- if (x[j] == '\0') { //it's a match
- n--;
- if(replaceAll) { //replace it
- replace(a, y, i, j);
- i += lengthY - 1;
- }
- else if(n == 0) { //replace it
- replace(a, y, i, j);
- return dot;
- }
- break;
- }
- if(a[i+j] == '\0') //end of string
- return dot;
- }
- }
-}
-
-/* In string a[], replace characters x - y with b[] */
-static void replace(char a[], char b[], int x, int y)
-{
- int i, j;
- for(i = 0; a[i] != '\0'; i++);
- char save[i-y+1];
- for(i = x+y, j = 0; (save[j] = a[i]) != '\0'; i++, j++);
- for(i = x, j = 0; (a[i] = b[j]) != '\0'; i++, j++);
- for(i = i, j = 0; (a[i] = save[j]) != '\0'; i++, j++);
-}
-
/* Concatinates a and b and returns a different
string. Only use when returned string can be recycled. */
char* cat(char a[], char b[]) {
bgstack15