Author Topic: The Source Code Exporter Backslash Problem  (Read 12482 times)

Offline NanoBytes

  • Single posting newcomer
  • *
  • Posts: 2
The Source Code Exporter Backslash Problem
« on: August 14, 2011, 01:19:02 am »
Im not sure if this topic has already been dicussed here, but im new (i made the account just to tell you guys this) I was exporting the code from one of my projects in RTF format. every time it came across a backslash character it screws up (Not because of the exporter, but because of RTF format) if the \ token is unrecognized it will simply ingore it.
eg. "Hello\0 World" would become "Hello0 World"
And it gets realy messed up with other characters such as \' or \"
BUT double backslashes work fine "Hello\\0 World" becomes "Hello\0 World"
And that is how it should be displayed, but that wont work in code

The solution is simple enough though, all you have to do is put a recognized in the RTF exporter. If the current character is a backslash simply output it twice

outputRTFChar(currentChar);
if (currentChar == '\\') outputRTFChar(currentChar);

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: The Source Code Exporter Backslash Problem
« Reply #1 on: August 14, 2011, 10:43:29 am »
outputRTFChar(currentChar);
if (currentChar == '\\') outputRTFChar(currentChar);
This is not as simple as it sounds, have a look at RTFExporter::RTFBody(...) - the whole content is converted at once, not char-by-char. However, it's surely do-able. Can you provide a patch accordingly, please?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline seb_seb0

  • Almost regular
  • **
  • Posts: 166
Re: The Source Code Exporter Backslash Problem
« Reply #2 on: August 14, 2011, 06:26:07 pm »
I have done a small patch here.
It works with output of "Hello\0 World".

In
Code
RTFExporter::RTFBody
, there is a switch over each character from the memory buffer. I have simply added a case:
Code
      case '\\':
        {
            rtf_body += string("\\\\");
        }
        break;

I have made a test of a 2000 lines file, and it works OK for me.

Seb

Offline NanoBytes

  • Single posting newcomer
  • *
  • Posts: 2
Re: The Source Code Exporter Backslash Problem
« Reply #3 on: September 05, 2011, 04:22:17 am »
Hey, Im not sure how to get your patch to work with code blocks, I have no ide where to start actualy. So could one of you simply post the Exporter.dll, or you could teach me how to use the .patch that you already posted, but the later is inpreferable.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: The Source Code Exporter Backslash Problem
« Reply #4 on: September 05, 2011, 07:04:15 am »
Hey, Im not sure how to get your patch to work with code blocks, I have no ide where to start actualy. So could one of you simply post the Exporter.dll, or you could teach me how to use the .patch that you already posted, but the later is inpreferable.
Wait for the net nightly. It will have this implemented.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