Coverage Report

Created: 2025-04-11 06:33

/src/w3m/libwc/priv.c
Line
Count
Source (jump to first uncovered line)
1
2
#include "wc.h"
3
#include "wtf.h"
4
5
Str
6
wc_conv_from_priv1(Str is, wc_ces ces)
7
467
{
8
467
    Str os;
9
467
    wc_uchar *sp = (wc_uchar *)is->ptr;
10
467
    wc_uchar *ep = sp + is->length;
11
467
    wc_uchar *p;
12
467
    wc_ccs ccs = WcCesInfo[WC_CCS_INDEX(ces)].gset[1].ccs;
13
14
1.05k
    for (p = sp; p < ep && *p < 0x80; p++)
15
586
  ;
16
467
    if (p == ep)
17
88
  return is;
18
379
    os = Strnew_size(is->length);
19
379
    if (p > sp)
20
34
  Strcat_charp_n(os, is->ptr, (int)(p - sp));
21
22
4.14M
    for (; p < ep; p++) {
23
4.14M
  if (*p & 0x80)
24
3.98M
      wtf_push(os, ccs, (wc_uint32)*p);
25
164k
  else
26
164k
      Strcat_char(os, (char)*p);
27
4.14M
    }
28
379
    return os;
29
467
}
30
31
Str
32
wc_char_conv_from_priv1(wc_uchar c, wc_status *st)
33
0
{
34
0
    Str os = Strnew_size(1);
35
36
0
    if (c & 0x80)
37
0
  wtf_push(os, st->ces_info->gset[1].ccs, (wc_uint32)c);
38
0
    else
39
0
  Strcat_char(os, (char)c);
40
0
    return os;
41
0
}
42
43
Str
44
wc_conv_from_ascii(Str is, wc_ces ces)
45
1.38k
{
46
1.38k
    Str os;
47
1.38k
    wc_uchar *sp = (wc_uchar *)is->ptr;
48
1.38k
    wc_uchar *ep = sp + is->length;
49
1.38k
    wc_uchar *p;
50
51
20.3k
    for (p = sp; p < ep && *p < 0x80; p++)
52
18.9k
  ;
53
1.38k
    if (p == ep)
54
975
  return is;
55
414
    os = Strnew_size(is->length);
56
414
    if (p > sp)
57
115
  Strcat_charp_n(os, is->ptr, (int)(p - sp));
58
59
2.12M
    for (; p < ep; p++) {
60
2.12M
  if (*p & 0x80)
61
1.16M
      wtf_push_unknown(os, p, 1);
62
960k
  else
63
960k
      Strcat_char(os, (char)*p);
64
2.12M
    }
65
414
    return os;
66
1.38k
}
67
68
void
69
wc_push_to_raw(Str os, wc_wchar_t cc, wc_status *st)
70
1.01M
{
71
72
1.01M
    switch (cc.ccs) {
73
198
    case WC_CCS_US_ASCII:
74
1.01M
    case WC_CCS_RAW:
75
1.01M
  Strcat_char(os, (char)cc.code);
76
1.01M
    }
77
1.01M
    return;
78
1.01M
}