All BASIC

BASIC Developer & Support Resources => Scripting Languages => Topic started by: AIR on October 09, 2018, 06:59:08 AM

Title: Proposed SB change to config file path in Windows...
Post by: AIR on October 09, 2018, 06:59:08 AM
In looking into how to make SB completely portable, I'd like to propose the following change for Windows:

Instead of having the path to the config file stored in the Registry, or using a hard-coded path to the Windows folder, use the SCRIBACONF environment variable instead like the non-Windows version can.

In conftree.c, change the cft_GetConfigFileName function to the following:

Code: C
  1. int cft_GetConfigFileName(ptConfigTree pCT,
  2.                           char **ppszConfigFile,
  3.                           char *env,/* environment variable or registry key on win32 */
  4.                           char *DefaultFileName
  5.   ){
  6. /*noverbatim
  7. This function is T<static> and can not be called from outside of this module.
  8. CUT*/
  9.  
  10. #if _WIN32
  11.   char *s = getenv("SCRIBACONF");
  12. #else
  13.   char *s = getenv(env);
  14. #endif
  15.   if( s == NULL ){
  16.     *ppszConfigFile = ALLOC(strlen(DefaultFileName)+1);
  17.     if( *ppszConfigFile == NULL )return CFT_ERROR_MEMORY;
  18.     strcpy(*ppszConfigFile,DefaultFileName);
  19.     return 0;
  20.     }
  21.   *ppszConfigFile = ALLOC(strlen(s)+1);
  22.   if( *ppszConfigFile == NULL )return CFT_ERROR_MEMORY;
  23.   strcpy(*ppszConfigFile,s);
  24.   return 0;
  25. }
  26.  

Then all you need to do is set SCRIBACONF to the path to the config file and you're set.

AIR.
Title: Re: Proposed SB change to config file path in Windows...
Post by: John on October 09, 2018, 09:36:07 AM
Great idea!

+1