bugGNU Enscript - Bugs: bug #26774, sh.st - hash/pound within a string...

 
 

bug #26774: sh.st - hash/pound within a string mishandled

Submitter:  None
Submitted:  Wed 10 Jun 2009 03:46:31 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 11 Jun 2009 02:19:21 PM UTC, comment #4: 

Ok, I think I have a working solution.  I got rid of the separate sh_string state I created and instead mimicked what Andy Eskilsson did in his python state:


state sh_string extends Highlight
{
  /\\\\./ {
    language_print ($0);
  }
  sh_string_end {
    language_print ($0);
    return;
  }
}


Then I have sh_string_end set to a regular expression.


state sh extends HighlightEntry
{
  <snip>
  /* String constants. */
  /\"|'/ {
    sh_string_end = regexp($0);
    string_face (true);
    language_print ($0);
    call (sh_string);
    string_face (false);
  }
  <snip>
}


This correctly highlights nested single and double quotes, as well as hash/pound symbols inside quotes.  See the attached state file for more details.

(file #18250)

Josh Zenker <jzenk>
Wed 10 Jun 2009 05:14:04 PM UTC, comment #3: 

Sorry, I'm still getting the hang of this markup.  Let's try that again.


printf "Found the following differences between today and yesterday's "


Josh Zenker <jzenk>
Wed 10 Jun 2009 05:11:48 PM UTC, comment #2: 

Ah, no.  My changes cause problems with lines like these:

printf "Found the following differences between today and yesterday's "

Everything after the single quote returns to the plain, non-string style.

Josh Zenker <jzenk>
Wed 10 Jun 2009 04:00:52 PM UTC, comment #1: 

That sed script was meant to be:
s/^\s*#*\s*PORT=[1-9][0-9]*/PORT=1691/

Josh Zenker <jzenk>
Wed 10 Jun 2009 03:46:31 PM UTC, original submission:  

Lines like the following are improperly parsed by enscript 1.6.4:

sed 's/^\s*#*\s*PORT=[1-9][0-9]*/PORT=1691/' $SYSEDGE_INIT~ | uniq > $SYSEDGE_INIT

Everything after the hash/pound in the regex gets pretty-printed as though it were a comment.  On my system, I copied c_string.st to a new state, which I called sh_string.st:


/*
 * Read one sh-string.  sh-styled strings are needed in many languages.
 * Therefore it is implemented in a separate file to ease its reusing.
 */

state sh_string extends Highlight
{
  /\\\\./ {
    language_print ($0);
  }
  /\"|'/ {
    language_print ($0);
    return;
  }
}


/*
Local variables:
mode: sh
End:
*/


Then I changed sh.st to call sh_string instead of c_string:


  /* String constants. */
  /\"|'/ {
    string_face (true);
    language_print ($0);
    call (sh_string);
    string_face (false);
  }


This seems to be an imperfect solution, but it works for the time being.

JZ

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #18250:  sh.st added by jzenk (1KiB)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jzenk (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-06-11 jzenk Attached File- Added sh.st, #18250

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code