diff --git a/CMakeLists.txt b/CMakeLists.txt index 4359fe4..68638cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ FIND_PACKAGE( ZLIB REQUIRED) message( STATUS "FOUNDATION_LIBRARY is ${FOUNDATION_LIBRARY}") message( STATUS "ZLIB_LIBRARIES is ${ZLIB_LIBRARIES}") -add_definitions( -DPROJECT_VERSION=1857) +add_definitions( -DPROJECT_VERSION=1858) add_library( MulleScion STATIC diff --git a/MulleScion.podspec b/MulleScion.podspec index 7c7764f..d9c5286 100644 --- a/MulleScion.podspec +++ b/MulleScion.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MulleScion" - s.version = '1857' + s.version = '1858' s.summary = "MulleScion a modern Template library for ObjC." s.description = <<-DESC MulleScion is indeed a modern Template library for ObjC. diff --git a/MulleScion.xcodeproj/project.pbxproj b/MulleScion.xcodeproj/project.pbxproj index 195cab3..2d8a632 100644 --- a/MulleScion.xcodeproj/project.pbxproj +++ b/MulleScion.xcodeproj/project.pbxproj @@ -1963,7 +1963,7 @@ baseConfigurationReference = 413C51611CC284CA00F62468 /* Debug.xcconfig */; buildSettings = { CLANG_WARN_INT_CONVERSION = YES; - CURRENT_PROJECT_VERSION = 1857; + CURRENT_PROJECT_VERSION = 1858; DYLIB_COMPATIBILITY_VERSION = 1848.0; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; GCC_OPTIMIZATION_LEVEL = 0; @@ -1995,7 +1995,7 @@ baseConfigurationReference = 413C516B1CC284CA00F62468 /* Release.xcconfig */; buildSettings = { CLANG_WARN_INT_CONVERSION = YES; - CURRENT_PROJECT_VERSION = 1857; + CURRENT_PROJECT_VERSION = 1858; DYLIB_COMPATIBILITY_VERSION = 1848.0; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -2064,7 +2064,7 @@ baseConfigurationReference = 413C516B1CC284CA00F62468 /* Release.xcconfig */; buildSettings = { CLANG_WARN_INT_CONVERSION = YES; - CURRENT_PROJECT_VERSION = 1857; + CURRENT_PROJECT_VERSION = 1858; DYLIB_COMPATIBILITY_VERSION = 1848.0; DYLIB_CURRENT_VERSION = "$(CURRENT_PROJECT_VERSION)"; GCC_PREPROCESSOR_DEFINITIONS = ( diff --git a/MulleScion.xcodeproj/xcshareddata/xcschemes/mulle-scion.xcscheme b/MulleScion.xcodeproj/xcshareddata/xcschemes/mulle-scion.xcscheme index afa5c89..042536c 100644 --- a/MulleScion.xcodeproj/xcshareddata/xcschemes/mulle-scion.xcscheme +++ b/MulleScion.xcodeproj/xcshareddata/xcschemes/mulle-scion.xcscheme @@ -47,7 +47,7 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" launchStyle = "0" useCustomWorkingDirectory = "YES" - customWorkingDirectory = "/Volumes/Source/srcM/MulleScion/tests" + customWorkingDirectory = "/Volumes/Source/srcO/MulleObjC-master/MulleObjCFoundation" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" @@ -64,7 +64,7 @@ diff --git a/RELEASENOTES.md b/RELEASENOTES.md index c27938e..492abcc 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,3 +1,12 @@ +## 1858 + +There is an option that allows specifying includes via the environment like +so: +`MULLESCION_ALLOW_GETENV_INCLUDES="YES" MY_INCLUDE="foo.scion" mulle-scion bar.scion none` +and then in `bar.scion` use `{% includes MY_INCLUDE %}`. This looks obscure, +but I needed it to wrap code around existing templates. +* MULLESCION_.. environment variables now are of the YES/NO variety. + ## 1857 * fix missing menu due to change of root dox diff --git a/src/MulleScionParser+Parsing.m b/src/MulleScionParser+Parsing.m index fbbc923..b8b4d46 100644 --- a/src/MulleScionParser+Parsing.m +++ b/src/MulleScionParser+Parsing.m @@ -134,12 +134,13 @@ - (void) parserError:(parser_error_info *) info enum { - MULLESCION_VERBATIM_INCLUDE_HASHBANG = 0x01, + MULLESCION_ALLOW_GETENV_INCLUDES = 0x01, MULLESCION_NO_HASHBANG = 0x02, - MULLESCION_DUMP_MACROS = 0x04, + MULLESCION_VERBATIM_INCLUDE_HASHBANG = 0x04, MULLESCION_DUMP_COMMANDS = 0x08, MULLESCION_DUMP_EXPRESSIONS = 0x10, - MULLESCION_DUMP_FILE_INCLUDES = 0x20 + MULLESCION_DUMP_FILE_INCLUDES = 0x20, + MULLESCION_DUMP_MACROS = 0x40 }; static void parser_skip_after_newline( parser *p); @@ -158,6 +159,33 @@ static void parser_skip_initial_hashbang_line_if_present( parser *p) } +static int getenv_yes_no_default( char *name, int default_value) +{ + char *s; + + s = getenv( name); + if( ! s) + return( default_value); + + switch( *s) + { + case 'f' : + case 'F' : + case 'n' : + case 'N' : + case '0' : return( 0); + } + + return( 1); +} + + +static inline int getenv_yes_no( char *name) +{ + return( getenv_yes_no_default( name, 0)); +} + + static void parser_init( parser *p, unsigned char *buf, size_t len) { memset( p, 0, sizeof( parser)); @@ -168,12 +196,13 @@ static void parser_init( parser *p, unsigned char *buf, size_t len) p->lineNumber = 1; } - p->environment |= getenv( "MULLESCION_DUMP_MACROS") ? MULLESCION_DUMP_MACROS : 0; - p->environment |= getenv( "MULLESCION_VERBATIM_INCLUDE_HASHBANG") ? MULLESCION_VERBATIM_INCLUDE_HASHBANG : 0; - p->environment |= getenv( "MULLESCION_NO_HASHBANG") ? MULLESCION_NO_HASHBANG : 0; - p->environment |= getenv( "MULLESCION_DUMP_COMMANDS") ? MULLESCION_DUMP_COMMANDS : 0; - p->environment |= getenv( "MULLESCION_DUMP_EXPRESSIONS") ? MULLESCION_DUMP_EXPRESSIONS : 0; - p->environment |= getenv( "MULLESCION_DUMP_FILE_INCLUDES") ? MULLESCION_DUMP_FILE_INCLUDES : 0; + p->environment |= getenv_yes_no( "MULLESCION_ALLOW_GETENV_INCLUDES") ? MULLESCION_ALLOW_GETENV_INCLUDES : 0; + p->environment |= getenv_yes_no( "MULLESCION_NO_HASHBANG") ? MULLESCION_NO_HASHBANG : 0; + p->environment |= getenv_yes_no( "MULLESCION_VERBATIM_INCLUDE_HASHBANG") ? MULLESCION_VERBATIM_INCLUDE_HASHBANG : 0; + p->environment |= getenv_yes_no( "MULLESCION_DUMP_COMMANDS") ? MULLESCION_DUMP_COMMANDS : 0; + p->environment |= getenv_yes_no( "MULLESCION_DUMP_EXPRESSIONS") ? MULLESCION_DUMP_EXPRESSIONS : 0; + p->environment |= getenv_yes_no( "MULLESCION_DUMP_FILE_INCLUDES") ? MULLESCION_DUMP_FILE_INCLUDES : 0; + p->environment |= getenv_yes_no( "MULLESCION_DUMP_MACROS") ? MULLESCION_DUMP_MACROS : 0; } @@ -2224,7 +2253,8 @@ static void parser_add_dependency( parser *p, NSString *fileName, NSString *inc NSString *converter; SEL sel; NSString *s; - + char *env; + if( p->inMacro) parser_error( p, "no including or extending in macro"); @@ -2245,19 +2275,30 @@ static void parser_add_dependency( parser *p, NSString *fileName, NSString *inc converter = nil; goto retry; } - + + if( p->environment & MULLESCION_ALLOW_GETENV_INCLUDES) + { + env = getenv( [converter cString]); + if( env) + { + fileName = [NSString stringWithCString:env]; + goto env_string; + } + } + // // markdown -> markdownedData or some other variety // (rarely useful) sel = NSSelectorFromString( converter); if( ! [NSData instancesRespondToSelector:sel]) - parser_error( p, "converter method \"%s\" not found on NSData", [converter cString]); + parser_error( p, "unknown converter method \"%s\" (hint: use quoted strings for filenames)", [converter cString]); } fileName = parser_do_string( p); if( ! [fileName length]) parser_error( p, "a filename was expected as a quoted string"); +env_string: if( p->environment & MULLESCION_DUMP_FILE_INCLUDES) fprintf( stderr, "-> opening \"%s\"\n", [fileName UTF8String]); diff --git a/src/main.m b/src/main.m index 1156eaa..8830202 100644 --- a/src/main.m +++ b/src/main.m @@ -42,12 +42,14 @@ #import "NSFileHandle+MulleOutputFileHandle.h" +// all C strings #ifndef DEBUG -# define DOCUMENT_ROOT "/usr/local/share/mulle-scion/dox" // C string! +# define DOCUMENT_ROOT "/usr/local/share/mulle-scion/dox" #else # define DOCUMENT_ROOT "/Volumes/Source/srcM/MulleScion/dox" #endif - +#define SERVER_HOST "127.0.0.1" +#define SERVER_PORT "18048" static NSString *processName( void); @@ -460,7 +462,7 @@ static int _archive_main( int argc, char *argv[], BOOL keyed) static char *default_options[] = { "document_root", DOCUMENT_ROOT, - "listening_ports", "127.0.0.1:18048", + "listening_ports", SERVER_HOST ":" SERVER_PORT, "num_threads", "1", "index_files", "index.scion,index.html,index.htm,index.cgi,index.shtml,index.php,index.lp", NULL @@ -503,6 +505,9 @@ static int main_www( int argc, char *argv[]) if( ! plist) plist = [NSDictionary dictionary]; +#if __APPLE__ + system( "(sleep 1 ; open http://" SERVER_HOST ":" SERVER_PORT ") &"); +#endif mulle_mongoose_main( plist, default_options); return( 0); }