aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordam <dam@gudinoff>2023-03-23 23:56:53 +0000
committerdam <dam@gudinoff>2023-03-23 23:56:53 +0000
commitcd79b5a7e99178d1d51b864bf03d4da611e3e448 (patch)
tree131be0a9fd0a12dd741f2cc62fb9e648bd1384a8
parentb9971dce185f876b9358d399f23ebb4a1630ef1b (diff)
downloadtask-time-tracker-cd79b5a7e99178d1d51b864bf03d4da611e3e448.tar.zst
task-time-tracker-cd79b5a7e99178d1d51b864bf03d4da611e3e448.zip
Converting is_empty_string.
-rw-r--r--ttt.jai37
1 files changed, 20 insertions, 17 deletions
diff --git a/ttt.jai b/ttt.jai
index 08f471a..e15b00f 100644
--- a/ttt.jai
+++ b/ttt.jai
@@ -218,29 +218,32 @@ truncate_string :: (str: string, length: s64, $encoding: Text_Encoding = .UTF8)
memset(data + length, 0, count - length);
return length;
}
-/*
+
// Returns true when the string is empty or consists of white space characters.
-bool is_empty_string(const char *string) {
- for (int idx = 0; string[idx] != '\0'; idx++) {
- switch(string[idx]) {
- case ' ':
- case '\t':
- case '\v':
- case '\f':
- case '\r':
- case '\n':
- break;
- default:
+is_empty_string :: (str: string) -> bool {
+ // TODO TEST
+ WIP
+ for 0..str.count-1 {
+ if str[it] == {;
+ case #char "\0"; #through;
+ case #char "\t"; #through; // horizontal tab
+ case #char "\n"; #through; // line feed
+ case #char "\x0B"; #through; // vertical tabulation
+ case #char "\x0C"; #through; // form feed
+ case #char "\r"; #through; // carriage return
+ case #char " ";
+ continue;
+ case;
return false;
}
}
return true;
}
-
+/*
// Uses strchr to replace all instances of find by replace.
// Returns string.
-char *replace_char(char *string, char find, char replace) { // TODO Use modules/String/module.jai:replace_chars
-
+replace_char :: (str: string, char find, char replace) -> string { // TODO Use modules/String/module.jai:replace_chars
+ // TODO replace_chars :: (s: string, chars: string, replacement: u8) {
char *idx = string;
while((idx = strchr(idx, find)) != NULL) {
*idx = replace;
@@ -248,7 +251,7 @@ char *replace_char(char *string, char find, char replace) { // TODO Use modules/
}
return string;
}
-
+/*
// Prints, on row y and column x, the time using 5 characters centered on space.
// Returns the result of a call to mvprintw.
int mvprintw_time(int y, int x, intmax_t time, int space) {
@@ -1313,7 +1316,7 @@ main :: () {
}
- db : Database;
+ db: Database;
{
import_from_csv(*db, ar_file_path);