[Redbutton-devel] SF.net SVN: redbutton: [475] redbutton-author/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2008-01-14 17:19:18
|
Revision: 475
http://redbutton.svn.sourceforge.net/redbutton/?rev=475&view=rev
Author: skilvington
Date: 2008-01-14 09:19:14 -0800 (Mon, 14 Jan 2008)
Log Message:
-----------
make mhegd output even nicer
Modified Paths:
--------------
redbutton-author/trunk/TODO
redbutton-author/trunk/mhegd.c
redbutton-author/trunk/output.c
redbutton-author/trunk/output.h
Modified: redbutton-author/trunk/TODO
===================================================================
--- redbutton-author/trunk/TODO 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/TODO 2008-01-14 17:19:14 UTC (rev 475)
@@ -31,3 +31,32 @@
allow INTEGERs to be arthimetic expressions
#include "uk.inc"
+---
+
+mhegd
+make this look nicer (4165/a)...
+{:TokenGroup 1000
+ :Shared true
+ :TokenGroupItems (
+ ( 102
+ :ActionSlots (
+ (
+ :Call ( ... )
+ :Activate ( 1001 )
+ ) )
+ )
+}
+
+this is even worse (4165/enh_gateway.mhg)...
+ {:TokenGroup 82
+ :TokenGroupItems (
+ ( ( '/a' 1 )
+ :ActionSlots (
+ (
+ :Run ( ( '/a' 119 ) ) ) (
+ :Run ( ( '/a' 119 ) ) ) (
+ :Run ( ( '/a' 122 ) )
+ :Run ( ( '/a' 120 ) ) )
+ ) )
+ )
+
Modified: redbutton-author/trunk/mhegd.c
===================================================================
--- redbutton-author/trunk/mhegd.c 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/mhegd.c 2008-01-14 17:19:14 UTC (rev 475)
@@ -29,6 +29,7 @@
#include "asn1decode.h"
#include "der_decode.h"
+#include "output.h"
#include "utils.h"
void verbose(const char *, ...);
@@ -82,6 +83,7 @@
rewind(in_file);
/* write text form of DER encoded in_file to out_file */
+ output_init();
used = asn1decode_InterchangedObject(in_file, out_file, filesize);
fprintf(out_file, "\n");
if(used < 0)
Modified: redbutton-author/trunk/output.c
===================================================================
--- redbutton-author/trunk/output.c 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/output.c 2008-01-14 17:19:14 UTC (rev 475)
@@ -32,15 +32,55 @@
int indent = 0;
bool newline = true;
+/* keep track of () blocks that should be indented */
+#define PAREN_LEVEL_MAX 8192
+int paren_level = 0;
+bool indent_paren[PAREN_LEVEL_MAX];
+
void
+output_init(void)
+{
+ bzero(indent_paren, sizeof(indent_paren));
+
+ return;
+}
+
+void
output_token(FILE *out, char *tok)
{
/* assert */
if(tok[0] == '\0')
fatal("output_token: 0 length token");
- if(tok[0] == '{' && tok[1] == ':')
+ if(tok[0] == '(' && tok[1] == '\0')
{
+ /* assert */
+ if(paren_level >= (PAREN_LEVEL_MAX - 1))
+ fatal("output_token: max nested parenthesis reached");
+ print_token(out, tok);
+ paren_level ++;
+ if(indent_paren[paren_level])
+ {
+ print_newline(out);
+ indent ++;
+ }
+ }
+ else if(tok[0] == ')' && tok[1] == '\0')
+ {
+ /* assert */
+ if(paren_level <=0)
+ fatal("output_token: unexpected ')'");
+ if(indent_paren[paren_level])
+ {
+ indent --;
+ print_newline(out);
+ }
+ indent_paren[paren_level] = false;
+ paren_level --;
+ print_token(out, tok);
+ }
+ else if(tok[0] == '{' && tok[1] == ':')
+ {
print_newline(out);
print_token(out, tok);
indent ++;
@@ -54,14 +94,33 @@
print_newline(out);
print_token(out, tok);
}
+ else if(strcmp(tok, ":ActionSlots") == 0
+ || strcmp(tok, ":Items") == 0
+ || strcmp(tok, ":LinkEffect") == 0
+ || strcmp(tok, ":MovementTable") == 0
+ || strcmp(tok, ":Multiplex") == 0
+ || strcmp(tok, ":NextScenes") == 0
+ || strcmp(tok, ":NextScenes") == 0
+ || strcmp(tok, ":NoTokenActionSlots") == 0
+ || strcmp(tok, ":Positions") == 0
+ || strcmp(tok, ":TokenGroupItems") == 0)
+ {
+ print_newline(out);
+ print_token(out, tok);
+ /* next () block should be indented */
+ indent_paren[paren_level + 1] = true;
+ }
else if(tok[0] == ':'
+ && strcmp(tok, ":CCPriority") != 0
+ && strcmp(tok, ":ContentRef") != 0
+ && strcmp(tok, ":IndirectRef") != 0
&& strcmp(tok, ":GBoolean") != 0
+ && strcmp(tok, ":GContentRef") != 0
&& strcmp(tok, ":GInteger") != 0
+ && strcmp(tok, ":GObjectRef") != 0
&& strcmp(tok, ":GOctetString") != 0
- && strcmp(tok, ":GObjectRef") != 0
- && strcmp(tok, ":GContentRef") != 0
- && strcmp(tok, ":IndirectRef") != 0
- && strcmp(tok, ":ContentRef") != 0)
+ && strcmp(tok, ":NewCCPriority") != 0
+ && strcmp(tok, ":NewRefContent") != 0)
{
print_newline(out);
print_token(out, tok);
Modified: redbutton-author/trunk/output.h
===================================================================
--- redbutton-author/trunk/output.h 2008-01-09 17:06:53 UTC (rev 474)
+++ redbutton-author/trunk/output.h 2008-01-14 17:19:14 UTC (rev 475)
@@ -25,6 +25,8 @@
#include <stdio.h>
+void output_init(void);
+
void output_token(FILE *, char *);
#endif /* __OUTPUT_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|