Hi guys-
I have a bit of a problem. Basically, I'm trying to loop through the code to our application, and find all instances of the function gettext(). I then want to extract the first parameter of this function and throw it in a file for later processing. All is well, I can do this, the problem occurs when the gettext() function spans more than one line (due to coding style and readability issues this occurs often). Another dilemma being, the gettext() function can contain nested functions (i.e. gettext(dumb_function(whatever)). The way I tried to handle this was, grab everything in between the gettext parenthesis, so in this case "dumb_function(whatever)" and return that. The function will not always have only one parameter. Sometimes there are two or three, but the first one is the only one I'm interested in. Anyway, while looping through the file, I use a goto statement and index jumping to do this. The problem with this is it's sloppy and prone to errors, impossible to read, and just plain ugly. I'd really like to use a recursive function to step through the file, pulling out the gettext() functions completely (including multi-lined functions if necessary). Once this is done, I can parse each one individually to pull out the first parameter. But I'm having trouble working through the logic. I've never really used recursive functions, so any input on this problem, or design examples or anything would be greatly appreciated. I hope someone can help me. Thanks
~Eric
I have a bit of a problem. Basically, I'm trying to loop through the code to our application, and find all instances of the function gettext(). I then want to extract the first parameter of this function and throw it in a file for later processing. All is well, I can do this, the problem occurs when the gettext() function spans more than one line (due to coding style and readability issues this occurs often). Another dilemma being, the gettext() function can contain nested functions (i.e. gettext(dumb_function(whatever)). The way I tried to handle this was, grab everything in between the gettext parenthesis, so in this case "dumb_function(whatever)" and return that. The function will not always have only one parameter. Sometimes there are two or three, but the first one is the only one I'm interested in. Anyway, while looping through the file, I use a goto statement and index jumping to do this. The problem with this is it's sloppy and prone to errors, impossible to read, and just plain ugly. I'd really like to use a recursive function to step through the file, pulling out the gettext() functions completely (including multi-lined functions if necessary). Once this is done, I can parse each one individually to pull out the first parameter. But I'm having trouble working through the logic. I've never really used recursive functions, so any input on this problem, or design examples or anything would be greatly appreciated. I hope someone can help me. Thanks
~Eric