Pelles C forum

Pelles C => General discussions => Topic started by: czerny on July 06, 2011, 11:06:16 PM

Title: snippets db
Post by: czerny on July 06, 2011, 11:06:16 PM
Hi,

I tryed to store this little function in the snippets db, but the I get an error message saying that this is not possible. What I am doing wrong?

int chomp(char *s)
{
   char *p = strchr(s, '\n');
   if ( p != NULL ) {
       *p = '\0';
       return 1;
     }
     return 0;
}

czerny
Title: Re: snippets db
Post by: CommonTater on July 08, 2011, 03:41:51 AM
Ok... how did you try to do it?

Tools -> Customize -> snippets -> select type -> new snippet -> type or paste into dialog.

Title: Re: snippets db
Post by: czerny on July 10, 2011, 12:08:50 AM
exactly!
Title: Re: snippets db
Post by: CommonTater on July 10, 2011, 12:38:53 AM
exactly!

Ummmm.... meaning what? 

Did my suggestion work... or is that the one that failed?

Title: Re: snippets db
Post by: czerny on July 10, 2011, 01:33:41 AM
This was the way that didn't work!

Have you tryed to do the same?

czerny
Title: Re: snippets db
Post by: CommonTater on July 10, 2011, 03:43:04 AM
This was the way that didn't work!

Have you tryed to do the same?

czerny

Yep, it worked for me  on ver 6.50 rc4 x64 .... 
But I typed my test in by hand...

EDIT:
Hrrrmmmm... copy and paste from outside the IDE doesn't seem to be working
but copy and paste from an IDE source window to the snippet does.

Kinda odd....



Title: Re: snippets db
Post by: AlexN on July 11, 2011, 11:55:59 AM
I (6.50 rc4 x86) tried it also (with different modifications) and I think only Pelle knows why you can't store it.

PS: If you remove the lines with "*p =" you can store it (but I think this will not help you).
Title: Re: snippets db
Post by: TimoVJL on July 11, 2011, 01:47:54 PM
Maybe problem with ' Single quote.
Use two single quotes for one single quote.
Code: [Select]
int chomp(char *s)
{
   char *p = strchr(s, ''\n'');
   if ( p != NULL ) {
       *p = ''\0'';
       return 1;
     }
     return 0;
}
Title: Re: snippets db
Post by: CommonTater on July 11, 2011, 01:59:21 PM
I don't think the snippets window does syntax checking...

What I was wondering is if it was a clipboard format problem...
Text pushed to the clipboard as ASCII where the IDE is internally unicode ... ???

Title: Re: snippets db
Post by: czerny on July 20, 2011, 10:01:43 PM
Hallo,

it looks as if the SQLite db does refuse the snipped because the single quotes are not escaped.

czerny
Title: Re: snippets db
Post by: CommonTater on July 21, 2011, 02:11:06 AM
Hmmm... Ok, I took your sample code and copied it... I could paste it into the source editor but not the snippets window... if I copied it from the source editor, it pasted into the snippets window just fine...

Title: Re: snippets db
Post by: czerny on July 22, 2011, 01:22:19 AM
Thats not the point!

Can you save it than?

czerny
Title: Re: snippets db
Post by: CommonTater on July 22, 2011, 04:23:15 AM
When I copy from the Source editor, yes it saves.
When I copy from the first message, no it does not save.

I believe you've found a bug and you should report it as such in the appropriate forum
Title: Re: snippets db
Post by: czerny on July 22, 2011, 07:29:41 PM
This is definitivly not the case with my version (6.50.8 R4 32 bit).
I can't save it neither from notepad nor from the ide copyed.
The only way I can save it is to double the single quotes.

czerny