• Linux
  • September 2018
    M T W T F S S
    « Aug   Oct »
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
  • Meta

  • Follow me on Twitter

  • Advertisements

FnLoC v2.2

I’m not certain what version the program really is. I’d made several modifications to the original program some 20 years ago and apparently some of the early source code is missing. I know there was once a version 1.3 that listed the functions in the same order as they appeared in the target source code.

The last version was dubbed version 2.1.2 and since the code I finished today is so much different, I decided to make it 2.2. Maybe there’s enough difference to make it a major revision and call it 3.0. I don’t know.

I did some research and refreshed my knowledge of linked lists. Once I felt reasonably comfortable with them, I set out to implement a singly linked list to replace the stack. The primary motivation was to list functions in the output in the same order as they appeared in the target source code file. Using a stack (first in, last out), the functions were listed in reverse order.

A side benefit was that I needed fewer functions to implement the linked list since all I needed to do was to add data to the end of the list , display the output, and then free the memory when I was done.

In process of implementing the list, I simplified my data structures for holding the function data. Instead of a struct containing the data in main(), I used a couple of simple variables to hold the data until it was put into the list. Much easier to manage.

Most of the code for parsing a line of code and determining states was left intact since it was already working well. I did tweak the code for determining the possible states a function could be in because, for some reason, it would sometimes display main() with name of the next function encountered. The count would be right but the name would be wrong. Fixing the problem was a matter of changing one if condition. I’d been suspicious of that line for a while.

Finally, I split up the function that displayed the data in to three different functions, based on the the information they displayed. One prints a header to identify the program and display some introductory information. Next came the function that displayed the function data, if any. Finally, there was the function that printed a summary of the counts.

After testing it, I updated the documentation and the installation package (.tar.gz). The next step is to compile it in Windows and update the Windows package. I should be able to translate the Bash script that redirects the output to a text file into a Windows batch file without too much trouble.

Advertisements

2 Responses

  1. I compiled FnLoC on Windows 7 and updated the package. I also made some changes to the loc2file script I now displays the results to the screen as it writes it to a file. I made a few other small tweaks as well.

    I made an effort to write a Windows version of loc2file but the script was very cumbersome and I just couldn’t find a way to replicated much of the functionality i needed. Perhaps it could be done with VBscript or PowerShell but I don’t feel inclined to learn those. If someone else wants to tackle that problem, go for it.

    I briefly thought about adding options to the program to print the output to a file but decided against it. It would have duplicated all of the display code and added a layer of complexity to the code. At least for now, redirection on the command line will suffice.

  2. Created a .deb package for FnLoC and put it in my Dropbox.

    Link: https://www.dropbox.com/s/z9jk17pcln3grsj/fnloc.deb?dl=0

    Put source code and sample output into a tarball

    Link: https://www.dropbox.com/s/y95dl281m6d00v5/fnloc.tar.gz?dl=0

Comments are closed.

%d bloggers like this: