Coverage Report

Created: 2026-12-01 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/postgis/liblwgeom/lwascii.h
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * PostGIS - Spatial Types for PostgreSQL
4
 * http://postgis.net
5
 * Copyright 2026 Darafei Praliaskouski <me@komzpa.net>
6
 *
7
 * This is free software; you can redistribute and/or modify it under
8
 * the terms of the GNU General Public Licence. See the COPYING file.
9
 *
10
 **********************************************************************/
11
12
#ifndef LWASCII_H
13
#define LWASCII_H 1
14
15
#include <stdbool.h>
16
17
/* ASCII syntax, independent of LC_CTYPE and the signedness of char. */
18
static inline bool
19
lw_ascii_isspace(unsigned char ch)
20
0
{ return ch == ' ' || (ch >= '\t' && ch <= '\r'); }
21
22
static inline bool
23
lw_ascii_isdigit(unsigned char ch)
24
0
{ return ch >= '0' && ch <= '9'; }
25
26
/* Like pg_ascii_tolower and pg_ascii_toupper, leave high bytes intact. */
27
static inline unsigned char
28
lw_ascii_tolower(unsigned char ch)
29
0
{ return ch >= 'A' && ch <= 'Z' ? ch + ('a' - 'A') : ch; }
30
31
static inline unsigned char
32
lw_ascii_toupper(unsigned char ch)
33
0
{ return ch >= 'a' && ch <= 'z' ? ch + ('A' - 'a') : ch; }
34
35
/* Fold ASCII in place without changing the length or touching UTF-8 bytes. */
36
static inline void
37
lw_ascii_strtolower(char *str)
38
0
{
39
0
  for (unsigned char *p = (unsigned char *)str; *p; p++)
40
0
    *p = lw_ascii_tolower(*p);
41
0
}
42
43
#endif /* LWASCII_H */