Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
AFKMud 2.2.2
Mar 3, 2019 5:35 pm
By Samson
Development
Nov 28, 2018 12:10 pm
By Keirath
First Immortal
Oct 12, 2018 2:02 pm
By GatewaySysop
Bug in do_climb( )
Jun 5, 2018 7:31 pm
By joeyfogas
question on overland code
May 31, 2018 12:03 pm
By joeyfogas
SmaugFUSS 1.9.3
Author: Various
Submitted by: Samson
AFKMud 2.2.2
Author: AFKMud Team
Submitted by: Samson
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl

Members: 0
Guests: 12
Stats
Files
Topics
Posts
Members
Newest Member
483
3,743
19,401
655
RodrickMci
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds » Bugfix Lists » SWFOTE FUSS Bugfix List » [Bug] one_argument smashes ca...
Forum Rules | Mark all | Recent Posts

[Bug] one_argument smashes case on all things it processes
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Aug 19, 2006 4:30 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,647
JoinedJan 1, 2002

Bug: one_argument smashes case on all things it processes
Danger: Medium - Often leads to unintended changing of case in things that should not have it changed.
Found by: Samson
Fixed by: Samson

---

interp.c, one_argument + one_argument2

Replace the functions with these new one:
/*
 * Pick off one argument from a string and return the rest.
 * Understands quotes. No longer mangles case either. That used to be annoying.
 */
char *one_argument( char *argument, char *arg_first )
{
   char cEnd;
   int count;

   count = 0;

   while( isspace( *argument ) )
      argument++;

   cEnd = ' ';
   if( *argument == '\'' || *argument == '"' )
      cEnd = *argument++;

   while( *argument != '\0' || ++count >= 255 )
   {
      if( *argument == cEnd )
      {
         argument++;
         break;
      }
      *arg_first = ( *argument );
      arg_first++;
      argument++;
   }
   *arg_first = '\0';

   while( isspace( *argument ) )
      argument++;

   return argument;
}

/*
 * Pick off one argument from a string and return the rest.
 * Understands quotes.  Delimiters = { ' ', '-' }
 * No longer mangles case either. That used to be annoying.
 */
char *one_argument2( char *argument, char *arg_first )
{
   char cEnd;
   short count;

   count = 0;

   if( !argument || argument[0] == '\0' )
   {
      arg_first[0] = '\0';
      return argument;
   }

   while( isspace( *argument ) )
      argument++;

   cEnd = ' ';
   if( *argument == '\'' || *argument == '"' )
      cEnd = *argument++;

   while( *argument != '\0' || ++count >= 255 )
   {
      if( *argument == cEnd || *argument == '-' )
      {
         argument++;
         break;
      }
      *arg_first = ( *argument );
      arg_first++;
      argument++;
   }
   *arg_first = '\0';

   while( isspace( *argument ) )
      argument++;

   return argument;
}


Upon replacing these, arguments to commands will no longer have their case smashed to lowercase in all situations. There are some things where one might want to have aBcDeFgHiJ be a valid argument for something, but as long as one_argument is used to parse commands that would get smashed down to abcdefghij even if that wasn't the desired result. This won't affect commands where one_argument isn't necessary. The same will also now be true of anything which uses one_argument2 to parse arguments.
       
Pages:<< prev 1 next >>