#include <ctype.h>
#include "log.h"
#include "format.h"
#include "common.h"
#include "stringUtil.h"
Go to the source code of this file.
Functions | |
| char * | addSuffix (char *head, char *suffix) |
| Adds head to suffix. | |
| char * | chopPrefix (char *s) |
| This will replace the first dot in a string with 0, and return the character after this. | |
| char * | chopPrefixAt (char *s, char c) |
| Like chopPrefix, but can chop on any character, not just dot. | |
| void | chopSuffix (char *s) |
| Remove suffix (last dot in string and beyond) if any. | |
| void | chopSuffixAt (char *s, char c) |
| Remove end of string from first occurrence of char c. | |
| int | countChars (char *s, char c) |
| Return number of characters c in string s. | |
| int | countSame (char *a, char *b) |
| Count number of characters that from start in a,b that are same. | |
| char * | emptyForNull (char *s) |
| Return "" if s is NULL, otherwise s. | |
| void | eraseTrailingSpaces (char *s) |
| Replace trailing white space with zeroes. | |
| void | eraseWhiteSpace (char *s) |
| Remove white space from a string. | |
| char * | firstWordInLine (char *line) |
| Returns first word in line if any (white space separated). | |
| int | hasWhiteSpace (char *s) |
| Return 1 if there is white space in string. | |
| char * | insertWordEveryNthPosition (char *string, char *word, int n) |
| Insert word at every nth postion, but not at the end. | |
| char | lastChar (char *s) |
| Return last character in string. | |
| char * | lastWordInLine (char *line) |
| Returns last word in line if any (white space separated). | |
| char * | naForEmpty (char *s) |
| Return n/a if s is "" or NULL, otherwise s. | |
| char * | naForNull (char *s) |
| Return 'n/a' if s is NULL, otherwise s. | |
| char * | nullIfAllSpace (char *s) |
| Return NULL if s is all spaces, otherwise s. | |
| char * | rStringIn (char *needle, char *haystack) |
| Return last position of needle in haystack, or NULL if it's not there. | |
| char * | skipLeadingSpaces (char *s) |
| Return first non-white space. | |
| char * | skipNumeric (char *s) |
| Return first char of s that's not a digit. | |
| char * | skipToNumeric (char *s) |
| Skip up to where numeric digits appear. | |
| char * | skipToSpaces (char *s) |
| Return first white space or NULL if none. | |
| char * | stringBetween (char *start, char *end, char *haystack) |
| Return string between start and end strings, or NULL if none found. | |
| void | stripChar (char *s, char c) |
| Remove all occurences of c from s. | |
| void | subChar (char *s, char oldChar, char newChar) |
| Substitute newChar for oldChar throughout string s. | |
| char * | subString (char *str, int start, int end) |
| Get a substring. | |
| void | toggleCase (char *s, int size) |
| Toggle upper and lower case chars in string. | |
| char * | trimSpaces (char *s) |
| Remove leading and trailing white space. | |
| char * | trueFalseString (int b) |
| Return "true" or "false". | |
Definition in file stringUtil.c.
| char* addSuffix | ( | char * | head, | |
| char * | suffix | |||
| ) |
Adds head to suffix.
In this case returns 'headsuffix'.
Definition at line 347 of file stringUtil.c.
| char* chopPrefix | ( | char * | s | ) |
This will replace the first dot in a string with 0, and return the character after this.
If there is no '.' in the string this will just return the unchanged s passed in.
Definition at line 400 of file stringUtil.c.
| char* chopPrefixAt | ( | char * | s, | |
| char | c | |||
| ) |
Like chopPrefix, but can chop on any character, not just dot.
Definition at line 386 of file stringUtil.c.
| void chopSuffixAt | ( | char * | s, | |
| char | c | |||
| ) |
Remove end of string from first occurrence of char c.
chopSuffixAt(s, '.') is equivalent to regular chopSuffix.
Definition at line 363 of file stringUtil.c.
| char* firstWordInLine | ( | char * | line | ) |
Returns first word in line if any (white space separated).
Puts 0 in place of white space after word.
Definition at line 307 of file stringUtil.c.
| int hasWhiteSpace | ( | char * | s | ) |
Return 1 if there is white space in string.
0 otherwise.
Definition at line 292 of file stringUtil.c.
| char lastChar | ( | char * | s | ) |
Return last character in string.
If s == NULL or s[o] == 0, return 0
Definition at line 85 of file stringUtil.c.
| char* lastWordInLine | ( | char * | line | ) |
Returns last word in line if any (white space separated).
Returns NULL if string is empty. Removes any terminating white space from line.
Definition at line 323 of file stringUtil.c.
| char* stringBetween | ( | char * | start, | |
| char * | end, | |||
| char * | haystack | |||
| ) |
Return string between start and end strings, or NULL if none found.
The first such instance is returned.
Definition at line 60 of file stringUtil.c.
| char* subString | ( | char * | str, | |
| int | start, | |||
| int | end | |||
| ) |
Get a substring.
| str | A valid string (not NULL) | |
| start | Etart index (inclusive) | |
| end | End index (inclusive) |
Definition at line 22 of file stringUtil.c.
1.5.7.1