<---------__________
返回到all_tests()
{
. . . . . .
mu_run_test(test_cmd_spec_restrict_file_names);/* ____________---------->/src/init.c*/
. . . . .
}
___________------------>
test_cmd_spec_restrict_file_names()
1673 test_cmd_spec_restrict_file_names()
1674 {
1675 int i;
1676 struct {
1677 char *val;
1678 int expected_restrict_files_os;
1679 int expected_restrict_files_ctrl;
1680 int expected_restrict_files_case;
1681 bool result;
1682 } test_array[] = {
1683 { "windows", restrict_windows, true, restrict_no_case_restriction, true },
1684 { "windows,", restrict_windows, true, restrict_no_case_restriction, tru e },
1685 { "windows,lowercase", restrict_windows, true, restrict_lowercase, true },
1686 { "unix,nocontrol,lowercase,", restrict_unix, false, restrict_lowercase , true },
1687 };
1688
1689 for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i)
1690 {
1691 bool res;
1692
1693 defaults(); 1、 _______________---------------->/*init.c*/
1694 res = cmd_spec_restrict_file_names ("dummy", test_array[i].val, NULL) ;/*2 、___------>init.c */
1695 . . . . . . .
1702 mu_assert ("test_cmd_spec_restrict_file_names: wrong result",
1703 res == test_array[i].result
1704 && opt.restrict_files_os == test_array[i].expected_restrict_files_os
1705 && opt.restrict_files_ctrl == test_array[i].expected_restrict_files_ctrl
1706 && opt.restrict_files_case ==
test_array[i].expected_restrict_files_case);
/*跟前面相同,是测试使用,看结果的设置和否符合预期*/
1707 }
1708
1709 return NULL;
1710 }
1 、_________________________---------------------->
defaults(void )
{
char *tmp;
xzero(opt);
opt.cookies = true;
. . . . . . .
/*对opotion的初始化*/
}
2、___________----------------->
static bool
1311 cmd_spec_restrict_file_names (const char *com, const char *val, v oid *place_ignored)
1312 {
1313 int restrict_os = opt.restrict_files_os; /*文件名限制规则*/
1314 int restrict_ctrl = opt.restrict_files_ctrl;/*如果控制字符被限制从一般文件名中显示,此为非零*/
1315 int restrict_case = opt.restrict_files_case;/*文件名字类型限制*/
1316 int restrict_nonascii = opt.restrict_files_nonascii;/*如果字符大于127被禁止的话,那么此为非0*/
1317 /*全部见下方3、_____---------->*/
1318 const char *end;
1319
1320 #define VAL_IS(string_literal) BOUNDED_EQUAL (val, end, string_literal) /*4、_______------->/src/wget.c*/
1321
1322 do
1323 {
1324 end = strchr (val, ','); /*查找第一个,看前面的的定义*/
1325 if (!end)
1326 end = val + strlen (val); /*如果end返回为NULL,那么就End 指向末尾位置*/
1327 /*依次赋值*/
1328 if (VAL_IS ("unix"))
1329 restrict_os = restrict_unix;
1330 else if (VAL_IS ("windows"))
1331 restrict_os = restrict_windows;
1332 else if (VAL_IS ("lowercase"))
1333 restrict_case = restrict_lowercase;
1334 else if (VAL_IS ("uppercase"))
1335 restrict_case = restrict_uppercase;
1336 else if (VAL_IS ("nocontrol"))
1337 restrict_ctrl = false;
1338 else if (VAL_IS ("ascii"))
1339 restrict_nonascii = true;
1340 else
1341 {
1342 fprintf (stderr, _("\
1343 %s: %s: Invalid restriction %s,\n\
1344 use [unix|windows],[lowercase|uppercase],[nocontrol],[ascii]. \n"),
1345 exec_name, com, quote (val));
1346 return false;
1347 }
1348
1349 if (*end)
1350 val = end + 1; /*将end指向的地址加一就是下个字符串的地址*/
1351 }
1352 while (*val && *end);
1353
1354 #undef VAL_IS
1355
1356 opt.restrict_files_os = restrict_os;
1357 opt.restrict_files_ctrl = restrict_ctrl;
1358 opt.restrict_files_case = restrict_case;
1359 opt.restrict_files_nonascii = restrict_nonascii;
1360
1361 return true;
1362 }
3 、______________________________----------------------------->
208 enum {
209 restrict_unix,
210 restrict_windows
211 } restrict_files_os; /*win 和linux 命名文件名字是不同的*/
212 bool restrict_files_ctrl;
217 enum {
218 restrict_no_case_restriction, /*无格式限制*/
219 restrict_lowercase, /*限制小写*/
220 restrict_uppercase /*限制大写*/
221 } restrict_files_case;
215 bool restrict_files_nonascii;
4、______________----------------->
#define BOUNDED_EQUAL (beg, end, string_literal)
( ( end) - (beg) = sizeof(string_literal - 1) && !memcmp( beg, string_literal, sizeof(string_literal) -1 ))
/*------------END ____ IN ----test_cmd_spec_restrict_file_names*/
阅读(732) | 评论(0) | 转发(0) |