**This is an old revision of the document!** ----
July 6: Fixed a bug which prevented using for and while statements split over multiple lines. The problem was that the cur_command variable stored the last line of an incomplete command. Fixed by concatenating incomplete lines before storing. AndyTim suggested that instead of a memory-intensive list, I just store the offset into the script for interesting lines. A problem with that is that it would act differently for scripts and interactive input. But, it will use a lot less memory. So, this is what I plan to do: * A global variable start_len will store the offset of the current command for both scripts and user input. * The looping commands would use this variable as a program counter, to store/retrieve. * For scripts: use the start_len variable to retrieve the next command. After the command is executed, increment the variable as appropriate (either add the length of the command or, if it has been modified, do not modify it). This would remove the need for a list if a script is executed. * For shell input: store each line as it is entered, into a dynamic string. The start_len variable is used similarly to the script method. I started work on these modifications. The script changes were simple, but there's some problem with the shell input. I'll continue work on it tomorrow. Today's commits: * [[http://git.etherboot.org/?p=people/lynusvaz/gpxe.git;a=commit;h=748d46ff2eedaa25c127bdc4a6d70f890c637a28|Bug fix for loops]] July 7: Yesterday's problem with the shell input turned out to be due to an asprintf() call with a NULL pointer. So I fixed that, with the help of DBG() statements. After that, I decided to implement incomplete statements, using this new method. The only changes made were: instead of a start_len variable, a cur_len variable is used by the script_exec() and shell() functions, to get the current line, which may not be complete. The start_len variable now holds the offset of the current complete line in the script/user input. As usual, a static char *complete_command in the system() function will hold the complete command found so far. The parse functions will set the value of incomplete if an incomplete line is found. If the line is complete, it is passed to execv() and complete_command is freed, else control is passed back to script_exec() or shell() to get the next line and concatenate it to complete_command. Also had a look at the memory allocations and frees. AndyTim had suggested making gPXE with the DEBUG=malloc option. However, this produced too much output. As I just wanted to check whether all the memory allocated was being freed, I printed out the value of the variable freemem (malloc.c) before and after the script_exec() and shell() functions. I found a glaring mistake in arith.c, where I had missed freeing a variable. So I fixed that by trying to do a git rebase. Today's commits are on the offset branch: * [[http://git.etherboot.org/?p=people/lynusvaz/gpxe.git;a=commit;h=59e72569d3875d34cd74fa914543fa36e96f744a|Using the offset for loops]] * [[http://git.etherboot.org/?p=people/lynusvaz/gpxe.git;a=commit;h=2fd7543a960c7d18ff5bf6fbe4f75cbfcce10bfb|Support for incomplete lines]]