Menu

#2278 Fix handling line continuations for generating Embedded.properties

Bug
closed-fixed
nobody
5
2021-09-22
2021-08-28
No

Platform: win32 on Windows 7, if it matters.

The generation of Embedded.properties has an issue with lines starting with #.

The # is used for comment lines though it can also be used for keywords. I did the update to au3.properties with the knowledge of this and so added spaces aat the start of lines that were continued as the keywords start with #.

I now have a fix for this.

This patch (for display only) shows the issues I noticed of recent:

--- a/Embedded.properties
+++ b/Embedded.properties
@@ -263,7 +263,6 @@
 import *


-
 module abaqus

 file.patterns.abaqus=*.inp;*.dat;*.msg
@@ -3147,6 +3146,7 @@
 sysdate sysdate4 time timespan to trim ubigint uchar uinteger unload_driver unlock use ushort valid_drive valuetreedeserializeparameter \
 valuetreeserializeparameter variant vconstrain version_information vfind virtual_key webget webpublishfunction webpublishprocedure webset \
 websetresponsive write write_hex writeln xmlhandle zerofile zerostring zerotype #check #error #include #pop #push #replace #set \
+#spop #spush

 keywords2.$(file.patterns.dataflex)=\
 begin class function procedure object repeat for while begin_constraints procedure_section begin_row \
@@ -3858,6 +3858,7 @@
 word.characters.$(file.patterns.forth)=$(chars.alpha)$(chars.numeric)%-

 comment.block.forth=\
+#comment.block.at.line.start.forth=0
 comment.stream.start.forth=(
 comment.stream.end.forth=)
 comment.box.start.forth=\
@@ -4106,6 +4107,8 @@
 window windowtitle with write xor zstring

 keywordclass.preprocessor=\
+#define #dynamic #else #endif #error #if #ifdef #ifndef #inclib #include \
+#print #static #undef

 keywords.$(file.patterns.freebasic)=$(keywordclass.freebasic)
 keywords2.$(file.patterns.freebasic)=$(keywordclass.preprocessor)

The #spop and #spush is removed as well as other keywords. So this affects abaqus, dataflex, forth (needs continuation line fix...) and freebasic.

This shows that some keywords do not survive the current operation of running scite\scripts\RegenerateSource.py as the script removes lines starting with # without any conditions.

The patch attached is just a few more lines to handle the line continuation condition:

Patch for the forth.properties already submitted as a separate issue [#2277].

1 Attachments

Related

Bugs: #2277

Discussion

  • Michael Heath

    Michael Heath - 2021-08-28

    Sorry about the single quotes used in the patch which are not consistent with the double quotes used in RegenerateSource.py. Just recognized my mistake. You can change the quotes before commit or if you prefer, I could upload and attach another patch that will have double quotes.

    I have attached a another patch which uses double quotes.

     

    Last edit: Michael Heath 2021-08-29
  • Neil Hodgson

    Neil Hodgson - 2021-08-29
    • labels: scite --> scite, properties
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2021-08-29

    Not understanding why setting continuation uses the ternary True if line.endswith('\\\n') else False instead of just line.endswith('\\\n'). continuation should be reset for each file although its unlikely a file will end with a continuation.

    continuation = False
    for line in fi:
        if not continuation and line.startswith("#"):
            continue
        continuation = line.endswith("\\\n")
        linesEmbedded.append(line)
    

    Double versus single quotes isn't really important - the code is already inconsistent.

    Committed with changes as [d21ba7].

    Credited to 'mpheath'. If you want different text in the credits then tell me.

     

    Related

    Commit: [d21ba7]

  • Michael Heath

    Michael Heath - 2021-08-29

    The continuation value is for each line, though is reset for each file. I do not expect a file to end with a continuation, though still consider it good to reset for each file. Although Embedded.properties is 1 file as the result in which a continuation at the end of a file read could cause an issue, which should be fixed in the read file.

    With the continuation = line.endswith("\\\n"), you show the ternary was excessive code to achieve the same result. Thankyou for pointing out the improvement.

    As for the quotes, I like some consistency as it makes bugs easier to find. Your C++ code is tidier than your Python code, still, I do not like giving someone messy code if I can avoid it.

    Put me down as Michael Heath. I notice that you are in NSW. I am to the north, over the border in Qld. ;)

     
    • Neil Hodgson

      Neil Hodgson - 2021-08-29

      If there is an end of file continuation then it will affect the module statement (except for the first two non-module files). Added an extra \n at file start of each file to absorb any file end issue with [158e76].

      I normally use " for strings like C++ but when there are strings containing quotes I'll use '"' in preference to "\"" (or the inverse) and that sometimes spreads to nearby code.

       

      Related

      Commit: [158e76]

  • Neil Hodgson

    Neil Hodgson - 2021-09-22
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB