This file is indexed.

/usr/share/libustr-dev/ustr-split-code.h is in libustr-dev 1.0.4-3ubuntu2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/* Copyright (c) 2007 Paul Rosenfeld
                      James Antill -- See LICENSE file for terms. */
#ifndef USTR_SPLIT_H
#error " Include ustr-split.h before this file."
#endif

#if !defined(USTR_FMT_INTERNAL_H) && !defined(USTR_IO_H)
#include <stdio.h>
#endif

USTR_CONF_i_PROTO
struct Ustr *ustrp__split_buf(struct Ustr_pool *p,
                              const struct Ustr *s1, size_t *poff, 
                              const void *sep, size_t slen, struct Ustr *ret,
                              unsigned int flags)
{
  size_t len = ustr_len(s1);
  size_t off = *poff;
  size_t found_pos = 0;
  size_t ret_len   = 0;
  
  USTR_ASSERT(ustrp__assert_valid(!!p, s1));

  USTR_ASSERT_RET(off <= len, USTR_NULL);

  if (!slen || (off == len))
  {
    ustrp__free(p, ret);
    errno = 0; /* only way to tell between FAILURE and END */
    return (USTR_NULL);
  }
  
  /* Separator not found, just return the rest of the string */
  if (!(found_pos = ustr_srch_buf_fwd(s1, off, sep, slen)))
  {
    ret_len = len - off;
    *poff   = len;
    goto copy_buf;
  }

  /* Set the offset for the next, must skip sep */
  *poff = (found_pos - 1) + slen;
  if (!(flags & (USTR_FLAG_SPLIT_RET_SEP | USTR_FLAG_SPLIT_RET_NON)))
  {
    const char *ptr = ustr_cstr(s1);
    
    while (((len - *poff) >= slen) && !memcmp(ptr + *poff, sep, slen))
      *poff += slen;
  }
  
  /* If we don't wish to return blanks or separators, we might get "a,,b" with
   * sep="," so we need to skip the first "found" separator -- so just try
   * again */
  if (((found_pos - 1) == off) &&
      !(flags & (USTR_FLAG_SPLIT_RET_SEP | USTR_FLAG_SPLIT_RET_NON)))
    return (ustrp__split_buf(p, s1, poff, sep, slen, ret, flags));

  ret_len = (found_pos - 1) - off;
  if (flags & USTR_FLAG_SPLIT_RET_SEP) /* Include sep in the return value */
    ret_len += slen;
  
 copy_buf:
  if (ret)
  {
    if (!ustrp__set_subustr(p, &ret, s1, off + 1, ret_len))
    {
      ustrp__free(p, ret);
      return (USTR_NULL);
    }
    
    return (ret);
  }
  
  if (flags & USTR_FLAG_SPLIT_KEEP_CONF)
    return (ustrp__dup_subustr(p, s1, off + 1, ret_len));

  return (ustrp__dupx_buf(p, USTR__DUPX_DEF, ustr_cstr(s1) + off, ret_len));
}
USTR_CONF_I_PROTO
struct Ustr *ustr_split_buf(const struct Ustr *s1, size_t *off, 
                            const void *sep, size_t slen, struct Ustr *ret,
                            unsigned int flags)
{ return (ustrp__split_buf(0, s1, off, sep, slen, ret, flags)); }
USTR_CONF_I_PROTO
struct Ustrp *ustrp_split_buf(struct Ustr_pool *p,
                              const struct Ustrp *s1, size_t *off, 
                              const void *sep, size_t slen, struct Ustrp *ret,
                              unsigned int flags)
{ return (USTRP(ustrp__split_buf(p, &s1->s, off, sep, slen, &ret->s, flags))); }

USTR_CONF_I_PROTO
struct Ustr *ustr_split(const struct Ustr *s1, size_t *off, 
                        const struct Ustr *sep, struct Ustr *ret,
                        unsigned int flags)
{
  USTR_ASSERT(ustrp__assert_valid(0, sep));
  return (ustrp__split_buf(0, s1,off,ustr_cstr(sep),ustr_len(sep), ret, flags));
}

USTR_CONF_I_PROTO
struct Ustrp *ustrp_split(struct Ustr_pool *p,
                          const struct Ustrp *s1, size_t *off, 
                          const struct Ustrp *sep, struct Ustrp *ret,
                          unsigned int flags)
{
  USTR_ASSERT(ustrp_assert_valid(sep));
  return (USTRP(ustrp__split_buf(p, &s1->s, off, ustrp_cstr(sep),ustrp_len(sep),
                                 &ret->s, flags)));
}

USTR_CONF_i_PROTO
struct Ustr *ustrp__split_spn_chrs(struct Ustr_pool *p, const struct Ustr *s1, 
                                   size_t *poff, const char *seps, size_t slen,
                                   struct Ustr *ret, unsigned int flags)
{
  size_t len = ustr_len(s1);
  size_t off = *poff;
  size_t spn = 0;
  size_t sep = 0;
  size_t ret_len = 0;
  
  USTR_ASSERT(ustrp__assert_valid(!!p, s1));

  USTR_ASSERT_RET(off <= len, USTR_NULL);

  if (!slen || (off == len))
  {
    ustrp__free(p, ret);
    errno = 0; /* only way to tell between FAILURE and END */
    return (USTR_NULL);
  }

  spn = ustr_cspn_chrs_fwd(s1, off, seps, slen);
  if (!spn && !(flags & (USTR_FLAG_SPLIT_RET_SEP | USTR_FLAG_SPLIT_RET_NON)))
  {
    *poff += ustr_spn_chrs_fwd(s1, off, seps, slen);
    return (ustrp__split_spn_chrs(p, s1, poff, seps, slen, ret, flags));
  }

  /* if there's any data left the first byte must be in seps */
  
  if (flags & (USTR_FLAG_SPLIT_RET_SEP | USTR_FLAG_SPLIT_RET_NON))
    sep = !((off + spn) == len);
  else
    sep = ustr_spn_chrs_fwd(s1, off + spn, seps, slen);
  USTR_ASSERT(!sep == !ustr_spn_chrs_fwd(s1, off + spn, seps, slen));
  
  *poff += spn + sep;
  
  ret_len = spn;
  if (flags & USTR_FLAG_SPLIT_RET_SEP) /* Include seps in the return value */
    ret_len += sep;
  
  if (ret)
  {
    if (!ustrp__set_subustr(p, &ret, s1, off + 1, ret_len))
      return (USTR_NULL);
    
    return (ret);
  }
  
  if (flags & USTR_FLAG_SPLIT_KEEP_CONF)
    return (ustrp__dup_subustr(p, s1, off + 1, ret_len));

  return (ustrp__dupx_buf(p, USTR__DUPX_DEF, ustr_cstr(s1) + off, ret_len));
}
USTR_CONF_I_PROTO
struct Ustr *ustr_split_spn_chrs(const struct Ustr *s1, size_t *poff, 
                                 const char *seps, size_t slen,
                                 struct Ustr *ret, unsigned int flags)
{ return (ustrp__split_spn_chrs(0, s1, poff, seps, slen, ret, flags)); }
USTR_CONF_I_PROTO
struct Ustrp *ustrp_split_spn_chrs(struct Ustr_pool *p, const struct Ustrp *s1,
                                   size_t *poff, const char *seps, size_t slen,
                                   struct Ustrp *ret, unsigned int flags)
{ return (USTRP(ustrp__split_spn_chrs(p, &s1->s, poff, seps, slen,
                                      &ret->s, flags))); }

USTR_CONF_I_PROTO
struct Ustr *ustr_split_spn(const struct Ustr *s1, size_t *off, 
                            const struct Ustr *sep, struct Ustr *ret,
                            unsigned int flags)
{
  USTR_ASSERT(ustrp__assert_valid(0, sep));
  return (ustrp__split_spn_chrs(0, s1, off, ustr_cstr(sep), ustr_len(sep),
                                ret, flags));
}

USTR_CONF_I_PROTO
struct Ustrp *ustrp_split_spn(struct Ustr_pool *p,
                              const struct Ustrp *s1, size_t *off, 
                              const struct Ustrp *sep, struct Ustrp *ret,
                              unsigned int flags)
{
  USTR_ASSERT(ustrp_assert_valid(sep));
  return (USTRP(ustrp__split_spn_chrs(p, &s1->s, off, ustrp_cstr(sep),
                                      ustrp_len(sep), &ret->s, flags)));
}