Chinaunix首页 | 论坛 | 博客
  • 博客访问: 303191
  • 博文数量: 94
  • 博客积分: 2163
  • 博客等级: 大尉
  • 技术积分: 932
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-20 09:23
文章存档

2012年(2)

2011年(92)

分类: LINUX

2011-09-30 11:46:45

[code]
<---------------____________
返回到
 test_parse_constent_dipostion()  /*读到这里可以看出只是一个测试,某某编码格式的一种*/
{
 mu_assert()      /*返回某个信息*/
}
__________------------>
/*src/test.h*/
#define  mu_assert(message, test) do{ if (!test)) return message; } while (0)
/*根据提供的实参,我们可以知道一次也不会返回错误的:理由是:如果返回res 为 false 那么 filename 和 test_array[i].name 是肯定不会相等的,如果是ture,更不用说*/

_____________________________________________________________________
返回到main
#define  mu_run_test (test) 定义在 /src/test.h
#define  mu_run_test(test) \
do{   \
   const  char *message ; \
   puts("RUNNING TEST " #test ". . .");  \
   message = test( );  \
   tests_run++;   \
   if (message ) return message ; \  /*这里message返回的是NULL,所以不会输出什么*/
   puts ("PASSED \n") ;   \
  } while ( 0 )
________________________________________________
mu_run_test (test_parse_content_disposition); 分析完毕  */

——————————————————————————————————————————————
subdir_p()
{
 ......
  if(!op.ignore_case)
   for(; *d1 && *d2 && (!d1 == *d2); ++d1, d2) /*如果不忽略对目录和文件名的检查,那么就检查*/
            ;
   else(; *d1 && *d2 &&(c_tolower( !d1) == c_tolower(*d2)); ++d1; ++d2)
     ;
   return *d1 == '\0' &&( d2  ==  '\0' || *d2 == '/'); /*在此的意思却自己设置了几个文件名,然后用来检查,只有最后那一个不符合返回值为 false*/

}
<----------------____________________
test_subdir_p()
{
 ....
mu_assert();
return NULL;
}
__________________------------------------->
第三个测试,跟过关一样:),不过离主体还有段不小距离。至少得检查完吧。
mu_run_test(test_dir_matches_p);_________------------>
/*src/utils.c*/
test_dir_matches_p()
{
  ......
/*这个和上面一样,都是定义一些名字然后让你去测试,这次好像是从一些目录名称中找到对应的*/
例如  struct {
            char *dirlist[3];
            char *dir;
            bool result;
 }test_array[] = {
 { { "/somedir", "someotherdir",NULL}, "somedir", ture}, /*这个显然是有的,所以返回必须是ture,才是正确的,*/
{ { */*dl", "someotherdir", NULL}, "somedir/d1", ture}, /*我认为这里面的*是通配符*/
 .... ... ...
};
  . . .
for ( i = 0; i < count(test_array); i++)
{
   bool res = dir_matches_p(test_array[i].dirlist, test_array[i].dir);/*_______-------->/src/utils.c*/
   mu_assert ("test ..... , res == test_array[i].result);
 }
return NULL;
}
__________------------>
dir_matches_p()
{
char  **x;
int (*mather) (const char *, const char *, int) = opt.ignore_case? fnmatch_nocase: fnmatch;
   for(x = dirlist; *x; x++)
{
     . . .

 . . . 

————————————————————————————----
fnmatch_nocase( )/*___________---------->utils.c*/
#ifdef FNM_CASEDFOLD 进行匹配时,不区分大小写字母
return fnmatch( pattern, string, flags | FNM_CASEFOLD);
#else  /*就是区分大小写先看不区分大小写的匹配*/
char *patcopy = (char *)allca(strlen (pattern) + 1); /*________--------->/lib/alloca.c*/
char *strcopy = (char *)alloca(strlen (string) + 1);
 . . .
__________-------------->
/*lib/alloca.c*/
 /* If your stack is a linked list of frames, you have to
   provide an "address metric" ADDRESS_FUNCTION macro.  如果栈是页表的链表,那么就提供ADDRESS_FUNCTION 的宏*/

alloca()
{
  ADDRESS_FUNCTION(); /*检查栈__________---------------->同一个文件*/
___________---------->
#if defined (CRAY) && defined(CRAY_STACKES_END)
#define ADDRESS_FUNCTION(arg) (char *) i00afunc(&(arg)) /*_____--------->alloca.c*/
#else
#define ADDRESS_FUNCTION(arg) &(arg)
#endif
___________---------->
static long i100afunc(long *address)
{
     struct stk_stat status; __________-------------->/*lib/alloca.c*/
     struct sk_trailer *trailer; ___________---------->/*lib/alloca.c*/
 . . .
}
_____-------------->
struct skt_stat
{
   275   {
276     long now;                   /* Current total stack size. 当前堆栈总大小 */
277     long maxc;                  /* Amount of contiguous space which would
278                                    be required to satisfy the maximum
279                                    stack demand to date.  */
280     long high_water;            /* Stack high-water mark. 栈高水位标记 */
281     long overflows;             /* Number of stack overflow ($STKOFEN) calls    .  */
282     long hits;                  /* Number of internal buffer hits.  内部命中的次数*/
283     long extends;               /* Number of block extensions.  块的扩展数目*/
284     long stko_mallocs;          /* Block allocations by $STKOFEN.  申请块*/
285     long underflows;            /* Number of stack underflow calls ($STKRETN    ).  */
286     long stko_free;             /* Number of deallocations by $STKRETN.  */
287     long stkm_free;             /* Number of deallocations by $STKMRET.  */
288     long segments;              /* Current number of stack segments.  当前栈的段数目*/
289     long maxs;                  /* Maximum number of stack segments so far.  目前为止最大的段数目 */
290     long pad_size;              /* Stack pad size.  栈块大小*/
291     long current_address;       /* Current stack segment address.当前栈段地址  */
292     long current_size;          /* Current stack segment size.  This
293                                    number is actually corrupted by STKSTAT to
294                                    include the fifteen word trailer area.  *    /
295     long initial_address;       /* Address of initial segment.  */
296     long initial_size;          /* Size of initial segment.  */
297   };
_______---------------->
303 struct stk_trailer
304   {
305     long this_address;          /* Address of this block.  */
306     long this_size;             /* Size of this block (does not include
307                                    this trailer).  */
308     long unknown2;
309     long unknown3;
310     long link;                  /* Address of trailer block of previous
311                                    segment.  */
312     long unknown5;
313     long unknown6;
314     long unknown7;
315     long unknown8;
316     long unknown9;
317     long unknown10;
318     long unknown11;
319     long unknown12;
320     long unknown13;
321     long unknown14;
322   };
<-----------------------_______________
返回到
i00afunc()
{
 ..
 trailer  = (struct stk_trailer *) (status.current_address + status.current_size -15) /*见上访的current_size.栈上有15个字被STKSTAT贪污,此处地址就拿回来*/
 if ( trailer  == 0)
  abort();
while( trailer ! = 0)
{
  block = (long* ) trailer->this_address;
  size = trailer->this_size;
  if (block == 0 | |size == 0)
   abort();
  trailer = (struct sk_trailer *) trailer->link; /*上一个此结构的地址,早已经有联系*/
  if (( block <= address) &&(address < (block + size))) /*发现这个地址正好在此块中*/
    break;
}
/*此处,栈上本来在初始化时就有这些变量,现在只是取出来使用*/
   result = address - block;
 
   if (trailer == 0)
     {
      return result;
     }
 
   do
     {
      if (trailer->this_size <= 0)
        abort ();
      result += trailer->this_size;
       trailer = (struct stk_trailer *) trailer->link;
     }
   while (trailer != 0);
  return (result);
}
阅读(1673) | 评论(0) | 转发(0) |
0

上一篇:第二篇 (wget)

下一篇:AVL 树和 RB树的分析

给主人留下些什么吧!~~