v6502
The MOS 6502 Virtual Machine and Toolchain Infrastructure
linectl.h
Go to the documentation of this file.
1 
4 /*
5  * Copyright (c) 2013 Daniel Loffgren
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to
9  * deal in the Software without restriction, including without limitation the
10  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11  * sell copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23  * IN THE SOFTWARE.
24  */
25 
26 #ifndef v6502_linectl_h
27 #define v6502_linectl_h
28 
29 #include <stddef.h>
30 
32 #define CTYPE_CAST (int)
33 
37 void trimtaild(char *str);
38 
40 void trimtailchard(char *str, char token);
41 
43 void trimgreedytaild(char *str, size_t len);
44 
46 void trimgreedytailchard(char *str, char token);
47 
49 char *trimhead(const char *str, size_t len);
50 
52 char *trimheadchar(char *str, char token, size_t len);
53 
55 char *trimheadtospc(const char *str, size_t len);
56 
58 char *strnspc(const char *str, size_t len);
59 
61 char *strnpc(const char *str, size_t len);
62 
66 char *rev_strnspc(const char *stop, const char *start);
67 
71 char *rev_strnpc(const char *stop, const char *start);
72 
77 const char *rev_strnchr(const char *stop, const char *start, const char chr);
78 
80 char *strnchr(const char *str, char chr, size_t len);
83 #endif
void trimtailchard(char *str, char token)
Destructively tail trim at first encounter of token char from the tail end.
Definition: linectl.c:41
char * trimhead(const char *str, size_t len)
Safely trim leading whitespace by pushing pointer.
Definition: linectl.c:73
const char * rev_strnchr(const char *stop, const char *start, const char chr)
Reverse search string for character, safely.
Definition: linectl.c:138
char * rev_strnspc(const char *stop, const char *start)
Reverse search string for space, safely.
Definition: linectl.c:120
char * trimheadtospc(const char *str, size_t len)
Safely trim head til first encounter of whitespace from the head end.
Definition: linectl.c:92
void trimtaild(char *str)
Destructively trim trailing whitespace with NUL.
Definition: linectl.c:32
char * strnpc(const char *str, size_t len)
Search string for first encounter of a printable char (non-whitespace), safely. If no printable chara...
Definition: linectl.c:111
void trimgreedytailchard(char *str, char token)
Destructively tail trim at first encounter of token char from the head end.
Definition: linectl.c:62
void trimgreedytaild(char *str, size_t len)
Destructively tail trim at first encounter of whitespace from the head end.
Definition: linectl.c:53
char * strnchr(const char *str, char chr, size_t len)
Safely search potentially unterminated string for character.
Definition: linectl.c:147
char * strnspc(const char *str, size_t len)
Search string for first encounter of a space, safely. If no whitespace is found, a pointer to the end...
Definition: linectl.c:102
char * trimheadchar(char *str, char token, size_t len)
Safely trim head til first encounter of token char from the head end.
Definition: linectl.c:82
char * rev_strnpc(const char *stop, const char *start)
Reverse search string for printable char (non-whitespace), safely.
Definition: linectl.c:129