Changeset 400


Ignore:
Timestamp:
Jul 29, 2006, 9:51:30 PM (19 years ago)
Author:
root
Message:

Add xgets_stripped

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/wrappers.c

    r395 r400  
    99
    1010  22 Jul 06 SHL Baseline
     11  29 Jul 06 SHL Add xgets_stripped
    1112
    1213***********************************************************************/
     
    2324
    2425#pragma alloc_text(WRAPPERS1,xfree,xfopen,xfsopen,xmalloc,xrealloc)
     26
     27PSZ xfgets(PSZ pszBuf, size_t cMaxBytes, FILE *fp, PCSZ pszSrcFile, UINT uiLineNumber)
     28{
     29  PSZ psz = fgets(pszBuf,cMaxBytes,fp);
     30  if (!psz) {
     31    if (ferror(fp))
     32      Runtime_Error(pszSrcFile, uiLineNumber, "fgets");
     33  }
     34  else {
     35    size_t c = strlen(psz);
     36    if (c + 1 > cMaxBytes)
     37      Runtime_Error(pszSrcFile, uiLineNumber, "buffer overflow");
     38    else if (!c || (psz[c-1] != '\n' && psz[c-1] != '\r'))
     39      Runtime_Error(pszSrcFile, uiLineNumber, "missing EOL");
     40  }
     41  return psz;
     42}
     43
     44PSZ xfgets_bstripcr(PSZ pszBuf, size_t cMaxBytes, FILE *fp, PCSZ pszSrcFile, UINT uiLineNumber)
     45{
     46  PSZ psz = xfgets(pszBuf,cMaxBytes,fp,pszSrcFile,__LINE__);
     47  if (psz)
     48    bstripcr(psz);
     49  return psz;
     50}
    2551
    2652FILE *xfopen(PCSZ pszFileName, PCSZ pszMode, PCSZ pszSrcFile, UINT uiLineNumber)
Note: See TracChangeset for help on using the changeset viewer.