Unnamed Fossil Project

Check-in [2cc2bfbd1b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:updated
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2cc2bfbd1b33e7cc3755c537b2878c16da1b9f10
User & Date: alexey@sudachen.name 2011-09-07 09:25:35
Context
2011-09-12
09:42
updated check-in: c92a6d63a0 user: alexey@sudachen.name tags: trunk
2011-09-07
09:25
updated check-in: 2cc2bfbd1b user: alexey@sudachen.name tags: trunk
2011-09-06
00:52
updated check-in: 1c9d4b953c user: alexey@sudachen.name tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to core.hc.

  1571   1571       char *msg = Error_Message();
  1572   1572       
  1573   1573     #ifndef _BACKTRACE
  1574   1574       if ( (code & YOYO_TRACED_ERROR_GROUP) || !Error_Info()->msg )
  1575   1575     #endif
  1576   1576         StdErr_Print_Nl(Yo_Error_Format_Btrace());
  1577   1577       
  1578         -    if ( YOYO_ERROR_IS_USER_ERROR(code) )
         1578  +    if ( code == YOYO_ERROR_USER )
         1579  +      StdErr_Print_Nl(Yo_Format(__yoTa("\n%s: %s",0),(pfx?pfx:__yoTa("error",0)),code,msg));
         1580  +    else if ( YOYO_ERROR_IS_USER_ERROR(code) )
  1579   1581         StdErr_Print_Nl(Yo_Format(__yoTa("\n%s(%d): %s",0),(pfx?pfx:__yoTa("error",0)),code,msg));
  1580   1582       else
  1581   1583         StdErr_Print_Nl(Yo_Format(__yoTa("\n%s(%08x): %s",0),(pfx?pfx:__yoTa("error",0)),code,msg));
  1582   1584       if ( code & YOYO_FATAL_ERROR_GROUP )
  1583   1585         abort();
  1584   1586       Yo_Unwind_Scope(0,-1);
  1585   1587       exit(code);
................................................................................
  1591   1593   #define __Pool_Ptr(Ptr,Free)            Yo_Pool_Ptr(Ptr,Free)
  1592   1594   #define __Release(Pooled)               Yo_Release(Pooled)
  1593   1595   #define __Retain(Pooled)                Yo_Retain(Pooled)
  1594   1596   #define __Purge(TholdPtr)               Yo_Pool_Purge(TholdPtr,YOYO_DEFAULT_PURGE_CAP)
  1595   1597   #define __Refe(Ptr)                     Yo_Refe(Ptr)
  1596   1598   #define __Unrefe(Ptr)                   Yo_Unrefe(Ptr)
  1597   1599   #define __Raise(Err,Msg)                Yo_Raise(Err,Msg,__Yo_FILE__,__LINE__)
         1600  +#define __Raise_User_Error(Msg)         Yo_Raise(YOYO_ERROR_USER,Msg,__Yo_FILE__,__LINE__)
  1598   1601   #define __Raise_Format(Err,Fmt)         Yo_Raise(Err,(Yo_Format Fmt),__Yo_FILE__,__LINE__)
  1599   1602   #define __Raise_If_Occured()            Yo_Raise_If_Occured()
  1600   1603   #define __Fatal(Ctx)                    Yo_Fatal(YOYO_FATAL_ERROR,Ctx,__Yo_FILE__,__LINE__)
  1601   1604   #define __Fatal_Format(x)               Yo_Fatal(YOYO_FATAL_ERROR,Yo_Format_Npl x,__Yo_FILE__,__LINE__)
  1602   1605   #define __Format                        Yo_Format
  1603   1606   #define __Format_Npl                    Yo_Format_Npl
  1604   1607   #define __Format_Error()                Yo_Error_Format()

Changes to file.hc.

   307    307   #else
   308    308     typedef struct stat _YOYO_stat;
   309    309   #endif        
   310    310   
   311    311   YOYO_FILE_STATS *File_Translate_Filestats(_YOYO_stat *fst,YOYO_FILE_STATS *st,int exists)
   312    312   #ifdef _YOYO_FILE_BUILTIN
   313    313     {
   314         -    if ( !st ) st = Yo_Malloc(sizeof(YOYO_FILE_STATS));
          314  +    if ( !st ) st = __Malloc(sizeof(YOYO_FILE_STATS));
   315    315       memset(st,0,sizeof(*st));
   316    316   
   317    317       st->f.exists       = exists;
   318    318       st->f.is_regular   = (fst->st_mode&S_IFMT) == S_IFREG;
   319    319       st->f.is_directory = (fst->st_mode&S_IFMT) == S_IFDIR;
   320    320     #ifndef __windoze  
   321    321       st->f.is_symlink   = (fst->st_mode&S_IFMT) == S_IFLNK;    
................................................................................
   346    346         err = _wstat(uni_name,&fst);
   347    347       #endif
   348    348       Yo_Release(uni_name);
   349    349     #else
   350    350       err = stat(name,&fst);
   351    351     #endif
   352    352       if ( !err || ignorerr )
   353         -      File_Translate_Filestats(&fst,st,!err);
   354         -    if ( err && !ignorerr )              
   355    353         {
          354  +        st = File_Translate_Filestats(&fst,st,!err);
          355  +      }
          356  +    else if ( err && !ignorerr )              
          357  +      {
          358  +        int eno = errno;
   356    359           if ( st ) memset(st,0,sizeof(*st));
   357         -        if ( errno != ENOENT && errno != ENOTDIR )
   358         -          File_Check_Error("getting stats",0,name,1); 
          360  +        if ( eno == ENOENT || eno == ENOTDIR )
          361  +          __Raise_Format(YOYO_ERROR_DOESNT_EXIST,("file '%s' does not exist",name));
          362  +        File_Check_Error("getting stats",0,name,1); 
   359    363         }
   360    364       return st;
   361    365     }
   362    366   #endif
   363    367     ;
   364    368   
   365    369   YOYO_FILE_STATS *File_Get_Stats_Reuse(char *name, YOYO_FILE_STATS **stp)
................................................................................
   443    447   enum _YOYO_DIRLIST_FLAGS
   444    448     {
   445    449       FILE_LIST_ALL = 0,
   446    450       FILE_LIST_DIRECTORIES = 1,
   447    451       FILE_LIST_FILES = 2,
   448    452     };
   449    453   
   450         -void *File_List_Directory(char *dirname, unsigned flags)
          454  +YOYO_ARRAY *File_List_Directory(char *dirname, unsigned flags)
   451    455   #ifdef _YOYO_FILE_BUILTIN
   452    456     {
   453    457     #ifdef __windoze
   454    458       WIN32_FIND_DATAW fdtw;
   455    459       HANDLE hfnd;
   456    460     #else
   457    461       DIR *dir;
................................................................................
   468    472             {
   469    473               do
   470    474                 if ( wcscmp(fdtw.cFileName,L".") && wcscmp(fdtw.cFileName,L"..") )
   471    475                   {
   472    476                     int m = fdtw.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY ?
   473    477                       FILE_LIST_DIRECTORIES : FILE_LIST_FILES;
   474    478                     if ( m & flags )
   475         -                    Array_Push(L,Str_Unicode_To_Utf8_Npl(fdtw.cFileName));
          479  +                    {
          480  +                      char *name = Str_Unicode_To_Utf8_Npl(fdtw.cFileName);
          481  +                      Array_Push(L,name);
          482  +                    }
   476    483                   }
   477    484               while( FindNextFileW(hfnd,&fdtw) );
   478    485               FindClose(hfnd);
   479    486             }
   480    487         #else
   481    488           dir = Yo_Pool_Ptr(opendir(dirname),closedir);
   482    489           if ( dir )
................................................................................
  1060   1067       YOYO_FILE_MODIFY      = YOYO_FILE_READWRITE|YOYO_FILE_OPENEXISTS, 
  1061   1068     };
  1062   1069   
  1063   1070   void File_Check_Access_Is_Satisfied(char *path, uint_t access)
  1064   1071   #ifdef _YOYO_FILE_BUILTIN
  1065   1072     {
  1066   1073       YOYO_FILE_STATS st = {0};
  1067         -    File_Get_Stats(path,&st,0);
  1068         -
         1074  +    File_Get_Stats(path,&st,1);
         1075  +    
  1069   1076       if ( (access & YOYO_FILE_CREATE_PATH) && !st.f.exists )
  1070   1077         Create_Required_Dirs(path);
  1071         -      
         1078  +    
  1072   1079       if ( st.f.exists )
  1073   1080         if (st.f.is_directory )
  1074   1081           __Raise_Format(YOYO_ERROR_IO,("file '%s' is directory",path));
  1075   1082         else if ( (access & YOYO_FILE_CREATE_MASK) == YOYO_FILE_CREATENEW  )
  1076   1083           __Raise_Format(YOYO_ERROR_IO,("file '%s' already exists",path));
  1077   1084         else if ( (access & YOYO_FILE_CREATE_MASK) == YOYO_FILE_CREATEALWAYS )
  1078   1085           File_Unlink(path,0);

Changes to string.hc.

    36     36   #ifdef _YOYO_STRING_BUILTIN
    37     37   #define _YOYO_STRING_EXTERN
    38     38   #else
    39     39   #define _YOYO_STRING_EXTERN extern
    40     40   #endif
    41     41   
    42     42   /* caseinsensitive strcmp, returns 0 if equal */
           43  +#define Str_Ansi_Equal_Nocase(Cs,Ct) (!strcmp_I(Cs,Ct))
    43     44   int strcmp_I(char *cs, char *ct)
    44     45   #ifdef _YOYO_STRING_BUILTIN
    45     46     {
    46     47       int q = 0;
    47     48       do 
    48     49         {
    49     50           q = Toupper(*cs) - Toupper(*ct++);
    50     51         }
           52  +    while ( *cs++ && !q );
           53  +    return q;
           54  +  }
           55  +#endif
           56  +  ;
           57  +
           58  +#define Str_Unicode_Compare_Nocase(Cs,Ct) wcscmp_I(Cs,Ct)
           59  +int wcscmp_I(wchar_t *cs, wchar_t *ct)
           60  +#ifdef _YOYO_STRING_BUILTIN
           61  +  {
           62  +    int q = 0;
           63  +    do 
           64  +      {
           65  +        q = towupper(*cs) - towupper(*ct++);
           66  +      }
    51     67       while ( *cs++ && !q );
    52     68       return q;
    53     69     }
    54     70   #endif
    55     71     ;
    56     72   
    57     73   /* caseinsensitive strncmp, returns 0 if equal */
................................................................................
    65     81         }
    66     82       while ( *cs++ && !q && --l );
    67     83       return q;
    68     84     }    
    69     85   #endif
    70     86     ;
    71     87   
           88  +int wcsncmp_I(wchar_t *cs, wchar_t *ct, int l)
           89  +#ifdef _YOYO_STRING_BUILTIN
           90  +  {
           91  +    int q = 0;
           92  +    if ( l ) do 
           93  +      {
           94  +        q = towupper(*cs) - towupper(*ct++);
           95  +      }
           96  +    while ( *cs++ && !q && --l );
           97  +    return q;
           98  +  }    
           99  +#endif
          100  +  ;
    72    101   
    73    102   int Str_Length(char *S)
    74    103   #ifdef _YOYO_STRING_BUILTIN
    75    104     {
    76    105       return S ? strlen(S) : 0;
    77    106     }
    78    107   #endif