LCOV - code coverage report
Current view: top level - util - misc.cpp (source / functions) Coverage Total Hit
Test: gjs- Code Coverage Lines: 82.4 % 17 14
Test Date: 2024-04-20 17:42:51 Functions: 100.0 % 2 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 70.0 % 10 7

             Branch data     Line data    Source code
       1                 :             : /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
       2                 :             : // SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
       3                 :             : // SPDX-FileCopyrightText: 2008 litl, LLC
       4                 :             : 
       5                 :             : #include <config.h>
       6                 :             : 
       7                 :             : #include <glib.h>
       8                 :             : 
       9                 :             : #include "util/misc.h"
      10                 :             : 
      11                 :             : bool
      12                 :         484 : gjs_environment_variable_is_set(const char *env_variable_name)
      13                 :             : {
      14                 :             :     const char *s;
      15                 :             : 
      16                 :         484 :     s = g_getenv(env_variable_name);
      17         [ +  - ]:         484 :     if (!s)
      18                 :         484 :         return false;
      19                 :             : 
      20         [ #  # ]:           0 :     if (*s == '\0')
      21                 :           0 :         return false;
      22                 :             : 
      23                 :           0 :     return true;
      24                 :             : }
      25                 :             : 
      26                 :             : /** gjs_g_strv_concat:
      27                 :             :  *
      28                 :             :  * Concate an array of string arrays to one string array. The strings in each
      29                 :             :  * array is copied to the resulting array.
      30                 :             :  *
      31                 :             :  * @strv_array: array of 0-terminated arrays of strings. Null elements are
      32                 :             :  * allowed.
      33                 :             :  * @len: number of arrays in @strv_array
      34                 :             :  *
      35                 :             :  * Returns: (transfer full): a newly allocated 0-terminated array of strings.
      36                 :             :  */
      37                 :           2 : char** gjs_g_strv_concat(char*** strv_array, int len) {
      38                 :           2 :     GPtrArray* array = g_ptr_array_sized_new(16);
      39                 :             : 
      40         [ +  + ]:           6 :     for (int i = 0; i < len; i++) {
      41                 :           4 :         char** strv = strv_array[i];
      42         [ +  + ]:           4 :         if (!strv)
      43                 :           1 :             continue;
      44                 :             : 
      45         [ +  + ]:           5 :         for (int j = 0; strv[j]; ++j)
      46                 :           4 :             g_ptr_array_add(array, g_strdup(strv[j]));
      47                 :             :     }
      48                 :             : 
      49                 :           2 :     g_ptr_array_add(array, nullptr);
      50                 :             : 
      51                 :           2 :     return reinterpret_cast<char**>(g_ptr_array_free(array, false));
      52                 :             : }
        

Generated by: LCOV version 2.0-1