Printing in Windows Service - Library Cleanup
I found a library and it does everything I want!
So I mentioned that I found a good guide library in the last part to walk me through interacting with Windows in D DWinProgramming. I cloned the project and started compiling the libs I will need. Unfortunately I was treated to a slew of error messages!
Arduous Journey
I started going through the files line by agonizing line (RBAR!) and started thinking maybe this was a bad idea since it appeared that it would take me the rest of the day (if not longer) to finish. Luckily, I noticed that most of the compile errors were due to differences between D and C when defining arrays (see code below). C Array: int variableName[size]; D Array: int[size] variableName;
Regex to the rescue!
I decided to build a regex to save some time, but of course I have to mention the normal joke about regular expressions… You start out by solving a single problem with a regular expression, and you now have 2 problems!
At any rate, I am using Notepad++ (since I am on Windows, and I cannot speak highly enough about that wonderful editor) and it has regular expressions built in.
Find: (\S) ([^\s[]]+)[([^]]+)]
Replace: $1[$3] $2
There is probably a more efficient expression for the gurus among you but I am merely a learner (Star Wars joke ommitted for obvious reasons). I eventually reallized that I was missing one detail… I could not be gauruntee that there was only 1 space between the type and variable name, so a second attempt…
Find: (\S)([\t ]+)([^\s[]]+)[([^]]+)]
Replace: $1[$4]$2$3
This led me to successfully cleanup the array issues, which left me with this:
If it compiles then everything must be good! Right?
I clearly haven’t fixed everything, but I am working torward the solution. I am also thinking about only fixing the interfaces that I need to build my project (such gdi and winspool), but I also am viewing this an opportunity to contribute to the open source community so onward I trod.
I was able to finish the patches for the Windows API build. There are a few deprecation warnings left, but the lib is now able to be built! Now I am going to see about submitting my changes back to the Github project. My issue here is that I did the work on my company laptop and have to validate that there is no issue with uploading code to an open source project.