string.diff
mud++0.33/src/string.diff · 2.5 KB
From the archive mud++0.33.tar.gz
Download the archive « Back to the archive contents
--- string.cpp Thu Jul 17 16:31:55 1997
+++ string.cpp.new Thu Jul 17 16:58:39 1997
@@ -19,10 +19,8 @@
#include "string.h"
-#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
-#include "config.h"
#if defined(WIN32)
#include "win32/crypt.h"
@@ -165,8 +163,9 @@
}
-String & String::append( const String & x, int xlen )
+String & String::append( const String & x )
{
+ int xlen = strlen( x.rep->str );
int ylen = strlen( rep->str );
if( xlen == 0 )
@@ -204,8 +203,9 @@
}
-String & String::append( const char * x, int xlen )
+String & String::append( const char * x )
{
+ int xlen = strlen( x );
int ylen = strlen( rep->str );
if( xlen == 0 )
@@ -710,7 +710,7 @@
va_start( args, fmt );
xlen = vsprintf( buf, fmt, args );
clr();
- append( buf, xlen );
+ append( buf );
va_end( args );
return xlen;
}
@@ -725,7 +725,7 @@
va_start( args, fmt );
xlen = vsprintf( buf, fmt, args );
- append( buf, xlen );
+ append( buf );
va_end( args );
return xlen;
}
@@ -830,7 +830,6 @@
String String::getArg() const
{
// _argptr and _argnext are undefined until startArgs is called.
- //const_cast<String *>(this)->_argptr = _argnext;
((String *)this)->_argptr = _argnext;
// Naughty - you forgot to call String::startArgs() first.
@@ -840,10 +839,22 @@
abort();
while( *_argptr && isspace( *_argptr ) )
- //const_cast<String *>(this)->_argptr++;
((String *)this)->_argptr++;
- //const_cast<String *>(this)->_argnext = _argptr;
+ if( *_argptr == '"' )
+ {
+ ((String *)this)->_argptr++;
+ ((String *)this)->_argnext = _argptr;
+ while( *_argnext && *_argnext != '"' )
+ ((String *)this)->_argnext++;
+ if( *_argnext )
+ {
+ *(((String *)this)->_argnext) = '\0';
+ ((String *)this)->_argnext++;
+ }
+ return String( _argptr );
+ }
+
((String *)this)->_argnext = _argptr;
// Now we are either at beginning of arg or NULL Char
@@ -851,14 +862,11 @@
return String( _argptr );
while( *_argnext && !isspace( *_argnext ) )
- //const_cast<String *>(this)->_argnext++;
((String *)this)->_argnext++;
if( *_argnext )
{
- //*(const_cast<String *>(this)->_argnext) = '\0';
*(((String *)this)->_argnext) = '\0';
- //const_cast<String *>(this)->_argnext++;
((String *)this)->_argnext++;
}
@@ -868,7 +876,7 @@
// check if string is legal and safe filename
// allowed chars are letters, digits and dot
-bool String::legalFilename() const
+bool String::isLegalFilename()
{
int i;
int length = len();
@@ -880,3 +888,4 @@
}
return true;
}
+