[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extensions for emacsclient (CVS version)

From: Miles Bader
Subject: Re: extensions for emacsclient (CVS version)
Date: Wed, 10 Sep 2003 10:37:48 -0400
User-agent: Mutt/1.3.28i

On Wed, Sep 10, 2003 at 03:45:34PM +0200, Andreas B?sching wrote:
+      while ((str = fgets (string, BUFSIZ, stdin)))
+       {
+         fprintf (out, "%s ", quote_file_name (str));
+       }

I think that there shouldn't be a space after the %s -- that will cause each
line of input to be evaluated independantly, which is probably not what you
want, as well as being the wrong thing if a line is longer than BUFSIZ.
Also, you don't free the result from quote_file_name (it's only only going to
matter for extremely long input -- but that's probably more likely for stuff
being fed from stdin).

Hmmm, this isn't really your fault, but I notice that _every_ call to
quote_file_name immediately just prints the result, like:

    fprintf (out, "-display %s ", quote_file_name (display));

where quote_file_name mallocs a new string.

It would be nicer to just change quote_file_name to something like
`output_quoted_string (char *str, FILE *stream)', which just copies STR to
STREAM with appropriate quoting (doing away with all the mallocing).

Then expressions like the above could be changed to:

     fputs ("-display ", out);
     output_quoted_string (display, out);

and your loop would be:

   while ((str = fgets (string, BUFSIZ, stdin)))
     output_quoted_string (str, out);

Would you like fries with that?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]