[Ulitily] Simplifinf, a basic inf simplifier (v0.30b)

Discuss & post Update Pack addons here.
User avatar
Mrs Peel
The Dominatrix Recoded
Posts: 1344
Joined: Tue Jan 17, 2006 2:02 am
Location: Aotearoa
Contact:

Post by Mrs Peel » Sun Sep 23, 2007 11:20 am

Hehehe I see I'm not the only one who's been busy as a bee around here lately. It's hard to know when to stop sometimes as new ideas keep rolling in isn't it :D

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Sun Sep 23, 2007 2:10 pm

hehe, sure is. I've still got some big plans for this, although I dunno how many I'll be able to realise. I really ought to write a proper FileHandler class based on Win32 API calls, as well. (and add Unicode support) Hmm, I was wondering, are there any other things I could do to inf files to make them more readable? What do you all think?

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Sun Sep 23, 2007 6:33 pm

Talk about jumping in the deep end. Okay kids, don't expect to see Win32 API stuff anytime soon, as I'll have to research transacted IO and security descriptors and write some sort of lib so I can use it without losing it. (but what do you care, it's not like you'll notice a difference from the way Simplifinf currently works) Unicode support may come sooner, but first up is configuration support. That should be simple, but I've yet to figure out a good system for switches. I'm considering offering two options:

1.) switches in the form of +f1, +f2 to +fn and -f1, -f2 to -fn for respectively enabling and disabling the various filters.
2.) a bitmask switch in the form of -b[32-bit hexadecimal number] (for instance -b00000012 to enable filters 2 and 5) that does the same thing.

Thoughts?

TechnoHunter
Posts: 506
Joined: Sun Feb 26, 2006 4:13 am

Post by TechnoHunter » Sun Sep 23, 2007 6:49 pm

follow the standards :)

progname.exe /bleh /something /someotherthing

should be easier than re-inventing the wheel ;)

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Sun Sep 23, 2007 6:56 pm

I've seen the + and - syntax used before, as well as bitmasks (flags!) ;) The reason I'd use either is because I intend to allow one to store the default configuration in a .cfg file, so the switches will be relative to that (the bitmask one won't be though, for obvious reasons)

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Tue Sep 25, 2007 2:38 pm

I'm bored, so here's a sneak peak of code for a filter I'm working on:

Code: Select all

if((B = S->substr(0,S->find_last_not_of(" \t",A-1)+1)).size() > A) continue;
B = B.substr(B.find_first_not_of(" \t"));
Here, S is a line in an inf file and A is the first position of an unquoted assignment character on that line..
So my question to you: what is B to S? (and no, the answer isn't BS :P)

Edit: oh dear, two corrections needed. My apologies.
Last edited by Mitsuko Aninikkou on Tue Sep 25, 2007 4:39 pm, edited 2 times in total.

User avatar
n7Epsilon
Moderator
Posts: 624
Joined: Thu Feb 17, 2005 1:37 am
Location: Cairo, Egypt

Post by n7Epsilon » Tue Sep 25, 2007 3:14 pm

B is the substring of S that contains the INF key value...

However if I get this correctly... if A is the position of the first char in the value, wouldn't considering (A-1) to be the position of the "=" unreliable...

Again if I get this correctly, this code belongs in a loop that processes the INF line by line and adding it to a buffer allocated outside the loop and continues if it meets certain filters...

The first line seems to check for INF key values that contain many "=" (ie: Invalid) and the second checks for empty keys ?

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Tue Sep 25, 2007 3:32 pm

Well, as it happens string::npos, which is what the second argument of string::find_last_not_of() defaults to and makes it check from the end of the string, is equal to -1 by definition. So in the edge case that = is the first character on the line, it'll check the whole line. And since in this case the size of the substring will always be more than A == 0 (as it will always atleast contain =), the loop will go to the next iteration. If no characters are found other than spaces or tabs, the whole string will be used, but as this is also more than A it has the same result. What the first line does is get the largest substring of S that doesn't end in a tab character or a space, and assign it to B.

I see now that the second line is incorrect, so give me a moment to fix it.

Edit: fixed. I also removed the conditional, as it wasn't necessary (the first line returns if the substring is empty, and the substring obtained in the second line can't be empty since it would run into one of the characters found the first time). The second line gets the largest substring of B that doesn't start with a space or a tab and assigns it to B.

So in the end you're left with a string that has no whitespace before or after it, and which is the left-hand side of the assignment. This is assuming that the code isn't run unless the line contains an assignment symbol, but that's easy enough to ensure.

Of course, what I need that for is another question altogether..

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Tue Sep 25, 2007 5:44 pm

Strings sections are good - we all know this: they can save a lot of clutter and clarify things like GUIDs. However, unfortunately many manufacturers use them far too much, which can make the inf very hard to read, and a terrible pain to simplify.
For this reason, starting from the next version, which will also add configuration support through switches, Simplifinf shall contain a Strings section filter. This filter replaces every use of %[key]% strings with their corresponding value. The strings are then removed from the strings section. This filter tries to make sure strings that need them will still have quotes around them, while strings that don't have them removed to prevent syntax errors. It should also work independently of all other filters (although this is not recommended)

PS: yes, that's what the code was needed for.

User avatar
ENU_user
Posts: 1253
Joined: Wed Jan 25, 2006 1:42 pm

Post by ENU_user » Tue Sep 25, 2007 8:51 pm

their is a good lead from code65536 signiture/runtimes/ regarding Uniscribe

and their may be some helpful info in getting around those char code ,Unicode files after all ;)

