How big are you expecting these files to be? Instead of a temporary file just read the whole thing into RAM. If someone has a 2 gig script they should expect it to take a while.
C Programming Language
Welcome to the C community!
C is quirky, flawed, and an enormous success.
... When I read commentary about suggestions for where C should go, I often think back and give thanks that it wasn't developed under the advice of a worldwide crowd.
... The only way to learn a new programming language is by writing programs in it.
- irc: #c
π https://en.cppreference.com/w/c
I want to make as much space available as I can. I once wrote a small language called tiny. It had a fixed array of statements, that was a hard limit on the size of any program it could run. Because I can read the source and find out how big it is, I can attempt to malloc the needed space to store and run it. That way the program can be as big as memory allows.
As far as I recall and for Linux, the shebang is interpreted by the kernel to execute the text file as the input of a given program. Are you talking about adding a shebang to a C source file? If so, this would not work, because the hash could be interpreted as a preprocessor instruction.
Take into consideration that, in bash, you can use ${0} to get the filename of the current script. If you want the count of lines in your script wc -l ${0}
ought do the trick.
If you're using C, you could rely on the FILE define for your imolementation but the rest implies reading the source code and then acting on it.
As far as I recall and for Linux, the shebang is interpreted by the kernel to execute the text file as the input of a given program. Are you talking about adding a shebang to a C source file? If so, this would not work, because the hash could be interpreted as a preprocessor instruction.
No, the #! is the input to an Interpreter that is written in C. The rest of the file is in "calculator language" (sort of like an HP41C but labels are merged with steps and variables take up one step each but are named so you can have as many as you like). The
Take into consideration that, in bash, you can use ${0} to get the filename of the current script. If you want the count of lines in your script |wc -l ${0} ought do the trick.
I am not getting this, but anyway, I am writing an interpreter in C to run a program written in "Calculator Language"
|If youβre using C, you could rely on the FILE define for your imolementation but the rest implies reading the source code and then acting |on it.
What are you saying? I think that word was supposed to be "implementation", but what is a "FILE define"? The interpreter won't have the name of the file, will it?
One thing I might do is provide the name of the calculator language file in the shebang so the interpreter sees it..
This is the start of a file in calculator language named fizbuz.lnc :
#! /bin/lincalc fizbuz.lnc
The interpreter would see this first line on its standard input and stop reading standard input, and open the file "fizbuz.lnc" but this is non-standard for a shbang line. Also, this won't work if the shebang is stripped off the input by the shell and not provided to the called program.
More Background might be helpful - I am writing an interpreter that will read and execute "keystroke programmable RPN calculator program"
The #! I am asking about will be in the text of the calculator program, it will cause the interpreter to be loaded.
My understanding is that after that the rest of the file of calculator program steps will be presented to the C program as standard input. But if that is the case, then I only see this input once and have no way to elicit a second pass through the code.