~ubuntu-branches/ubuntu/wily/geany/wily-proposed

« back to all changes in this revision

Viewing changes to scintilla/lexers/LexOthers.cxx

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2013-05-10 15:27:35 UTC
  • mfrom: (4.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130510152735-bvm7jw5k95ahpp8q
Tags: 1.23+dfsg-2
* Upload to unstable, fixes FTBFS (Closes: #707368)
* [a472a80] Enable parallel builds
* [17a6378] No-change bump of Standards-Version to 3.9.4
* [ea78f31] Add README.source describing git branch structure

Show diffs side-by-side

added added

removed removed

Lines of Context:
500
500
        }
501
501
}
502
502
 
 
503
#define DIFF_BUFFER_START_SIZE 16
 
504
// Note that ColouriseDiffLine analyzes only the first DIFF_BUFFER_START_SIZE
 
505
// characters of each line to classify the line.
 
506
 
503
507
static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
504
508
        // It is needed to remember the current state to recognize starting
505
509
        // comment lines before the first "diff " or "--- ". If a real
556
560
}
557
561
 
558
562
static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
559
 
        char lineBuffer[1024];
 
563
        char lineBuffer[DIFF_BUFFER_START_SIZE] = "";
560
564
        styler.StartAt(startPos);
561
565
        styler.StartSegment(startPos);
562
566
        unsigned int linePos = 0;
563
567
        for (unsigned int i = startPos; i < startPos + length; i++) {
564
 
                lineBuffer[linePos++] = styler[i];
565
 
                if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
566
 
                        // End of line (or of line buffer) met, colourise it
567
 
                        lineBuffer[linePos] = '\0';
 
568
                if (AtEOL(styler, i)) {
 
569
                        if (linePos < DIFF_BUFFER_START_SIZE) {
 
570
                                lineBuffer[linePos] = 0;
 
571
                        }
568
572
                        ColouriseDiffLine(lineBuffer, i, styler);
569
573
                        linePos = 0;
 
574
                } else if (linePos < DIFF_BUFFER_START_SIZE - 1) {
 
575
                        lineBuffer[linePos++] = styler[i];
 
576
                } else if (linePos == DIFF_BUFFER_START_SIZE - 1) {
 
577
                        lineBuffer[linePos++] = 0;
570
578
                }
571
579
        }
572
580
        if (linePos > 0) {      // Last line does not have ending characters
 
581
                if (linePos < DIFF_BUFFER_START_SIZE) {
 
582
                        lineBuffer[linePos] = 0;
 
583
                }
573
584
                ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
574
585
        }
575
586
}
603
614
        } while (static_cast<int>(startPos) + length > curLineStart);
604
615
}
605
616
 
606
 
static void ColourisePoLine(
607
 
    char *lineBuffer,
608
 
    unsigned int lengthLine,
609
 
    unsigned int startLine,
610
 
    unsigned int endPos,
611
 
    Accessor &styler) {
612
 
 
613
 
        unsigned int i = 0;
614
 
        static unsigned int state = SCE_PO_DEFAULT;
615
 
        unsigned int state_start = SCE_PO_DEFAULT;
616
 
 
617
 
        while ((i < lengthLine) && isspacechar(lineBuffer[i]))  // Skip initial spaces
618
 
                i++;
619
 
        if (i < lengthLine) {
620
 
                if (lineBuffer[i] == '#') {
621
 
                        // check if the comment contains any flags ("#, ") and
622
 
                        // then whether the flags contain "fuzzy"
623
 
                        if (strstart(lineBuffer, "#, ") && strstr(lineBuffer, "fuzzy"))
624
 
                                styler.ColourTo(endPos, SCE_PO_FUZZY);
625
 
                        else
626
 
                                styler.ColourTo(endPos, SCE_PO_COMMENT);
627
 
                } else {
628
 
                        if (lineBuffer[0] == '"') {
629
 
                                // line continuation, use previous style
630
 
                                styler.ColourTo(endPos, state);
631
 
                                return;
632
 
                        // this implicitly also matches "msgid_plural"
633
 
                        } else if (strstart(lineBuffer, "msgid")) {
634
 
                                state_start = SCE_PO_MSGID;
635
 
                                state = SCE_PO_MSGID_TEXT;
636
 
                        } else if (strstart(lineBuffer, "msgstr")) {
637
 
                                state_start = SCE_PO_MSGSTR;
638
 
                                state = SCE_PO_MSGSTR_TEXT;
639
 
                        } else if (strstart(lineBuffer, "msgctxt")) {
640
 
                                state_start = SCE_PO_MSGCTXT;
641
 
                                state = SCE_PO_MSGCTXT_TEXT;
642
 
                        }
643
 
                        if (state_start != SCE_PO_DEFAULT) {
644
 
                                // find the next space
645
 
                                while ((i < lengthLine) && ! isspacechar(lineBuffer[i]))
646
 
                                        i++;
647
 
                                styler.ColourTo(startLine + i - 1, state_start);
648
 
                                styler.ColourTo(startLine + i, SCE_PO_DEFAULT);
649
 
                                styler.ColourTo(endPos, state);
650
 
                        }
651
 
                }
652
 
        } else {
653
 
                styler.ColourTo(endPos, SCE_PO_DEFAULT);
654
 
        }
655
 
}
656
 
 
657
 
