• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thoni56 / c-xrefactory / 1598

08 Oct 2025 10:56AM UTC coverage: 25.401% (-54.8%) from 80.177%
1598

push

travis-ci

thoni56
Add llvm-cov to gcov conversion for Emacs cov-mode support

- Create llvm2gcov.sh script to convert Apple coverage to traditional format
- Parse llvm-cov show output and transform to gcov-compatible format
- Handle count formats including 'k' suffix (4.18k -> 4180)
- Generate proper gcov headers for Emacs compatibility
- Integrate conversion into Darwin gcov target
- Preserve full Emacs fringe coverage display functionality

Now Darwin users get both:
- Superior Apple coverage accuracy
- Full Emacs cov-mode integration

4019 of 15822 relevant lines covered (25.4%)

3416.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

53.13
src/encoding.c
1
#include "encoding.h"
2

3
#include "options.h"
4

5

6
#define EDITOR_ENCODING_WALK_THROUGH_BUFFER(buffer, command) {          \
7
        unsigned char *s, *d, *max;                                     \
8
        unsigned char *text = (unsigned char *)getTextInEditorBuffer(buffer); \
9
        max = text + getSizeOfEditorBuffer(buffer);                     \
10
        for (s=d=text; s<max; s++) {                                    \
11
            command;                                                    \
12
            d++;                                                        \
13
        }                                                               \
14
        setSizeOfEditorBuffer(buffer, d - text);                        \
15
    }
16

17
#define EDITOR_ENCODING_CR_LF_OR_CR_TO_LF_CONVERSION(s,d)   \
18
    if (*s == '\r') {                                       \
19
        if (s+1<max && *(s+1)=='\n') {                      \
20
            s++;                                            \
21
            *d = *s;                                        \
22
        } else {                                            \
23
            *d = '\n';                                      \
24
        }                                                   \
25
    }
26
#define EDITOR_ENCODING_CR_LF_TO_LF_CONVERSION(s,d) \
27
    if (*s == '\r' && s+1<max && *(s+1)=='\n') {    \
28
        s++;                                        \
29
        *d = *s;                                    \
30
    }
31
#define EDITOR_ENCODING_CR_TO_LF_CONVERSION(s,d)      \
32
    if (*s == '\r') {                                 \
33
        *d = '\n';                                    \
34
    }
35

36
static bool convertUtf8(unsigned char **srcP, unsigned char **dstP) {
97✔
37
    if (**(srcP)&0x80) {
97✔
38
        unsigned z = **srcP;
2✔
39
        if (z >= 0xC2 && z <= 0xDF) {
2✔
40
            *srcP += 1;  // 2-byte sequence (U+0080 - U+07FF)
2✔
41
        } else if (z >= 0xE0 && z <= 0xEF) {
×
42
            *srcP += 2;  // 3-byte sequence (U+0800 - U+FFFF)
×
43
        } else if (z >= 0xF0 && z <= 0xF4) {
×
44
            *srcP += 3;  // 4-byte sequence (U+10000 - U+10FFFF)
×
45
        } else {
46
            // Illegal UTF-8, just skip one byte for minimal damage
47
            *srcP += 1;
×
48
        }
49

50
        **dstP = ' '; // Replace the sequence with a single space
2✔
51
        return true;
2✔
52
    }
53
    return false;
95✔
54
}
55

56

57
static void applyUtf8CrLfCrConversion(EditorBuffer *buffer) {
×
58
    EDITOR_ENCODING_WALK_THROUGH_BUFFER(buffer, {
×
59
            if (convertUtf8(&s, &d)) ;
60
            else EDITOR_ENCODING_CR_LF_OR_CR_TO_LF_CONVERSION(s,d)
61
                else
62
                    *d = *s;
63
        });
64
}
65

66
static void applyUtf8CrLfConversion(EditorBuffer *buffer) {
×
67
    EDITOR_ENCODING_WALK_THROUGH_BUFFER(buffer, {
×
68
            if (convertUtf8(&s, &d)) ;
69
            else EDITOR_ENCODING_CR_LF_TO_LF_CONVERSION(s,d)
70
                else
71
                    *d = *s;
72
        });
73
}
74

75
static void applyUtf8CrConversion(EditorBuffer *buffer) {
×
76
    EDITOR_ENCODING_WALK_THROUGH_BUFFER(buffer, {
×
77
            if (convertUtf8(&s, &d)) ;
78
            else EDITOR_ENCODING_CR_TO_LF_CONVERSION(s,d)
79
                else
80
                    *d = *s;
81
        });
82
}
83

84
static void applyUtf8Conversion(EditorBuffer *buffer) {
2✔
85
    EDITOR_ENCODING_WALK_THROUGH_BUFFER(buffer, {
99✔
86
            if (convertUtf8(&s, &d)) ;
87
            else
88
                *d = *s;
89
                });
90
}
2✔
91

92

93
void performEncodingAdjustments(EditorBuffer *buffer) {
2✔
94
    // utf-8
95
    if ((options.eolConversion&CR_LF_EOL_CONVERSION)
2✔
96
        && (options.eolConversion & CR_EOL_CONVERSION)) {
×
97
        applyUtf8CrLfCrConversion(buffer);
×
98
    } else if (options.eolConversion & CR_LF_EOL_CONVERSION) {
2✔
99
        applyUtf8CrLfConversion(buffer);
×
100
    } else if (options.eolConversion & CR_EOL_CONVERSION) {
2✔
101
        applyUtf8CrConversion(buffer);
×
102
    } else {
103
        applyUtf8Conversion(buffer);
2✔
104
    }
105
}
2✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc