Browse Source

Sol Part 67: Exposing Its Internals Since 1979!

Graham Northup 3 years ago
parent
commit
193bdeec04
Signed by: Graham Northup <grissess@nexusg.org> GPG Key ID: 5D000E6F539376FB
5 changed files with 20 additions and 12 deletions
  1. 6
    2
      sol.h
  2. 3
    8
      sol_help.txt
  3. 7
    0
      solrun.c
  4. 4
    2
      state.c
  5. 0
    0
      tests/_fails.sol

+ 6
- 2
sol.h View File

@@ -10,7 +10,7 @@
10 10
 #include "dsl/dsl.h"
11 11
 
12 12
 /** The version of the project, as made available through `debug.version`. */
13
-#define SOL_VERSION "0.5a2"
13
+#define SOL_VERSION "0.5a3"
14 14
 /** The hexadecimal version of the project, formatted 0xAAIIRPP where:
15 15
  * 
16 16
  * - AA is the two-digit major version
@@ -23,7 +23,7 @@
23 23
  * version shall be available in all versions numerically greater than it
24 24
  * (unless they are later deprecated or removed).
25 25
  */
26
-#define SOL_HEXVER 0x0005A02
26
+#define SOL_HEXVER 0x0005A03
27 27
 
28 28
 #ifndef SOL_BUILD_HOST
29 29
 #define SOL_BUILD_HOST "(unknown host)"
@@ -471,6 +471,10 @@ typedef struct sol_tag_state_t {
471 471
 
472 472
 // state.c
473 473
 
474
+#define SOL_PATH_ARRAY_SIZE 8
475
+extern char *sol_AbsInitPaths[SOL_PATH_ARRAY_SIZE];
476
+extern char *sol_HomeInitPaths[SOL_PATH_ARRAY_SIZE];
477
+
474 478
 /** Initializes the state.
475 479
  *
476 480
  * This should be called once (and only once!) for every state; it does the important

+ 3
- 8
sol_help.txt View File

@@ -1,4 +1,4 @@
1
-./sol [<options> [<arg> [<arg> ...]]]
1
+sol [<options> [<arg> [<arg> ...]]]
2 2
 
3 3
 Sol Executive - compiles and/or runs a Sol program.
4 4
 
@@ -12,13 +12,8 @@ Sol currently recognizes the following options:
12 12
 -d: Sets yydebug=1, which enables debug tracing of the parser/lexer.
13 13
 -D: Sets debugging within the language runtime itself.
14 14
 -t: Prints the Sol syntax tree after program loading.
15
--i: Ignore any initialization files. By default, Sol executes any of these
16
- files, if they exist and are readable, in the initial environment in this
17
- order:
18
- - /etc/sol/init.sol
19
- - /opt/sol/init.sol
20
- - $HOME/.config/sol/init.sol
21
- These may be overridden during compilation.
15
+-i: Ignore any initialization files. See the information below for the
16
+ initialization files this version of Sol is compiled to use.
22 17
 -r <file>: Read the program from the file, instead of the default (stdin).
23 18
  Programs run this way have access to stdin via `io.stdin` in the global
24 19
  environment.

+ 7
- 0
solrun.c View File

@@ -70,6 +70,13 @@ int main(int argc, char **argv) {
70 70
 #else
71 71
 					printf("Sorry, no help in this version (-DNO_HELP)!\n");
72 72
 #endif
73
+					printf("\nThis Sol is configured to use the following initialization files (it is never an\nerror if these files cannot be read, but errors propagate normally):\n");
74
+					for(unsigned i = 0; i < sizeof(sol_AbsInitPaths) / sizeof(sol_AbsInitPaths[0]); i++)
75
+						if(sol_AbsInitPaths[i])
76
+							printf("- %s\n", sol_AbsInitPaths[i]);
77
+					for(unsigned i = 0; i < sizeof(sol_HomeInitPaths) / sizeof(sol_HomeInitPaths[0]); i++)
78
+						if(sol_HomeInitPaths[i])
79
+							printf("- $HOME%s\n", sol_HomeInitPaths[i]);
73 80
 					return 0;
74 81
 					break;
75 82
 			}

+ 4
- 2
state.c View File

@@ -8,12 +8,12 @@
8 8
 
9 9
 #define TMP_PATH_SZ 256
10 10
 
11
-char *sol_AbsInitPaths[] = {
11
+char *sol_AbsInitPaths[SOL_PATH_ARRAY_SIZE] = {
12 12
 	"/etc/sol/init.sol",
13 13
 	"/opt/sol/init.sol",
14 14
 };
15 15
 
16
-char *sol_HomeInitPaths[] = {
16
+char *sol_HomeInitPaths[SOL_PATH_ARRAY_SIZE] = {
17 17
 	"/.config/sol/init.sol",
18 18
 };
19 19
 
@@ -512,6 +512,7 @@ int sol_state_init(sol_state_t *state) {
512 512
 	
513 513
 	if(!(state->features & SOL_FT_NO_USR_INIT)) {
514 514
 		for(i = 0; i < LENGTH(sol_AbsInitPaths); i++) {
515
+			if(!sol_AbsInitPaths[i]) continue;
515 516
 			fp = fopen(sol_AbsInitPaths[i], "r");
516 517
 			if(state->features & SOL_FT_DEBUG) {
517 518
 				printf("state init: loading abs %s: ", sol_AbsInitPaths[i]);
@@ -542,6 +543,7 @@ int sol_state_init(sol_state_t *state) {
542 543
 			strncpy(sol_TempPath, suffix, TMP_PATH_SZ);
543 544
 			suffix = sol_TempPath + strlen(sol_TempPath);
544 545
 			for(i = 0; i < LENGTH(sol_HomeInitPaths); i++) {
546
+				if(!sol_HomeInitPaths[i]) continue;
545 547
 				strncpy(suffix, sol_HomeInitPaths[i], TMP_PATH_SZ - (suffix - sol_TempPath));
546 548
 				if(state->features & SOL_FT_DEBUG) {
547 549
 					printf("state init: loading rel %s: ", sol_TempPath);

tests/fails.sol.disabled → tests/_fails.sol View File


Loading…
Cancel
Save