diff options
| author | Tyge Løvset <[email protected]> | 2022-01-03 23:04:52 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-01-03 23:04:52 +0100 |
| commit | d37056f1ef380a5649e192436e84a15d1520c5e0 (patch) | |
| tree | 7814b6b0c76163ca4e37303cfbe2a4941039fefa /include/stc/csview.h | |
| parent | c935d2af7cf730fec80695d20529d0b15bda2898 (diff) | |
| download | STC-modified-d37056f1ef380a5649e192436e84a15d1520c5e0.tar.gz STC-modified-d37056f1ef380a5649e192436e84a15d1520c5e0.zip | |
"gcc/clang -O2 -Wall -std=c99 -pedantic" compiles examples with no warnings. More cleanups.
Diffstat (limited to 'include/stc/csview.h')
| -rw-r--r-- | include/stc/csview.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/include/stc/csview.h b/include/stc/csview.h index e1f82272..c1f4c9ac 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -126,16 +126,26 @@ STC_INLINE int csview_cmp(const csview* x, const csview* y) { STC_DEF csview
csview_substr(csview sv, intptr_t pos, size_t n) {
- if (pos < 0) { pos += sv.size; if (pos < 0) pos = 0; }
- if (pos > sv.size) pos = sv.size; if (pos + n > sv.size) n = sv.size - pos;
- sv.str += pos, sv.size = n; return sv;
+ if (pos < 0) {
+ pos += sv.size;
+ if (pos < 0) pos = 0;
+ }
+ if (pos > sv.size) pos = sv.size;
+ if (pos + n > sv.size) n = sv.size - pos;
+ sv.str += pos, sv.size = n;
+ return sv;
}
STC_DEF csview
csview_slice(csview sv, intptr_t p1, intptr_t p2) {
- if (p1 < 0) { p1 += sv.size; if (p1 < 0) p1 = 0; }
- if (p2 < 0) p2 += sv.size; if (p2 > sv.size) p2 = sv.size;
- sv.str += p1, sv.size = p2 > p1 ? p2 - p1 : 0; return sv;
+ if (p1 < 0) {
+ p1 += sv.size;
+ if (p1 < 0) p1 = 0;
+ }
+ if (p2 < 0) p2 += sv.size;
+ if (p2 > sv.size) p2 = sv.size;
+ sv.str += p1, sv.size = p2 > p1 ? p2 - p1 : 0;
+ return sv;
}
STC_DEF csview
@@ -149,4 +159,4 @@ csview_token(csview sv, csview sep, size_t* start) { #endif
#endif
-#undef i_opt
\ No newline at end of file +#undef i_opt
|
