Skip to content
Snippets Groups Projects

Updates to some BURT related functions in the EPICS sequencer.

Merged Jonathan Hanks requested to merge jonathan-hanks/advligorts:more_epics_seq_work into master
3 unresolved threads
  • Remove plain char arrays from writeTable2File, replace with fixed_string.
  • Rework encodeBURTString to take fixed_string inputs
    • Update it to have no failure cases. This is done by replacing pointers with references and putting compile time checks in on input lengths.
    • Put encodeBURTString under test.
  • Minor updates to fixed_string
    • introduce begin()/end() for range for loop support and empty() to clarify code.
    • introduce an operator+=(char) for appending a character at a time.
  • Updates to the parseLine function
    • put parseLine under test
    • Fixed an overflow issue in parseLine when there is a quoted word that is longer than the output buffers.
    • Fixed an issue with parsing where the quotes were returned in the output if the first word was quote escaped.
    • Reworked it to use fixed strings and vectors instead of 6 char* out parameters.
  • Moved encodeBURTString and parseLine to burt_file.hh
    • Put them in a BURT namespace
    • Renamed BURT::encodeBURTString -> BURT::encodeString

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
19 * @note BURT encoding of strings does not escape quotes,
20 * and lists empty strings as \0 (backslash and 0)
21 *
22 * @tparam SRC_SIZE
23 * @tparam DEST_SIZE Must be at least 2 greater than SRC_SIZE
24 * @param src Input string to encode.
25 * @param dest Destination for an encoded version of src.
26 */
27 template < std::size_t SRC_SIZE, std::size_t DEST_SIZE >
28 void
29 encodeString( const embedded::fixed_string< SRC_SIZE >& src,
30 embedded::fixed_string< DEST_SIZE >& dest )
31 {
32 static_assert(
33 DEST_SIZE >= ( SRC_SIZE + 2 ),
34 "The destination buffer must be at last bytes larger than "
  • 36 static_assert(
    37 DEST_SIZE >= 2,
    38 "The destination buffer must be long enough to burt encode "
    39 "a NULL string" );
    40
    41 if ( src.empty( ) )
    42 {
    43 dest = "\\0";
    44 return;
    45 }
    46
    47 bool expand = false;
    48
    49 for ( char ch : src )
    50 {
    51 if ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '"' )
  • 95 lastwasspace = 1;
    96 }
    97 else if ( *s != '"' || !lastwasspace )
    98 {
    99 cur_word += *s;
    100 lastwasspace = 0;
    101 }
    102 else
    103 {
    104 // quote
    105 // burt does not escape quotes, you have to look for the last
    106 // quote and just take it.
    107 lastquote = nullptr;
    108 qch = s + 1;
    109
    110 while ( *qch && *qch != '\n' )
    • If this is supposed to allow for individual words to be quoted, it doesn't do the trick.

    • BURT strings do not escape things well. Strings with quotes in them are dangerous.

    • I wrote a test case to remind myself how BURT does things.

      Using a python pcaspy server that returns the following string for the PV named BURT:QUOTE

      'Hello " World how are you" I have " sets of "quotes" in "me""'

      Then running burtrb with one value in the req file (BURT:QUOTE) gives:

      $ burtrb -f test.req 
      --- Start BURT header
      Time:     Mon Apr 18 17:30:11 2022
      Login ID: jonathan.hanks (Jonathan Hanks)
      Eff  UID: 41399
      Group ID: 41399
      Keywords: 
      Comments: 
      Type:     Absolute
      Directory /home/jonathan.hanks/burt_test
      Req File: test.req
      --- End BURT header
      BTEST:QUOTE 1 "Hello " World how are you" I have " set"
      

      So the string gets truncated by epics and burt does not do good escaping.

    • Ultimately it is probably better to do some other format than BURT. It works ok for numeric values, but complex strings is not its strong point.

    • Please register or sign in to reply
  • Erik von Reis approved this merge request

    approved this merge request

  • There's a typo in an error message.

    The parser has problems but I assume it had the same problems before it was copied to burt_file.hh.

    Once the type is fixed the MR is ready to be merged.

  • Jonathan Hanks added 1 commit

    added 1 commit

    • 0dfa01bb - EPICS Sequencer - typo fix in burt_file.hh

    Compare with previous version

  • merged

  • Erik von Reis mentioned in commit 3e07245d

    mentioned in commit 3e07245d

  • Please register or sign in to reply
    Loading