Amalgamator bugfix with utf-8 files


#1

i think the munge function should look like this, or it will segfault when processing utf-8 files.

    String oldData;
    const String newText (lines.joinIntoString (T("\n")) + T("\n"));
    oldData = targetFile.loadFileAsString ();

    if (oldData == newText)
    {
        printf ("(No need to write - new file is identical)\n\n");
        return true;
    }

    if (! targetFile.replaceWithText (newText, true))
    {
        printf ("\n!! ERROR - couldn't write to the target file: " + targetFile.getFullPathName() + "\n\n");
        return false;
    }

it was a pain to discover, because i was not having trace of which file was creating problems !


#2

it doesn’t work the same… how i’m supposed to create a valid utf-8 file from a wide char string ?


#3

The amalgamator’s only designed for the juce codebase - why are you trying to feed it other files?

But I guess the simplest way to write utf8 is just to call String::toUTF8 and dump that block to the file.


#4

cause it’s very handy and saves a lot of compilation time, also somehow debugging is easier as i have a single file and a line and i can grab the lines around and see what happens in less clicks than traversing the juce tree and open the file manually.

and anyway, i have an extended juce version here, which lives beside the juce_core, juce_appframework… my own juce_extended directory. so i’m feeding it tothe amalgamator the same, and i save an extra library compilation step and packaging, cause the jucetice library is built on juce and uses the same juce style (at least it tries).

anyway i fixed it manually removing those offending characters…


#5

I’m using amalgamator for creating an amalgamated version of a library of mine (few .h and .cpp files). Since I am italian, some of the comments inside my source tree are in italian and include accented characters "à ", “è”, and so on.

It turns out that amalgamator truncates the files it merges, when it encounters the first accented character in it, and then goes on with the next file to be included. Obviously, since the file with the offending character gets truncated, the resulting .h and .cpp amalgamated files aren’t compilable at all.

Is there hope this could be fixed any soon? I may remove the offending characters from the source code (and I probably will), but this is a stopping bug for people wanting to use amalgamator for their code.
Not only that, but maybe (it happened to me) people get the need to add few extra lines of code to their juce codebase for fixing something that will be fixed later in the tip… In the mean time, adding an explaining comment in one’s mother language is a very good way to make it clear that the modification is a “local one”, and then generating an amalgamated version of that would result in a broken pair of amalgamated sources…


#6

Are you using an old version? I can’t see how it’d fail if you’re using the latest build?..


#7

no, I just built amalgamator.exe using the current tip. I may send you one of the files that gets truncated…


#8

Oh, maybe you’re not saving your files as utf8? If you give it characters that aren’t valid utf8 then that’ll make it halt.


#9

Yes, I guess that’s the problem. May look like a dumb question but… does someone know how to enable utf8 saving in Visual Studio 2008?