bugPSPP - Bugs: bug #18860, Need a quoting function and/or...

 
 

bug #18860: Need a quoting function and/or conversion .

Submitted by:  John Darrington <jmd>
Submitted on:  Wed 24 Jan 2007 08:28:41 AM UTC  
 
Category: Graphical User InterfaceSeverity: 3 - Ordinary
Status: FixedAssigned to: None
Open/Closed: ClosedRelease: None
Effort: 0.00

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 17 Feb 2007 05:40:51 PM UTC, comment #5:

> > Could the function named "quote" be renamed?
> OK. Do you have any suggestions?


It's doing the opposite of lexical analysis. It's analogous to emitting code or code generation. Maybe we'll want to have more of an infrastructure for this in the future. So maybe we could select a prefix like unlex_, gen_, or emit_. Anything you like there?

Ben Pfaff <blp>
Project Administrator
Sat 17 Feb 2007 08:05:33 AM UTC, comment #4:

Could the function named "quote" be renamed? It conflicts with the "quote" function in gnulib, which although we don't use now we will probably want to use in the future.

OK. Do you have any suggestions?

The following:
/* Copy the quoted string into str */ ds_destroy (str); ds_init_string (str, &quoted_str); ds_destroy (&quoted_str);

can be simplified into:
ds_swap (str, &quoted_str); ds_destroy (&quoted_str);

and it'll avoid copying data to boot.

OK. Thanks.

What reason do you foresee for wanting to escape '%'s? To me this option just looks like a bad idea. It seems to encourage the idea of passing user data as part of the format string to printf and friends, and I can't say I like to encourage that.

I did this as I thought it would help with a %sq printf conversion that I was working on. But it didn't work out. Maybe you're right; I should just delete it. It'd be simple to put it back again if I need it.

John Darrington <jmd>
Project Administrator
Sat 17 Feb 2007 05:36:18 AM UTC, comment #3:

Could the function named "quote" be renamed? It conflicts with the "quote" function in gnulib, which although we don't use now we will probably want to use in the future.

The following:
can be simplified into:
and it'll avoid copying data to boot.

What reason do you foresee for wanting to escape '%'s? To me this option just looks like a bad idea. It seems to encourage the idea of passing user data as part of the format string to printf and friends, and I can't say I like to encourage that.

Ben Pfaff <blp>
Project Administrator
Fri 16 Feb 2007 06:23:39 PM UTC, comment #2:

See Jason Stover's comments on bug #19003.

Ben Pfaff <blp>
Project Administrator
Fri 16 Feb 2007 01:45:45 PM UTC, comment #1:

After thinking about this and trying various approaches, this patch is what I've decided upon.

(file #11984)

John Darrington <jmd>
Project Administrator
Wed 24 Jan 2007 08:28:41 AM UTC, original submission:

From pspp-dev:

Ben Pfaff -unavailable- writes:
I'd suggest adding a function, analogous to the "quote" function in gnulib, that returns its argument as a quoted string in syntax format. It could return it in single quotes if it doesn't contain a single quote, in double quotes if it doesn't contain a double quote, or in single quotes with doubled single quotes otherwise.

John Darrington <john@cellform.com.au> writes:

> I was thinking that an alternative approach would be to implement a
> special conversion specification within the
> create_syntax_string_source function. Then we could simply write
> something like:
>
> create_syntax_string_source ("EXPORT OUTFILE=%q.", de->file_name);
>
> This way, there's no need for the caller to worry about buffers or
> dealloction at all.


Yes, that's a good idea.

However, I'd propose a slightly different syntax:
create_syntax_string_source ("EXPORT OUTFILE=%sq.",
de->file_name);
If you make the full specification %sq, then you can still get
GCC to check that a "char *" argument is present by telling it
that it's a printf-like function. There'd need to be a suffix
character for unquoted strings too, e.g. %su, but all in all the
slight inconvenience of using 2-character conversions is vastly
outweighed (in my opinion) by having compile-time checking.

John Darrington <jmd>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #11984:  q.patch added by jmd (9KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by blp (Posted a comment)
  • -unavailable- added by jmd (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 22 Feb 2007 11:27:58 AM UTCjmdStatusWorks For Me=>Fixed
      Assigned tojmd=>None
      Open/ClosedOpen=>Closed
    Sat 17 Feb 2007 05:36:18 AM UTCblpStatusReady for Test/Review=>Works For Me
      Assigned toblp=>jmd
    Fri 16 Feb 2007 01:45:45 PM UTCjmdAttached File-=>Added q.patch, #11984
      StatusNone=>Ready for Test/Review
      Assigned toNone=>blp

    Back to the top


    Powered by Savane 3.1-cleanup1