📄 translate-test.c
字号:
expect[70 - 1] =
apr_pstrcat (pool, "$Author: ", author, " $Rev$.", NULL);
}
/* Else Lines 48, 49, and 70 remain unchanged. */
}
else if (rev && (! author))
{
if (expand)
{
expect[48 - 1] =
apr_pstrcat (pool, "Line 48: ",
"Two keywords back to back: "
"$Author$$Rev: ", rev, " $.",
NULL);
expect[49 - 1] =
apr_pstrcat (pool, "Line 49: ",
"One keyword, one not, back to back: "
"$Author$Rev: ", rev, " $.",
NULL);
expect[70 - 1] =
apr_pstrcat (pool, "$Author$Rev: ", rev, " $.", NULL);
}
/* Else Lines 48, 49, and 70 remain unchanged. */
}
else if ((! rev) && author)
{
if (expand)
{
expect[48 - 1] =
apr_pstrcat (pool, "Line 48: ",
"Two keywords back to back: "
"$Author: ", author, " $$Rev$.",
NULL);
expect[49 - 1] =
apr_pstrcat (pool, "Line 49: ",
"One keyword, one not, back to back: "
"$Author: ", author, " $Rev$.",
NULL);
expect[70 - 1] =
apr_pstrcat (pool, "$Author: ", author, " $Rev$.", NULL);
}
/* Else Lines 48, 49, and 70 remain unchanged. */
}
/* Else neither rev nor author, so Lines 48, 49, and 70 remain
unchanged. */
/* Handle line 24 specially, as it contains two valid keywords. */
if (date && author)
{
if (expand)
{
expect[24 - 1] =
apr_pstrcat (pool, "Line 24: ",
"keyword in a keyword: $Author: ",
author,
" $Date$ $",
NULL);
}
else /* unexpand */
{
expect[24 - 1] =
apr_pstrcat (pool, "Line 24: ",
"keyword in a keyword: $Author$Date$ $",
NULL);
}
}
else if (date && (! author))
{
if (expand)
{
expect[24 - 1] =
apr_pstrcat (pool, "Line 24: ",
"keyword in a keyword: $Author: $Date: ",
date,
" $ $",
NULL);
}
/* Else Line 24 remains unchanged. */
}
else if ((! date) && author)
{
if (expand)
{
expect[24 - 1] =
apr_pstrcat (pool, "Line 24: ",
"keyword in a keyword: $Author: ",
author,
" $Date$ $",
NULL);
}
else /* unexpand */
{
expect[24 - 1] =
apr_pstrcat (pool, "Line 24: ",
"keyword in a keyword: $Author$Date$ $",
NULL);
}
}
/* Else neither author nor date, so Line 24 remains unchanged. */
/** Ready to verify. **/
SVN_ERR (svn_stringbuf_from_file (&contents, dst_fname, pool));
for (i = 0; i < (sizeof (expect) / sizeof (*expect)); i++)
{
if (contents->len < idx)
return svn_error_createf
(SVN_ERR_MALFORMED_FILE, NULL,
"'%s' has short contents at line %" APR_SIZE_T_FMT,
dst_fname, i + 1);
if (strncmp (contents->data + idx, expect[i], strlen (expect[i])) != 0)
return svn_error_createf
(SVN_ERR_MALFORMED_FILE, NULL,
"'%s' has wrong contents at line %" APR_SIZE_T_FMT,
dst_fname, i + 1);
/* Else, the data is correct, at least up to the next eol. */
idx += strlen (expect[i]);
if (dst_eol) /* verify the promised consistent eol style */
{
if (strncmp (contents->data + idx, dst_eol, strlen (dst_eol)) != 0)
return svn_error_createf
(SVN_ERR_IO_CORRUPT_EOL, NULL,
"'%s' has wrong eol style at line %" APR_SIZE_T_FMT, dst_fname,
i + 1);
else
idx += strlen (dst_eol);
}
else /* allow any eol style, even inconsistent ones, loosely */
{
while ((*(contents->data + idx) == '\r')
|| (*(contents->data + idx) == '\n'))
idx++;
}
}
/* Clean up this test, since successful. */
SVN_ERR (remove_file (src_fname, pool));
SVN_ERR (remove_file (dst_fname, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
noop (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "no conversions";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("noop", NULL, NULL, 0, NULL, NULL, NULL, NULL, 1, pool));
SVN_ERR (substitute_and_verify
("noop", "\r", NULL, 0, NULL, NULL, NULL, NULL, 1, pool));
SVN_ERR (substitute_and_verify
("noop", "\n", NULL, 0, NULL, NULL, NULL, NULL, 1, pool));
SVN_ERR (substitute_and_verify
("noop", "\r\n", NULL, 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
/** EOL conversion alone. **/
static svn_error_t *
crlf_to_crlf (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert CRLF to CRLF";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("crlf_to_crlf", "\r\n", "\r\n", 0,
NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
lf_to_crlf (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert LF to CRLF";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("lf_to_crlf", "\n", "\r\n", 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
cr_to_crlf (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert CR to CRLF";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("cr_to_crlf", "\r", "\r\n", 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
mixed_to_crlf (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert mixed line endings to CRLF";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("mixed_to_crlf", NULL, "\r\n", 1,
NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
lf_to_lf (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert LF to LF";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("lf_to_lf", "\n", "\n", 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
crlf_to_lf (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert CRLF to LF";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("crlf_to_lf", "\r\n", "\n", 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
cr_to_lf (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert CR to LF";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("cr_to_lf", "\r", "\n", 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
mixed_to_lf (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert mixed line endings to LF";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("cr_to_lf", NULL, "\n", 1, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
crlf_to_cr (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert CRLF to CR";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("crlf_to_cr", "\r\n", "\r", 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
lf_to_cr (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert LF to CR";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("lf_to_cr", "\n", "\r", 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
cr_to_cr (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert CR to CR";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("cr_to_cr", "\r", "\r", 0, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
mixed_to_cr (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "convert mixed line endings to CR";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("mixed_to_cr", NULL, "\r", 1, NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
mixed_no_repair (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "keep mixed line endings without repair flag";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("mixed_no_repair", NULL, "\n", 0,
NULL, NULL, NULL, NULL, 1, pool));
SVN_ERR (substitute_and_verify
("mixed_no_repair", NULL, "\r\n", 0,
NULL, NULL, NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
/** Keyword expansion alone. **/
static svn_error_t *
expand_author (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "expand author";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("author", "\n", NULL, 0, NULL, NULL, "jrandom", NULL, 1, pool));
SVN_ERR (substitute_and_verify
("author", "\r\n", NULL, 0, NULL, NULL, "jrandom", NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
expand_date (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "expand date";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("date", "\n", NULL, 0,
NULL, "Wed Jan 9 07:49:05 2002", NULL, NULL, 1, pool));
SVN_ERR (substitute_and_verify
("date", "\r\n", NULL, 0,
NULL, "Wed Jan 9 07:49:05 2002", NULL, NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
expand_author_date (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "expand author and date";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("author_date", "\n", NULL, 0,
NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 1, pool));
SVN_ERR (substitute_and_verify
("author_date", "\r\n", NULL, 0,
NULL, "Wed Jan 9 07:49:05 2002", "jrandom", NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
expand_author_rev (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "expand author and rev";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("author_rev", "\n", NULL, 0,
"1729", NULL, "jrandom", NULL, 1, pool));
SVN_ERR (substitute_and_verify
("author_rev", "\r\n", NULL, 0,
"1729", NULL, "jrandom", NULL, 1, pool));
return SVN_NO_ERROR;
}
static svn_error_t *
expand_rev (const char **msg,
svn_boolean_t msg_only,
apr_pool_t *pool)
{
*msg = "expand rev";
if (msg_only)
return SVN_NO_ERROR;
SVN_ERR (substitute_and_verify
("rev", "\n", NULL, 0,
"1729", NULL, NULL, NULL, 1, pool));
SVN_ERR (substitute_and_verify
("rev", "\r\n", NULL, 0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -