Browse Source

Sol Part 67: Exposing Its Internals Since 1979!

master
Graham Northup 4 years ago
parent
commit
193bdeec04
Signed by: grissess GPG Key ID: 5D000E6F539376FB
  1. 8
      sol.h
  2. 11
      sol_help.txt
  3. 7
      solrun.c
  4. 6
      state.c
  5. 0
      tests/_fails.sol

8
sol.h

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

11
sol_help.txt

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

7
solrun.c

@ -70,6 +70,13 @@ int main(int argc, char **argv) {
#else
printf("Sorry, no help in this version (-DNO_HELP)!\n");
#endif
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");
for(unsigned i = 0; i < sizeof(sol_AbsInitPaths) / sizeof(sol_AbsInitPaths[0]); i++)
if(sol_AbsInitPaths[i])
printf("- %s\n", sol_AbsInitPaths[i]);
for(unsigned i = 0; i < sizeof(sol_HomeInitPaths) / sizeof(sol_HomeInitPaths[0]); i++)
if(sol_HomeInitPaths[i])
printf("- $HOME%s\n", sol_HomeInitPaths[i]);
return 0;
break;
}

6
state.c

@ -8,12 +8,12 @@
#define TMP_PATH_SZ 256
char *sol_AbsInitPaths[] = {
char *sol_AbsInitPaths[SOL_PATH_ARRAY_SIZE] = {
"/etc/sol/init.sol",
"/opt/sol/init.sol",
};
char *sol_HomeInitPaths[] = {
char *sol_HomeInitPaths[SOL_PATH_ARRAY_SIZE] = {
"/.config/sol/init.sol",
};
@ -512,6 +512,7 @@ int sol_state_init(sol_state_t *state) {
if(!(state->features & SOL_FT_NO_USR_INIT)) {
for(i = 0; i < LENGTH(sol_AbsInitPaths); i++) {
if(!sol_AbsInitPaths[i]) continue;
fp = fopen(sol_AbsInitPaths[i], "r");
if(state->features & SOL_FT_DEBUG) {
printf("state init: loading abs %s: ", sol_AbsInitPaths[i]);
@ -542,6 +543,7 @@ int sol_state_init(sol_state_t *state) {
strncpy(sol_TempPath, suffix, TMP_PATH_SZ);
suffix = sol_TempPath + strlen(sol_TempPath);
for(i = 0; i < LENGTH(sol_HomeInitPaths); i++) {
if(!sol_HomeInitPaths[i]) continue;
strncpy(suffix, sol_HomeInitPaths[i], TMP_PATH_SZ - (suffix - sol_TempPath));
if(state->features & SOL_FT_DEBUG) {
printf("state init: loading rel %s: ", sol_TempPath);

0
tests/fails.sol.disabled → tests/_fails.sol

Loading…
Cancel
Save