Category: Strings

Strings and text in the code.

Removing ANSI Color Codes With Regex

Strangely enough, I haven’t really used regular expressions until recently. They’re incredibly powerful. In fact, here’s one that replaces about 40 lines of C++ code with a single line of C#.NET code: text = Regex.Replace(text, @”\e\[\d*;?\d+m”, “”); It’s not absolutely perfect, but it does the trick for removing all of the ANSI color codes from

Command Processing Engine Complete

I completed the last of the code for the command processing engine today. Not much detail to report — it’s done and seems to work well enough.

A New Command Processing Engine

Command processing in the old Basternae was pretty klunky. The command interpreter would just pass on any text that was entered and each command function would have to do a lot of parsing to split up the command strings and figure out what the user actually intended. About half of each command would be devoted

Automatic Line Wrap

When writing a zone, it can be tough to know where to end your lines of text. While a standard terminal has 80 characters, some telnet programs start to look weird with any line that is more than 77 characters, and some terminals have 130 or more characters per line (usually depends on screen resolution).

Better String Visualization in VS2005

The text visualizer in Visual Studio 2005 isn’t very good. When you’re looking at a string in the debugger, you won’t see what you’re looking for if there are any null characters in the string. As far as I can tell this is a holdover from the bad old days when null-terminated C strings were

String Conversion Update

I’m still working on converting char * strings to std::string strings. Here’s the recent progress: Reference 5-27-07 5-29-07 6-1-07 6-4-07 6-10-07 6-15-07 strncat 772 723 641 605 606 581 snprintf 1199 1166 1096 1079 1064 1032 const char * 343 287 317 330 341 330 MAX_STRING_LENGTH 2404 2313 2062 2011 2000 1955 MAX_INPUT_LENGTH 471 446

Visual Studio 2005

I’ve been using Visual Studio .Net 2003 for a long time. I’ve finally upgraded to 2005, and some of the changes are interesting. One of the things I’ve been doing is converting a lot of the c-string functions to STL std::string. It turns out that the old string functions I’m gradually eliminating have been deprecated:

New String Functions

I’ve written new string functions based on std::string. They’re the typical case insensitive compare, check prefix, compare with list of names, get first argument, get last argument, and other string manipulation functions you’d normally see used with a MUD. The difference is: They’re not very prone to buffer overflows and pointer errors because they’re using

Goodbye Shared Strings

Shared string management has been completely removed from the code. Gone. Done for. The result: greater stability at the cost of higher memory requirements and a slight reduction in processor power requirements (which aren’t even a concern). The removal automagically fixed a few bugs due to the less-than-perfect shared string management. Next task: Getting Thendar’s