[Scummvm-cvs-logs] CVS: tools descumm-common.cpp,1.3,1.4 descumm.cpp,1.36,1.37 descumm6.cpp,1.101,1.102 descumm.h,1.3,1.4
Max Horn
fingolfin at users.sourceforge.net
Sun May 11 15:24:02 CEST 2003
Update of /cvsroot/scummvm/tools
In directory sc8-pr-cvs1:/tmp/cvs-serv26586
Modified Files:
descumm-common.cpp descumm.cpp descumm6.cpp descumm.h
Log Message:
cleanup / tweaks
Index: descumm-common.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm-common.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- descumm-common.cpp 10 May 2003 23:20:13 -0000 1.3
+++ descumm-common.cpp 11 May 2003 22:23:11 -0000 1.4
@@ -99,21 +99,22 @@
#define INDENT_SIZE 2
-static char *indentbuf;
+static char indentbuf[127 * INDENT_SIZE + 1];
-char *getIndentString(int i)
+// Generate a string with white spaces for the given indention level.
+// For each level, INDENT_SIZE spaces are inserted.
+char *getIndentString(int level)
{
- char *c = indentbuf;
- i += i;
- if (!c)
- indentbuf = c = (char *)malloc(127 * INDENT_SIZE + 1);
- if (i >= 127 * INDENT_SIZE)
- i = 127 * INDENT_SIZE;
- if (i < 0)
- i = 0;
- memset(c, 32, i);
- c[i] = 0;
- return c;
+ if (level >= 127)
+ level = 127;
+ if (level < 0)
+ level = 0;
+
+ level *= INDENT_SIZE;
+
+ memset(indentbuf, ' ', level);
+ indentbuf[level] = 0;
+ return indentbuf;
}
void outputLine(char *buf, int curoffs, int opcode, int indent)
Index: descumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- descumm.cpp 10 May 2003 23:39:49 -0000 1.36
+++ descumm.cpp 11 May 2003 22:23:11 -0000 1.37
@@ -3012,8 +3012,16 @@
buf = (char *)malloc(4096);
if (GF_UNBLOCKED) {
+ if (size_of_code < 4) {
+ printf("File too small to be a script\n");
+ exit(0);
+ }
mem += 4;
} else if (scriptVersion == 5) {
+ if (size_of_code < 8) {
+ printf("File too small to be a script\n");
+ exit(0);
+ }
switch (TO_BE_32(*((uint32 *)mem))) {
case 'LSCR':
printf("Script# %d\n", (byte)mem[8]);
@@ -3036,6 +3044,10 @@
exit(0);
}
} else {
+ if (size_of_code < 6) {
+ printf("File too small to be a script\n");
+ exit(0);
+ }
switch (TO_LE_16(*((uint16 *)mem + 2))) {
case MKID('LS'):
printf("Script# %d\n", (byte)mem[8]);
@@ -3065,7 +3077,7 @@
offs_of_line = 0;
- do {
+ while (cur_pos < mem + len) {
byte opcode = *cur_pos;
int j = num_block_stack;
buf[0] = 0;
@@ -3086,7 +3098,7 @@
outputLine("}", -1, -1, -1);
}
fflush(stdout);
- } while (cur_pos < mem + len);
+ }
printf("END\n");
Index: descumm6.cpp
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm6.cpp,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- descumm6.cpp 10 May 2003 23:39:49 -0000 1.101
+++ descumm6.cpp 11 May 2003 22:23:11 -0000 1.102
@@ -2586,6 +2586,11 @@
fclose(in);
size_of_code = len;
+ if (size_of_code < 10) {
+ printf("File too small to be a script\n");
+ exit(0);
+ }
+
output = buf = (char *)malloc(8192);
switch (TO_BE_32(*((uint32 *)mem))) {
@@ -2627,7 +2632,7 @@
offs_of_line = 0;
- do {
+ while (cur_pos < mem + len) {
byte opcode = *cur_pos;
int j = num_block_stack;
buf[0] = 0;
@@ -2648,7 +2653,7 @@
outputLine("}", -1, -1, -1);
}
fflush(stdout);
- } while (cur_pos < mem + len);
+ }
printf("END\n");
Index: descumm.h
===================================================================
RCS file: /cvsroot/scummvm/tools/descumm.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- descumm.h 10 May 2003 23:20:13 -0000 1.3
+++ descumm.h 11 May 2003 22:23:11 -0000 1.4
@@ -131,7 +131,6 @@
// Common
//
-extern char *getIndentString(int i);
extern void outputLine(char *buf, int curoffs, int opcode, int indent);
extern bool indentBlock(unsigned int cur);
More information about the Scummvm-git-logs
mailing list