Hard Light Productions Forums

Off-Topic Discussion => Programming => Topic started by: Sandwich on March 12, 2012, 05:50:04 pm

Title: Need a killer feature added to any Windows GUI diff tool (such as WinMerge, etc)
Post by: Sandwich on March 12, 2012, 05:50:04 pm
Basically, see here: http://sourceforge.net/tracker/index.php?func=detail&aid=3484771&group_id=13216&atid=363216

tl;dr: I want to be able to specify "equivalent strings" that the diff engine would ignore.

For the link-challenged:
Quote
I'm maintaining a plugin script (in PHP) for 2 different versions of ExpressionEngine, a popular commercial CMS. In one version, PHP cache functionality is accessed by "$SESS->cache", while in the other, by "$this->EE->session->cache". Obviously, WinMerge sees these as differences. I'd love to be able to indicate that these string pairs are to be considered equivalent to each other for purposes of comparison.

I imagine this would be useful in many situations, such as About Us pages containing email addresses of organizations that have local branches in different countries (eg. '[email protected]' would be equivalent to '[email protected]'), or perhaps even different spellings of words for different target audiences (eg. 'color' vs 'colour').

Any takers?
Title: Re: Need a killer feature added to any Windows GUI diff tool (such as WinMerge, etc)
Post by: Tomo on March 14, 2012, 02:05:52 pm
I doubt that such an approach would work, and it would be a real pain to maintain.

The problem you're hitting is not a new one, the classic examples are localisation and multi-platform applications.

The general solution is to have multiple target-specific source files or methods, and select the appropriate one to use at either compile or run time.

In the localisation example, there would be several language data files, one for "English", another "French", "Klingon" etc.
The appropriate file is then chosen at run time using some kind of user setting.

The same thing is done for multi-platform applications.
In the case of C/C++, usually using #ifdef ... #endif structures to enclose small call differences, or compiling using "win_stuff.cpp" as opposed to "linux_stuff.cpp" to select a platform-specific implementation of "stuff.h".

Take a look at the FSO source for examples!

PHP doesn't have a direct equivalent of #ifdef as it's an interpreted/JIT language, however you can get the same kind of effect using a straight if - then - else structure.

[Edit]

In your specific case, the very best way would be if there was some way for your plugin to determine the ExpressionEngine version automatically at runtime to pick the right call with no user intervention.
- Maybe APP_VER?

If that's not possible (or too difficult), then have a user-set config flag somewhere sensible so each user can manually set their ExpressionEngine version.
Title: Re: Need a killer feature added to any Windows GUI diff tool (such as WinMerge, etc)
Post by: Sandwich on March 17, 2012, 08:22:48 pm
Interesting ideas... I still wish for an equivalent strings feature, but perhaps...