diff options
| author | dam <dam@gudinoff> | 2023-03-23 23:56:53 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2023-03-23 23:56:53 +0000 |
| commit | cd79b5a7e99178d1d51b864bf03d4da611e3e448 (patch) | |
| tree | 131be0a9fd0a12dd741f2cc62fb9e648bd1384a8 | |
| parent | b9971dce185f876b9358d399f23ebb4a1630ef1b (diff) | |
| download | task-time-tracker-cd79b5a7e99178d1d51b864bf03d4da611e3e448.tar.zst task-time-tracker-cd79b5a7e99178d1d51b864bf03d4da611e3e448.zip | |
Converting is_empty_string.
| -rw-r--r-- | ttt.jai | 37 |
1 files changed, 20 insertions, 17 deletions
@@ -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); |
