#define TOKEN_FALSE 10
-#define MAX_TOKEN_LENGTH 1024
+#define MAX_TOKEN_LENGTH 4096
static char token_string[MAX_TOKEN_LENGTH + 1] = "";
static int token_length = 0;
bool
LispReader::read_string (const char* name, std::string& str)
{
- char str_[1204];
+ char str_[1024];
sprintf(str_, "%s-%s", name, getenv("LANG"));
lisp_object_t* obj = search_for (str_);
{
std::string text;
std::vector<std::string> names;
-
- lisp_object_t* root_obj = lisp_read_from_file(datadir + file);
- lisp_object_t* cur = lisp_car(root_obj);
- if (lisp_symbol_p(cur) && strcmp(lisp_symbol(cur), "text") == 0)
- {
- LispReader reader(lisp_cdr(root_obj));
- reader.read_string("text", text);
- }
- else
+ LispReader* reader = LispReader::load(datadir + "/" + file, "supertux-text");
+
+ if(!reader)
{
- std::cerr << "Error: Could not open text. Ignoring...\n";
- return;
+ std::cerr << "Error: Could not open text. Ignoring...\n";
+ return;
}
- unsigned int l, i;
- l = 0;
+
+ reader->read_string("text", text);
+ delete reader;
+
+ names.clear();
+ unsigned int i, l;
+ i = 0;
while(true)
{
- i = l;
l = text.find("\n", i);
- if(l != std::string::npos)
+
+ if(l == std::string::npos)
+ {
+ char temp[1024];
+ temp[text.copy(temp, text.size() - i, i)] = '\0';
+ names.push_back(temp);
break;
+ }
- char* temp = 0;
- text.copy(temp, l, i);
+ char temp[1024];
+ temp[text.copy(temp, l-i, i)] = '\0';
names.push_back(temp);
+
+ i = l+1;
}
int done = 0;
#include "surface.h"
#include "vector.h"
+/** Reads a text file (using LispReader, so it as to be in its formatting)
+ and displays it in a StarTrek fashion */
void display_text_file(const std::string& file, const std::string& surface, float scroll_speed);
void display_text_file(const std::string& file, Surface* surface, float scroll_speed);