http://msdn.microsoft.com/library/defau ... b_35k5.asp

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Wed Sep 26, 2007 3:59 pm

New version has been delayed by atleast a day. Mrs Peel asked me about a problem with one of her addons that she couldn't solve, and unfortunately it turned out to be a bitch to solve (long story short, it can't be done just using an inf file, so I had to add a cmd file) and had me busy all day. Have an exam coming up now, so I may not be able to update this for a few days.

User avatar
Kelsenellenelvian
Moderator
Posts: 4383
Joined: Tue Nov 30, 2004 8:32 pm
Location: Pocatello, ID
Contact:

Post by Kelsenellenelvian » Thu Feb 14, 2008 10:03 pm

Would you kindly upload this to a new server please.

Also do you use a messenger? I need to ask you a couple of things.

User avatar
ENU_user
Posts: 1253
Joined: Wed Jan 25, 2006 1:42 pm

Post by ENU_user » Fri Feb 15, 2008 9:16 am

there is something %NT% doesn't like about it, i may be the only one having this error signature pop each time it is run.

Code: Select all

 AppName: simplifinf.exe	 AppVer: 0.0.0.0	 ModName: simplifinf.exe
ModVer: 0.0.0.0	 Offset: 00005e99
blah blah blah

and there are still some problems using it through console ...naming related mainly

User avatar
ENU_user
Posts: 1253
Joined: Wed Jan 25, 2006 1:42 pm

Post by ENU_user » Fri Mar 07, 2008 12:19 am

can this be changed to leave the commented stuff :default:
and gone by reading a switch in to it ... \ncomment ..

TIA

Mitsuko Aninikkou
Posts: 210
Joined: Tue Dec 13, 2005 12:52 pm
Location: The Netherlands (But running US WinXP, in case it comes up)

Post by Mitsuko Aninikkou » Sun Mar 09, 2008 8:35 pm

Hey guys, sorry for the late reply, been away for quite a while. Still kinda busy atm with uni and stuff, but I'll see if I can update this soon.

User avatar
UtCollector
Posts: 464
Joined: Sun Apr 09, 2006 8:31 pm
Contact:

Post by UtCollector » Mon Mar 24, 2008 7:07 pm

Links seems to be dead :(

Post Reply