⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 args.c

📁 indent为linux下代码自动格式化工具
💻 C
📖 第 1 页 / 共 4 页
字号:
    }        return val;}/* The first 2 characters of a c++ comment have been read skip the remainder of the line * and return the first character from the next line. */static int skip_cpp_comment(    FILE * f){    int i;        do    {        i = getc (f);    } while ((i != EOF) && (i != EOL));    if (i == EOL)    {        i = getc (f);    }        return i;}/* * the first 2 characters of a c comment have been read. Read past the * remainder of the comment and return the first character after the * comment. */static int skip_c_comment(    FILE * f){    int i = getc (f);        do    {        /* skip to the next '*' character */                while ((i != EOF) && (i != '*'))        {            i = getc (f);        }                                                        if (i == EOF)        {            WARNING (_("Profile contains an unterminated comment"), 0, 0);            break;        }        /* current char is '*' so skip over it. */                i = getc (f);                /* If the current character is a '/' the comment is over. */    } while (i != '/');    if (i != EOF)    {        i = getc (f);    }        return i;}/* The starting / of a comment has been read. * skip over the rest of the comment and return the * first character after the comment. */static int skip_comment(    FILE * f){    int i = getc (f);        switch (i)    {        case '/':            i = skip_cpp_comment(f);            break;        case '*':            i = skip_c_comment(f);            break;        default:            WARNING (_("Profile contains unpalatable characters"), 0, 0);    }        return i;}/* * Skip a sequence of space and control characters and return the * first character after the sequence. */static int skip_spaces(    FILE * f,    int    first){    int    i = first;    while ((i <= ' ') &&           (i != EOF))    {        i = getc (f);    }               return i;}/* Read a string from the input until the next control character, space or /. * Return the first character after the read string. */static int read_string(    FILE  * f,    char  * buff,    int     first){    int i = first;    char *p = buff;        while ( ( i != EOF) &&            (i > ' ')   &&            (i != '/')  &&            (p < buff + BUFSIZ))    {        *(p++) = i;        i = getc (f);    }    *p = EOS;        return i;}/* Scan the options in the file f. */static void scan_profile (    FILE  * f){    char   b0[BUFSIZ];    char   b1[BUFSIZ];    char * current = b0;    int    i = skip_spaces(f, ' ');        while (i != EOF)    {        if (i == '/')        {            /* The start of a comment. */            i = skip_comment(f);        }        else        {            i = read_string(f, current, i);            /* We've scanned something... */            if (current == b0)            {                /* Second buffer still has to be filled. */                current = b1;            }            else if (set_option (b0, b1, 1) == 1)            {                /* The option had a parameter, thus both values                 * have been consumed.                 * Reset the 2 buffers to 'empty'                 */                current = b0;            }            else            {                /* Set option consumed one value. Move the                 * other value to the first buffer and go get a new                 * second value.                 */                                strcpy(b0, b1);                current = b1;            }                    }                i = skip_spaces(f, i);    }    if (current != b0)    {        set_option (b0, NULL, 1);    }}/* Some operating systems don't allow more than one dot in a filename.  */#if defined (ONE_DOT_PER_FILENAME)#define INDENT_PROFILE "indent.pro"#else#define INDENT_PROFILE ".indent.pro"#endif#ifndef PROFILE_FORMAT#define PROFILE_FORMAT "%s/%s"#endif#define PROFILE_ENV_NAME "INDENT_PROFILE"/* set_profile looks for ./.indent.pro or $HOME/.indent.pro, in * that order, and reads the options given in that file.  Return the * path of the file read. * * Note that as of version 1.3, indent only reads one file. */char * set_profile (void){    FILE        * f       = NULL;    char        * fname   = NULL;    static char   prof[]  = INDENT_PROFILE;    char        * homedir = NULL;    char        * envname = getenv(PROFILE_ENV_NAME);    if (envname != NULL)    {        f = fopen (envname, "r");    }    if (f != NULL)    {        scan_profile (f);                (void) fclose (f);                fname = strdup(envname);    }    else    {        f = fopen (INDENT_PROFILE, "r");                if (f != NULL)        {            int len = strlen (INDENT_PROFILE) + 3;            scan_profile (f);            (void) fclose (f);            fname = xmalloc (len);            strcpy(fname, "./");            (void) strcat (fname, INDENT_PROFILE);        }        else        {            homedir = getenv ("HOME");                if (homedir)            {                fname = xmalloc (strlen (homedir) + strlen(PROFILE_FORMAT) + sizeof (prof));                sprintf (fname, PROFILE_FORMAT, homedir, prof);                                if ((f = fopen (fname, "r")) != NULL)                {                    scan_profile (f);                    (void) fclose (f);                }                else                {                    free (fname);                    fname = NULL;                }            }        }    }        return fname;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -