I want to embed a bash script inside the c program.
How could you do the below bash snippet in "c"?:
cat > /tmp/foo <<\__EOD_
all kinds of nasty stuff in here including single and double quotes
and bashslashes ..
(note that the here doc delimiter is preceded by a "\"
__EOD_
--
regards,
Tom Rodman
pls run for my address:
perl -e 'print unpack("u", "1\:6UP\,\$\!T\<F\]D\;6\%N\+F\-O\;0H\`");' 27 7325
On Wed, 03 Sep 2003 15:14:28 -0500
Tom Rodman <Use-Author-Address-Header@[127.1]> wrote: I want to embed a bash script inside the c program.
Standard C knows nothing of 'embed', 'bash' or 'script'.
How could you do the below bash snippet in "c"?:
cat > /tmp/foo <<\__EOD_ all kinds of nasty stuff in here including single and double quotes and bashslashes .. (note that the here doc delimiter is preceded by a "\" __EOD_
Ask this in comp.unix.programmer and prepare to be helped, or rephrase the
question to something not involving anything platform-specific.
--
char*x(c,k,s)char*k,*s;{if(!k)return*s-36?x(0,0,s+1):s;if(s)if(*s)c=10+(c?(x(
c,k,0),x(c,k+=*s-c,s+1),*k):(x(*s,k,s+1),0));else c=10;printf(&x(~0,0,k)[c-~-
c+"1"[~c<-c]],c);}main(){x(0,"^[kXc6]dn_eaoh$%c","-34*1'.+(,03#;+,)/'///*");}
Tom Rodman <Use-Author-Address-Header@[127.1]> writes: I want to embed a bash script inside the c program.
How could you do the below bash snippet in "c"?:
cat > /tmp/foo <<\__EOD_ all kinds of nasty stuff in here including single and double quotes and bashslashes .. (note that the here doc delimiter is preceded by a "\" __EOD_
#include <stdlib.h>
#include <stdio.h>
int main (void)
{
FILE *f;
f = fopen ("/tmp/foo", "w");
if (f == NULL)
{
fputs ("Cannot create /tmp/foo.\n", stderr);
return EXIT_FAILURE;
}
if (fputs ("\
all kinds of nasty stuff in here including single and double quotes\n\
and bashslashes ..\n\
(note that the here doc delimiter is preceded by a \"\\\"\n", f) == EOF
|| fclose (f) == EOF)
{
fputs ("Error writing to /tmp/foo.\n", stderr);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Martin
In article <20*************************@tigris.pounder.sol.ne t>,
Tom Rodman <Use-Author-Address-Header@[127.1]> wrote: I want to embed a bash script inside the c program.
How could you do the below bash snippet in "c"?:
cat > /tmp/foo <<\__EOD_ all kinds of nasty stuff in here including single and double quotes and bashslashes .. (note that the here doc delimiter is preceded by a "\" __EOD_
Treating a chunk of text as a bash script once you've got it embedded
in your program is beyond the scope of this newsgroup (but why don't
you just create it as a separate file and use system() to ask bash to
run it?), but:
You can pack a big chunk of text nicely into a string literal by doing
something like this:
--------
const char *my_long_string=
"This is a nice long string.\n"
"Note that every line ends with a '\\n\"', and we're taking advantage\n"
"of the string-splicing feature.\n"
"Note that single quotes inside string literals don't need to be escaped.\n";
--------
You're not guaranteed to be able to embed arbitrarily long strings this
way (the Standard places a minimum on the maximum length compilers can
restrict you to, but a compiler is allowed to complain about or reject
anything beyond that minimum[1]), but in practice I'd be surprised to see
GCC (which I assume you're using) choke on any length of string literal.
Something not entirely unlike this snippet (typed directly into the editor
for my posting software, never seen a compiler, usual disclaimers apply)
might help you with escaping the double quotes and backslashes if you'd
rather not do it by hand:
--------
/*This code as posted is a demonstration-of-concept and has never seen a
compiler, let alone been tested. The usual disclaimers apply.
Output will need fixing up by hand at beginning (adding '"' at the
beginning of the first line) and end (removing '"' at the beginning of
the nonexistent just-past-last line), but should be appropriately
escaped for inclusion into C source as a big string literal otherwise.
Caller is responsible for checking ferror(in) and acting appropriately
on error.
*/
void convert_to_string_literal(FILE *in,FILE *out)
{
int c;
while(c=getc(in) != EOF)
{
switch(c)
{
case '\n':
fputs("\\n\"\n\"",out);
break;
case '"':
fputs("\\\"",out);
break;
case '\\':
fputs("\\\\",out);
break;
default:
putc(c,out);
break;
}
}
}
--------
dave
[1] Actually, it doesn't quite even guarantee this, but the intention
is clear enough that even the DS9k implementors had to try pretty
hard to get around it.
--
Dave Vandervies dj******@csclub.uwaterloo.ca
Maybe I should add a line that says, "No matter what you do, it is sure
to annoy at least one of the regulars".
--Billy Chambless in comp.lang.c
In article <20*************************@binky.homeunix.org> ,
Pieter Droogendijk <gi*@binky.homeunix.org> wrote: or rephrase the question to something not involving anything platform-specific.
Since you seem to realize that it was in fact a C question, is there any
particular reason you couldn't answer the C question instead of telling
the OP "This isn't off topic, but go away anyways"?
dave
--
Dave Vandervies dj******@csclub.uwaterloo.ca
I have neither the need, the time, or the inclination to put words into your
mouth. You are perfectly capable of damaging your reputation without any help
from me. --Richard Heathfield roasts a troll in comp.lang.c dj******@csclub.uwaterloo.ca (Dave Vandervies) wrote in
news:bj**********@tabloid.uwaterloo.ca on Wed 03 Sep 2003 05:34:12p: In article <20*************************@binky.homeunix.org> , Pieter Droogendijk <gi*@binky.homeunix.org> wrote:
or rephrase the question to something not involving anything platform-specific.
Since you seem to realize that it was in fact a C question, is there any particular reason you couldn't answer the C question instead of telling the OP "This isn't off topic, but go away anyways"?
Ah, but it /is/ off-topic for comp.lang.c. This group's charter is for
Standard C (C89 and C99, mainly, but K&R pre-Standard C is also acceptable
for historic reasons), and Standard C is not as platform-specific as OS
shells are. Therefore, Standard C has nothing to say about here documents,
bash, or any behaviors thereof.
Asking us to translate a snippet of platform-specific code is not only
unfair to us (who will probably give a bad answer because we don't know
the behavior of the code), but is markedly stupid behavior. It wastes your
time, our time, and the bandwidth of this newsgroup, making it less likely
that we'll /ever/ help you, even if you should stumble upon a good
question. After all, we're none of us paid for this.
On Thu, 04 Sep 2003 01:58:28 GMT, August Derleth
<li*****************@onewest.net> wrote in comp.lang.c: dj******@csclub.uwaterloo.ca (Dave Vandervies) wrote in news:bj**********@tabloid.uwaterloo.ca on Wed 03 Sep 2003 05:34:12p:
In article <20*************************@binky.homeunix.org> , Pieter Droogendijk <gi*@binky.homeunix.org> wrote:
or rephrase the question to something not involving anything platform-specific.
Since you seem to realize that it was in fact a C question, is there any particular reason you couldn't answer the C question instead of telling the OP "This isn't off topic, but go away anyways"?
Ah, but it /is/ off-topic for comp.lang.c. This group's charter is for
^^^^^^^
While I agree with everything you said, you are wrong where
highlighted above. This group has no charter, it started long before
there were newsgroup charters.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
"Dave Vandervies" <dj******@csclub.uwaterloo.ca> wrote in message
news:bj**********@tabloid.uwaterloo.ca... In article <20*************************@binky.homeunix.org> , Pieter Droogendijk <gi*@binky.homeunix.org> wrote:
or rephrase the question to something not involving anything platform-specific. Since you seem to realize that it was in fact a C question, is there any particular reason you couldn't answer the C question instead of telling the OP "This isn't off topic, but go away anyways"?
dave
-- Dave Vandervies dj******@csclub.uwaterloo.ca I have neither the need, the time, or the inclination to put words into
your mouth. You are perfectly capable of damaging your reputation without any
help from me. --Richard Heathfield roasts a troll in
comp.lang.c
You are wrong. The OP question is clearly off-topic. Although the OP
mentioned C language in his post, he is asking a platform-specific question,
it is off-topic. We should kindly redirect him to the relevant group, it is
good for him.
--
Jeff
On Wed, 3 Sep 2003 23:34:12 +0000 (UTC) dj******@csclub.uwaterloo.ca (Dave Vandervies) wrote: In article <20*************************@binky.homeunix.org> , Pieter Droogendijk <gi*@binky.homeunix.org> wrote:
or rephrase the question to something not involving anything platform-specific.
Since you seem to realize that it was in fact a C question, is there any particular reason you couldn't answer the C question instead of telling the OP "This isn't off topic, but go away anyways"?
Questions to this newsgroup are topical if they are questions about Standard C
(C89/C99). This question was about translating a bash script. While he mentioned
C, it was in fact A. a homework question and B. off-topic. The first deserves
plonking and the second deserves redirection.
Giving him the option to rephrase the question to something not containing any
off-topic material, means 'translate your question to one that is topical here'
(like: how do I write text to a file).
--
char*x(c,k,s)char*k,*s;{if(!k)return*s-36?x(0,0,s+1):s;if(s)if(*s)c=10+(c?(x(
c,k,0),x(c,k+=*s-c,s+1),*k):(x(*s,k,s+1),0));else c=10;printf(&x(~0,0,k)[c-~-
c+"1"[~c<-c]],c);}main(){x(0,"^[kXc6]dn_eaoh$%c","-34*1'.+(,03#;+,)/'///*");}
On Thu, 04 Sep 2003 13:30:09 +0800, Jeff wrote: You are wrong. The OP question is clearly off-topic. Although the OP mentioned C language in his post, he is asking a platform-specific question, it is off-topic. We should kindly redirect him to the relevant group, it is good for him.
No the question is clarly on-topic, to rephrase the OP's question (with
apologies to the OP if I misunderstand) "What would I do in standard C to
achieve a result similar to that of bash-s here-documents". The question
is NOT platform specific, while the example he used to describe what he
wanted to achieve is.
An appropriate response could have been something like "Your example is
platform specific, please explain in plain english what you want to
achieve"
OP: Look at the response from Derk Gwen, and ignore the people that are so
used to complaining about off-topic posts that they can't recognize an
on-topic.
NPV
--
"Linux is to Lego as Windows is to Fisher Price." - Doctor J Frink
Nils Petter Vaskinn wrote: On Thu, 04 Sep 2003 13:30:09 +0800, Jeff wrote:
You are wrong. The OP question is clearly off-topic. Although the OP mentioned C language in his post, he is asking a platform-specific question, it is off-topic. We should kindly redirect him to the relevant group, it is good for him.
No the question is clarly on-topic,
I think that translating text into a C string, is on topic,
regardless of what the text says.
Translating text into a C string was the question, wasn't it ?
I thought that this part:
"all kinds of nasty stuff in here including single and double quotes
and bashslashes .."
had to do with how you quote quotes and backslashes,
which is in fact, something that gets asked here from time to time.
--
pete
On Thu, 4 Sep 2003 02:42:15 +0000 (UTC), Richard Heathfield
<do******@address.co.uk.invalid> wrote: August Derleth wrote:
Ah, but it /is/ off-topic for comp.lang.c. This group's charter is for Standard C
This group no Charter.
Can have a charter without having a Charter :-)
Someone should write one, just to have an answer to the question of
"where's the charter?" and for ready reference to an "authority" at
those time when it might be useful. (No, I'm not volunteering.)
--
Al Balmer
Balmer Consulting re************************@att.net
Alan Balmer wrote: Someone should write one, just to have an answer to the question of "where's the charter?" and for ready reference to an "authority" at those time when it might be useful. (No, I'm not volunteering.)
Some of us prefer the group /not/ to have a charter, not least because of
the Schadenfreude that inevitably results from someone thoughtlessly
suggesting that we refer to it.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Richard Heathfield <do******@address.co.uk.invalid> wrote in message news:<bj**********@hercules.btinternet.com>... August Derleth wrote:
Ah, but it /is/ off-topic for comp.lang.c. This group's charter is for Standard C
This group no Charter.
We don't have a Charter, but we do have a FAQ which is fairly complete
and, IMHO, authoritative. In other words, the authority that would be
granted a Charter has de facto devolved onto the FAQ, making what the
FAQ says the law around here.
If people read the FAQ before posting (as I did, all that time ago),
they'd know exactly what was up in here and might not post that
VisualAda++ question about how to access a specific model of video
card under MSWinXPR6.765443 Patchlevel 23.998.
Maybe.
August Derleth wrote: We don't have a Charter, but we do have a FAQ which is fairly complete and, IMHO, authoritative. In other words, the authority that would be granted a Charter has de facto devolved onto the FAQ, making what the FAQ says the law around here.
Please cite the relevant FAQ, the one that deals with topicality in
comp.lang.c.
If people read the FAQ before posting (as I did, all that time ago), they'd know exactly what was up in here and might not post that VisualAda++ question about how to access a specific model of video card under MSWinXPR6.765443 Patchlevel 23.998.
Which FAQ tells them that VisualAda++ is off-topic here? I don't think the
word "topic" is even mentioned in the FAQ. It certainly doesn't appear in
the index of the book version.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Richard Heathfield <do******@address.co.uk.invalid> wrote in
news:bj**********@hercules.btinternet.com on Thu 04 Sep 2003 06:34:49p: August Derleth wrote:
We don't have a Charter, but we do have a FAQ which is fairly complete and, IMHO, authoritative. In other words, the authority that would be granted a Charter has de facto devolved onto the FAQ, making what the FAQ says the law around here. Please cite the relevant FAQ, the one that deals with topicality in comp.lang.c.
OK. I was wrong about the FAQ being about comp.lang.c in that way.
Jeez, the one way I can get people to notice me is to screw up... :) If people read the FAQ before posting (as I did, all that time ago), they'd know exactly what was up in here and might not post that VisualAda++ question about how to access a specific model of video card under MSWinXPR6.765443 Patchlevel 23.998.
Which FAQ tells them that VisualAda++ is off-topic here? I don't think the word "topic" is even mentioned in the FAQ. It certainly doesn't appear in the index of the book version. http://www.eskimo.com/~scs/C-faq/q19.1.html -- First topic in the section
System Dependencies. It says:
"Since comp.lang.c is oriented towards topics that C does deal with, you
will usually get better answers to these questions by referring to a
system-specific newsgroup such as comp.unix.questions or
comp.os.msdos.programmer, and to the FAQ lists for these groups."
It isn't as hardassed as most clc regs are, but it does gently state that
we deal with Standard C, not Ada, not Pascal, not system-specific
extensions to C.
And if we see a post about VisualAda++, we will storm Redmond and shove
the One Boot up the Gates of Hell.
So was I wrong? Yes, I was. Will I admit that? No, not really. I can still
quote mostly-relevant portions of the FAQ and appeal to the common sense
of Usenetters.
Richard Heathfield <do******@address.co.uk.invalid> wrote in
news:bj**********@hercules.btinternet.com on Thu 04 Sep 2003 03:41:19p: Alan Balmer wrote: Some of us prefer the group /not/ to have a charter, not least because of the Schadenfreude that inevitably results from someone thoughtlessly suggesting that we refer to it.
And I might write one, just for the Schadenfreude that will result when
someone smugly says that we don't have one.
.... grumble grumble grumble ...
August Derleth wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in news:bj**********@hercules.btinternet.com on Thu 04 Sep 2003 06:34:49p:
<snip> Which FAQ tells them that VisualAda++ is off-topic here? I don't think the word "topic" is even mentioned in the FAQ. It certainly doesn't appear in the index of the book version.
http://www.eskimo.com/~scs/C-faq/q19.1.html -- First topic in the section System Dependencies. It says:
"Since comp.lang.c is oriented towards topics that C does deal with, you will usually get better answers to these questions by referring to a system-specific newsgroup such as comp.unix.questions or comp.os.msdos.programmer, and to the FAQ lists for these groups."
I don't suppose I should be too surprised that this sentence doesn't appear
in my paper edition. Clearly, it's been edited out as being irrelevant to
casual purchasers.
It isn't as hardassed as most clc regs are, but it does gently state that we deal with Standard C, not Ada, not Pascal, not system-specific extensions to C.
Yes, that's a fair point.
And if we see a post about VisualAda++, we will storm Redmond and shove the One Boot up the Gates of Hell.
Why wait for a post about VisualAda++? If it feels good, do it.
So was I wrong? Yes, I was. Will I admit that? No, not really. I can still quote mostly-relevant portions of the FAQ and appeal to the common sense of Usenetters.
The common sense of Usenetters? You're new here, right? ;-)
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
August Derleth wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in news:bj**********@hercules.btinternet.com on Thu 04 Sep 2003 03:41:19p:
Alan Balmer wrote: Some of us prefer the group /not/ to have a charter, not least because of the Schadenfreude that inevitably results from someone thoughtlessly suggesting that we refer to it.
And I might write one, just for the Schadenfreude that will result when someone smugly says that we don't have one.
But since any charter you write would be yours, not ours, the Schadenfreude
would be ours, not yours.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
August Derleth wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in news:bj**********@hercules.btinternet.com on Thu 04 Sep 2003 06:34:49p:
<snip> Which FAQ tells them that VisualAda++ is off-topic here? I don't think the word "topic" is even mentioned in the FAQ. It certainly doesn't appear in the index of the book version.
http://www.eskimo.com/~scs/C-faq/q19.1.html -- First topic in the section System Dependencies. It says:
"Since comp.lang.c is oriented towards topics that C does deal with, you will usually get better answers to these questions by referring to a system-specific newsgroup such as comp.unix.questions or comp.os.msdos.programmer, and to the FAQ lists for these groups."
I don't suppose I should be too surprised that this sentence doesn't appear
in my paper edition. Clearly, it's been edited out as being irrelevant to
casual purchasers.
It isn't as hardassed as most clc regs are, but it does gently state that we deal with Standard C, not Ada, not Pascal, not system-specific extensions to C.
Yes, that's a fair point.
And if we see a post about VisualAda++, we will storm Redmond and shove the One Boot up the Gates of Hell.
Why wait for a post about VisualAda++? If it feels good, do it.
So was I wrong? Yes, I was. Will I admit that? No, not really. I can still quote mostly-relevant portions of the FAQ and appeal to the common sense of Usenetters.
The common sense of Usenetters? You're new here, right? ;-)
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
August Derleth wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in news:bj**********@hercules.btinternet.com on Thu 04 Sep 2003 03:41:19p:
Alan Balmer wrote: Some of us prefer the group /not/ to have a charter, not least because of the Schadenfreude that inevitably results from someone thoughtlessly suggesting that we refer to it.
And I might write one, just for the Schadenfreude that will result when someone smugly says that we don't have one.
But since any charter you write would be yours, not ours, the Schadenfreude
would be ours, not yours.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Pieter Droogendijk wrote: Tom Rodman <Use-Author-Address-Header@[127.1]> wrote:
I want to embed a bash script inside the c program.
Standard C knows nothing of 'embed', 'bash' or 'script'.
How could you do the below bash snippet in "c"?:
cat > /tmp/foo <<\__EOD_ all kinds of nasty stuff in here including single and double quotes and bashslashes .. (note that the here doc delimiter is preceded by a "\" __EOD_
Ask this in comp.unix.programmer and prepare to be helped, or rephrase the question to something not involving anything platform-specific.
It is a perfectly valid C question, even though he is describing
the off-topic eventual use. The real question is "how to embed
all those characters within C source code", and the answer is to
use the escape character '\'.
--
Replies should be to the newsgroup
Chuck Falconer, on vacation.
On Fri, 05 Sep 2003 02:51:45 GMT, August Derleth
<li*****************@onewest.net> wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in news:bj**********@hercules.btinternet.com on Thu 04 Sep 2003 03:41:19p:
Alan Balmer wrote: Some of us prefer the group /not/ to have a charter, not least because of the Schadenfreude that inevitably results from someone thoughtlessly suggesting that we refer to it.
I might wish I had written the above, but it was actually Richard. And I might write one, just for the Schadenfreude that will result when someone smugly says that we don't have one.
... grumble grumble grumble ...
--
Al Balmer
Balmer Consulting re************************@att.net
Pieter Droogendijk wrote: Tom Rodman <Use-Author-Address-Header@[127.1]> wrote:
I want to embed a bash script inside the c program.
Standard C knows nothing of 'embed', 'bash' or 'script'.
How could you do the below bash snippet in "c"?:
cat > /tmp/foo <<\__EOD_ all kinds of nasty stuff in here including single and double quotes and bashslashes .. (note that the here doc delimiter is preceded by a "\" __EOD_
Ask this in comp.unix.programmer and prepare to be helped, or rephrase the question to something not involving anything platform-specific.
It is a perfectly valid C question, even though he is describing
the off-topic eventual use. The real question is "how to embed
all those characters within C source code", and the answer is to
use the escape character '\'.
--
Replies should be to the newsgroup
Chuck Falconer, on vacation.
Derk:
Thanks for your help - I'll use your approach; will write a
shell script filter to generate the meta-quoted strings in text[].
--
regards,
Tom Rodman
pls run for my address:
perl -e 'print unpack("u", "1\:6UP\,\$\!T\<F\]D\;6\%N\+F\-O\;0H\`");'
Derk wrote:
<snip> char *text[] = { /*X*/ "line 1\n", "line 2\n", ..., "line n\n", /*Y*/ 0 };
<snip>The lines between X and Y have to have quotes and backslashes backslashed escaped, besides the initial '"' and trailing 'n",' for each line. It's a pain to do this by hand. It's easy to write a simple filter for this and then do something like herefilter <textfile >textfile.here and replace the /*X*/.../*Y*/ with #include "textfile.here"
I do something similar quite often to insert Tcl scripts into C programs with the makefile calling the filter and compiling the file.
On Fri, 05 Sep 2003 02:51:45 GMT, August Derleth
<li*****************@onewest.net> wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in news:bj**********@hercules.btinternet.com on Thu 04 Sep 2003 03:41:19p:
Alan Balmer wrote: Some of us prefer the group /not/ to have a charter, not least because of the Schadenfreude that inevitably results from someone thoughtlessly suggesting that we refer to it.
I might wish I had written the above, but it was actually Richard. And I might write one, just for the Schadenfreude that will result when someone smugly says that we don't have one.
... grumble grumble grumble ...
--
Al Balmer
Balmer Consulting re************************@att.net
Derk:
Thanks for your help - I'll use your approach; will write a
shell script filter to generate the meta-quoted strings in text[].
--
regards,
Tom Rodman
pls run for my address:
perl -e 'print unpack("u", "1\:6UP\,\$\!T\<F\]D\;6\%N\+F\-O\;0H\`");'
Derk wrote:
<snip> char *text[] = { /*X*/ "line 1\n", "line 2\n", ..., "line n\n", /*Y*/ 0 };
<snip>The lines between X and Y have to have quotes and backslashes backslashed escaped, besides the initial '"' and trailing 'n",' for each line. It's a pain to do this by hand. It's easy to write a simple filter for this and then do something like herefilter <textfile >textfile.here and replace the /*X*/.../*Y*/ with #include "textfile.here"
I do something similar quite often to insert Tcl scripts into C programs with the makefile calling the filter and compiling the file. This discussion thread is closed Replies have been disabled for this discussion. Similar topics
33 posts
views
Thread by Jim Hill |
last post: by
|
5 posts
views
Thread by karteikarte |
last post: by
|
3 posts
views
Thread by Summit |
last post: by
|
1 post
views
Thread by gslim |
last post: by
|
35 posts
views
Thread by erikwickstrom |
last post: by
|
206 posts
views
Thread by WaterWalk |
last post: by
|
13 posts
views
Thread by xzzy |
last post: by
| | | | | | | | | | | | |