Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c -switch "unknown" case

Tags:

c

keyword

I did recently read a bit of the st terminal sourcecode. There I did find this piece of code:

switch (csiescseq.mode[0]) {
default:
unknown:
    fprintf(stderr, "erresc: unknown csi ");
    csidump();
    /* die(""); */
    break;
case '@': /* ICH -- Insert <n> blank char */

What does the "unknown" keyword(?) do? I wasn't able to find anything to a "unknown" keyword anywhere. Thanks in advice for help.

like image 391
flobue Avatar asked Mar 05 '23 12:03

flobue


1 Answers

In this code, unknown is simply a label. C permits you to prefix any statement with a label. The label can be used as the target of a goto statement.

This is in the grammar in C 2018 6.8.1, “Labeled statements”:

labeled-statement:
    identifier : statement
    case constant-expression : statement
    default : statement

Any statement may be preceded by a prefix that declares an identifier as a label name.

like image 194
Eric Postpischil Avatar answered Mar 10 '23 10:03

Eric Postpischil