1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: remove byteptr and charptr; replace them with &byte and &char

This commit is contained in:
Alexander Medvednikov
2021-04-04 17:43:32 +03:00
parent 8dd4a63913
commit 57e6138a61
32 changed files with 250 additions and 226 deletions

View File

@@ -37,7 +37,7 @@ pub fn parse_rfc2822(s string) ?Time {
mm := pos / 3 + 1
unsafe {
tmstr := malloc(s.len * 2)
count := C.snprintf(charptr(tmstr), (s.len * 2), '%s-%02d-%s %s', fields[3].str,
count := C.snprintf(&char(tmstr), (s.len * 2), c'%s-%02d-%s %s', fields[3].str,
mm, fields[1].str, fields[4].str)
return parse(tos(tmstr, count))
}
@@ -50,7 +50,7 @@ const (
fn parse_iso8601_date(s string) ?(int, int, int) {
year, month, day, dummy := 0, 0, 0, byte(0)
count := unsafe { C.sscanf(charptr(s.str), '%4d-%2d-%2d%c', &year, &month, &day, &dummy) }
count := unsafe { C.sscanf(&char(s.str), '%4d-%2d-%2d%c', &year, &month, &day, &dummy) }
if count != 3 {
return time.err_invalid_8601
}
@@ -66,14 +66,14 @@ fn parse_iso8601_time(s string) ?(int, int, int, int, i64, bool) {
offset_hour := 0
offset_minute := 0
mut count := unsafe {
C.sscanf(charptr(s.str), '%2d:%2d:%2d.%6d%c%2d:%2d', &hour_, &minute_, &second_,
&microsecond_, charptr(&plus_min_z), &offset_hour, &offset_minute)
C.sscanf(&char(s.str), '%2d:%2d:%2d.%6d%c%2d:%2d', &hour_, &minute_, &second_,
&microsecond_, &char(&plus_min_z), &offset_hour, &offset_minute)
}
// Missread microsecond ([Sec Hour Minute].len == 3 < 4)
if count < 4 {
count = unsafe {
C.sscanf(charptr(s.str), '%2d:%2d:%2d%c%2d:%2d', &hour_, &minute_, &second_,
charptr(&plus_min_z), &offset_hour, &offset_minute)
C.sscanf(&char(s.str), '%2d:%2d:%2d%c%2d:%2d', &hour_, &minute_, &second_,
&char(&plus_min_z), &offset_hour, &offset_minute)
}
count++ // Increment count because skipped microsecond
}