Servostar / gemstone

programming language compiler
GNU General Public License v2.0
3 stars 0 forks source link

6 add mechanism to read and globally save options #78

Closed SirTalksalot75 closed 1 month ago

SirTalksalot75 commented 1 month ago

added mechanism to save and read options globally

SirTalksalot75 commented 1 month ago

Currently on hold.

Servostar commented 1 month ago

Implementation proposal

(Based on a spontaneous idea)

May you please consider the following: Instead of copying the arguments to a static buffer we can keep a copy of the argc value and argv pointer globally. Since both are valid the entire duration of the app, we can search through them directly (instead of the static buffer).

// store argc and arg from main globally
int argc;
char** argv;

size_t check_option(const char* name) {
    // directly search through argv 
    for (int i = 0; i < argc; i++) {
        if (strcmp(name, argv[i] + 2) == 0) {
            return 1;
        }
    }
    return 0;
}
Servostar commented 1 month ago

Development switched to @Servostar