mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Rename I/O available methods to length
This commit is contained in:
1 parent
79b923c322
commit
be8542e313
15 files changed
+149
-152
No files matched your search
+70
-70
@@ -138,7 +138,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
|
||||
while.outer true {
|
||||
while.goto_parsed_a_leaf_value true {{
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue.outer
|
||||
}
|
||||
@@ -148,10 +148,10 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
c = 0
|
||||
class = 0
|
||||
while.ws true,
|
||||
inv args.dst.available() > 0,
|
||||
post args.src.available() > 0,
|
||||
inv args.dst.length() > 0,
|
||||
post args.src.length() > 0,
|
||||
{
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if whitespace_length > 0 {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -195,7 +195,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
continued: 0,
|
||||
length: whitespace_length)
|
||||
whitespace_length = 0
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
continue.outer
|
||||
}
|
||||
}
|
||||
@@ -209,8 +209,8 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
// know these facts; deleting these assertions should still compile)
|
||||
// but are listed explicitly to guard against future edits to the code
|
||||
// above inadvertently invalidating these assertions.
|
||||
assert args.dst.available() > 0
|
||||
assert args.src.available() > 0
|
||||
assert args.dst.length() > 0
|
||||
assert args.src.length() > 0
|
||||
|
||||
if class == CLASS_STRING {
|
||||
// -------- BEGIN parse strings.
|
||||
@@ -226,16 +226,16 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
args.src.skip_u32_fast!(actual: 1, worst_case: 1)
|
||||
|
||||
while.string_loop_outer true {
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue.string_loop_outer
|
||||
}
|
||||
|
||||
string_length = 0
|
||||
while.string_loop_inner true,
|
||||
pre args.dst.available() > 0,
|
||||
pre args.dst.length() > 0,
|
||||
{
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if string_length > 0 {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -256,9 +256,9 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
|
||||
// As an optimization, consume non-special ASCII 4 bytes at
|
||||
// a time.
|
||||
while args.src.available() > 4,
|
||||
inv args.dst.available() > 0,
|
||||
inv args.src.available() > 0,
|
||||
while args.src.length() > 4,
|
||||
inv args.dst.length() > 0,
|
||||
inv args.src.length() > 0,
|
||||
{
|
||||
c4 = args.src.peek_u32le()
|
||||
if 0x00 <> (LUT_CHARS[0xFF & (c4 >> 0)] |
|
||||
@@ -324,13 +324,13 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
continued: 1,
|
||||
length: string_length)
|
||||
string_length = 0
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
continue.string_loop_outer
|
||||
}
|
||||
}
|
||||
assert args.dst.available() > 0
|
||||
assert args.dst.length() > 0
|
||||
|
||||
if args.src.available() < 2 {
|
||||
if args.src.length() < 2 {
|
||||
if args.src.is_closed() {
|
||||
return "#bad backslash-escape"
|
||||
}
|
||||
@@ -365,7 +365,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
|
||||
} else if c == 'u' {
|
||||
// -------- BEGIN backslash-u.
|
||||
if args.src.available() < 6 {
|
||||
if args.src.length() < 6 {
|
||||
if args.src.is_closed() {
|
||||
return "#bad backslash-escape"
|
||||
}
|
||||
@@ -417,7 +417,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
// peeked 6 bytes for the high surrogate. We
|
||||
// need 12 in total: another 8 bytes at an
|
||||
// offset of 4.
|
||||
if args.src.available() < 12 {
|
||||
if args.src.length() < 12 {
|
||||
if args.src.is_closed() {
|
||||
if this.quirks[QUIRK_REPLACE_INVALID_UNICODE - QUIRKS_BASE] {
|
||||
args.src.skip_u32_fast!(actual: 6, worst_case: 6)
|
||||
@@ -484,7 +484,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
}
|
||||
|
||||
if this.quirks[QUIRK_REPLACE_INVALID_UNICODE - QUIRKS_BASE] {
|
||||
if args.src.available() < 6 {
|
||||
if args.src.length() < 6 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip_u32_fast!(actual: 6, worst_case: 6)
|
||||
@@ -501,7 +501,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
} else if (c == 'U') and
|
||||
this.quirks[QUIRK_ALLOW_BACKSLASH_CAPITAL_U - QUIRKS_BASE] {
|
||||
// -------- BEGIN backslash-capital-u.
|
||||
if args.src.available() < 10 {
|
||||
if args.src.length() < 10 {
|
||||
if args.src.is_closed() {
|
||||
return "#bad backslash-escape"
|
||||
}
|
||||
@@ -569,7 +569,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
} else if (c == 'x') {
|
||||
// -------- BEGIN backslash-x
|
||||
if this.quirks[QUIRK_ALLOW_BACKSLASH_X_AS_CODE_POINTS - QUIRKS_BASE] {
|
||||
if args.src.available() < 4 {
|
||||
if args.src.length() < 4 {
|
||||
if args.src.is_closed() {
|
||||
return "#bad backslash-escape"
|
||||
}
|
||||
@@ -604,7 +604,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
length: 4)
|
||||
continue.string_loop_outer
|
||||
} else if this.quirks[QUIRK_ALLOW_BACKSLASH_X_AS_BYTES - QUIRKS_BASE] {
|
||||
if args.src.available() < 4 {
|
||||
if args.src.length() < 4 {
|
||||
if args.src.is_closed() {
|
||||
return "#bad backslash-escape"
|
||||
}
|
||||
@@ -615,8 +615,8 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
}
|
||||
|
||||
backslash_x_length = 0
|
||||
while (backslash_x_length <= 0xFFFB) and (args.src.available() >= 4),
|
||||
inv args.dst.available() > 0,
|
||||
while (backslash_x_length <= 0xFFFB) and (args.src.length() >= 4),
|
||||
inv args.dst.length() > 0,
|
||||
{
|
||||
backslash_x_string = args.src.peek_u32le()
|
||||
backslash_x_ok = 0x80
|
||||
@@ -654,7 +654,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
return "#bad backslash-escape"
|
||||
|
||||
} else if char == 0x03 { // 2-byte UTF-8.
|
||||
if args.src.available() < 2 {
|
||||
if args.src.length() < 2 {
|
||||
if string_length > 0 {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -664,7 +664,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
continued: 1,
|
||||
length: string_length)
|
||||
string_length = 0
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
continue.string_loop_outer
|
||||
}
|
||||
}
|
||||
@@ -707,7 +707,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
}
|
||||
|
||||
} else if char == 0x04 { // 3-byte UTF-8.
|
||||
if args.src.available() < 3 {
|
||||
if args.src.length() < 3 {
|
||||
if string_length > 0 {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -717,7 +717,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
continued: 1,
|
||||
length: string_length)
|
||||
string_length = 0
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
continue.string_loop_outer
|
||||
}
|
||||
}
|
||||
@@ -765,7 +765,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
}
|
||||
|
||||
} else if char == 0x05 { // 4-byte UTF-8.
|
||||
if args.src.available() < 4 {
|
||||
if args.src.length() < 4 {
|
||||
if string_length > 0 {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -775,7 +775,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
continued: 1,
|
||||
length: string_length)
|
||||
string_length = 0
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
continue.string_loop_outer
|
||||
}
|
||||
}
|
||||
@@ -831,7 +831,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
continued: 1,
|
||||
length: string_length)
|
||||
string_length = 0
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
continue.string_loop_outer
|
||||
}
|
||||
}
|
||||
@@ -864,14 +864,14 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
|
||||
// Emit the trailing '"'.
|
||||
while true {
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if args.src.is_closed() {
|
||||
return "#bad input"
|
||||
}
|
||||
yield? base."$short read"
|
||||
continue
|
||||
}
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue
|
||||
}
|
||||
@@ -936,7 +936,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
} else if class == CLASS_NUMBER {
|
||||
// -------- BEGIN parse numbers.
|
||||
while true,
|
||||
pre args.dst.available() > 0,
|
||||
pre args.dst.length() > 0,
|
||||
{
|
||||
number_length = this.decode_number!(src: args.src)
|
||||
number_status = number_length >> 8
|
||||
@@ -978,8 +978,8 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
return "#unsupported number length"
|
||||
} else {
|
||||
yield? base."$short read"
|
||||
while args.dst.available() <= 0,
|
||||
post args.dst.available() > 0,
|
||||
while args.dst.length() <= 0,
|
||||
post args.dst.length() > 0,
|
||||
{
|
||||
yield? base."$short write"
|
||||
} endwhile
|
||||
@@ -1151,7 +1151,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
base.TOKEN__VBD__LITERAL__FALSE,
|
||||
continued: 0,
|
||||
length: 5)
|
||||
if args.src.available() < 5 {
|
||||
if args.src.length() < 5 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip_u32_fast!(actual: 5, worst_case: 5)
|
||||
@@ -1170,7 +1170,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
base.TOKEN__VBD__LITERAL__TRUE,
|
||||
continued: 0,
|
||||
length: 4)
|
||||
if args.src.available() < 4 {
|
||||
if args.src.length() < 4 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip_u32_fast!(actual: 4, worst_case: 4)
|
||||
@@ -1189,7 +1189,7 @@ pub func decoder.decode_tokens?(dst: base.token_writer, src: base.io_reader, wor
|
||||
base.TOKEN__VBD__LITERAL__NULL,
|
||||
continued: 0,
|
||||
length: 4)
|
||||
if args.src.available() < 4 {
|
||||
if args.src.length() < 4 {
|
||||
return "#internal error: inconsistent I/O"
|
||||
}
|
||||
args.src.skip_u32_fast!(actual: 4, worst_case: 4)
|
||||
@@ -1239,7 +1239,7 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
n = 0
|
||||
|
||||
// Peek.
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if not args.src.is_closed() {
|
||||
n |= 0x300
|
||||
}
|
||||
@@ -1249,14 +1249,14 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
|
||||
// Scan the optional minus sign.
|
||||
if c <> '-' {
|
||||
assert args.src.available() > 0
|
||||
assert args.src.length() > 0
|
||||
assert n <= 1
|
||||
} else {
|
||||
n += 1
|
||||
args.src.skip_u32_fast!(actual: 1, worst_case: 1)
|
||||
|
||||
// Peek.
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if not args.src.is_closed() {
|
||||
n |= 0x300
|
||||
}
|
||||
@@ -1265,7 +1265,7 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
}
|
||||
c = args.src.peek_u8()
|
||||
|
||||
assert args.src.available() > 0
|
||||
assert args.src.length() > 0
|
||||
assert n <= 1
|
||||
}
|
||||
|
||||
@@ -1283,7 +1283,7 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
}
|
||||
|
||||
// Peek.
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if not args.src.is_closed() {
|
||||
n |= 0x300
|
||||
}
|
||||
@@ -1293,7 +1293,7 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
|
||||
// Scan the optional fraction.
|
||||
if c <> '.' {
|
||||
assert args.src.available() > 0
|
||||
assert args.src.length() > 0
|
||||
assert n <= 99
|
||||
} else {
|
||||
if n >= 99 {
|
||||
@@ -1310,7 +1310,7 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
}
|
||||
|
||||
// Peek.
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if not args.src.is_closed() {
|
||||
n |= 0x300
|
||||
}
|
||||
@@ -1318,7 +1318,7 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
}
|
||||
c = args.src.peek_u8()
|
||||
|
||||
assert args.src.available() > 0
|
||||
assert args.src.length() > 0
|
||||
assert n <= 99
|
||||
}
|
||||
|
||||
@@ -1336,7 +1336,7 @@ pri func decoder.decode_number!(src: base.io_reader) base.u32[..= 0x3FF] {
|
||||
assert n <= 99
|
||||
|
||||
// Peek.
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if not args.src.is_closed() {
|
||||
n |= 0x300
|
||||
}
|
||||
@@ -1373,7 +1373,7 @@ pri func decoder.decode_digits!(src: base.io_reader, n: base.u32[..= 99]) base.u
|
||||
|
||||
n = args.n
|
||||
while true {
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if not args.src.is_closed() {
|
||||
n |= 0x300
|
||||
}
|
||||
@@ -1415,11 +1415,11 @@ pri func decoder.decode_leading?(dst: base.token_writer, src: base.io_reader) {
|
||||
this.quirks[QUIRK_ALLOW_LEADING_UNICODE_BYTE_ORDER_MARK - QUIRKS_BASE]
|
||||
|
||||
while this.allow_leading_ars or this.allow_leading_ubom {
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue
|
||||
}
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if args.src.is_closed() {
|
||||
break
|
||||
}
|
||||
@@ -1434,7 +1434,7 @@ pri func decoder.decode_leading?(dst: base.token_writer, src: base.io_reader) {
|
||||
value_major: 0, value_minor: 0, continued: 0, length: 1)
|
||||
continue
|
||||
} else if (c == 0xEF) and this.allow_leading_ubom {
|
||||
if args.src.available() < 3 {
|
||||
if args.src.length() < 3 {
|
||||
if args.src.is_closed() {
|
||||
break
|
||||
}
|
||||
@@ -1459,11 +1459,11 @@ pri func decoder.decode_comment?(dst: base.token_writer, src: base.io_reader) {
|
||||
var c2 : base.u16
|
||||
var length : base.u32[..= 0xFFFD]
|
||||
|
||||
while (args.dst.available() <= 0) or (args.src.available() <= 1),
|
||||
post args.dst.available() > 0,
|
||||
post args.src.available() > 1,
|
||||
while (args.dst.length() <= 0) or (args.src.length() <= 1),
|
||||
post args.dst.length() > 0,
|
||||
post args.src.length() > 1,
|
||||
{
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue
|
||||
}
|
||||
@@ -1479,16 +1479,16 @@ pri func decoder.decode_comment?(dst: base.token_writer, src: base.io_reader) {
|
||||
length = 2
|
||||
|
||||
while.comment_block true {
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
length = 0
|
||||
continue.comment_block
|
||||
}
|
||||
|
||||
while true,
|
||||
pre args.dst.available() > 0,
|
||||
pre args.dst.length() > 0,
|
||||
{
|
||||
if args.src.available() <= 1 {
|
||||
if args.src.length() <= 1 {
|
||||
if length > 0 {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -1537,16 +1537,16 @@ pri func decoder.decode_comment?(dst: base.token_writer, src: base.io_reader) {
|
||||
length = 2
|
||||
|
||||
while.comment_line true {
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
length = 0
|
||||
continue.comment_line
|
||||
}
|
||||
|
||||
while true,
|
||||
pre args.dst.available() > 0,
|
||||
pre args.dst.length() > 0,
|
||||
{
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if length > 0 {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -1599,11 +1599,11 @@ pri func decoder.decode_inf_nan?(dst: base.token_writer, src: base.io_reader) {
|
||||
var neg : base.u32[..= 1]
|
||||
|
||||
while true {
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
continue
|
||||
}
|
||||
if args.src.available() <= 2 {
|
||||
if args.src.length() <= 2 {
|
||||
if args.src.is_closed() {
|
||||
return "#bad input"
|
||||
}
|
||||
@@ -1615,7 +1615,7 @@ pri func decoder.decode_inf_nan?(dst: base.token_writer, src: base.io_reader) {
|
||||
|
||||
c4 = args.src.peek_u24le_as_u32()
|
||||
if (c4 | 0x20_2020) == 'inf'le {
|
||||
if args.src.available() > 7 {
|
||||
if args.src.length() > 7 {
|
||||
if (args.src.peek_u64le() | 0x2020_2020_2020_2020) == 'infinity'le {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -1656,7 +1656,7 @@ pri func decoder.decode_inf_nan?(dst: base.token_writer, src: base.io_reader) {
|
||||
return "#bad input"
|
||||
}
|
||||
|
||||
if args.src.available() <= 3 {
|
||||
if args.src.length() <= 3 {
|
||||
if args.src.is_closed() {
|
||||
return "#bad input"
|
||||
}
|
||||
@@ -1666,7 +1666,7 @@ pri func decoder.decode_inf_nan?(dst: base.token_writer, src: base.io_reader) {
|
||||
|
||||
c4 = args.src.peek_u32le() >> 8
|
||||
if (c4 | 0x20_2020) == 'inf'le {
|
||||
if args.src.available() > 8 {
|
||||
if args.src.length() > 8 {
|
||||
if (args.src.peek_u64le_at(offset: 1) | 0x2020_2020_2020_2020) == 'infinity'le {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0,
|
||||
@@ -1710,16 +1710,16 @@ pri func decoder.decode_trailing_new_line?(dst: base.token_writer, src: base.io_
|
||||
var whitespace_length : base.u32[..= 0xFFFE]
|
||||
|
||||
while.outer true {
|
||||
if args.dst.available() <= 0 {
|
||||
if args.dst.length() <= 0 {
|
||||
yield? base."$short write"
|
||||
whitespace_length = 0
|
||||
continue.outer
|
||||
}
|
||||
|
||||
while.inner true,
|
||||
pre args.dst.available() > 0,
|
||||
pre args.dst.length() > 0,
|
||||
{
|
||||
if args.src.available() <= 0 {
|
||||
if args.src.length() <= 0 {
|
||||
if whitespace_length > 0 {
|
||||
args.dst.write_simple_token_fast!(
|
||||
value_major: 0, value_minor: 0, continued: 0, length: whitespace_length)
|
||||
|
||||
Reference in new issue
Block a user