Search code examples
clanguage-features

How do I call “@” at-symbol quotation in C?


Having seen Fossil's code [ https://fossil-scm.org/home/annotate?filename=src/schema.c&checkin=b03652382a327740 L27.. ]:

    /*
    ** The database schema for the ~/.fossil configuration database.
    */
    const char zConfigSchema[] =
    @ -- This file contains the schema for the database that is kept in the
    @ -- ~/.fossil file and that stores information about the users setup.
    @ --
    @ CREATE TABLE global_config(
    @   name TEXT PRIMARY KEY,
    @   value TEXT
    @ );
    @
    @ -- Identifier for this file type.
    @ -- The integer is the same as 'FSLG'.
    @ PRAGMA application_id=252006675;
    ;

I'm wondering what is @... syntax is for. I have never seen it before, and I do not know how to call it to search the web for it. "string literal extensions in C" and various rephrasing of that yield no result.

Please consider leaving this question be, despite its triviality, for the purpose of better discoverability. Thanks.


Solution

  • From "BUILD.txt" of the project:

    • Most *.c source files are preprocessed using a program called "translate". The sources to translate are found in src/translate.c. A header comment in src/translate.c explains in detail what it does.

    More information can be found directly in the referenced file, but it seems to be used to better handle CGI capabilities in C, particularly in generating HTML.

    The synopsis provided in that "src/translate.c" is as follows:

    ** Input lines that begin with the "@" character are translated into
    ** either cgi_printf() statements or string literals and the
    ** translated code is written on standard output.
    **
    ** The problem this program is attempt to solve is as follows: When
    ** writing CGI programs in C, we typically want to output a lot of HTML
    ** text to standard output. In pure C code, this involves doing a
    ** printf() with a big string containing all that text. But we have
    ** to insert special codes (ex: \n and \") for many common characters,
    ** which interferes with the readability of the HTML.
    **
    ** This tool allows us to put raw HTML, without the special codes, in
    ** the middle of a C program. This program then translates the text
    ** into standard C by inserting all necessary backslashes and other
    ** punctuation.