summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-11-30 19:24:40 +0000
committerMike Buland <eichlan@xagasoft.com>2007-11-30 19:24:40 +0000
commit0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7 (patch)
tree14951a51950dffbe094b6cdd3fd56d239b1079f2
parent4d0a7466320e54f45f413efef09ef8e6ad21bb3e (diff)
downloadlibbu++-0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7.tar.gz
libbu++-0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7.tar.bz2
libbu++-0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7.tar.xz
libbu++-0ff3fdfaa52ee4b71632f201d6bfabb0ffbc36d7.zip
Fixed the overshoot in the Bu::TafReader, it was reading the lookahead character
from the stream even when it should have known it was at the end, and then it was reading an extra character after that anyway :-P It is now fixed, and the stream is positioned at the character immediately after the closing } of the root taf group, great for things like the svtools.
-rw-r--r--src/minimacro.cpp17
-rw-r--r--src/minimacro.h63
-rw-r--r--src/tafreader.cpp16
3 files changed, 93 insertions, 3 deletions
diff --git a/src/minimacro.cpp b/src/minimacro.cpp
new file mode 100644
index 0000000..274c13b
--- /dev/null
+++ b/src/minimacro.cpp
@@ -0,0 +1,17 @@
1/*
2 * Copyright (C) 2007 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#include "bu/minimacro.h"
9
10Bu::MiniMacro::MiniMacro()
11{
12}
13
14Bu::MiniMacro::~MiniMacro()
15{
16}
17
diff --git a/src/minimacro.h b/src/minimacro.h
new file mode 100644
index 0000000..e136015
--- /dev/null
+++ b/src/minimacro.h
@@ -0,0 +1,63 @@
1/*
2 * Copyright (C) 2007 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_MINI_MACRO_H
9#define BU_MINI_MACRO_H
10
11namespace Bu
12{
13 /**
14 * A processor for Libbu++ brand Mini Macros. These are really simple, but
15 * still fairly flexible. It's mainly text replacement, but with a few
16 * extras like filter functions and conditional text segments. So far we
17 * don't support loops or anything, I'm not sure we ever will.
18 *
19 * Anatomy of a mini macro:
20 * - Every macro begins with a two character code, the first character is
21 * always '{', the second character determines the operation to perform.
22 * - If the '{' is followed by a character that is not valid it is not
23 * considered for expansion and the characters are copied to the output.
24 * - Every macro ends with a closing '}'
25 * - Macro types:
26 * - '=': variable replacement. The '=' is immediatley followed by the
27 * name of the variable to replace, then any number of optional filter
28 * segments.
29 * - '?': conditional text. The '?' is immediately followed by the
30 * variable to test. This works two ways, the variable can be alone, in
31 * which case it's existance is tested, or it can be followed by a "="
32 * and a string to compare to. This is then followed by a text segment
33 * that will be used if the test is true, and an optional text segment
34 * to be used if the test is false.
35 * - Segments:
36 * - Each segment is seperated by a colon.
37 * - Filter segments give the name of the filter, followed by
38 * parenthesies. Parameters may be provided within the parenthesies.
39 * - Text segments should always be quoted, but may contain any characters
40 * within the quotes, backslash is used as per C/ANSI/ISO standard.
41 * You can also quote any text using [" "] instead of quotes, which
42 * allows for nested strings. The [" token is only recognised within
43 * a macro.
44 *
45 *@verbatim
46 {=name:tolower()}
47 {=name:ccsplit("_"):toupper()}
48 {?name:"name exists and is {=name}"}
49 {?name:"{=name}":"no name!"}
50 {?name="bob":"You're named bob!":"Who are you? I only know bob..."}
51 @endverbatim
52 */
53 class MiniMacro
54 {
55 public:
56 MiniMacro();
57 virtual ~MiniMacro();
58
59 private:
60 };
61};
62
63#endif
diff --git a/src/tafreader.cpp b/src/tafreader.cpp
index aaac8d7..7054581 100644
--- a/src/tafreader.cpp
+++ b/src/tafreader.cpp
@@ -40,7 +40,7 @@ Bu::TafGroup *Bu::TafReader::readGroup()
40 if( c != '}' ) 40 if( c != '}' )
41 throw TafException("Expected '}'"); 41 throw TafException("Expected '}'");
42 42
43 next(); 43 //next();
44 44
45 return pGroup; 45 return pGroup;
46} 46}
@@ -184,7 +184,17 @@ bool Bu::TafReader::isws()
184 184
185void Bu::TafReader::next() 185void Bu::TafReader::next()
186{ 186{
187 c = la; 187 if( c == '}' )
188 sIn.read( &la, 1 ); 188 {
189 sIn.read( &c, 1 );
190 if( c != '}' )
191 sIn.read( &la, 1 );
192 }
193 else
194 {
195 c = la;
196 if( c != '}' )
197 sIn.read( &la, 1 );
198 }
189} 199}
190 200