TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

[Query:] #CONFIGs best at the beginning of saved scripts?

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
Slysven



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Sun Dec 16, 2012 1:04 pm    Post subject: [Query:] #CONFIGs best at the beginning of saved scripts? Reply with quote

Given that a user may use UTF-8 characters in their scripts is there a possibility that as the #CONFIG {CHARSET} is only read in after any #ALIASes or #ACTIONS have been read in there could be issues on parsing the latter incorrectly before the #CONFIG {CHARSET} is seen?

I quickly cobbled together this revised function for the file.c source file that puts the #CONFIG entries as the first thing in the file when a #WRITE is done - but other than the cosmetic change to have these at the easy to find place at the start of the file, does it have any merit.

In passing I note the complications that capturing the first character of the file and using that as the "TinTin++ Command character" - as can be changed by #CONFIG {TINTIN CHAR} otherwise - introduces into the code-base; I suppose the modification here and renaming the command to say #CONFIG {_TINTIN CHAR} to ensure it is the FIRST one would almost do away with that twisty bit of coding... Cool
Code:
DO_COMMAND(do_write)
{
   FILE *file;
   char filename[BUFFER_SIZE];
   struct listroot *root;
   int i, j, cnt = 0;

   get_arg_in_braces(ses, arg, filename, TRUE);

   if (*filename == 0 || (file = fopen(filename, "w")) == NULL)
   {
      tintin_printf(ses, "#ERROR: #WRITE: COULDN'T OPEN {%s} TO WRITE.", filename);
      return ses;
   }

   root = ses->list[LIST_CONFIG];
   for (j = 0 ; j < root->used ; j++)
   {
      if (*root->list[j]->group == 0)
      {
         write_node(ses, LIST_CONFIG, root->list[j], file);

         cnt++;
      }
   }

   for (i = 0 ; i < LIST_MAX ; i++)
   {
      root = ses->list[i];

      if (!HAS_BIT(root->flags, LIST_FLAG_WRITE) || i==LIST_CONFIG)
      {
         continue;
      }

      for (j = 0 ; j < root->used ; j++)
      {
         if (*root->list[j]->group == 0)
         {
            write_node(ses, i, root->list[j], file);

            cnt++;
         }
      }
   }

   fclose(file);

   show_message(ses, LIST_MESSAGE, "#WRITE: %d COMMANDS WRITTEN TO {%s}.", cnt, filename);

   return ses;
}
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Sun Dec 16, 2012 3:56 pm    Post subject: Reply with quote

The UTF-8 setting primarily impacts word wrapping, so it's alright if it's not set right away.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> General Discussion All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group