static void ColourisePoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
658
 
        char lineBuffer[1024];
659
 
        styler.StartAt(startPos);
660
 
        styler.StartSegment(startPos);
661
 
        unsigned int linePos = 0;
662
 
        unsigned int startLine = startPos;
663
 
        for (unsigned int i = startPos; i < startPos + length; i++) {
664
 
                lineBuffer[linePos++] = styler[i];
665
 
                if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
666
 
                        // End of line (or of line buffer) met, colourise it
667
 
                        lineBuffer[linePos] = '\0';
668
 
                        ColourisePoLine(lineBuffer, linePos, startLine, i, styler);
669
 
                        linePos = 0;
670
 
                        startLine = i + 1;
671
 
                }
672
 
        }
673
 
        if (linePos > 0) {      // Last line does not have ending characters
674
 
                ColourisePoLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
675
 
        }
676
 
}
677
 
 
678
617
static inline bool isassignchar(unsigned char ch) {
679
618
        return (ch == '=') || (ch == ':');
680
619
}
846
785
        while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
847
786
                i++;
848
787
        }
849
 
        if (lineBuffer[i] == '#') {     // Comment
850
 
                styler.ColourTo(endPos, SCE_MAKE_COMMENT);
851
 
                return;
852
 
        }
853
 
        if (lineBuffer[i] == '!') {     // Special directive
854
 
                styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
855
 
                return;
 
788
        if (i < lengthLine) {
 
789
                if (lineBuffer[i] == '#') {     // Comment
 
790
                        styler.ColourTo(endPos, SCE_MAKE_COMMENT);
 
791
                        return;
 
792
                }
 
793
                if (lineBuffer[i] == '!') {     // Special directive
 
794
                        styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
 
795
                        return;
 
796
                }
856
797
        }
857
798
        int varCount = 0;
858
799
        while (i < lengthLine) {
859
 
                if (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(') {
 
800
                if (((i + 1) < lengthLine) && (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(')) {
860
801
                        styler.ColourTo(startLine + i - 1, state);
861
802
                        state = SCE_MAKE_IDENTIFIER;
862
803
                        varCount++;
1015
956
                bool initialTab = (lineBuffer[0] == '\t');
1016
957
                bool initialColonPart = false;
1017
958
                enum { stInitial,
1018
 
                        stGccStart, stGccDigit, stGcc,
 
959
                        stGccStart, stGccDigit, stGccColumn, stGcc,
1019
960
                        stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
1020
961
                        stCtagsStart, stCtagsStartString, stCtagsStringDollar, stCtags,
1021
962
                        stUnrecognized
1047
988
                                state = Is1To9(ch) ? stGccDigit : stUnrecognized;
1048
989
                        } else if (state == stGccDigit) {       // <filename>:<line>
1049
990
                                if (ch == ':') {
1050
 
                                        state = stGcc;  // :9.*: is GCC
 
991
                                        state = stGccColumn;    // :9.*: is GCC
1051
992
                                        startValue = i + 1;
1052
 
                                        break;
1053
993
                                } else if (!Is0To9(ch)) {
1054
994
                                        state = stUnrecognized;
1055
995
                                }
 
996
                        } else if (state == stGccColumn) {      // <filename>:<line>:<column>
 
997
                                if (!Is0To9(ch)) {
 
998
                                        state = stGcc;
 
999
                                        if (ch == ':')
 
1000
                                                startValue = i + 1;
 
1001
                                        break;
 
1002
                                }
1056
1003
                        } else if (state == stMsStart) {        // <filename>(
1057
1004
                                state = Is0To9(ch) ? stMsDigit : stUnrecognized;
1058
1005
                        } else if (state == stMsDigit) {        // <filename>(<line>
1479
1426
 
1480
1427
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
1481
1428
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc);
1482
 
LexerModule lmPo(SCLEX_PO, ColourisePoDoc, "po", 0, emptyWordListDesc);
1483
1429
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", FoldPropsDoc, emptyWordListDesc);
1484
1430
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);
1485
1431
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);