Changeset 6645 for trunk/src/crtdll


Ignore:
Timestamp:
Sep 5, 2001, 2:14:25 PM (24 years ago)
Author:
bird
Message:

Added $Id:$ keyword.

Location:
trunk/src/crtdll
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/crtdll/crtdll.cpp

    r5472 r6645  
     1/* $Id: crtdll.cpp,v 1.30 2001-09-05 12:14:23 bird Exp $ */
    12/*
    23 * The C RunTime DLL
    3  * 
     4 *
    45 * Implements C run-time functionality as known from UNIX.
    56 *
    6  * TODO: 
     7 * TODO:
    78 *   - Check setjmp(3)
    89 *   - fix *ALL* functions for the FS: wrapper problem
     
    7273// Definitions for internal functions
    7374//
    74 void            qsort1 (char*, char*, size_t,
     75void        qsort1 (char*, char*, size_t,
    7576                    int (* CDECL)(const void*, const void*));
    7677
     
    444445
    445446/*********************************************************************
    446  *      _cscanf                                 (CRTDLL.67)
     447 *  _cscanf                     (CRTDLL.67)
    447448 */
    448449INT CDECL CRTDLL__cscanf( char *s, va_list arg )
     
    604605
    605606/*********************************************************************
    606  *      _ftime                                  (CRTDLL.112)
     607 *  _ftime                  (CRTDLL.112)
    607608 */
    608609void CDECL CRTDLL__ftime( struct timeb *timebuf )
     
    618619LONG CDECL CRTDLL__ftol(void)
    619620{
    620         /* don't just do DO_FPU("fistp",retval), because the rounding
    621         * mode must also be set to "round towards zero"... */
    622         double fl;
    623         POP_FPU(fl);
    624         return (LONG)fl;
     621    /* don't just do DO_FPU("fistp",retval), because the rounding
     622    * mode must also be set to "round towards zero"... */
     623    double fl;
     624    POP_FPU(fl);
     625    return (LONG)fl;
    625626}
    626627
     
    775776
    776777/*********************************************************************
    777  *                  _ltoa       (CRTDLL.179)
     778 *                  _ltoa   (CRTDLL.179)
    778779 */
    779780LPSTR  CDECL CRTDLL__ltoa(long x,LPSTR buf,INT radix)
     
    784785
    785786/*********************************************************************
    786  *                  _matherr    (CRTDLL.181)
     787 *                  _matherr    (CRTDLL.181)
    787788 */
    788789double CDECL CRTDLL__matherr( struct exception * excep )
     
    881882
    882883/*********************************************************************
    883  *           CRTDLL__searchenv   (CRTDLL.260)
     884 *           CRTDLL__searchenv   (CRTDLL.260)
    884885 */
    885886void CDECL CRTDLL__searchenv(char *file, char *var,char *path )
     
    891892
    892893/*********************************************************************
    893  *           CRTDLL__seterrormode       (CRTDLL.261)
     894 *           CRTDLL__seterrormode   (CRTDLL.261)
    894895 */
    895896void CDECL CRTDLL__seterrormode(int uMode)
     
    902903
    903904/*********************************************************************
    904  *           CRTDLL__setjmp     (CRTDLL.262)
     905 *           CRTDLL__setjmp     (CRTDLL.262)
    905906 */
    906907int CDECL CRTDLL__setjmp( jmp_buf env )
     
    937938
    938939/*********************************************************************
    939  *      _sopen                                  (CRTDLL.268)
     940 *  _sopen                  (CRTDLL.268)
    940941 */
    941942int CDECL CRTDLL__sopen( const char *s, int i1, int i2, va_list arg )
     
    947948
    948949/*********************************************************************
    949  *           CRTDLL__spawnl     (CRTDLL.269)
     950 *           CRTDLL__spawnl     (CRTDLL.269)
    950951 */
    951952int CDECL CRTDLL__spawnl(int nMode, char* szPath, char* szArgv0, va_list arg)
     
    957958
    958959/*********************************************************************
    959  *           CRTDLL__spawnle     (CRTDLL.270)
     960 *           CRTDLL__spawnle     (CRTDLL.270)
    960961 */
    961962int CDECL CRTDLL__spawnle( int mode, char *path, char **szArgv0, va_list arg )
     
    967968
    968969/*********************************************************************
    969  *           CRTDLL__spawnlp     (CRTDLL.271)
     970 *           CRTDLL__spawnlp     (CRTDLL.271)
    970971 */
    971972int CDECL CRTDLL__spawnlp(int nMode, char* szPath, char* szArgv0, va_list arg)
     
    977978
    978979/*********************************************************************
    979  *           CRTDLL__spawnlpe   (CRTDLL.272)
     980 *           CRTDLL__spawnlpe   (CRTDLL.272)
    980981 */
    981982int CDECL CRTDLL__spawnlpe( int mode, char *path, char *szArgv0, va_list arg )
     
    987988
    988989/*********************************************************************
    989  *           CRTDLL__spawnv     (CRTDLL.273)
     990 *           CRTDLL__spawnv     (CRTDLL.273)
    990991 */
    991992int CDECL CRTDLL__spawnv( int i, char *s1, char ** s2 )
     
    997998
    998999/*********************************************************************
    999  *           CRTDLL__spawnvp     (CRTDLL.275)
     1000 *           CRTDLL__spawnvp     (CRTDLL.275)
    10001001 */
    10011002int CDECL CRTDLL__spawnvp( int i, char *s1, char ** s2 )
     
    10061007
    10071008/*********************************************************************
    1008  *           CRTDLL__spawnv     (CRTDLL.276)
     1009 *           CRTDLL__spawnv     (CRTDLL.276)
    10091010 */
    10101011int CDECL CRTDLL__spawnvpe( int i, char *s1, char ** s2, char ** s3 )
     
    10161017
    10171018/*********************************************************************
    1018  *           CRTDLL__statusfp    (CRTDLL.279)
     1019 *           CRTDLL__statusfp    (CRTDLL.279)
    10191020 */
    10201021unsigned int CDECL CRTDLL__statusfp( void )
     
    10231024  return (_status87());
    10241025}
    1025        
    1026 
    1027 /*********************************************************************
    1028  *           _ultoa              (CRTDLL.309)
     1026
     1027
     1028/*********************************************************************
     1029 *           _ultoa      (CRTDLL.309)
    10291030 */
    10301031LPSTR  CDECL CRTDLL__ultoa(long x,LPSTR buf,INT radix)
     
    10361037
    10371038/*********************************************************************
    1038  *           CRTDLL__ungetch    (CRTDLL.311)
     1039 *           CRTDLL__ungetch    (CRTDLL.311)
    10391040 */
    10401041int CDECL CRTDLL__ungetch( int i )
     
    10461047
    10471048/*********************************************************************
    1048  *           _utime              (CRTDLL.314)
     1049 *           _utime      (CRTDLL.314)
    10491050 */
    10501051int CDECL CRTDLL__utime( char *path, struct utimbuf * times )
     
    10561057
    10571058/*********************************************************************
    1058  *      _vsnprintf                              (CRTDLL.315)
     1059 *  _vsnprintf              (CRTDLL.315)
    10591060 */
    10601061int CDECL CRTDLL__vsnprintf( char *s, size_t bufsize, const char *format, va_list arg )
     
    11001101
    11011102/*********************************************************************
    1102  *                  abs         (CRTDLL.336)
     1103 *                  abs     (CRTDLL.336)
    11031104 */
    11041105double CDECL CRTDLL_abs(double d)
     
    11121113
    11131114/*********************************************************************
    1114  *                  acos        (CRTDLL.337)
     1115 *                  acos    (CRTDLL.337)
    11151116 */
    11161117double CDECL CRTDLL_acos( double x )
     
    11221123
    11231124/*********************************************************************
    1124  *                  asctime     (CRTDLL.338)
     1125 *                  asctime (CRTDLL.338)
    11251126 */
    11261127char * CDECL CRTDLL_asctime( const struct tm *timeptr )
     
    11321133
    11331134/*********************************************************************
    1134  *                  asin        (CRTDLL.339)
     1135 *                  asin    (CRTDLL.339)
    11351136 */
    11361137double CDECL CRTDLL_asin( double x )
     
    11421143
    11431144/*********************************************************************
    1144  *                  atan        (CRTDLL.340)
     1145 *                  atan    (CRTDLL.340)
    11451146 */
    11461147double CDECL CRTDLL_atan(double d)
     
    11541155
    11551156/*********************************************************************
    1156  *                  atan2       (CRTDLL.341)
     1157 *                  atan2   (CRTDLL.341)
    11571158 */
    11581159double CDECL CRTDLL_atan2( double y, double x )
     
    11641165
    11651166/*********************************************************************
    1166  *                  atof        (CRTDLL.343)
     1167 *                  atof    (CRTDLL.343)
    11671168 */
    11681169double CDECL CRTDLL_atof( const char *nptr )
     
    11741175
    11751176/*********************************************************************
    1176  *                  atoi        (CRTDLL.344)
     1177 *                  atoi    (CRTDLL.344)
    11771178 */
    11781179int CDECL CRTDLL_atoi(LPSTR str)
     
    11861187
    11871188/*********************************************************************
    1188  *                  atol        (CRTDLL.345)
     1189 *                  atol    (CRTDLL.345)
    11891190 */
    11901191long CDECL CRTDLL_atol(LPSTR str)
     
    11981199
    11991200/*********************************************************************
    1200  *                  bsearch     (CRTDLL.346)
     1201 *                  bsearch (CRTDLL.346)
    12011202 */
    12021203void *CDECL CRTDLL_bsearch (const void *key, const void *base, size_t num, size_t width,
     
    12051206  int left, right, median, sign;
    12061207  const void *element;
    1207  
     1208
    12081209  if (width == 0)
    12091210    return 0;
     
    12261227
    12271228/*********************************************************************
    1228  *                  ceil        (CRTDLL.348)
     1229 *                  ceil    (CRTDLL.348)
    12291230 */
    12301231double CDECL CRTDLL_ceil(double d)
     
    12371238
    12381239/*********************************************************************
    1239  *                  clock       (CRTDLL.350)
     1240 *                  clock   (CRTDLL.350)
    12401241 */
    12411242clock_t CDECL CRTDLL_clock( void )
     
    12471248
    12481249/*********************************************************************
    1249  *                  cos         (CRTDLL.351)
     1250 *                  cos     (CRTDLL.351)
    12501251 */
    12511252double CDECL CRTDLL_cos(double d)
     
    12591260
    12601261/*********************************************************************
    1261  *                  cosh        (CRTDLL.352)
     1262 *                  cosh    (CRTDLL.352)
    12621263 */
    12631264double CDECL CRTDLL_cosh( double x )
     
    12691270
    12701271/*********************************************************************
    1271  *                  ctime       (CRTDLL.353)
     1272 *                  ctime   (CRTDLL.353)
    12721273 */
    12731274char * CDECL CRTDLL_ctime( const time_t *timer )
     
    12791280
    12801281/*********************************************************************
    1281  *                  difftime    (CRTDLL.354)
     1282 *                  difftime    (CRTDLL.354)
    12821283 */
    12831284double CDECL CRTDLL_difftime( time_t t1, time_t t0 )
     
    12891290
    12901291/*********************************************************************
    1291  *                  div         (CRTDLL.355)
     1292 *                  div     (CRTDLL.355)
    12921293 */
    12931294ULONG CDECL CRTDLL_div( int number, int denom )
     
    13031304
    13041305/*********************************************************************
    1305  *                  exp         (CRTDLL.357)
     1306 *                  exp     (CRTDLL.357)
    13061307 */
    13071308double CDECL CRTDLL_exp( double x )
     
    13131314
    13141315/*********************************************************************
    1315  *                  fabs        (CRTDLL.358)
     1316 *                  fabs    (CRTDLL.358)
    13161317 */
    13171318double CDECL CRTDLL_fabs(double d)
     
    13251326
    13261327/*********************************************************************
    1327  *                  floor               (CRTDLL.367)
     1328 *                  floor       (CRTDLL.367)
    13281329 */
    13291330double CDECL CRTDLL_floor(double d)
     
    13371338
    13381339/*********************************************************************
    1339  *                  fmod        (CRTDLL.368)
     1340 *                  fmod    (CRTDLL.368)
    13401341 */
    13411342double CDECL CRTDLL_fmod(double x, double y )
     
    13471348
    13481349/*********************************************************************
    1349  *                  frexp         (CRTDLL.377)
     1350 *                  frexp     (CRTDLL.377)
    13501351 */
    13511352double CDECL CRTDLL_frexp( double value, int *exp )
     
    14891490
    14901491/*********************************************************************
    1491  *                  labs        (CRTDLL.416)
     1492 *                  labs    (CRTDLL.416)
    14921493 */
    14931494long int CDECL CRTDLL_labs( long int j )
     
    14991500
    15001501/*********************************************************************
    1501  *                  ldexp       (CRTDLL.417)
    1502  */
    1503 double CDECL CRTDLL_ldexp( double x, int exp ) 
     1502 *                  ldexp   (CRTDLL.417)
     1503 */
     1504double CDECL CRTDLL_ldexp( double x, int exp )
    15041505{
    15051506  dprintf2(("CRTDLL: ldexp\n"));
     
    15091510
    15101511/*********************************************************************
    1511  *                  ldiv        (CRTDLL.418)
    1512  */
    1513 ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom ) 
     1512 *                  ldiv    (CRTDLL.418)
     1513 */
     1514ldiv_t CDECL CRTDLL_ldiv( long int numer, long int denom )
    15141515{
    15151516  dprintf2(("CRTDLL: ldiv\n"));
     
    15191520
    15201521/*********************************************************************
    1521  *                  localeconv  (CRTDLL.419)
     1522 *                  localeconv  (CRTDLL.419)
    15221523 */
    15231524struct lconv * CDECL CRTDLL_localeconv(void)
     
    15291530
    15301531/*********************************************************************
    1531  *                  localtime   (CRTDLL.420)
     1532 *                  localtime   (CRTDLL.420)
    15321533 */
    15331534struct tm * CDECL CRTDLL_localtime( const time_t *timer )
     
    15391540
    15401541/*********************************************************************
    1541  *                  log         (CRTDLL.421)
     1542 *                  log     (CRTDLL.421)
    15421543 */
    15431544double CDECL CRTDLL_log( double x )
     
    15491550
    15501551/*********************************************************************
    1551  *                  log10       (CRTDLL.422)
     1552 *                  log10   (CRTDLL.422)
    15521553 */
    15531554double CDECL CRTDLL_log10( double x )
     
    15811582 *                  pow      (CRTDLL.436)
    15821583 */
    1583 double CDECL CRTDLL_pow( double x, double y )   
     1584double CDECL CRTDLL_pow( double x, double y )
    15841585{
    15851586    dprintf2(("CRTDLL: pow(%08xh, %08xh)\n",x, y));
     
    16211622
    16221623/*********************************************************************
    1623  *      scanf                                   (CRTDLL.448)
     1624 *  scanf                   (CRTDLL.448)
    16241625 */
    16251626int CDECL CRTDLL_scanf( const char *format, va_list arg )
     
    17051706
    17061707/*********************************************************************
    1707  *      sscanf                                  (CRTDLL.458)
     1708 *  sscanf                  (CRTDLL.458)
    17081709 */
    17091710int CDECL CRTDLL_sscanf( const char *s, const char *format, va_list arg )
     
    17821783
    17831784/*********************************************************************
    1784  *      ungetc                                  (CRTDLL.492)
     1785 *  ungetc                  (CRTDLL.492)
    17851786 */
    17861787INT CDECL CRTDLL_ungetc(int c, FILE *f)
     
    18121813
    18131814/*********************************************************************
    1814  *           CRTDLL__setjmp3     (CRTDLL.600)
     1815 *           CRTDLL__setjmp3     (CRTDLL.600)
    18151816 */
    18161817int CDECL CRTDLL__setjmp3( jmp_buf env )
  • trunk/src/crtdll/crtdll_main.c

    r4667 r6645  
     1/* $Id: crtdll_main.c,v 1.2 2001-09-05 12:14:24 bird Exp $ */
    12/*
    23 * The C RunTime DLL
    3  * 
     4 *
    45 * Implements C run-time functionality as known from UNIX.
    56 *
     
    1314Unresolved issues Uwe Bonnes 970904:
    1415- tested with ftp://ftp.remcomp.com/pub/remcomp/lcc-win32.zip, a C-Compiler
    15                 for Win32, based on lcc, from Jacob Navia
     16        for Win32, based on lcc, from Jacob Navia
    1617UB 000416:
    1718- probably not thread safe
    1819*/
    1920
    20 /* NOTE: This file also implements the wcs* functions. They _ARE_ in 
     21/* NOTE: This file also implements the wcs* functions. They _ARE_ in
    2122 * the newer Linux libcs, but use 4 byte wide characters, so are unusable,
    2223 * since we need 2 byte wide characters. - Marcus Meissner, 981031
     
    6364UINT CRTDLL_winminor_dll;     /* CRTDLL.330 */
    6465UINT CRTDLL_winver_dll;       /* CRTDLL.331 */
    65 INT  CRTDLL_doserrno = 0; 
     66INT  CRTDLL_doserrno = 0;
    6667INT  CRTDLL_errno = 0;
    6768const INT  CRTDLL__sys_nerr = 43;
     
    7778 *                  CRTDLL_MainInit  (CRTDLL.init)
    7879 */
    79  
     80
    8081BOOL WINAPI CRTDLL_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
    8182{
    8283  FS_OS2
    83    
     84
    8485    // call i/o initializer in file.c
    85     if (fdwReason == DLL_PROCESS_ATTACH) 
     86    if (fdwReason == DLL_PROCESS_ATTACH)
    8687    {
    8788      __CRTDLL__init_io();
    8889    }
    89    
     90
    9091  /*
    9192    PH 2000/11/21 this code doesn't look very useful
    92    
     93
    9394    if (fdwReason == DLL_PROCESS_ATTACH) {
    9495      _fdopen(0,"r");
     
    103104      }
    104105  */
    105  
     106
    106107  FS_WIN32
    107108  return TRUE;
     
    176177        char *cmdline;
    177178        char  **xargv;
    178         int     xargc,end,last_arg,afterlastspace;
    179         DWORD   version;
    180 
    181         TRACE("(%p,%p,%p,%ld).\n",
    182                 argc,argv,environ,flag
    183         );
    184 
    185         if (CRTDLL_acmdln_dll != NULL)
    186                 HeapFree(GetProcessHeap(), 0, CRTDLL_acmdln_dll);
    187 
    188         CRTDLL_acmdln_dll = cmdline = CRTDLL__strdup( GetCommandLineA() );
    189         TRACE("got '%s'\n", cmdline);
    190 
    191         version = GetVersion();
    192         CRTDLL_osver_dll       = version >> 16;
    193         CRTDLL_winminor_dll    = version & 0xFF;
    194         CRTDLL_winmajor_dll    = (version>>8) & 0xFF;
    195         CRTDLL_baseversion_dll = version >> 16;
    196         CRTDLL_winver_dll      = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);
    197         CRTDLL_baseminor_dll   = (version >> 16) & 0xFF;
    198         CRTDLL_basemajor_dll   = (version >> 24) & 0xFF;
    199         CRTDLL_osversion_dll   = version & 0xFFFF;
    200         CRTDLL_osminor_dll     = version & 0xFF;
    201         CRTDLL_osmajor_dll     = (version>>8) & 0xFF;
    202 
    203         /* missing threading init */
    204 
    205         end=0;last_arg=0;xargv=NULL;xargc=0;afterlastspace=0;
    206         while (1)
    207         {
    208             if ((cmdline[end]==' ') || (cmdline[end]=='\0'))
    209             {
    210                 if (cmdline[end]=='\0')
    211                     last_arg=1;
    212                 else
    213                     cmdline[end]='\0';
    214                 /* alloc xargc + NULL entry */
    215                         xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
    216                                              sizeof(char*)*(xargc+1));
    217                 if (strlen(cmdline+afterlastspace))
    218                 {
    219                     xargv[xargc] = CRTDLL__strdup(cmdline+afterlastspace);
    220                     xargc++;
     179    int xargc,end,last_arg,afterlastspace;
     180    DWORD   version;
     181
     182    TRACE("(%p,%p,%p,%ld).\n",
     183        argc,argv,environ,flag
     184    );
     185
     186    if (CRTDLL_acmdln_dll != NULL)
     187        HeapFree(GetProcessHeap(), 0, CRTDLL_acmdln_dll);
     188
     189    CRTDLL_acmdln_dll = cmdline = CRTDLL__strdup( GetCommandLineA() );
     190    TRACE("got '%s'\n", cmdline);
     191
     192    version = GetVersion();
     193    CRTDLL_osver_dll       = version >> 16;
     194    CRTDLL_winminor_dll    = version & 0xFF;
     195    CRTDLL_winmajor_dll    = (version>>8) & 0xFF;
     196    CRTDLL_baseversion_dll = version >> 16;
     197    CRTDLL_winver_dll      = ((version >> 8) & 0xFF) + ((version & 0xFF) << 8);
     198    CRTDLL_baseminor_dll   = (version >> 16) & 0xFF;
     199    CRTDLL_basemajor_dll   = (version >> 24) & 0xFF;
     200    CRTDLL_osversion_dll   = version & 0xFFFF;
     201    CRTDLL_osminor_dll     = version & 0xFF;
     202    CRTDLL_osmajor_dll     = (version>>8) & 0xFF;
     203
     204    /* missing threading init */
     205
     206    end=0;last_arg=0;xargv=NULL;xargc=0;afterlastspace=0;
     207    while (1)
     208    {
     209        if ((cmdline[end]==' ') || (cmdline[end]=='\0'))
     210        {
     211        if (cmdline[end]=='\0')
     212            last_arg=1;
     213        else
     214            cmdline[end]='\0';
     215        /* alloc xargc + NULL entry */
     216            xargv=(char**)HeapReAlloc( GetProcessHeap(), 0, xargv,
     217                                     sizeof(char*)*(xargc+1));
     218        if (strlen(cmdline+afterlastspace))
     219        {
     220            xargv[xargc] = CRTDLL__strdup(cmdline+afterlastspace);
     221            xargc++;
    221222                    if (!last_arg) /* need to seek to the next arg ? */
    222                     {
    223                         end++;
    224                         while (cmdline[end]==' ')
    225                             end++;
    226         }
    227                     afterlastspace=end;
    228                 }
    229                 else
    230                 {
    231                     xargv[xargc] = NULL; /* the last entry is NULL */
    232                     break;
    233                 }
    234             }
    235             else
    236                 end++;
    237         }
    238         CRTDLL_argc_dll = xargc;
    239         *argc           = xargc;
    240         CRTDLL_argv_dll = xargv;
    241         *argv           = xargv;
    242 
    243         TRACE("found %d arguments\n",
    244                 CRTDLL_argc_dll);
    245         CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
    246         return environ;
     223            {
     224            end++;
     225            while (cmdline[end]==' ')
     226                end++;
     227    }
     228            afterlastspace=end;
     229        }
     230        else
     231        {
     232            xargv[xargc] = NULL; /* the last entry is NULL */
     233            break;
     234        }
     235        }
     236        else
     237        end++;
     238    }
     239    CRTDLL_argc_dll = xargc;
     240    *argc       = xargc;
     241    CRTDLL_argv_dll = xargv;
     242    *argv       = xargv;
     243
     244    TRACE("found %d arguments\n",
     245        CRTDLL_argc_dll);
     246    CRTDLL_environ_dll = *environ = GetEnvironmentStringsA();
     247    return environ;
    247248}
    248249
     
    253254DWORD CDECL CRTDLL__initterm(_INITTERMFUN *start,_INITTERMFUN *end)
    254255{
    255         _INITTERMFUN    *current;
    256 
    257         TRACE("(%p,%p)\n",start,end);
    258         current=start;
    259         while (current<end) {
    260                 if (*current) (*current)();
    261                 current++;
    262         }
    263         return 0;
     256    _INITTERMFUN    *current;
     257
     258    TRACE("(%p,%p)\n",start,end);
     259    current=start;
     260    while (current<end) {
     261        if (*current) (*current)();
     262        current++;
     263    }
     264    return 0;
    264265}
    265266
     
    309310INT CDECL CRTDLL_rand()
    310311{
    311     return (rand() & CRTDLL_RAND_MAX); 
     312    return (rand() & CRTDLL_RAND_MAX);
    312313}
    313314
     
    319320{
    320321  // return (_rotl(value, shift));
    321  
     322
    322323    shift &= 31;
    323324    return (x << shift) | (x >> (32-shift));
     
    331332{
    332333  // return (_lrotl(value, shift));
    333  
     334
    334335    shift &= 31;
    335336    return (x << shift) | (x >> (32-shift));
     
    343344{
    344345  // return (_lrotr(value, shift));
    345  
     346
    346347    shift &= 0x1f;
    347348    return (x >> shift) | (x << (32-shift));
     
    355356{
    356357  // return (_rotr(value, shift));
    357  
     358
    358359    shift &= 0x1f;
    359360    return (x >> shift) | (x << (32-shift));
     
    367368{
    368369  // return (vswprintf(s, t, format, arg));
    369  
     370
    370371    return wvsprintfW( buffer, spec, args );
    371372}
     
    388389{
    389390  return (setlocale(category, locale));
    390  
     391
    391392  /*
    392393    LPSTR categorystr;
     
    437438{
    438439  // return (_fullpath(buf, path, size));
    439  
     440
    440441  if (!buf)
    441442  {
     
    455456{
    456457  // _splitpath( path, drive, dir, fname, ext);
    457  
     458
    458459  /* drive includes :
    459460     directory includes leading and trailing (forward and backward slashes)
     
    519520{
    520521  // _makepath(path, drive, dir, fname, ext);
    521  
     522
    522523    char ch;
    523524    TRACE("CRTDLL__makepath got %s %s %s %s\n", drive, directory,
     
    567568{
    568569  // return (_errno());
    569  
     570
    570571  return &CRTDLL_errno;
    571572}
     
    574575/*********************************************************************
    575576 *                  __doserrno       (CRTDLL.26)
    576  * 
     577 *
    577578 * Return the address of the DOS errno (holding the last OS error).
    578579 * @@@PH Note: veeeery strange ...
     
    583584{
    584585  // return (__doserrno());
    585  
     586
    586587  return &CRTDLL_doserrno;
    587588}
     
    601602{
    602603  // return (_strerror((char*)s));
    603  
     604
    604605  static char strerrbuff[256];
    605606  sprintf(strerrbuff,"%s: %s\n",err,CRTDLL_strerror(CRTDLL_errno));
     
    616617{
    617618  // perror( s );
    618  
     619
    619620  char *err_str = CRTDLL_strerror(CRTDLL_errno);
    620621  CRTDLL_fprintf(CRTDLL_stderr,"%s: %s\n",err,err_str);
    621622  CRTDLL_free(err_str);
    622623}
    623  
     624
    624625
    625626/*********************************************************************
     
    631632 * The caller does not own the string returned.
    632633 */
    633 extern char *strerror(int errnum); 
     634extern char *strerror(int errnum);
    634635
    635636LPSTR CDECL CRTDLL_strerror (INT err)
     
    645646{
    646647  //return (signal(sig, ptr));
    647  
     648
    648649  FIXME("(%d %p):stub.\n", sig, ptr);
    649650  return (void*)-1;
     
    667668{
    668669  // return (getenv(name));
    669  
     670
    670671     LPSTR environ = GetEnvironmentStringsA();
    671672     LPSTR pp,pos = NULL;
     
    674675     for (pp = environ; (*pp); pp = pp + strlen(pp) +1)
    675676       {
    676         pos =strchr(pp,'=');
    677         if (pos)
    678            length = pos -pp;
    679         else
    680            length = strlen(pp);
    681         if (!strncmp(pp,name,length)) break;
     677    pos =strchr(pp,'=');
     678    if (pos)
     679       length = pos -pp;
     680    else
     681       length = strlen(pp);
     682    if (!strncmp(pp,name,length)) break;
    682683       }
    683      if ((pp)&& (pos)) 
     684     if ((pp)&& (pos))
    684685       {
    685         pp = pos+1;
    686         TRACE("got %s\n",pp);
     686    pp = pos+1;
     687    TRACE("got %s\n",pp);
    687688       }
    688689     FreeEnvironmentStringsA( environ );
     
    695696 */
    696697INT CDECL CRTDLL__except_handler2 (
    697         PEXCEPTION_RECORD rec,
    698         PEXCEPTION_FRAME frame,
    699         PCONTEXT context,
    700         PEXCEPTION_FRAME  *dispatcher)
    701 {
    702         FIXME ("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
    703         rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
    704         frame->Handler, context, dispatcher);
    705         return ExceptionContinueSearch;
     698    PEXCEPTION_RECORD rec,
     699    PEXCEPTION_FRAME frame,
     700    PCONTEXT context,
     701    PEXCEPTION_FRAME  *dispatcher)
     702{
     703    FIXME ("exception %lx flags=%lx at %p handler=%p %p %p stub\n",
     704    rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress,
     705    frame->Handler, context, dispatcher);
     706    return ExceptionContinueSearch;
    706707}
    707708
     
    724725{
    725726  // return (_toascii(c));
    726  
     727
    727728  return c & 0x7f;
    728729}
     
    754755{
    755756  // return (_iscsym(c));
    756  
     757
    757758  return (isalnum(c) || c == '_');
    758759}
     
    773774{
    774775  // return (_iscsymf(c));
    775  
     776
    776777  return (isalpha(c) || c == '_');
    777778}
     
    846847    {
    847848      if (cf((LPVOID*)match, (LPVOID*)pStart) == 0)
    848         return pStart; /* found */
     849    return pStart; /* found */
    849850      pStart += elem_size;
    850851    } while (--size);
     
    914915{
    915916  // return (_toupper(n));
    916  
     917
    917918  return toupper(c);
    918919}
     
    925926{
    926927  // return (_tolower(n));
    927  
     928
    928929  return tolower(c);
    929930}
     
    946947{
    947948  // return (_cabs(c));
    948  
     949
    949950  return sqrt(c.real * c.real + c.imaginary * c.imaginary);
    950951}
     
    10061007 *
    10071008 * Reset the state of the floating point processor.
    1008  * 
     1009 *
    10091010 * PARAMS
    10101011 *   None.
  • trunk/src/crtdll/dir.c

    r4675 r6645  
     1/* $Id: dir.c,v 1.5 2001-09-05 12:14:24 bird Exp $ */
    12/*
    23 * CRTDLL drive/directory functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    5758 * RETURNS
    5859 * Sucess:  0
    59  * 
     60 *
    6061 * Failure: -1
    6162 */
     
    6465  dprintf(("CRTDLL: _chdir(%s)\n",
    6566          newdir));
    66  
     67
    6768  if (!SetCurrentDirectoryA(newdir))
    6869  {
     
    8485 * RETURNS
    8586 * Sucess:  0
    86  * 
    87  * Failure: 1 
     87 *
     88 * Failure: 1
    8889 */
    8990BOOL CDECL CRTDLL__chdrive(INT newdrive)
     
    9192  char buffer[3] = "A:";
    9293  buffer[0] += newdrive - 1;
    93  
     94
    9495  dprintf(("CRTDLL: _chdrive(%s)\n",
    9596          buffer));
    96  
     97
    9798  if (!SetCurrentDirectoryA( buffer ))
    9899  {
     
    108109/*********************************************************************
    109110 *                  _findclose     (CRTDLL.098)
    110  * 
     111 *
    111112 * Free the resources from a search handle created from _findfirst.
    112113 *
     
    123124  dprintf(("CRTDLL: _findclose(%08xh)\n",
    124125          hand));
    125  
     126
    126127  if (!FindClose((HANDLE)hand))
    127128  {
     
    141142 * PARAMS
    142143 *   fspec [in]  File specification string for search, e.g "C:\*.BAT"
    143  * 
     144 *
    144145 *   ft [out]    A pointer to a find_t structure to populate.
    145146 *
     
    155156  WIN32_FIND_DATAA find_data;
    156157  HANDLE hfind;
    157  
     158
    158159  dprintf(("CRTDLL: _findfirst(%s)\n",
    159160          fspec));
     
    173174/*********************************************************************
    174175 *                  _findnext     (CRTDLL.100)
    175  * 
     176 *
    176177 * Return the next matching file/directory from a search hadle.
    177178 *
    178179 * PARAMS
    179180 *   hand [in] Search handle from a pervious call to _findfirst
    180  * 
     181 *
    181182 *   ft [out]  A pointer to a find_t structure to populate.
    182183 *
     
    190191{
    191192  WIN32_FIND_DATAA find_data;
    192  
     193
    193194  dprintf(("CRTDLL: _findnext(%08xh)\n",
    194195          hand));
    195  
     196
    196197  if (!FindNextFileA(hand, &find_data))
    197198  {
     
    224225{
    225226  // return (_getcwd(buf, size));
    226  
     227
    227228  char dir[_MAX_PATH];
    228229  int dir_len = GetCurrentDirectoryA(_MAX_PATH,dir);
    229  
     230
    230231  dprintf(("CRTDLL: _getcwd()\n"));
    231  
     232
    232233  if (dir_len < 1)
    233234    return NULL; /* FIXME: Real return value untested */
     
    258259{
    259260  // return (_getdcwd(drive, buffer, maxlen));
    260  
     261
    261262  static CHAR* dummy;
    262  
     263
    263264  dprintf(("CRTDLL: _getdcwd()\n"));
    264  
     265
    265266  if (!drive || drive == CRTDLL__getdrive())
    266267    return CRTDLL__getcwd(buf,size); /* current */
     
    305306  DWORD ret[4];
    306307  UINT err;
    307  
     308
    308309  dprintf(("CRTDLL: _getdiskfree(%08xh)\n", disk));
    309  
     310
    310311  if (disk > 26)
    311312    return ERROR_INVALID_PARAMETER; /* CRTDLL doesn't set errno here */
     
    335336{
    336337  // return DRIVE_GetCurrentDrive() + 1;
    337  
     338
    338339  char buffer[MAX_PATH];
    339  
     340
    340341  dprintf(("CRTDLL: _getdrive()\n"));
    341342
    342   if (!GetCurrentDirectoryA( sizeof(buffer), buffer )) 
    343     return 0;
    344   if (buffer[1] != ':') 
     343  if (!GetCurrentDirectoryA( sizeof(buffer), buffer ))
     344    return 0;
     345  if (buffer[1] != ':')
    345346    return 0;
    346347  return toupper(buffer[0]) - 'A' + 1;
     
    357358  dprintf(("CRTDLL: _mkdir(%s)\n",
    358359          newdir));
    359  
     360
    360361  if (CreateDirectoryA(newdir,NULL))
    361362    return 0;
     
    368369 *                  _rmdir           (CRTDLL.255)
    369370 *
    370  * Delete a directory 
     371 * Delete a directory
    371372 *
    372373 */
     
    375376  dprintf(("CRTDLL: _rmdir(%s)\n",
    376377          dir));
    377  
     378
    378379  if (RemoveDirectoryA(dir))
    379380    return 0;
  • trunk/src/crtdll/exit.c

    r4667 r6645  
     1/* $Id: exit.c,v 1.2 2001-09-05 12:14:24 bird Exp $ */
    12/*
    23 * CRTDLL exit/abort/atexit functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    1011 * and whether they return to the caller (really!).
    1112 *            return      do
    12  *  Name      to caller?  cleanup? 
     13 *  Name      to caller?  cleanup?
    1314 *  _c_exit     Y           N
    1415 *  _cexit      Y           Y
     
    5455
    5556/*********************************************************************
    56  *      __dllonexit                             (CRTDLL.25)
     57 *  __dllonexit                     (CRTDLL.25)
    5758 */
    5859VOID CDECL CRTDLL___dllonexit ()
    59 {       
     60{
    6061  dprintf(("__dllonexit not implemented.\n"));
    6162  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
     
    6465
    6566/*********************************************************************
    66  *      _abnormal_termination                   (CRTDLL.36)
     67 *  _abnormal_termination           (CRTDLL.36)
    6768 */
    6869int CDECL CRTDLL__abnormal_termination(void)
     
    8384{
    8485  dprintf2(("CRTDLL: _amsg_exit\n"));
    85  
     86
    8687  // fprintf(stderr,strerror(errnum));
    8788  // ExitProcess(-1);
    88  
     89
    8990  CRTDLL_fprintf(CRTDLL_stderr,"\nrun-time error:\nError Code %d\n",errnum);
    9091  CRTDLL__exit(255);
     
    9596 *                  _assert     (CRTDLL.041)
    9697 *
    97  * Print an assertion message and call abort(). Really only present 
     98 * Print an assertion message and call abort(). Really only present
    9899 * for win binaries. Winelib programs would typically use libc's
    99100 * version.
     
    102103{
    103104  dprintf2(("CRTDLL: _assert\n"));
    104  
     105
    105106  CRTDLL_fprintf(CRTDLL_stderr,"Assertion failed: %s, file %s, line %d\n\n",
    106107                 (char*)str,(char*)file, line);
    107108  CRTDLL_abort();
    108  
     109
    109110  // _assert(str, file, line);
    110111}
     
    119120  dprintf2(("_c_exit(%d)\n",ret));
    120121  FIXME("not calling CRTDLL cleanup\n");
    121  
     122
    122123  /* dont exit, return to caller */
    123  
     124
    124125  ExitProcess(ret);
    125126}
     
    135136  FIXME("not calling CRTDLL cleanup\n");
    136137  /* dont exit, return to caller */
    137  
     138
    138139  ExitProcess(ret);
    139140}
     
    145146VOID CDECL CRTDLL__exit(LONG ret)
    146147{
    147   dprintf2(("CRTDLL: _exit (%08xh)\n", 
     148  dprintf2(("CRTDLL: _exit (%08xh)\n",
    148149            ret));
    149150  TRACE(":exit code %ld\n",ret);
     
    199200{
    200201  dprintf2(("CRTDLL: abort\n"));
    201  
     202
    202203  CRTDLL_fprintf(CRTDLL_stderr,"\nabnormal program termination\n");
    203204  CRTDLL__exit(3);
     
    207208
    208209/*********************************************************************
    209  *                  atexit      (CRTDLL.342)
     210 *                  atexit  (CRTDLL.342)
    210211 *
    211212 * Register a function to be called when the process terminates.
     
    214215{
    215216  dprintf(("CRTDLL: atexit\n"));
    216  
     217
    217218  return CRTDLL__onexit(func) == func ? 0 : -1;
    218  
     219
    219220  // if (_atexit_n >= sizeof (_atexit_v) / sizeof (_atexit_v[0]))
    220221  //   return -1;
  • trunk/src/crtdll/file.c

    r4671 r6645  
     1/* $Id: file.c,v 1.3 2001-09-05 12:14:24 bird Exp $ */
    12/*
    23 * CRTDLL file functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    89 *
    910 * Implementation Notes:
    10  * Mapping is performed between FILE*, fd and HANDLE's. This allows us to 
    11  * implement all calls using the Win32 API, support remapping fd's to 
     11 * Mapping is performed between FILE*, fd and HANDLE's. This allows us to
     12 * implement all calls using the Win32 API, support remapping fd's to
    1213 * FILES and do some other tricks as well (like closeall, _get_osfhandle).
    1314 * For mix and matching with the host libc, processes can use the Win32 HANDLE
     
    128129  else
    129130    while(__CRTDLL_fdstart < __CRTDLL_fdend &&
    130           __CRTDLL_handles[__CRTDLL_fdstart] != INVALID_HANDLE_VALUE)
     131      __CRTDLL_handles[__CRTDLL_fdstart] != INVALID_HANDLE_VALUE)
    131132      __CRTDLL_fdstart++;
    132133
     
    143144{
    144145  TRACE(":fd (%d) allocating FILE*\n",fd);
    145   if (fd < 0 || fd >= __CRTDLL_fdend || 
     146  if (fd < 0 || fd >= __CRTDLL_fdend ||
    146147      __CRTDLL_handles[fd] == INVALID_HANDLE_VALUE)
    147148  {
     
    178179
    179180  TRACE(":handles (%d)(%d)(%d)\n",__CRTDLL_handles[0],
    180         __CRTDLL_handles[1],__CRTDLL_handles[2]);
     181    __CRTDLL_handles[1],__CRTDLL_handles[2]);
    181182
    182183  for (i = 0; i < 3; i++)
     
    195196{
    196197  // return (_access(path, mode));
    197  
     198
    198199  DWORD attr = GetFileAttributesA(filename);
    199200
     
    202203    if (!filename)
    203204    {
    204         /* FIXME: Should GetFileAttributesA() return this? */
     205    /* FIXME: Should GetFileAttributesA() return this? */
    205206      __CRTDLL__set_errno(ERROR_INVALID_DATA);
    206207      return -1;
     
    303304{
    304305  // return (__eof(_fd));
    305  
     306
    306307  DWORD curpos,endpos;
    307308  HANDLE hand = __CRTDLL__fdtoh(fd);
     
    338339{
    339340  // return (_fcloseall());
    340  
     341
    341342  int num_closed = 0, i = 3;
    342343
     
    361362{
    362363  // return (_fdopen(handle, mode));
    363  
     364
    364365  CRTDLL_FILE* file = __CRTDLL__alloc_fp(fd);
    365366
     
    378379{
    379380  // return (_fgetchar());
    380  
     381
    381382  return CRTDLL_fgetc(CRTDLL_stdin);
    382383}
     
    390391 * becomes negative. We ensure that _cnt is always 0 after any read
    391392 * so this function is always called. Our implementation simply calls
    392  * fgetc as all the underlying buffering is handled by Wines 
     393 * fgetc as all the underlying buffering is handled by Wines
    393394 * implementation of the Win32 file I/O calls.
    394395 */
     
    410411{
    411412  // return (_fileno(f));
    412  
     413
    413414  TRACE(":FILE* (%p) fd (%d)\n",file,file->_file);
    414415  return file->_file;
     
    440441{
    441442  // return (_flushall());
    442  
     443
    443444  int num_flushed = 0, i = 3;
    444445
     
    447448    {
    448449      if (CRTDLL__commit(i) == -1)
    449         if (__CRTDLL_files[i])
    450           __CRTDLL_files[i]->_flag |= _IOERR;
     450    if (__CRTDLL_files[i])
     451      __CRTDLL_files[i]->_flag |= _IOERR;
    451452      num_flushed++;
    452453    }
     
    465466{
    466467  // return(_fputchar(c));
    467  
     468
    468469  return CRTDLL_fputc(c, CRTDLL_stdout);
    469470}
     
    484485/*********************************************************************
    485486 *                  _fstat        (CRTDLL.111)
    486  * 
     487 *
    487488 * Get information about an open file.
    488489 */
     
    490491{
    491492  // return (_fstat(file, buf));
    492  
     493
    493494  DWORD dw;
    494495  BY_HANDLE_FILE_INFORMATION hfi;
     
    548549  {
    549550    /* FIXME: I'm not convinced that I should be copying the
    550      * handle here - it may be leaked if the app doesn't 
     551     * handle here - it may be leaked if the app doesn't
    551552     * close it (and the API docs dont say that it should)
    552553     * Not duplicating it means that it can't be inherited
     
    557558     */
    558559    DuplicateHandle(GetCurrentProcess(),hand,GetCurrentProcess(),
    559                     &newhand,0,TRUE,DUPLICATE_SAME_ACCESS );
     560            &newhand,0,TRUE,DUPLICATE_SAME_ACCESS );
    560561  }
    561562  return newhand;
     
    588589{
    589590  // return (_lseek(handle, offset, origin));
    590  
     591
    591592  LONG ret;
    592593  HANDLE hand = __CRTDLL__fdtoh(fd);
     
    777778{
    778779  // return (_setmode(fh, mode));
    779  
     780
    780781  if (mode & _O_TEXT)
    781782    FIXME("fd (%d) mode (%d) TEXT not implemented\n",fd,mode);
     
    790791{
    791792  // return(_stat(s1, n));
    792  
     793
    793794  DWORD dw;
    794795  WIN32_FILE_ATTRIBUTE_DATA hfi;
     
    826827    {
    827828      unsigned int ext = tolower(path[plen-1]) | (tolower(path[plen-2]) << 8)
    828         | (tolower(path[plen-3]) << 16);
     829    | (tolower(path[plen-3]) << 16);
    829830      if (ext == EXE || ext == BAT || ext == CMD || ext == COM)
    830         mode |= CRTDLL_S_IEXEC;
     831    mode |= CRTDLL_S_IEXEC;
    831832    }
    832833  }
     
    843844  buf->st_mtime = buf->st_ctime = dw;
    844845  TRACE("\n%d %d %d %d %d %d\n", buf->st_mode,buf->st_nlink,buf->st_size,
    845         buf->st_atime,buf->st_mtime, buf->st_ctime);
     846    buf->st_atime,buf->st_mtime, buf->st_ctime);
    846847  return 0;
    847848}
     
    856857{
    857858  // return (_tell(i));
    858  
     859
    859860  return CRTDLL__lseek(fd, 0, SEEK_CUR);
    860861}
     
    863864/*********************************************************************
    864865 *                  _tempnam           (CRTDLL.305)
    865  * 
     866 *
    866867 */
    867868LPSTR CDECL CRTDLL__tempnam(LPCSTR dir, LPCSTR prefix)
    868869{
    869870  // return (_tempnam(dir, prefix));
    870  
     871
    871872  char tmpbuf[MAX_PATH];
    872873
     
    890891{
    891892  // return (_umask(i));
    892  
     893
    893894  INT old_umask = __CRTDLL_umask;
    894895  TRACE("umask (%d)\n",umask);
     
    976977{
    977978  // return (fclose(fp));
    978  
     979
    979980  return CRTDLL__close(file->_file);
    980981}
     
    989990{
    990991  // return (feof(fp));
    991  
     992
    992993  return file->_flag & _IOEOF;
    993994}
     
    10021003{
    10031004  // return (ferror(fp));
    1004  
     1005
    10051006  return file->_flag & _IOERR;
    10061007}
     
    10241025{
    10251026  // return (fgetc(fp));
    1026  
     1027
    10271028  char c;
    10281029  if (CRTDLL__read(file->_file,&c,1) != 1)
     
    10501051{
    10511052  // return (fgets(s, n, fp));
    1052  
     1053
    10531054  int    cc;
    10541055  LPSTR  buf_start = s;
    10551056
    10561057  TRACE(":file(%p) fd (%d) str (%p) len (%d)\n",
    1057         file,file->_file,s,size);
     1058    file,file->_file,s,size);
    10581059
    10591060  /* BAD, for the whole WINE process blocks... just done this way to test
     
    10881089{
    10891090  // return (fputs(s, fp));
    1090  
     1091
    10911092  return CRTDLL_fwrite(s,strlen(s),1,file);
    10921093}
     
    10991100{
    11001101    // return (fprintf(file, format, arg));
    1101  
     1102
    11021103    va_list valist;
    11031104    INT res;
     
    11181119{
    11191120  // return (fopen( filename, mode));
    1120  
     1121
    11211122  CRTDLL_FILE* file;
    11221123  INT flags = 0, plus = 0, fd;
     
    11821183{
    11831184  // return (fputc(c, fp));
    1184  
     1185
    11851186  return CRTDLL__write(file->_file, &c, 1) == 1? c : EOF;
    11861187}
     
    11931194{
    11941195  // return (fread(ptr, size, n, fp));
    1195  
     1196
    11961197  DWORD read = CRTDLL__read(file->_file,ptr, size * nmemb);
    11971198  if (read <= 0)
     
    12031204/*********************************************************************
    12041205 *                  freopen    (CRTDLL.379)
    1205  * 
     1206 *
    12061207 */
    12071208CRTDLL_FILE* CDECL CRTDLL_freopen(LPCSTR path, LPCSTR mode,CRTDLL_FILE* file)
    12081209{
    12091210  // return (freopen(filename, mode, fp));
    1210  
     1211
    12111212  CRTDLL_FILE* newfile;
    12121213  INT fd;
     
    12561257{
    12571258  // return (fsetpos(fp, pos));
    1258  
     1259
    12591260  return CRTDLL__lseek(file->_file,*pos,SEEK_SET);
    12601261}
     
    13921393{
    13931394  // return (fseek(file, offset, whence));
    1394  
     1395
    13951396  return CRTDLL__lseek(file->_file,offset,whence);
    13961397}
     
    14031404{
    14041405  // return (ftell(fp));
    1405  
     1406
    14061407  return CRTDLL__tell(file->_file);
    14071408}
     
    14281429{
    14291430  // return (getchar());
    1430  
     1431
    14311432  return CRTDLL_fgetc(CRTDLL_stdin);
    14321433}
     
    14591460     */
    14601461    for(cc = CRTDLL_fgetc(CRTDLL_stdin); cc != EOF && cc != '\n';
    1461         cc = CRTDLL_fgetc(CRTDLL_stdin))
    1462         if(cc != '\r') *buf++ = (char)cc;
     1462    cc = CRTDLL_fgetc(CRTDLL_stdin))
     1463    if(cc != '\r') *buf++ = (char)cc;
    14631464
    14641465    *buf = '\0';
     
    14971498{
    14981499  // return puts( s );
    1499  
     1500
    15001501  return CRTDLL_fputs(s, CRTDLL_stdout);
    15011502}
     
    15111512{
    15121513  // rewind(fp);
    1513  
     1514
    15141515  TRACE(":file (%p) fd (%d)\n",file,file->_file);
    15151516  CRTDLL__lseek(file->_file,0,SEEK_SET);
     
    15241525{
    15251526  // return (remove(file));
    1526  
     1527
    15271528  TRACE(":path (%s)\n",path);
    15281529  if (DeleteFileA(path))
     
    15401541{
    15411542  // return (rename(old, new2));
    1542  
     1543
    15431544  TRACE(":from %s to %s\n",oldpath,newpath);
    15441545  if (MoveFileExA( oldpath, newpath, MOVEFILE_REPLACE_EXISTING))
     
    15561557{
    15571558  // setbuf(fp, buf);
    1558  
     1559
    15591560  TRACE(":file (%p) fd (%d) buf (%p)\n", file, file->_file,buf);
    15601561  if (buf)
     
    15691570 *
    15701571 * lcclnk from lcc-win32 relies on a terminating dot in the name returned
    1571  * 
     1572 *
    15721573 */
    15731574LPSTR CDECL CRTDLL_tmpnam(LPSTR s)
    15741575{
    15751576  // return (tmpnam(s));
    1576  
     1577
    15771578  char tmpbuf[MAX_PATH];
    15781579  char* prefix = "TMP";
     
    15991600{
    16001601  // return (vfprintf(file, format, args));
    1601  
     1602
    16021603  /* FIXME: We should parse the format string, calculate the maximum,
    16031604   * length of each arg, malloc a buffer, print to it, and fwrite that.
  • trunk/src/crtdll/initterm.cpp

    r5135 r6645  
     1/* $Id: initterm.cpp,v 1.7 2001-09-05 12:14:25 bird Exp $ */
    12/*
    23 * DLL entry point
     
    5556   case DLL_THREAD_ATTACH:
    5657   case DLL_THREAD_DETACH:
    57         return CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
     58    return CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
    5859
    5960   case DLL_PROCESS_DETACH:
    60         CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
    61         ctordtorTerm();
    62         return TRUE;
     61    CRTDLL_Init(hinstDLL, fdwReason, fImpLoad);
     62    ctordtorTerm();
     63    return TRUE;
    6364   }
    6465   return FALSE;
     
    9091         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
    9192
    92         dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
    93          if(dllHandle == 0) 
    94                 return 0UL;
     93    dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab);
     94         if(dllHandle == 0)
     95        return 0UL;
    9596
    9697         break;
    9798      case 1 :
    9899         if(dllHandle) {
    99                 UnregisterLxDll(dllHandle);
     100        UnregisterLxDll(dllHandle);
    100101         }
    101102         break;
  • trunk/src/crtdll/memory.c

    r4671 r6645  
     1/* $Id: memory.c,v 1.3 2001-09-05 12:14:25 bird Exp $ */
    12/*
    23 * CRTDLL memory functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    3233    VOID* result;
    3334    if(!(result = HeapAlloc(GetProcessHeap(),0,size)) && new_handler)
    34         (*new_handler)();
     35    (*new_handler)();
    3536    return result;
    3637}
     
    7980{
    8081  // return (_heapchk());
    81  
     82
    8283  if (!HeapValidate( GetProcessHeap(), 0, NULL))
    8384  {
     
    9798{
    9899  // return (_heapmin());
    99  
     100
    100101  if (!HeapCompact( GetProcessHeap(), 0 ))
    101102  {
     
    116117{
    117118  // return (_heapset(fill));
    118  
     119
    119120  INT retVal;
    120121  struct _heapinfo heap;
     
    144145  phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
    145146
    146   if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY && 
     147  if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
    147148      !HeapValidate( GetProcessHeap(), 0, phe.lpData ))
    148149  {
     
    180181{
    181182  // return (_msize(ptr));
    182  
     183
    183184  LONG size = HeapSize(GetProcessHeap(),0,mem);
    184185  if (size == -1)
     
    215216/*********************************************************************
    216217 *                  malloc        (CRTDLL.424)
    217  * 
     218 *
    218219 * Alocate memory from the heap.
    219220 */
  • trunk/src/crtdll/spawn.c

    r4672 r6645  
     1/* $Id: spawn.c,v 1.3 2001-09-05 12:14:25 bird Exp $ */
    12/*
    23 * CRTDLL spawn functions
    3  * 
     4 *
    45 * Copyright 1996,1998 Marcus Meissner
    56 * Copyright 1996 Jukka Iivonen
     
    2425 * Implementation Notes:
    2526 * MT Safe - But only because of missing functionality.
    26  * 
     27 *
    2728 * After translating input arguments into the required format for
    2829 * CreateProcess(), the internal function __CRTDLL__spawn() is
     
    8283
    8384  if (!CreateProcessA(exe, args, NULL, NULL, TRUE,
    84                       flags == _P_DETACH ? DETACHED_PROCESS : 0,
    85                       env, NULL, &si, &pi))
     85              flags == _P_DETACH ? DETACHED_PROCESS : 0,
     86              env, NULL, &si, &pi))
    8687  {
    8788    __CRTDLL__set_errno(GetLastError());
     
    157158{
    158159  // return (_spawnve(i, s1, s2, s3));
    159  
     160
    160161  LPSTR args = __CRTDLL__argvtos(argv,' ');
    161162  LPSTR envs = __CRTDLL__argvtos(envv,0);
     
    186187{
    187188  // return system(string);
    188  
     189
    189190    /* FIXME: should probably launch cmd interpreter in COMSPEC */
    190191    return __CRTDLL__spawn(_P_WAIT, NULL, x, NULL);
Note: See TracChangeset for help on using the changeset viewer.