asm/lex.c
char *token_line(const struct Token *token, char *buf, usize n) {
    const char *end = strchr(token->line, '\n');
    const usize llen =
        end == NULL ?
            strlen(token->line) :
            ((usize) (end - token->line));

    if (buf == NULL) {
        buf = asmalloc(llen + 1);
    } else if (llen + 1 > n) {
        return NULL;
    }

    memcpy(buf, token->line, llen);
    buf[llen] = '\0';

    return buf;
}
// retrieves the entire line of a token into buf of size n. if buf is NULL, a
// buffer of adequate size is asmalloc'd and returned. returns NULL on failure.
retrieves the entire line of a token into buf of size n. if buf is NULL, a
buffer of adequate size is asmalloc'd and returned. returns NULL on failure.
retrieves the entire line of a token into buf of size n . if buf is NULL a buffer of adequate size is asmalloc ' d and returned . returns NULL on failure .
char *token_line(const struct Token *token, char *buf, usize n) {
    const char *end = strchr(token->line, '\n');
    const usize llen =
        end == NULL ?
            strlen(token->line) :
            ((usize) (end - token->line));
    if (buf == NULL) {
        buf = asmalloc(llen + 1);
    } else if (llen + 1 > n) {
        return NULL;
    }
    memcpy(buf, token->line, llen);
    buf[llen] = '\0';
    return buf;
}
char * token_line ( const struct Token * token , char * buf , usize n ) { const char * end = strchr ( token -> line , ' \n ' ) ; const usize llen = end == NULL ? strlen ( token -> line ) : ( ( usize ) ( end - token -> line ) ) ; if ( buf == NULL ) { buf = asmalloc ( llen + 1 ) ; } else if ( llen + 1 > n ) { return NULL ; } memcpy ( buf , token -> line , llen ) ; buf [ llen ] = ' \0 ' ; return buf ; }
retrieves the entire line of a token into buf of size n. if buf is NULL, a
buffer of adequate size is asmalloc'd and returned.
retrieves the entire line of a token into buf of size n . if buf is NULL a buffer of adequate size is asmalloc ' d and returned .