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

taosdata / TDengine / #4720

08 Sep 2025 08:43AM UTC coverage: 58.139% (-0.6%) from 58.762%
#4720

push

travis-ci

web-flow
Merge pull request #32881 from taosdata/enh/add-new-windows-ci

fix(ci): update workflow reference to use new Windows CI YAML

133181 of 292179 branches covered (45.58%)

Branch coverage included in aggregate %.

201691 of 283811 relevant lines covered (71.07%)

5442780.71 hits per line

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

33.33
/source/util/src/tenv.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#define _DEFAULT_SOURCE
17
#include "tconfig.h"
18
#include "tenv.h"
19

20
static char toLowChar(char c) { return (c > 'Z' || c < 'A' ? c : (c - 'A' + 'a')); }
×
21

22
int32_t taosEnvNameToCfgName(const char *envNameStr, char *cfgNameStr, int32_t cfgNameMaxLen) {
384,807✔
23
  if (envNameStr == NULL || cfgNameStr == NULL) return -1;
384,807!
24
  char *p = cfgNameStr;
384,807✔
25
  if (envNameStr[0] != 'T' || envNameStr[1] != 'A' || envNameStr[2] != 'O' || envNameStr[3] != 'S' ||
384,807!
26
      envNameStr[4] != '_') {
×
27
    cfgNameStr[0] = '\0';
384,807✔
28
    return TSDB_CODE_INVALID_PARA;
384,807✔
29
  }
30
  envNameStr += 5;
×
31
  if (*envNameStr != '\0') {
×
32
    *p = toLowChar(*envNameStr);
×
33
    p++;
×
34
    envNameStr++;
×
35
  }
36

37
  for (size_t i = 1; i < cfgNameMaxLen && *envNameStr != '\0'; i++) {
×
38
    if (*envNameStr == '_') {
×
39
      envNameStr++;
×
40
      *p = *envNameStr;
×
41
      if (*envNameStr == '\0') break;
×
42
    } else {
43
      *p = toLowChar(*envNameStr);
×
44
    }
45
    p++;
×
46
    envNameStr++;
×
47
  }
48

49
  *p = '\0';
×
50
  return strlen(cfgNameStr);
×
51
}
52

53
int32_t taosEnvToCfg(const char *envStr, char *cfgStr, int32_t cfgStrLen) {
384,807✔
54
  if (envStr == NULL || cfgStr == NULL) {
384,807!
55
    return TSDB_CODE_INVALID_PARA;
×
56
  }
57
  if (cfgStr != envStr) {
384,807!
58
    tstrncpy(cfgStr, envStr, cfgStrLen);
×
59
  }
60
  char *p = strchr(cfgStr, '=');
384,807✔
61

62
  if (p != NULL) {
384,807!
63
    char buf[CFG_NAME_MAX_LEN];
64
    if (*(p + 1) == '\'') {
384,807!
65
      *(p + 1) = ' ';
×
66
      char *pEnd = &cfgStr[strlen(cfgStr) - 1];
×
67
      if (*pEnd == '\'') *pEnd = '\0';
×
68
    }
69
    *p = '\0';
384,807✔
70
    int32_t cfgNameLen = taosEnvNameToCfgName(cfgStr, buf, CFG_NAME_MAX_LEN);
384,807✔
71
    if (cfgNameLen > 0) {
384,807!
72
      memcpy(cfgStr, buf, cfgNameLen);
×
73
      memset(&cfgStr[cfgNameLen], ' ', p - cfgStr - cfgNameLen + 1);
×
74
    } else {
75
      *cfgStr = '\0';
384,807✔
76
      return TSDB_CODE_INVALID_PARA;
384,807✔
77
    }
78
  }
79
  return strlen(cfgStr);
×
80
}
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

© 2025 Coveralls, Inc